summaryrefslogtreecommitdiffstats
path: root/watch-library
diff options
context:
space:
mode:
authorJoey Castillo <jose.castillo@gmail.com>2021-08-31 19:38:06 -0400
committerJoey Castillo <jose.castillo@gmail.com>2021-08-31 19:38:06 -0400
commit637964ae4bdbd5af4647e0e53789b77d66a23993 (patch)
tree5b3cdd970c1ad2d02201dab0492808322d4eb315 /watch-library
parentb22915431babce4264a2e3d333939894e5a60c0f (diff)
downloadSensor-Watch-637964ae4bdbd5af4647e0e53789b77d66a23993.tar.gz
Sensor-Watch-637964ae4bdbd5af4647e0e53789b77d66a23993.tar.bz2
Sensor-Watch-637964ae4bdbd5af4647e0e53789b77d66a23993.zip
simplify: always use the TCC to drive the LEDs
Diffstat (limited to 'watch-library')
-rw-r--r--watch-library/watch/watch_led.c60
-rw-r--r--watch-library/watch/watch_led.h30
2 files changed, 37 insertions, 53 deletions
diff --git a/watch-library/watch/watch_led.c b/watch-library/watch/watch_led.c
index 4f9898d8..42bed56a 100644
--- a/watch-library/watch/watch_led.c
+++ b/watch-library/watch/watch_led.c
@@ -22,26 +22,24 @@
* SOFTWARE.
*/
-
-void watch_enable_led(bool pwm) {
- if (pwm) {
- if (!hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
- _watch_enable_tcc();
- }
- } else {
- watch_enable_digital_output(RED);
- watch_enable_digital_output(GREEN);
- watch_set_led_off();
+void watch_enable_leds() {
+ if (!hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
+ _watch_enable_tcc();
}
}
-void watch_disable_led(bool pwm) {
- if (pwm) {
- _watch_disable_tcc();
- } else {
- watch_disable_digital_output(RED);
- watch_disable_digital_output(GREEN);
- }
+void watch_disable_leds() {
+ _watch_disable_tcc();
+}
+
+void watch_enable_led(bool unused) {
+ (void)unused;
+ watch_enable_leds();
+}
+
+void watch_disable_led(bool unused) {
+ (void)unused;
+ watch_disable_leds();
}
void watch_set_led_color(uint8_t red, uint8_t green) {
@@ -53,37 +51,17 @@ void watch_set_led_color(uint8_t red, uint8_t green) {
}
void watch_set_led_red() {
- if (hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
- watch_set_led_color(255, 0);
- } else {
- watch_set_pin_level(RED, true);
- watch_set_pin_level(GREEN, false);
- }
+ watch_set_led_color(255, 0);
}
void watch_set_led_green() {
- if (hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
- watch_set_led_color(0, 255);
- } else {
- watch_set_pin_level(RED, false);
- watch_set_pin_level(GREEN, true);
- }
+ watch_set_led_color(0, 255);
}
void watch_set_led_yellow() {
- if (hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
- watch_set_led_color(255, 255);
- } else {
- watch_set_pin_level(RED, true);
- watch_set_pin_level(GREEN, true);
- }
+ watch_set_led_color(255, 255);
}
void watch_set_led_off() {
- if (hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
- watch_set_led_color(0, 0);
- } else {
- watch_set_pin_level(RED, false);
- watch_set_pin_level(GREEN, false);
- }
+ watch_set_led_color(0, 0);
}
diff --git a/watch-library/watch/watch_led.h b/watch-library/watch/watch_led.h
index 5dedadf3..d711a052 100644
--- a/watch-library/watch/watch_led.h
+++ b/watch-library/watch/watch_led.h
@@ -29,28 +29,28 @@
* hungry. The green LED, at full power, consumes more power than the whole chip in active mode,
* and the red LED consumes about twelve times as much power! The LED's should thus be used only
* sparingly in order to preserve battery life.
- * @todo Explore running the TC3 PWM driver in standby mode; this would require that the user disable it
- * in app_prepare_for_sleep, but could allow for low power, low duty indicator LED usage.
*/
/// @{
-/** @brief Enables the LED.
- * @param pwm if true, enables PWM output for brightness control (required to use @ref watch_set_led_color).
- If false, configures the LED pins as digital outputs.
- * @note The TC driver required for PWM mode does not run in STANDBY mode. You should keep your app awake
- while PWM'ing the LED's, and disable them before going to sleep.
+/** @brief Enables the bi-color LED.
+ * @note The TCC peripheral that drives the LEDs does not run in STANDBY mode — but the outputs do! This
+ * means that if you set either red, green or both LEDs to full power, they will shine even when
+ * your app is asleep. If, however, you set a custom color using watch_set_led_color, the color will
+ * not display correctly in STANDBY mode. You will need to keep your app running while the LED is on.
*/
-void watch_enable_led(bool pwm);
+void watch_enable_leds();
/** @brief Disables the LEDs.
- * @param pwm if true, disables the PWM output. If false, disables the digital outputs.
- * @note If pwm is true, this method will also disable the buzzer, since the buzzer and LED both make use of
- * the same peripheral to drive their PWM behavior.
+ * @note This method will also disable the buzzer, since the buzzer and LED both make use of the same
+ * peripheral to drive their PWM behavior.
*/
-void watch_disable_led(bool pwm);
+void watch_disable_leds();
/** @brief Sets the LED to a custom color by modulating each output's duty cycle.
* @param red The red value from 0-255.
* @param green The green value from 0-255.
+ * @note If you are displaying a custom color, you will need to prevent your app from going to sleep
+ * while the LED is on; otherwise, the color will not display correctly. You can do this by
+ * returning false in your app_loop method.
*/
void watch_set_led_color(uint8_t red, uint8_t green);
@@ -72,4 +72,10 @@ void watch_set_led_yellow();
/** @brief Turns both the red and the green LEDs off. */
void watch_set_led_off();
+
+__attribute__((deprecated("Use watch_enable_leds instead")))
+void watch_enable_led(bool unused);
+
+__attribute__((deprecated("Use watch_disable_leds instead")))
+void watch_disable_led(bool unused);
/// @}