aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fsm/adc.c20
-rw-r--r--fsm/adc.h4
2 files changed, 11 insertions, 13 deletions
diff --git a/fsm/adc.c b/fsm/adc.c
index 93f9a1a..fbe84a1 100644
--- a/fsm/adc.c
+++ b/fsm/adc.c
@@ -166,7 +166,7 @@ void adc_deferred() {
#ifdef USE_LVP
-static inline void ADC_voltage_handler() {
+static void ADC_voltage_handler() {
// rate-limit low-voltage warnings to a max of 1 per N seconds
static uint8_t lvp_timer = 0;
#define LVP_TIMER_START (VOLTAGE_WARNING_SECONDS*ADC_CYCLES_PER_SECOND) // N seconds between LVP warnings
@@ -240,7 +240,7 @@ static inline void ADC_voltage_handler() {
#ifdef USE_THERMAL_REGULATION
// generally happens once per second while awake
-static inline void ADC_temperature_handler() {
+static void ADC_temperature_handler() {
// coarse adjustment
#ifndef THERM_LOOKAHEAD
#define THERM_LOOKAHEAD 4
@@ -265,15 +265,7 @@ static inline void ADC_temperature_handler() {
static uint16_t temperature_history[NUM_TEMP_HISTORY_STEPS];
static int8_t warning_threshold = 0;
- if (adc_reset) { // wipe out old data
- // ignore average, use latest sample
- uint16_t foo = adc_raw[1];
- adc_smooth[1] = foo;
-
- // forget any past measurements
- for(uint8_t i=0; i<NUM_TEMP_HISTORY_STEPS; i++)
- temperature_history[i] = (foo + 16) >> 5;
- }
+ if (adc_reset) adc_smooth[1] = adc_raw[1];
// latest 16-bit ADC reading
// convert raw ADC value to Kelvin << 6
@@ -302,6 +294,12 @@ static inline void ADC_temperature_handler() {
//measurement = (measurement + 16) & 0xffe0; // 1111 1111 1110 0000
#endif
+ if (adc_reset) { // wipe out old data after waking up
+ // forget any past measurements
+ for(uint8_t i=0; i<NUM_TEMP_HISTORY_STEPS; i++)
+ temperature_history[i] = measurement;
+ }
+
// how much has the temperature changed between now and a few seconds ago?
int16_t diff;
diff = measurement - temperature_history[history_step];
diff --git a/fsm/adc.h b/fsm/adc.h
index 0c0a9e5..02e33f8 100644
--- a/fsm/adc.h
+++ b/fsm/adc.h
@@ -49,7 +49,7 @@ uint16_t adc_smooth[2]; // lowpassed ADC measurements (0=voltage, 1=temperature
uint8_t adc_deferred_enable = 0; // stop waiting and run the deferred code
void adc_deferred(); // do the actual ADC-related calculations
-static inline void ADC_voltage_handler();
+static void ADC_voltage_handler();
uint8_t voltage = 0;
#ifdef USE_VOLTAGE_CORRECTION
#ifdef USE_CFG
@@ -101,7 +101,7 @@ int16_t temperature;
uint8_t therm_ceil = DEFAULT_THERM_CEIL;
int8_t therm_cal_offset = 0;
#endif
-static inline void ADC_temperature_handler();
+static void ADC_temperature_handler();
#endif // ifdef USE_THERMAL_REGULATION
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.