summaryrefslogtreecommitdiffstats
path: root/watch-library/watch/watch_led.c
diff options
context:
space:
mode:
authorJoey Castillo <jose.castillo@gmail.com>2021-08-31 20:28:36 -0400
committerJoey Castillo <jose.castillo@gmail.com>2021-08-31 20:29:13 -0400
commit71e411d8609b940ebd42b6aeaaad7d1ce106a424 (patch)
treead91bc908a67e3f34d9ad3c257c26c1ca715895a /watch-library/watch/watch_led.c
parenta232999e9384e2e895a74fee46d0344cf5d26b7a (diff)
downloadSensor-Watch-71e411d8609b940ebd42b6aeaaad7d1ce106a424.tar.gz
Sensor-Watch-71e411d8609b940ebd42b6aeaaad7d1ce106a424.tar.bz2
Sensor-Watch-71e411d8609b940ebd42b6aeaaad7d1ce106a424.zip
handle watch variant with red/blue LED
Diffstat (limited to 'watch-library/watch/watch_led.c')
-rw-r--r--watch-library/watch/watch_led.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/watch-library/watch/watch_led.c b/watch-library/watch/watch_led.c
index 42bed56a..f6419737 100644
--- a/watch-library/watch/watch_led.c
+++ b/watch-library/watch/watch_led.c
@@ -22,6 +22,14 @@
* SOFTWARE.
*/
+#ifdef WATCH_SWAP_LED_PINS
+ #define WATCH_RED_CHANNEL 3
+ #define WATCH_GREEN_CHANNEL 2
+#else
+ #define WATCH_RED_CHANNEL 2
+ #define WATCH_GREEN_CHANNEL 3
+#endif
+
void watch_enable_leds() {
if (!hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
_watch_enable_tcc();
@@ -45,8 +53,8 @@ void watch_disable_led(bool unused) {
void watch_set_led_color(uint8_t red, uint8_t green) {
if (hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
uint32_t period = hri_tcc_get_PER_reg(TCC0, TCC_PER_MASK);
- hri_tcc_write_CCBUF_reg(TCC0, 2, ((period * red * 1000ull) / 255000ull));
- hri_tcc_write_CCBUF_reg(TCC0, 3, ((period * green * 1000ull) / 255000ull));
+ hri_tcc_write_CCBUF_reg(TCC0, WATCH_RED_CHANNEL, ((period * red * 1000ull) / 255000ull));
+ hri_tcc_write_CCBUF_reg(TCC0, WATCH_GREEN_CHANNEL, ((period * green * 1000ull) / 255000ull));
}
}