#include "temperature_logging_face.h"
#include "watch.h"
-static void _temperature_logging_face_log_data(thermistor_logger_state_t *logger_state) {
+static void _temperature_logging_face_log_data(temperature_logging_state_t *logger_state) {
watch_date_time_t date_time = watch_rtc_get_date_time();
- size_t pos = logger_state->data_points % THERMISTOR_LOGGING_NUM_DATA_POINTS;
+ size_t pos = logger_state->data_points % TEMPERATURE_LOGGING_NUM_DATA_POINTS;
logger_state->data[pos].timestamp.reg = date_time.reg;
logger_state->data[pos].temperature_c = movement_get_temperature();
logger_state->data_points++;
}
-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;
+static void _temperature_logging_face_update_display(temperature_logging_state_t *logger_state, bool in_fahrenheit, bool clock_mode_24h) {
+ int8_t pos = (logger_state->data_points - 1 - logger_state->display_index) % TEMPERATURE_LOGGING_NUM_DATA_POINTS;
char buf[7];
watch_clear_indicator(WATCH_INDICATOR_24H);
void temperature_logging_face_setup(uint8_t watch_face_index, void ** context_ptr) {
(void) watch_face_index;
if (*context_ptr == NULL) {
- *context_ptr = malloc(sizeof(thermistor_logger_state_t));
- memset(*context_ptr, 0, sizeof(thermistor_logger_state_t));
+ *context_ptr = malloc(sizeof(temperature_logging_state_t));
+ memset(*context_ptr, 0, sizeof(temperature_logging_state_t));
}
}
void temperature_logging_face_activate(void *context) {
- thermistor_logger_state_t *logger_state = (thermistor_logger_state_t *)context;
+ temperature_logging_state_t *logger_state = (temperature_logging_state_t *)context;
logger_state->display_index = 0;
logger_state->ts_ticks = 0;
}
bool temperature_logging_face_loop(movement_event_t event, void *context) {
- thermistor_logger_state_t *logger_state = (thermistor_logger_state_t *)context;
+ temperature_logging_state_t *logger_state = (temperature_logging_state_t *)context;
switch (event.event_type) {
case EVENT_TIMEOUT:
movement_move_to_face(0);
_temperature_logging_face_update_display(logger_state, movement_use_imperial_units(), movement_clock_mode_24h());
break;
case EVENT_ALARM_BUTTON_DOWN:
- logger_state->display_index = (logger_state->display_index + 1) % THERMISTOR_LOGGING_NUM_DATA_POINTS;
+ logger_state->display_index = (logger_state->display_index + 1) % TEMPERATURE_LOGGING_NUM_DATA_POINTS;
logger_state->ts_ticks = 0;
// fall through
case EVENT_ACTIVATE:
#include "movement.h"
#include "watch.h"
-#define THERMISTOR_LOGGING_NUM_DATA_POINTS (36)
+#define TEMPERATURE_LOGGING_NUM_DATA_POINTS (36)
typedef struct {
watch_date_time_t timestamp;
uint8_t display_index; // the index we are displaying on screen
uint8_t ts_ticks; // when the user taps the LIGHT button, we show the timestamp for a few ticks.
int32_t data_points; // the absolute number of data points logged
- thermistor_logger_data_point_t data[THERMISTOR_LOGGING_NUM_DATA_POINTS];
-} thermistor_logger_state_t;
+ thermistor_logger_data_point_t data[TEMPERATURE_LOGGING_NUM_DATA_POINTS];
+} temperature_logging_state_t;
void temperature_logging_face_setup(uint8_t watch_face_index, void ** context_ptr);
void temperature_logging_face_activate(void *context);