From 8d5280a34f1159d8af0277ba04b7e1cb9c8bd7ac Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Sun, 3 Oct 2021 18:48:55 -0400 Subject: slcd: add function to blank entire screen --- watch-library/watch/watch_slcd.c | 6 ++++++ watch-library/watch/watch_slcd.h | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'watch-library/watch') diff --git a/watch-library/watch/watch_slcd.c b/watch-library/watch/watch_slcd.c index ba9d12b2..c1e24308 100644 --- a/watch-library/watch/watch_slcd.c +++ b/watch-library/watch/watch_slcd.c @@ -162,6 +162,12 @@ inline void watch_clear_pixel(uint8_t com, uint8_t seg) { slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(com, seg)); } +void watch_clear_display() { + SLCD->SDATAL0.reg = 0; + SLCD->SDATAL1.reg = 0; + SLCD->SDATAL2.reg = 0; +} + void watch_display_character(uint8_t character, uint8_t position) { // handle lowercase 7 if needed if (character == '7' && (position == 4 || position == 6)) character = '&'; diff --git a/watch-library/watch/watch_slcd.h b/watch-library/watch/watch_slcd.h index 4f5a617c..5a54b72e 100644 --- a/watch-library/watch/watch_slcd.h +++ b/watch-library/watch/watch_slcd.h @@ -69,6 +69,10 @@ void watch_set_pixel(uint8_t com, uint8_t seg); */ void watch_clear_pixel(uint8_t com, uint8_t seg); +/** @brief Clears all segments of the display, including incicators and the colon. + */ +void watch_clear_display(); + /** @brief Displays a string at the given position, starting from the top left. There are ten digits. A space in any position will clear that digit. * @param string A null-terminated string. -- cgit v1.2.3 From 4300dff61631143f794f186cadb222bdf5f75a06 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Sun, 3 Oct 2021 20:37:15 -0400 Subject: launcher: first crack at low power 'screensaver' mode --- watch-library/watch/watch_deepsleep.c | 7 ++----- watch-library/watch/watch_deepsleep.h | 15 +++++---------- 2 files changed, 7 insertions(+), 15 deletions(-) (limited to 'watch-library/watch') diff --git a/watch-library/watch/watch_deepsleep.c b/watch-library/watch/watch_deepsleep.c index b7da82ee..9ca53db0 100644 --- a/watch-library/watch/watch_deepsleep.c +++ b/watch-library/watch/watch_deepsleep.c @@ -151,11 +151,8 @@ void _watch_disable_all_peripherals_except_slcd() { MCLK->APBCMASK.reg &= ~MCLK_APBCMASK_SERCOM3; } -void watch_enter_shallow_sleep(char *message) { - if (message != NULL) { - watch_display_string(" ", 0); - watch_display_string(message, 0); - } else { +void watch_enter_shallow_sleep(bool display_on) { + if (!display_on) { slcd_sync_deinit(&SEGMENT_LCD_0); hri_mclk_clear_APBCMASK_SLCD_bit(SLCD); } diff --git a/watch-library/watch/watch_deepsleep.h b/watch-library/watch/watch_deepsleep.h index 3dc428d0..84825f00 100644 --- a/watch-library/watch/watch_deepsleep.h +++ b/watch-library/watch/watch_deepsleep.h @@ -81,13 +81,8 @@ uint32_t watch_get_backup_data(uint8_t reg); * the LCD. You can wake from this mode by pressing the ALARM button, if you have an registered an * external wake callback on the ALARM button. When your app wakes from this shallow sleep mode, your * app_setup method will be called, since this function will have disabled things you set up. - * @param message Either NULL, or a string representing a message to display while in shallow sleep mode. If - * this parameter is NULL, the screen will be blanked out, and this function will disable the - * SLCD peripheral for additional power savings. If the message is non-NULL, it will replace - * any text on the screen, and will be displayed at position 0 (so you should pad out the beginning - * of the string with spaces if you wish for the message to appear on line 2, i.e. " SLEEP"). - * Also note that this function will NOT clear any indicator segments that you have set. This is - * by design, in case you wish to leave an indicator lit in sleep mode. + * @param display_on if true, leaves the LCD on to display whatever content was on-screen. If false, disables + * the segment LCD controller for additional power savings. * @details This shallow sleep mode is not the lowest power mode available (see watch_enter_deep_sleep), but * it has the benefit of retaining your application state and being able to wake from the ALARM button. * It also provides an option for displaying a message to the user when asleep. Note that whether you @@ -96,10 +91,10 @@ uint32_t watch_get_backup_data(uint8_t reg); * * Power consumption in shallow sleep mode varies a bit with the battery voltage and the temperature, * but at 3 V and 25~30° C you can roughly estimate: - * * < 12µA current draw with the LCD controller on (message != NULL) - * * < 6µA current draw with the LCD controller off (message == NULL) + * * < 12µA current draw with the LCD controller on + * * < 6µA current draw with the LCD controller off */ -void watch_enter_shallow_sleep(char *message); +void watch_enter_shallow_sleep(bool display_on); /** @brief Enters the SAM L22's lowest-power mode, BACKUP. * @details This function does some housekeeping before entering BACKUP mode. It first disables all -- cgit v1.2.3 From 7f8973a8cc55e37cd8e2d59f7eab2def0045d2a6 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Mon, 4 Oct 2021 10:48:04 -0400 Subject: slcd: add more special cases --- watch-library/watch/watch_slcd.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'watch-library/watch') diff --git a/watch-library/watch/watch_slcd.c b/watch-library/watch/watch_slcd.c index c1e24308..fc8c255a 100644 --- a/watch-library/watch/watch_slcd.c +++ b/watch-library/watch/watch_slcd.c @@ -114,8 +114,8 @@ static const uint8_t Character_Set[] = 0b01010000, // r 0b01101101, // s 0b01111000, // t - 0b01100010, // u (appears as superscript to work in more positions) - 0b01100010, // v (appears as superscript to work in more positions) + 0b01100010, // u (appears in (u)pper half to work in more positions) + 0b00011100, // v (looks like u but in the lower half) 0b10111110, // w (only works in position 0) 0b01111110, // x 0b01101110, // y @@ -169,8 +169,16 @@ void watch_clear_display() { } void watch_display_character(uint8_t character, uint8_t position) { - // handle lowercase 7 if needed - if (character == '7' && (position == 4 || position == 6)) character = '&'; + // special cases for positions 4 and 6 + if (position == 4 || position == 6) { + if (character == '7') character = '&'; // "lowercase" 7 + if (character == 'v') character = 'u'; // bottom segment duplicated, so show in top half + if (character == 'J') character = 'j'; // same + } else if (position != 4 && position != 6) { + if (character == 'u') character = 'v'; // we can use the bottom segment; move to lower half + if (character == 'j') character = 'J'; // same but just display a normal J + } + if (position == 0) slcd_sync_seg_off(&SEGMENT_LCD_0, SLCD_SEGID(0, 15)); // clear funky ninth segment uint64_t segmap = Segment_Map[position]; uint64_t segdata = Character_Set[character - 0x20]; @@ -189,7 +197,8 @@ void watch_display_character(uint8_t character, uint8_t position) { segmap = segmap >> 8; segdata = segdata >> 1; } - if (character == 'T' && position == 1) slcd_sync_seg_on(&SEGMENT_LCD_0, SLCD_SEGID(1, 12)); + if (character == 'T' && position == 1) slcd_sync_seg_on(&SEGMENT_LCD_0, SLCD_SEGID(1, 12)); // add descender + else if (position == 0 && (character == 'B' || character == 'D')) slcd_sync_seg_on(&SEGMENT_LCD_0, SLCD_SEGID(0, 15)); // add funky ninth segment } void watch_display_string(char *string, uint8_t position) { -- cgit v1.2.3