aboutsummaryrefslogtreecommitdiff
path: root/hw/hank/emisar-d3aa
diff options
context:
space:
mode:
Diffstat (limited to 'hw/hank/emisar-d3aa')
-rw-r--r--hw/hank/emisar-d3aa/hwdef.c22
-rw-r--r--hw/hank/emisar-d3aa/readme.md18
2 files changed, 33 insertions, 7 deletions
diff --git a/hw/hank/emisar-d3aa/hwdef.c b/hw/hank/emisar-d3aa/hwdef.c
index 0ac0ddc..e6caf46 100644
--- a/hw/hank/emisar-d3aa/hwdef.c
+++ b/hw/hank/emisar-d3aa/hwdef.c
@@ -64,17 +64,17 @@ void set_level_main(uint8_t level) {
PWM1_DATATYPE dac_lvl = PWM1_GET(level) << 6;
PWM2_DATATYPE dac_vref = PWM2_GET(level);
+ // set these in successive clock cycles to avoid getting out of sync
+ // (minimizes ramp bumps when changing gears)
+ DAC_LVL = dac_lvl;
+ DAC_VREF = dac_vref;
+
// enable HDR on top half of ramp
if (level >= (HDR_ENABLE_LEVEL_MIN-1))
HDR_ENABLE_PORT |= (1 << HDR_ENABLE_PIN);
else
HDR_ENABLE_PORT &= ~(1 << HDR_ENABLE_PIN);
- // set these in successive clock cycles to avoid getting out of sync
- // (minimizes ramp bumps when changing gears)
- DAC_LVL = dac_lvl;
- DAC_VREF = dac_vref;
-
// if turning on from off, let things stabilize before enabling power
if (noflash) { nfet_delay(); }
@@ -146,9 +146,17 @@ void detect_weak_battery() {
uint16_t resting, loaded;
- // baseline unloaded measurement
set_level(0);
- for (uint8_t i=0; i<32; i++) { delay_zero(); } // wait about 10ms
+
+ // wait a moment so user can tighten the tailcap
+ #ifdef WEAK_BATTERY_TEST_DELAY
+ for (uint16_t i=0; i<(WEAK_BATTERY_TEST_DELAY * 2 / 3); i++)
+ delay_zero();
+ #else
+ for (uint8_t i=0; i<32; i++) delay_zero(); // wait about 10ms
+ #endif
+
+ // baseline unloaded measurement
//resting = voltage_raw2cooked(adc_smooth[0]); // probably not settled yet
resting = quick_volt_measurement();
diff --git a/hw/hank/emisar-d3aa/readme.md b/hw/hank/emisar-d3aa/readme.md
new file mode 100644
index 0000000..f234dad
--- /dev/null
+++ b/hw/hank/emisar-d3aa/readme.md
@@ -0,0 +1,18 @@
+# Emisar D3AA
+
+This driver measures battery strength when power is connected, and uses that
+info to set a hard limit on brightness when the battery is too weak to handle
+full power.
+
+The number of blinks at power-connect indicates the battery type and strength:
+
+- 1 blink: Strong Li-ion cell, full power enabled
+
+- 2 blinks: Strong AA cell, max AA power enabled
+ (not used, strong AA uses mode 1 with full power enabled)
+
+- 3 blinks: Weak battery, power severely limited
+
+The 2-blink mode is not actually used. So it should blink 1 time or 3 times,
+depending on the cell strength.
+
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.