From 3cafb86c00a95a70e58144230f641c2c94208e7b Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 29 Mar 2024 08:21:07 -0600 Subject: d3aa weak battery test: blink 3x instead of 2x, and omit number readout --- hw/hank/emisar-d3aa/anduril.h | 4 ++++ hw/hank/emisar-d3aa/hwdef.c | 16 ++++++++++++---- hw/hank/emisar-d3aa/hwdef.h | 3 ++- 3 files changed, 18 insertions(+), 5 deletions(-) (limited to 'hw/hank') diff --git a/hw/hank/emisar-d3aa/anduril.h b/hw/hank/emisar-d3aa/anduril.h index a80557d..e4e4458 100644 --- a/hw/hank/emisar-d3aa/anduril.h +++ b/hw/hank/emisar-d3aa/anduril.h @@ -44,6 +44,10 @@ #define HALFSPEED_LEVEL 41 #define QUARTERSPEED_LEVEL 40 // seems to run fine at 10kHz/4, try reducing more? +// should be about 300 mA or ~100 lm, +// to avoid overloading firmware flashing adapters +#define WEAK_BATTERY_TEST_MAX_LEVEL 75 + #define RAMP_SMOOTH_FLOOR 1 #define RAMP_SMOOTH_CEIL 130 // 50% power // 10 30 [50] 70 90 110 130 diff --git a/hw/hank/emisar-d3aa/hwdef.c b/hw/hank/emisar-d3aa/hwdef.c index 8aaa893..36c6fed 100644 --- a/hw/hank/emisar-d3aa/hwdef.c +++ b/hw/hank/emisar-d3aa/hwdef.c @@ -123,9 +123,10 @@ uint8_t quick_volt_measurement() { void detect_weak_battery() { // guess at the cell strength with a load test... - // - measure voltage while LEDs off + // - measure voltage with LEDs off // - measure again with LEDs on // - determine how much to limit power + // (ramp up until battery becomes unstable) // - blink to indicate weak battery mode, if active ramp_level_hard_limit = 0; @@ -162,17 +163,23 @@ void detect_weak_battery() { } set_level(0); - // TODO? limit NiMH to ~half power, even if it passed the sag test? - // (and if so, blink 2X for NiMH, 3X for alkaline) + // Blink again if not in full-power mode: + // - 1 blink total: Strong Li-ion cell, full power enabled + // - 2 blinks: Strong AA cell, max AA power enabled + // (not used on this driver, strong AA uses mode 1) + // - 3 blinks: Weak battery, power severely limited uint8_t extra_blinks = 0; - if (ramp_level_hard_limit) extra_blinks ++; + if (ramp_level_hard_limit) extra_blinks += 2; for (uint8_t i=0; i