slcd: add autonomous blinking and animation
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user