summaryrefslogtreecommitdiffstats
path: root/watch-library/watch/watch_slcd.c
diff options
context:
space:
mode:
authorJoey Castillo <jose.castillo@gmail.com>2021-10-01 17:09:05 -0400
committerJoey Castillo <jose.castillo@gmail.com>2021-10-01 20:53:32 -0400
commit84c0fbfa2a68dc3c29b989947567d111e70a037b (patch)
treefa68060b8a32b0450d58b50b571f0700c8280354 /watch-library/watch/watch_slcd.c
parent15ae7ab84b13953ec309a5823ade6ddb60f6a68c (diff)
downloadSensor-Watch-84c0fbfa2a68dc3c29b989947567d111e70a037b.tar.gz
Sensor-Watch-84c0fbfa2a68dc3c29b989947567d111e70a037b.tar.bz2
Sensor-Watch-84c0fbfa2a68dc3c29b989947567d111e70a037b.zip
slcd: add autonomous blinking and animation
Diffstat (limited to 'watch-library/watch/watch_slcd.c')
-rw-r--r--watch-library/watch/watch_slcd.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/watch-library/watch/watch_slcd.c b/watch-library/watch/watch_slcd.c
index ba9d12b2..58e1da7f 100644
--- a/watch-library/watch/watch_slcd.c
+++ b/watch-library/watch/watch_slcd.c
@@ -23,6 +23,7 @@
*/
#include "watch_slcd.h"
+#include "hpl_slcd_config.h"
//////////////////////////////////////////////////////////////////////////////////////////
// Segmented Display
@@ -149,6 +150,10 @@ static const uint32_t IndicatorSegments[6] = {
SLCD_SEGID(1, 10), // WATCH_INDICATOR_LAP
};
+void _sync_slcd() {
+ while (SLCD->SYNCBUSY.reg);
+}
+
void watch_enable_display() {
SEGMENT_LCD_0_init();
slcd_sync_enable(&SEGMENT_LCD_0);
@@ -218,3 +223,47 @@ void watch_clear_all_indicators() {
slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(0, 16));
slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(1, 10));
}
+
+void watch_start_character_blink(char character, uint32_t duration) {
+ SLCD->CTRLD.bit.FC0EN = 0;
+ _sync_slcd();
+
+ if (duration <= SLCD_FC_BYPASS_MAX_MS) {
+ SLCD->FC0.reg = SLCD_FC0_PB | ((duration / (1000 / SLCD_FRAME_FREQUENCY)) - 1);
+ } else {
+ SLCD->FC0.reg = (((duration / (1000 / SLCD_FRAME_FREQUENCY)) / 8 - 1));
+ }
+ SLCD->CTRLD.bit.FC0EN = 1;
+
+ watch_display_character(character, 7);
+ watch_clear_pixel(2, 10); // clear segment B of position 7 since it can't blink
+
+ SLCD->CTRLD.bit.BLINK = 0;
+ SLCD->CTRLA.bit.ENABLE = 0;
+ _sync_slcd();
+
+ SLCD->BCFG.bit.BSS0 = 0x07;
+ SLCD->BCFG.bit.BSS1 = 0x07;
+
+ SLCD->CTRLD.bit.BLINK = 1;
+ _sync_slcd();
+ SLCD->CTRLA.bit.ENABLE = 1;
+ _sync_slcd();
+}
+
+void watch_stop_blink() {
+ SLCD->CTRLD.bit.FC0EN = 0;
+ SLCD->CTRLD.bit.BLINK = 0;
+}
+
+void watch_start_tick_animation(uint32_t duration) {
+ watch_display_character(' ', 8);
+ const uint32_t segs[] = { SLCD_SEGID(0, 2)};
+ slcd_sync_start_animation(&SEGMENT_LCD_0, segs, 1, duration);
+}
+
+void watch_stop_tick_animation() {
+ const uint32_t segs[] = { SLCD_SEGID(0, 2)};
+ slcd_sync_stop_animation(&SEGMENT_LCD_0, segs, 1);
+ watch_display_character(' ', 8);
+}