aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spaghetti-monster/anduril/cfg-ff-rot66.h5
-rw-r--r--spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h4
-rw-r--r--spaghetti-monster/anduril/config-default.h4
-rw-r--r--spaghetti-monster/fsm-adc.c22
-rw-r--r--spaghetti-monster/fsm-standby.c2
5 files changed, 32 insertions, 5 deletions
diff --git a/spaghetti-monster/anduril/cfg-ff-rot66.h b/spaghetti-monster/anduril/cfg-ff-rot66.h
index 03b74db..e2d5ff7 100644
--- a/spaghetti-monster/anduril/cfg-ff-rot66.h
+++ b/spaghetti-monster/anduril/cfg-ff-rot66.h
@@ -49,5 +49,6 @@
//#undef USE_TACTICAL_STROBE_MODE
// reduce size a bit
-#define NO_LOWPASS_WHILE_ASLEEP
-
+#ifdef USE_LOWPASS_WHILE_ASLEEP
+#undef USE_LOWPASS_WHILE_ASLEEP
+#endif
diff --git a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h
index 09b684f..b5c3b12 100644
--- a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h
+++ b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h
@@ -59,5 +59,7 @@
//#undef USE_2C_STYLE_CONFIG
// reduce size a bit
-#define NO_LOWPASS_WHILE_ASLEEP
+#ifdef USE_LOWPASS_WHILE_ASLEEP
+#undef USE_LOWPASS_WHILE_ASLEEP
+#endif
diff --git a/spaghetti-monster/anduril/config-default.h b/spaghetti-monster/anduril/config-default.h
index 406e98b..77b5c6b 100644
--- a/spaghetti-monster/anduril/config-default.h
+++ b/spaghetti-monster/anduril/config-default.h
@@ -189,5 +189,9 @@
// (defined here so config files can override it)
#define USE_DYNAMIC_UNDERCLOCKING
+// if the aux LEDs oscillate between "full battery" and "empty battery"
+// while in "voltage" mode, enable this to reduce the amplitude of
+// those oscillations
+//#define USE_LOWPASS_WHILE_ASLEEP
#endif
diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c
index 975d12e..c5401ea 100644
--- a/spaghetti-monster/fsm-adc.c
+++ b/spaghetti-monster/fsm-adc.c
@@ -306,10 +306,28 @@ static inline void ADC_voltage_handler() {
uint16_t measurement;
// latest ADC value
- if (adc_reset) { // while asleep, or just after waking, don't lowpass
+ if (adc_reset) { // just after waking, don't lowpass
measurement = adc_raw[0];
- adc_smooth[0] = measurement; // no lowpass while asleep
+ adc_smooth[0] = measurement; // no lowpass, just use the latest value
}
+ #ifdef USE_LOWPASS_WHILE_ASLEEP
+ else if (go_to_standby) { // weaker lowpass while asleep
+ // occasionally the aux LED color can oscillate during standby,
+ // while using "voltage" mode ... so try to reduce the oscillation
+ uint16_t m = adc_raw[0];
+ uint16_t v = adc_smooth[0];
+ #if 0
+ // fixed-rate lowpass, slow, more stable but takes longer to settle
+ if (m < v) { v -= 64; }
+ if (m > v) { v += 64; }
+ #else
+ // weighted lowpass, faster but less stable
+ v = (m>>1) + (v>>1);
+ #endif
+ adc_smooth[0] = v;
+ measurement = v;
+ }
+ #endif
else measurement = adc_smooth[0];
// values stair-step between intervals of 64, with random variations
diff --git a/spaghetti-monster/fsm-standby.c b/spaghetti-monster/fsm-standby.c
index c450bca..0ae6a2f 100644
--- a/spaghetti-monster/fsm-standby.c
+++ b/spaghetti-monster/fsm-standby.c
@@ -73,7 +73,9 @@ void sleep_until_eswitch_pressed()
go_to_standby = 0;
}
if (irq_adc) { // ADC done measuring
+ #ifndef USE_LOWPASS_WHILE_ASLEEP
adc_reset = 1; // don't lowpass while asleep
+ #endif
adc_deferred_enable = 1;
adc_deferred();
//ADC_off(); // takes care of itself
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.