aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2024-03-29 08:21:07 -0600
committerSelene ToyKeeper2024-03-29 08:21:07 -0600
commit3cafb86c00a95a70e58144230f641c2c94208e7b (patch)
treef0da65c64f98b253c2a611f7c1d672ff60765568
parentweak battery detection: use different thresholds for AA and Li-Ion (diff)
downloadanduril-3cafb86c00a95a70e58144230f641c2c94208e7b.tar.gz
anduril-3cafb86c00a95a70e58144230f641c2c94208e7b.tar.bz2
anduril-3cafb86c00a95a70e58144230f641c2c94208e7b.zip
d3aa weak battery test: blink 3x instead of 2x, and omit number readout
Diffstat (limited to '')
-rw-r--r--hw/hank/emisar-d3aa/anduril.h4
-rw-r--r--hw/hank/emisar-d3aa/hwdef.c16
-rw-r--r--hw/hank/emisar-d3aa/hwdef.h3
3 files changed, 18 insertions, 5 deletions
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<extra_blinks; i++) {
delay_4ms(300/4);
blink_once();
}
+ #ifdef USE_WEAK_BATTERY_PROTECTION_READOUT
+ // this numeric display isn't really needed by default,
+ // but the code remains in case anyone wants to use it
if (ramp_level_hard_limit) {
delay_4ms(255);
// not booted far enough for this to work yet
@@ -190,6 +197,7 @@ void detect_weak_battery() {
blink_once();
}
}
+ #endif // ifdef USE_WEAK_BATTERY_PROTECTION_READOUT
}
#endif // ifdef USE_WEAK_BATTERY_PROTECTION
diff --git a/hw/hank/emisar-d3aa/hwdef.h b/hw/hank/emisar-d3aa/hwdef.h
index 7fbffbe..c675208 100644
--- a/hw/hank/emisar-d3aa/hwdef.h
+++ b/hw/hank/emisar-d3aa/hwdef.h
@@ -119,7 +119,8 @@ enum CHANNEL_MODES {
// (also helps protect firmware flashing adapters from overload)
#define USE_RAMP_LEVEL_HARD_LIMIT
#define USE_WEAK_BATTERY_PROTECTION
-#define WEAK_BATTERY_TEST_MAX_LEVEL 75 // about 300 mA
+// define this next to the ramp table instead
+//#define WEAK_BATTERY_TEST_MAX_LEVEL 75 // about 300 mA
#define WEAK_BATTERY_SAG_THRESHOLD_AA (3*4) // 0.3 V
#define WEAK_BATTERY_SAG_THRESHOLD_LIION (6*4) // 0.6 V
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.