diff options
author | Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com> | 2024-02-25 13:00:50 -0300 |
---|---|---|
committer | Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com> | 2024-02-25 15:24:14 -0300 |
commit | 8f0719205332e933219a52001ba31fba78fa12a1 (patch) | |
tree | 14dc1be1fde212f5a4d538c4dc2ddaba403a82fc | |
parent | 76add5a2da6c28e1701d0a69244fc3b3a71c1e67 (diff) | |
download | Sensor-Watch-8f0719205332e933219a52001ba31fba78fa12a1.tar.gz Sensor-Watch-8f0719205332e933219a52001ba31fba78fa12a1.tar.bz2 Sensor-Watch-8f0719205332e933219a52001ba31fba78fa12a1.zip |
faces/clock: refactor full time display code
Simplifies the code by defining dedicated functions for this.
-rw-r--r-- | movement/watch_faces/clock/clock_face.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/movement/watch_faces/clock/clock_face.c b/movement/watch_faces/clock/clock_face.c index 82052133..5b698341 100644 --- a/movement/watch_faces/clock/clock_face.c +++ b/movement/watch_faces/clock/clock_face.c @@ -99,6 +99,23 @@ static void clock_indicate_low_available_power(clock_state_t *clock) { clock_indicate(WATCH_INDICATOR_LAP, clock->battery_low); } +static void clock_display_all(watch_date_time date_time) { + char buf[10 + 1]; + + snprintf( + buf, + sizeof(buf), + "%s%2d%2d%02d%02d", + watch_utility_get_weekday(date_time), + date_time.unit.day, + date_time.unit.hour, + date_time.unit.minute, + date_time.unit.second + ); + + watch_display_string(buf, 0); +} + static void clock_display_low_energy(watch_date_time date_time) { char buf[10 + 1]; @@ -191,7 +208,8 @@ bool clock_face_loop(movement_event_t event, movement_settings_t *settings, void clock_indicate_pm(settings, date_time); date_time = clock_24h_to_12h(date_time); } - sprintf(buf, "%s%2d%2d%02d%02d", watch_utility_get_weekday(date_time), date_time.unit.day, date_time.unit.hour, date_time.unit.minute, date_time.unit.second); + clock_display_all(date_time); + break; } watch_display_string(buf, 0); |