From d05fdf2845053f93bc2b2c69477ec5ea1aa60ad0 Mon Sep 17 00:00:00 2001 From: joeycastillo Date: Tue, 8 Oct 2024 20:39:45 -0400 Subject: [PATCH] migrate temperature log to Second Movement --- movement_config.h | 1 + movement_faces.h | 1 + watch-faces.mk | 1 + .../sensor/temperature_logging_face.c | 25 +++++++++++++------ .../sensor/temperature_logging_face.h | 0 5 files changed, 21 insertions(+), 7 deletions(-) rename {movement/watch_faces => watch-faces}/sensor/temperature_logging_face.c (81%) rename {movement/watch_faces => watch-faces}/sensor/temperature_logging_face.h (100%) diff --git a/movement_config.h b/movement_config.h index 349de1ea..0fd8bb06 100644 --- a/movement_config.h +++ b/movement_config.h @@ -28,6 +28,7 @@ #include "movement_faces.h" const watch_face_t watch_faces[] = { + temperature_logging_face, clock_face, world_clock_face, sunrise_sunset_face, diff --git a/movement_faces.h b/movement_faces.h index a9226e97..1f7df834 100644 --- a/movement_faces.h +++ b/movement_faces.h @@ -35,6 +35,7 @@ #include "all_segments_face.h" #include "float_demo_face.h" #include "temperature_display_face.h" +#include "temperature_logging_face.h" #include "voltage_face.h" #include "set_time_face.h" #include "preferences_face.h" diff --git a/watch-faces.mk b/watch-faces.mk index 608e82ba..68798ad0 100644 --- a/watch-faces.mk +++ b/watch-faces.mk @@ -10,6 +10,7 @@ SRCS += \ ./watch-faces/demo/character_set_face.c \ ./watch-faces/demo/float_demo_face.c \ ./watch-faces/sensor/temperature_display_face.c \ + ./watch-faces/sensor/temperature_logging_face.c \ ./watch-faces/sensor/voltage_face.c \ ./watch-faces/settings/set_time_face.c \ ./watch-faces/settings/preferences_face.c \ diff --git a/movement/watch_faces/sensor/temperature_logging_face.c b/watch-faces/sensor/temperature_logging_face.c similarity index 81% rename from movement/watch_faces/sensor/temperature_logging_face.c rename to watch-faces/sensor/temperature_logging_face.c index f234f96d..227ca8f5 100644 --- a/movement/watch_faces/sensor/temperature_logging_face.c +++ b/watch-faces/sensor/temperature_logging_face.c @@ -42,15 +42,20 @@ static void _temperature_logging_face_log_data(thermistor_logger_state_t *logger static void _temperature_logging_face_update_display(thermistor_logger_state_t *logger_state, bool in_fahrenheit, bool clock_mode_24h) { int8_t pos = (logger_state->data_points - 1 - logger_state->display_index) % THERMISTOR_LOGGING_NUM_DATA_POINTS; - char buf[14]; + char buf[7]; watch_clear_indicator(WATCH_INDICATOR_24H); watch_clear_indicator(WATCH_INDICATOR_PM); watch_clear_colon(); if (pos < 0) { - sprintf(buf, "TL%2dno dat", logger_state->display_index); + // no data at this index + watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "LOG", "TL"); + watch_display_text(WATCH_POSITION_BOTTOM, "no dat"); + sprintf(buf, "%2d", logger_state->display_index); + watch_display_text(WATCH_POSITION_TOP_RIGHT, buf); } else if (logger_state->ts_ticks) { + // we are displaying the timestamp in response to a button press watch_date_time_t date_time = logger_state->data[pos].timestamp; watch_set_colon(); if (clock_mode_24h) { @@ -60,16 +65,22 @@ static void _temperature_logging_face_update_display(thermistor_logger_state_t * date_time.unit.hour %= 12; if (date_time.unit.hour == 0) date_time.unit.hour = 12; } - sprintf(buf, "AT%2d%2d%02d%02d", date_time.unit.day, date_time.unit.hour, date_time.unit.minute, date_time.unit.second); + watch_display_text(WATCH_POSITION_TOP_LEFT, "AT"); + sprintf(buf, "%2d", date_time.unit.day); + watch_display_text(WATCH_POSITION_TOP_RIGHT, buf); + sprintf(buf, "%2d%02d%02d", date_time.unit.hour, date_time.unit.minute, date_time.unit.second); + watch_display_text(WATCH_POSITION_BOTTOM, buf); } else { + // we are displaying the temperature + watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "LOG", "TL"); + sprintf(buf, "%2d", logger_state->display_index); + watch_display_text(WATCH_POSITION_TOP_RIGHT, buf); if (in_fahrenheit) { - sprintf(buf, "TL%2d%4.1f#F", logger_state->display_index, logger_state->data[pos].temperature_c * 1.8 + 32.0); + watch_display_float_with_best_effort(logger_state->data[pos].temperature_c * 1.8 + 32.0, "#F"); } else { - sprintf(buf, "TL%2d%4.1f#C", logger_state->display_index, logger_state->data[pos].temperature_c); + watch_display_float_with_best_effort(logger_state->data[pos].temperature_c, "#C"); } } - - watch_display_string(buf, 0); } void temperature_logging_face_setup(uint8_t watch_face_index, void ** context_ptr) { diff --git a/movement/watch_faces/sensor/temperature_logging_face.h b/watch-faces/sensor/temperature_logging_face.h similarity index 100% rename from movement/watch_faces/sensor/temperature_logging_face.h rename to watch-faces/sensor/temperature_logging_face.h