diff options
author | ConfuSomu | 2021-02-06 23:27:13 -0500 |
---|---|---|
committer | ConfuSomu | 2021-02-06 23:27:13 -0500 |
commit | 8dc9eb3515e735502713bff1bbffc6d7c04d4791 (patch) | |
tree | ca2f376515c73103021411bba7c2a6bbdc0fbf33 | |
parent | 4c99f42f5ac0147e92d4a1214111596cec2e9f36 (diff) | |
download | pico-watch-8dc9eb3515e735502713bff1bbffc6d7c04d4791.tar pico-watch-8dc9eb3515e735502713bff1bbffc6d7c04d4791.tar.gz pico-watch-8dc9eb3515e735502713bff1bbffc6d7c04d4791.zip |
Use custom function for time string formatting
-rw-r--r-- | pico-watch.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/pico-watch.c b/pico-watch.c index b9bc993..65a96d5 100644 --- a/pico-watch.c +++ b/pico-watch.c @@ -36,13 +36,24 @@ void init_rtc() { rtc_set_datetime(&init_date); } +// Time as string +// Adapted from pico-sdk/scr/common/pico_util/datetime.c +void time_as_str(char *buf, uint buf_size, const datetime_t *t) { + snprintf(buf, + buf_size, + "%d:%02d:%02d", + t->hour, + t->min, + t->sec); +}; + void show_datetime() { char datetime_buf[256]; char *datetime_str = &datetime_buf[0]; datetime_t t; rtc_get_datetime(&t); - datetime_to_str(datetime_str, sizeof(datetime_buf), &t); + time_as_str(datetime_str, sizeof(datetime_buf), &t); oledWriteString(&oled, 0,10,3, datetime_str, FONT_12x16, 0, 1); } |