From 84c0fbfa2a68dc3c29b989947567d111e70a037b Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Fri, 1 Oct 2021 17:09:05 -0400 Subject: slcd: add autonomous blinking and animation --- watch-library/watch/watch_slcd.c | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'watch-library/watch/watch_slcd.c') 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); +} -- cgit v1.2.3