diff options
| -rw-r--r-- | spaghetti-monster/anduril/aux-leds.c | 9 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-2ch.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-d1v2-7135-fet.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-d1v2-linear-fet.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-d1v2-nofet.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-noctigon-dm11-12v.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-noctigon-dm11-sbt90.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-noctigon-dm11.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-nofet.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-noctigon-k9.3.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-adc.c | 2 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-adc.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-standby.c | 9 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-wdt.c | 3 |
15 files changed, 16 insertions, 40 deletions
diff --git a/spaghetti-monster/anduril/aux-leds.c b/spaghetti-monster/anduril/aux-leds.c index d9b23d0..c72eb70 100644 --- a/spaghetti-monster/anduril/aux-leds.c +++ b/spaghetti-monster/anduril/aux-leds.c @@ -108,15 +108,6 @@ void rgb_led_update(uint8_t mode, uint8_t arg) { const uint8_t *colors = rgb_led_colors; uint8_t actual_color = 0; if (color < 7) { // normal color - #ifdef USE_K93_LOCKOUT_KLUDGE - // FIXME: jank alert: this is dumb - // this clause does nothing; it just uses up clock cycles - // because without it, the K9.3's lockout mode fails and returns - // to "off" after ~5 to 15 seconds when configured for a blinking - // single color, even though there is no code path from lockout to - // "off", and it doesn't act like a reboot either (no boot-up blink) - rainbow = (rainbow + 1 + pseudo_rand() % 5) % 6; - #endif actual_color = pgm_read_byte(colors + color); } else if (color == 7) { // disco diff --git a/spaghetti-monster/anduril/cfg-emisar-2ch.h b/spaghetti-monster/anduril/cfg-emisar-2ch.h index 00ef117..69e1524 100644 --- a/spaghetti-monster/anduril/cfg-emisar-2ch.h +++ b/spaghetti-monster/anduril/cfg-emisar-2ch.h @@ -109,6 +109,3 @@ // for consistency with KR4 (not otherwise necessary though) #define USE_SOFT_FACTORY_RESET - -// work around bizarre bug: lockout mode fails when set to solid color blinking -//#define USE_K93_LOCKOUT_KLUDGE diff --git a/spaghetti-monster/anduril/cfg-emisar-d1v2-7135-fet.h b/spaghetti-monster/anduril/cfg-emisar-d1v2-7135-fet.h index 15464db..6df56cf 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d1v2-7135-fet.h +++ b/spaghetti-monster/anduril/cfg-emisar-d1v2-7135-fet.h @@ -30,6 +30,3 @@ #endif #define THERM_FASTER_LEVEL (RAMP_SIZE*9/10) // throttle back faster when high - -// work around bizarre bug: lockout mode fails when set to solid color blinking -#define USE_K93_LOCKOUT_KLUDGE diff --git a/spaghetti-monster/anduril/cfg-emisar-d1v2-linear-fet.h b/spaghetti-monster/anduril/cfg-emisar-d1v2-linear-fet.h index c8864bf..c1f7238 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d1v2-linear-fet.h +++ b/spaghetti-monster/anduril/cfg-emisar-d1v2-linear-fet.h @@ -28,6 +28,3 @@ #endif #define THERM_FASTER_LEVEL (RAMP_SIZE*9/10) // throttle back faster when high - -// work around bizarre bug: lockout mode fails when set to solid color blinking -#define USE_K93_LOCKOUT_KLUDGE diff --git a/spaghetti-monster/anduril/cfg-emisar-d1v2-nofet.h b/spaghetti-monster/anduril/cfg-emisar-d1v2-nofet.h index ede1b67..a68a333 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d1v2-nofet.h +++ b/spaghetti-monster/anduril/cfg-emisar-d1v2-nofet.h @@ -22,6 +22,3 @@ #undef SIMPLE_UI_CEIL #define SIMPLE_UI_CEIL RAMP_SMOOTH_CEIL - -// work around bizarre bug: lockout mode fails when set to solid color blinking -#define USE_K93_LOCKOUT_KLUDGE diff --git a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h index bfbcba0..c9a0b4f 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h +++ b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h @@ -86,6 +86,3 @@ // for consistency with KR4 (not otherwise necessary though) #define USE_SOFT_FACTORY_RESET - -// work around bizarre bug: lockout mode fails when set to solid color blinking -#define USE_K93_LOCKOUT_KLUDGE diff --git a/spaghetti-monster/anduril/cfg-noctigon-dm11-12v.h b/spaghetti-monster/anduril/cfg-noctigon-dm11-12v.h index e0fc162..7798206 100644 --- a/spaghetti-monster/anduril/cfg-noctigon-dm11-12v.h +++ b/spaghetti-monster/anduril/cfg-noctigon-dm11-12v.h @@ -77,6 +77,3 @@ // added for convenience #define USE_SOFT_FACTORY_RESET - -// work around bizarre bug: lockout mode fails when set to solid color blinking -#define USE_K93_LOCKOUT_KLUDGE diff --git a/spaghetti-monster/anduril/cfg-noctigon-dm11-sbt90.h b/spaghetti-monster/anduril/cfg-noctigon-dm11-sbt90.h index 5a978b5..94c9a52 100644 --- a/spaghetti-monster/anduril/cfg-noctigon-dm11-sbt90.h +++ b/spaghetti-monster/anduril/cfg-noctigon-dm11-sbt90.h @@ -76,6 +76,3 @@ // added for convenience #define USE_SOFT_FACTORY_RESET - -// work around bizarre bug: lockout mode fails when set to solid color blinking -#define USE_K93_LOCKOUT_KLUDGE diff --git a/spaghetti-monster/anduril/cfg-noctigon-dm11.h b/spaghetti-monster/anduril/cfg-noctigon-dm11.h index d9b0b8c..5f3cb80 100644 --- a/spaghetti-monster/anduril/cfg-noctigon-dm11.h +++ b/spaghetti-monster/anduril/cfg-noctigon-dm11.h @@ -76,6 +76,3 @@ // added for convenience #define USE_SOFT_FACTORY_RESET - -// work around bizarre bug: lockout mode fails when set to solid color blinking -#define USE_K93_LOCKOUT_KLUDGE diff --git a/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-nofet.h b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-nofet.h index b505701..8eb55dc 100644 --- a/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-nofet.h +++ b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-nofet.h @@ -83,6 +83,3 @@ // for consistency with KR4 (not otherwise necessary though) #define USE_SOFT_FACTORY_RESET - -// work around bizarre bug: lockout mode fails when set to solid color blinking -#define USE_K93_LOCKOUT_KLUDGE diff --git a/spaghetti-monster/anduril/cfg-noctigon-k9.3.h b/spaghetti-monster/anduril/cfg-noctigon-k9.3.h index dfe1d18..bf504d2 100644 --- a/spaghetti-monster/anduril/cfg-noctigon-k9.3.h +++ b/spaghetti-monster/anduril/cfg-noctigon-k9.3.h @@ -84,6 +84,3 @@ inline void set_level_override(uint8_t level); // for consistency with KR4 (not otherwise necessary though) #define USE_SOFT_FACTORY_RESET - -// work around bizarre bug: lockout mode fails when set to solid color blinking -#define USE_K93_LOCKOUT_KLUDGE diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c index 5b238aa..0b79767 100644 --- a/spaghetti-monster/fsm-adc.c +++ b/spaghetti-monster/fsm-adc.c @@ -244,6 +244,8 @@ void adc_deferred() { // (and the usual standby level is only ~20 uA) if (go_to_standby) { ADC_off(); + // if any measurements were in progress, they're done now + adc_active_now = 0; // also, only check the battery while asleep, not the temperature adc_channel = 0; } diff --git a/spaghetti-monster/fsm-adc.h b/spaghetti-monster/fsm-adc.h index 16666f9..b25b650 100644 --- a/spaghetti-monster/fsm-adc.h +++ b/spaghetti-monster/fsm-adc.h @@ -32,6 +32,9 @@ volatile uint8_t adc_reset = 2; #endif #endif +#ifdef TICK_DURING_STANDBY +volatile uint8_t adc_active_now = 0; // sleep LVP needs a different sleep mode +#endif volatile uint8_t irq_adc = 0; // ADC interrupt happened? uint8_t adc_sample_count = 0; // skip the first sample; it's junk uint8_t adc_channel = 0; // 0=voltage, 1=temperature diff --git a/spaghetti-monster/fsm-standby.c b/spaghetti-monster/fsm-standby.c index 50e6e30..2ce3a24 100644 --- a/spaghetti-monster/fsm-standby.c +++ b/spaghetti-monster/fsm-standby.c @@ -40,6 +40,15 @@ void sleep_until_eswitch_pressed() #endif // configure sleep mode + #ifdef TICK_DURING_STANDBY + // needs a special sleep mode to get accurate measurements + // quickly ... full power-down ends up using more power + // overall, and causes some weird issues when the MCU + // doesn't stay awake enough cycles to complete a reading + if (adc_active_now) + set_sleep_mode(SLEEP_MODE_ADC); + else + #endif set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_enable(); diff --git a/spaghetti-monster/fsm-wdt.c b/spaghetti-monster/fsm-wdt.c index 847c7fd..7c25e9f 100644 --- a/spaghetti-monster/fsm-wdt.c +++ b/spaghetti-monster/fsm-wdt.c @@ -123,9 +123,10 @@ void WDT_inner() { 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 & 0x3f)) return; + if (0 != (ticks_since_last & 0x07)) return; adc_trigger = 0; // make sure a measurement will happen + adc_active_now = 1; // use ADC noise reduction sleep mode ADC_on(); // enable ADC voltage measurement functions temporarily #endif } |
