return false;
}
+float movement_get_temperature(void) {
+ float temperature_c = (float)0xFFFFFFFF;
+
+ if (movement_state.has_thermistor) {
+ thermistor_driver_enable();
+ temperature_c = thermistor_driver_get_temperature();
+ thermistor_driver_disable();
+ } else if (movement_state.has_lis2dw) {
+ int16_t val = lis2dw_get_temperature();
+ val = val >> 4;
+ temperature_c = 25 + (float)val / 16.0;
+ }
+
+ return temperature_c;
+}
+
void app_init(void) {
_watch_init();
filesystem_init();
- movement_state.has_thermistor = thermistor_driver_init();
-
// check if we are plugged into USB power.
HAL_GPIO_VBUS_DET_in();
HAL_GPIO_VBUS_DET_pulldown();
memset(&movement_state, 0, sizeof(movement_state));
+ movement_state.has_thermistor = thermistor_driver_init();
+
bool settings_file_exists = filesystem_file_exists("settings.u32");
movement_settings_t maybe_settings;
if (settings_file_exists && maybe_settings.bit.version == 0) {
// if the board has an accelerometer, these functions will enable or disable tap detection.
bool movement_enable_tap_detection_if_available(void);
bool movement_disable_tap_detection_if_available(void);
+
+// If the board has a temperature sensor, this function will give you the temperature in degrees celsius.
+// If the board has multiple temperature sensors, it will use the most accurate one available.
+// If the board has no temperature sensors, it will return 0xFFFFFFFF.
+float movement_get_temperature(void);
}
// log the temperature
- thermistor_driver_enable();
- float temperature_c = thermistor_driver_get_temperature();
- thermistor_driver_disable();
+ float temperature_c = movement_get_temperature();
// offset the temperature by 30, so -30°C is 0, and 72.3°C is 102.3
temperature_c = temperature_c + 30;
if (temperature_c < 0) temperature_c = 0;
#include "thermistor_driver.h"
#include "watch.h"
-#ifdef HAS_TEMPERATURE_SENSOR
-
static void _temperature_display_face_update_display(bool in_fahrenheit) {
- thermistor_driver_enable();
- float temperature_c = thermistor_driver_get_temperature();
+ float temperature_c = movement_get_temperature();
if (in_fahrenheit) {
watch_display_float_with_best_effort(temperature_c * 1.8 + 32.0, "#F");
} else {
watch_display_float_with_best_effort(temperature_c, "#C");
}
- thermistor_driver_disable();
}
void temperature_display_face_setup(uint8_t watch_face_index, void ** context_ptr) {
void temperature_display_face_resign(void *context) {
(void) context;
}
-
-#endif
#include "pins.h"
-#ifdef HAS_TEMPERATURE_SENSOR
-
/*
* THERMISTOR READOUT (aka Temperature Display)
*
temperature_display_face_resign, \
NULL, \
})
-
-#endif // HAS_TEMPERATURE_SENSOR
#include "thermistor_driver.h"
#include "watch.h"
-#ifdef HAS_TEMPERATURE_SENSOR
-
static void _temperature_logging_face_log_data(thermistor_logger_state_t *logger_state) {
- thermistor_driver_enable();
watch_date_time_t date_time = watch_rtc_get_date_time();
size_t pos = logger_state->data_points % THERMISTOR_LOGGING_NUM_DATA_POINTS;
logger_state->data[pos].timestamp.reg = date_time.reg;
- logger_state->data[pos].temperature_c = thermistor_driver_get_temperature();
+ logger_state->data[pos].temperature_c = movement_get_temperature();
logger_state->data_points++;
-
- thermistor_driver_disable();
}
static void _temperature_logging_face_update_display(thermistor_logger_state_t *logger_state, bool in_fahrenheit, bool clock_mode_24h) {
return retval;
}
-
-#endif
#include "pins.h"
-#ifdef HAS_TEMPERATURE_SENSOR
-
/*
* THERMISTOR LOGGING (aka Temperature Log)
*
temperature_logging_face_resign, \
temperature_logging_face_advise, \
})
-
-#endif // HAS_TEMPERATURE_SENSOR