From bc08c5a05e19ab52fd01e227bd63836ca04ad5b3 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Wed, 27 Nov 2024 10:43:23 -0500 Subject: [PATCH] add temperature data point for exploration --- watch-faces/sensor/activity_logging_face.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/watch-faces/sensor/activity_logging_face.c b/watch-faces/sensor/activity_logging_face.c index 370ba356..a6d58010 100644 --- a/watch-faces/sensor/activity_logging_face.c +++ b/watch-faces/sensor/activity_logging_face.c @@ -28,6 +28,7 @@ #include "filesystem.h" #include "watch.h" #include "tc.h" +#include "thermistor_driver.h" #ifdef HAS_ACCELEROMETER @@ -46,14 +47,26 @@ static void _activity_logging_face_log_data(activity_logging_state_t *state) { data_point.bit.minute = date_time.unit.minute; data_point.bit.stationary_minutes = stationary_minutes; data_point.bit.orientation_changes = tc_count16_get_count(2); // orientation changes are counted in TC2 - // print size of thing - printf("Size of data point: %d\n", sizeof(activity_logging_data_point_t)); + + // write data point. WARNING: Crashes the system if out of space, freezing the time at the moment of the crash. + // In this exploratory phase, I'm treating this as a "feature" that tells me to dump the data and begin again. if (filesystem_append_file("activity.dat", (char *)&data_point, sizeof(activity_logging_data_point_t))) { printf("Data point written\n"); } else { printf("Failed to write data point\n"); } + // test for off-wrist temperature stuff + thermistor_driver_enable(); + float temperature_c = thermistor_driver_get_temperature(); + thermistor_driver_disable(); + uint16_t temperature = temperature_c * 1000; + if (filesystem_append_file("activity.dat", (char *)&temperature, sizeof(uint16_t))) { + printf("Temperature written: %d\n", temperature); + } else { + printf("Failed to write temperature\n"); + } + state->data[pos].reg = data_point.reg; state->data_points++;