aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-adc.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-08-23 11:43:11 -0600
committerSelene ToyKeeper2020-08-23 11:43:11 -0600
commit8323c1823f4e1dbb7b78142a082bfbf7cdae2456 (patch)
tree12e614313174b0f60c9cbab7b41dd330e8873962 /spaghetti-monster/fsm-adc.c
parentmerged Emisar D4v2.5 build targets with Noctigon KR4 build targets (diff)
downloadanduril-8323c1823f4e1dbb7b78142a082bfbf7cdae2456.tar.gz
anduril-8323c1823f4e1dbb7b78142a082bfbf7cdae2456.tar.bz2
anduril-8323c1823f4e1dbb7b78142a082bfbf7cdae2456.zip
attempt to fix laggy voltage readings right after waking, on FW3A
(with no sleep ticks, the voltage value never gets reset to the raw value, and instead only goes through the lowpass filter) (this fix is not yet tested... will test before uploading) (also carries a risk of messing up thermal values after being asleep, so that needs to be tested too)
Diffstat (limited to '')
-rw-r--r--spaghetti-monster/fsm-adc.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c
index 45a4297..4fc777b 100644
--- a/spaghetti-monster/fsm-adc.c
+++ b/spaghetti-monster/fsm-adc.c
@@ -222,6 +222,8 @@ void adc_deferred() {
#endif
}
#endif
+
+ if (adc_reset) adc_reset --;
}
@@ -240,7 +242,7 @@ static inline void ADC_voltage_handler() {
uint16_t measurement;
// latest ADC value
- if (go_to_standby || (adc_smooth[0] < 255)) {
+ if (adc_reset) { // while asleep, or just after waking, don't lowpass
measurement = adc_raw[0];
adc_smooth[0] = measurement; // no lowpass while asleep
}
@@ -308,10 +310,7 @@ static inline void ADC_temperature_handler() {
static uint16_t temperature_history[NUM_TEMP_HISTORY_STEPS];
static int8_t warning_threshold = 0;
- if (reset_thermal_history) { // wipe out old data
- // don't keep resetting
- reset_thermal_history = 0;
-
+ if (adc_reset) { // wipe out old data
// ignore average, use latest sample
uint16_t foo = adc_raw[1];
adc_smooth[1] = foo;