From a7dc5522be7220590fe347585a4bb5d7827b10fc Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Mon, 23 Feb 2026 23:59:50 -0700 Subject: added &hank-kr1aa build for new Emisar / Noctigon KR1AA It's the same as &hank-emisar-d3aa, but needed some minor tweaks: - wait longer before measuring the battery, because it's hard to tighten the tailcap fast enough - ramp adjustments to compensate for slightly different "gear ratio" --- hw/hank/emisar-d3aa/hwdef.c | 22 +++++++++++++++------- hw/hank/emisar-d3aa/readme.md | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 hw/hank/emisar-d3aa/readme.md (limited to 'hw/hank/emisar-d3aa') 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. + -- cgit v1.2.3