diff options
author | joeycastillo <joeycastillo@utexas.edu> | 2021-10-18 15:37:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-18 15:37:41 -0400 |
commit | 6210e1c233a3ee66274389e85889b0681102378d (patch) | |
tree | ec94a012f533e8f7017223648321c46c3c9796f4 /watch-library/watch | |
parent | 84c0fbfa2a68dc3c29b989947567d111e70a037b (diff) | |
parent | 32710098577c982123d9391132165c0b02a57482 (diff) | |
download | Sensor-Watch-6210e1c233a3ee66274389e85889b0681102378d.tar.gz Sensor-Watch-6210e1c233a3ee66274389e85889b0681102378d.tar.bz2 Sensor-Watch-6210e1c233a3ee66274389e85889b0681102378d.zip |
Merge pull request #17 from joeycastillo/wip-launcher
Resolves #13
Diffstat (limited to 'watch-library/watch')
-rw-r--r-- | watch-library/watch/watch_deepsleep.c | 7 | ||||
-rw-r--r-- | watch-library/watch/watch_deepsleep.h | 15 | ||||
-rw-r--r-- | watch-library/watch/watch_slcd.c | 25 | ||||
-rw-r--r-- | watch-library/watch/watch_slcd.h | 4 |
4 files changed, 31 insertions, 20 deletions
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 diff --git a/watch-library/watch/watch_slcd.c b/watch-library/watch/watch_slcd.c index 58e1da7f..08f8c0e3 100644 --- a/watch-library/watch/watch_slcd.c +++ b/watch-library/watch/watch_slcd.c @@ -115,8 +115,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 @@ -167,9 +167,23 @@ 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 = '&'; + // 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]; @@ -188,7 +202,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) { diff --git a/watch-library/watch/watch_slcd.h b/watch-library/watch/watch_slcd.h index 4e710936..e18ee9b4 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. |