From 20e8606889bae219626c23051fe7d74b4a67db12 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 8 Jul 2023 06:02:27 -0600 Subject: Partially fixed oscillating aux LED voltage colors while asleep. Amplitude is smaller, frequency is slower, but it can still happen sometimes at color boundaries on models with bright aux LEDs on high mode. (because that's not a measurement error, it's actually oscillating voltage) The Wurkkos TS11 in particular tends to bounce when crossing certain color boundaries, because the aux LEDs are bright and change the voltage enough to push it back and forth across the boundary. Also sped up voltage measurement during first few seconds after turning off, to compensate for slowdown caused by the lowpass filter... while slowing down measurements afterward to slow the oscillation. I tried a bunch of different methods, spanning a range of "stable but slow" to "fast but unstable", and kept code clauses for three representative methods. The one enabled by default is the best compromise I found to reduce the issue as much as possible while keeping readings reasonably responsive. --- spaghetti-monster/fsm-wdt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'spaghetti-monster/fsm-wdt.c') diff --git a/spaghetti-monster/fsm-wdt.c b/spaghetti-monster/fsm-wdt.c index 7c25e9f..64f006e 100644 --- a/spaghetti-monster/fsm-wdt.c +++ b/spaghetti-monster/fsm-wdt.c @@ -122,8 +122,10 @@ void WDT_inner() { #ifndef USE_SLEEP_LVP return; // no sleep LVP needed if nothing drains power while off #else - // stop here, usually... but proceed often enough for sleep LVP to work - if (0 != (ticks_since_last & 0x07)) return; + // stop here, usually... except during the first few seconds asleep, + // and once in a while afterward for sleep LVP + if ((ticks_since_last > (8 * SLEEP_TICKS_PER_SECOND)) + && (0 != (ticks_since_last & 0x0f))) return; adc_trigger = 0; // make sure a measurement will happen adc_active_now = 1; // use ADC noise reduction sleep mode -- cgit v1.2.3