From 68ffcea4e3fb2b544501725f5de8fbb304369f64 Mon Sep 17 00:00:00 2001 From: Shane Synan Date: Tue, 13 Jul 2021 19:44:08 -0400 Subject: added #define USE_THERM_AUTOCALIBRATE to opt out Moved factory reset thermal auto-calibration behind a new default-on config #define USE_THERM_AUTOCALIBRATE. Commenting this out or the usual #ifdef/#undef in a cfg-[...].h build file allows for manually calibrating the temperature offset. This may be useful for factory-calibrated temperature sensors or for those who regularly flash custom builds and don't want to recalibrate each time. Determining the correct temperature offset for a given flashlight first requires flashing a build with auto-calibrate disabled, using that to determine the offset, which can then be baked in to future firmware builds. --- spaghetti-monster/anduril/config-default.h | 14 +++++++++++++- spaghetti-monster/anduril/factory-reset.c | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/spaghetti-monster/anduril/config-default.h b/spaghetti-monster/anduril/config-default.h index 31fcbf4..a50be5d 100644 --- a/spaghetti-monster/anduril/config-default.h +++ b/spaghetti-monster/anduril/config-default.h @@ -37,7 +37,19 @@ // overheat protection #define USE_THERMAL_REGULATION #define DEFAULT_THERM_CEIL 45 // try not to get hotter than this (in C) - +// Comment out to disable automatic calibration on factory reset +// - If so, be sure to set THERM_CAL_OFFSET to the correct calibration offset +// - Calibration can still be overridden in temperature check mode +// Or uncomment to use the default auto-calibrate on factory reset +// +// To determine THERM_CAL_OFFSET, comment out USE_THERM_AUTOCALIBRATE to +// disable auto-calibration, compile and flash, let flashlight rest at a known +// temperature, then enter temp check mode (do NOT enter calibration mode). +// +// THERM_CAL_OFFSET = known_temperature - temp_check_blinks + THERM_CAL_OFFSET +// +// (include THERM_CAL_OFFSET in sum as it might already be a non-zero number) +#define USE_THERM_AUTOCALIBRATE // Include a simplified UI for non-enthusiasts? #define USE_SIMPLE_UI diff --git a/spaghetti-monster/anduril/factory-reset.c b/spaghetti-monster/anduril/factory-reset.c index c327e65..5377b09 100644 --- a/spaghetti-monster/anduril/factory-reset.c +++ b/spaghetti-monster/anduril/factory-reset.c @@ -43,7 +43,7 @@ void factory_reset() { } // explode, if button pressed long enough if (reset) { - #ifdef USE_THERMAL_REGULATION + #if defined(USE_THERMAL_REGULATION) && defined(USE_THERM_AUTOCALIBRATE) // auto-calibrate temperature... assume current temperature is 21 C thermal_config_save(1, 21); #endif -- cgit v1.2.3