diff options
| author | Selene ToyKeeper | 2020-10-18 15:23:57 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2020-10-18 15:23:57 -0600 |
| commit | 65017fef69e8b5a4c5cd63fab8d235a0331e543c (patch) | |
| tree | d3268655d1cbd8ddb66a99c7b31797a160bf563a /spaghetti-monster/fsm-adc.c | |
| parent | added ramp 3H -> momentary turbo (diff) | |
| parent | merged lume1 branch for LoneOceans' FW3A-Lume1 driver support (diff) | |
| download | anduril-65017fef69e8b5a4c5cd63fab8d235a0331e543c.tar.gz anduril-65017fef69e8b5a4c5cd63fab8d235a0331e543c.tar.bz2 anduril-65017fef69e8b5a4c5cd63fab8d235a0331e543c.zip | |
merged fsm branch, mostly to get Lume1 driver support
Diffstat (limited to 'spaghetti-monster/fsm-adc.c')
| -rw-r--r-- | spaghetti-monster/fsm-adc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c index 4766786..71ecf65 100644 --- a/spaghetti-monster/fsm-adc.c +++ b/spaghetti-monster/fsm-adc.c @@ -20,6 +20,14 @@ #ifndef FSM_ADC_C #define FSM_ADC_C +// override onboard temperature sensor definition, if relevant +#ifdef USE_EXTERNAL_TEMP_SENSOR +#ifdef ADMUX_THERM +#undef ADMUX_THERM +#endif +#define ADMUX_THERM ADMUX_THERM_EXTERNAL_SENSOR +#endif + static inline void set_admux_therm() { #if (ATTINY == 1634) @@ -345,7 +353,13 @@ static inline void ADC_temperature_handler() { // let the UI see the current temperature in C // Convert ADC units to Celsius (ish) + #ifndef USE_EXTERNAL_TEMP_SENSOR + // onboard sensor for attiny25/45/85/1634 temperature = (measurement>>1) + THERM_CAL_OFFSET + (int16_t)therm_cal_offset - 275; + #else + // external sensor + temperature = EXTERN_TEMP_FORMULA(measurement>>1) + THERM_CAL_OFFSET + (int16_t)therm_cal_offset; + #endif // how much has the temperature changed between now and a few seconds ago? int16_t diff; |
