]> git.earman.xyz Git - sensor-watch.git/commitdiff
support common anode LEDs
authorJoey Castillo <jose.castillo@gmail.com>
Sat, 18 Sep 2021 18:26:18 +0000 (14:26 -0400)
committerJoey Castillo <jose.castillo@gmail.com>
Sat, 18 Sep 2021 18:50:20 +0000 (14:50 -0400)
watch-library/watch/watch_private.c

index d3da54266cf3f9fc95db364f7dbb0b1ba852d1cd..bdf6b78a1cc11ff5802618099acaee080dc12741 100644 (file)
@@ -88,6 +88,11 @@ void _watch_enable_tcc() {
     //    period (i.e. a square wave with a 50% duty cycle).
     //  * LEDs on CC[2] and CC[3] can be set to any value from 0 (off) to PER (fully on).
     hri_tcc_write_WAVE_reg(TCC0, TCC_WAVE_WAVEGEN_NPWM);
+    #ifdef WATCH_INVERT_LED_POLARITY
+    // This is here for the dev board, which uses a common anode LED (instead of common cathode like the actual watch).
+    hri_tcc_set_WAVE_reg(TCC0, (1 << (TCC_WAVE_POL0_Pos + WATCH_RED_TCC_CHANNEL)) |
+                               (1 << (TCC_WAVE_POL0_Pos + WATCH_GREEN_TCC_CHANNEL)));
+    #endif
     // The buzzer will set the period depending on the tone it wants to play, but we have to set some period here to
     // get the LED working. Almost any period will do, tho it should be below 20000 (i.e. 50 Hz) to avoid flickering.
     hri_tcc_write_PER_reg(TCC0, 4096);