From 35b5c42f8996167248b7e6d2e4053f6bbef1505c Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 26 Mar 2024 03:41:17 -0600 Subject: d3aa: got weak battery detection actually working, and not letting the magic smoke out of updi adapters any more (probably) The alkaline detection might be a little too lenient though; it could potentially fail to activate limits when the cell is completely full or stronger than an average alkaline. One of my test cells measured at 72 / 75, so if it was just a little stronger it'd pass... but most alkalines I tried were in the 40 to 60 range and failed easily. OTOH, if I make it easier to fail, it's likely to trip on normal li-ion cells, and I don't want that. So as a future enhancement idea, maybe it should have a smaller sag threshold for AA and a larger threshold for li-ion. That would reduce false negatives for AA, while still preventing false positives for li-ion. --- hw/hank/emisar-d3aa/hwdef.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'hw/hank/emisar-d3aa/hwdef.h') diff --git a/hw/hank/emisar-d3aa/hwdef.h b/hw/hank/emisar-d3aa/hwdef.h index 1e677b6..7cd2849 100644 --- a/hw/hank/emisar-d3aa/hwdef.h +++ b/hw/hank/emisar-d3aa/hwdef.h @@ -116,12 +116,11 @@ enum CHANNEL_MODES { // Alkaline AA can't handle the power this light wants, // so try to detect it and limit the maximum power +// (also helps protect firmware flashing adapters from overload) #define USE_RAMP_LEVEL_HARD_LIMIT #define USE_WEAK_BATTERY_PROTECTION -#define WEAK_BATTERY_HIGHEST_LIMIT RAMP_SIZE -#define WEAK_BATTERY_MEDIUM_LIMIT (RAMP_SIZE*2/3) -#define WEAK_BATTERY_LOWEST_LIMIT (RAMP_SIZE*1/3) -#define WEAK_BATTERY_CHECK_LEVEL (RAMP_SIZE*2/3) +#define WEAK_BATTERY_TEST_MAX_LEVEL 75 // about 300 mA +#define WEAK_BATTERY_SAG_THRESHOLD (5*4) // 0.5 V // average drop across diode on this hardware #ifndef VOLTAGE_FUDGE_FACTOR -- cgit v1.2.3