diff options
author | ConfuSomu | 2021-02-07 00:00:40 -0500 |
---|---|---|
committer | ConfuSomu | 2021-02-07 00:00:40 -0500 |
commit | d113cf3c7c1a0f68a07be26b460a68547fdf34c8 (patch) | |
tree | 1713d11b9794497e013465cb56be8cc7f6929166 | |
parent | 8dc9eb3515e735502713bff1bbffc6d7c04d4791 (diff) | |
download | pico-watch-d113cf3c7c1a0f68a07be26b460a68547fdf34c8.tar pico-watch-d113cf3c7c1a0f68a07be26b460a68547fdf34c8.tar.gz pico-watch-d113cf3c7c1a0f68a07be26b460a68547fdf34c8.zip |
Show date
-rw-r--r-- | pico-watch.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/pico-watch.c b/pico-watch.c index 65a96d5..f1e32af 100644 --- a/pico-watch.c +++ b/pico-watch.c @@ -20,7 +20,7 @@ void init_display() { oledInit(&oled, OLED_128x64, 0x3d, 0, 0, 1, SDA_PIN, SCL_PIN, RESET_PIN, 1000000L); oledFill(&oled, 0,1); oledSetContrast(&oled, 127); - oledSetTextWrap(&oled, true); + //oledSetTextWrap(&oled, true); } void init_rtc() { @@ -46,15 +46,38 @@ void time_as_str(char *buf, uint buf_size, const datetime_t *t) { t->min, t->sec); }; +void date_as_str(char *buf, uint buf_size, const datetime_t *t) { + static const char *DATETIME_DOWS[7] = { + "Sun", + "Mon", + "Tue", + "Wed", + "Thu", + "Fri", + "Sat", + }; + snprintf(buf, + buf_size, + "%02d-%02d-%02d %s", + t->year, + t->month, + t->day, + DATETIME_DOWS[t->dotw - 1]); +}; void show_datetime() { char datetime_buf[256]; char *datetime_str = &datetime_buf[0]; datetime_t t; - rtc_get_datetime(&t); + + // time time_as_str(datetime_str, sizeof(datetime_buf), &t); oledWriteString(&oled, 0,10,3, datetime_str, FONT_12x16, 0, 1); + + // date + date_as_str(datetime_str, sizeof(datetime_buf), &t); + oledWriteString(&oled, 0,0,7, datetime_str, FONT_8x8, 0, 1); } int main() |