add movement_get_temperature, works across different sensor boards

This commit is contained in:
Joey Castillo
2025-05-17 11:03:51 -04:00
parent 80cbb0fe30
commit 47fbaccc77
7 changed files with 26 additions and 28 deletions

View File

@@ -560,13 +560,27 @@ bool movement_disable_tap_detection_if_available(void) {
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();
@@ -578,6 +592,8 @@ void app_init(void) {
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) {