aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2026-02-23 23:59:50 -0700
committerSelene ToyKeeper2026-02-23 23:59:50 -0700
commita7dc5522be7220590fe347585a4bb5d7827b10fc (patch)
treeb2f85f0ddf7e69de90d3e26e40d7e75733486e4a
parentadded documentation section for Post-Off Voltage Display (POVD) (diff)
downloadanduril-a7dc5522be7220590fe347585a4bb5d7827b10fc.tar.gz
anduril-a7dc5522be7220590fe347585a4bb5d7827b10fc.tar.bz2
anduril-a7dc5522be7220590fe347585a4bb5d7827b10fc.zip
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"
Diffstat (limited to '')
-rw-r--r--MODELS3
-rw-r--r--hw/hank/emisar-d3aa/hwdef.c22
-rw-r--r--hw/hank/emisar-d3aa/readme.md18
-rw-r--r--hw/hank/kr1aa/anduril.h65
-rw-r--r--hw/hank/kr1aa/arch1
-rw-r--r--hw/hank/kr1aa/model1
-rw-r--r--hw/hank/kr1aa/readme.md12
7 files changed, 114 insertions, 8 deletions
diff --git a/MODELS b/MODELS
index 17536eb..06a8dcf 100644
--- a/MODELS
+++ b/MODELS
@@ -1,4 +1,4 @@
-Models: 78
+Models: 81
Model MCU Name
----- --- ----
@@ -24,6 +24,7 @@ Model MCU Name
0143 attiny1634 hank-noctigon-m44
0151 attiny1634 hank-emisar-d4k-3ch
0161 avr32dd20 hank-emisar-d3aa
+0162 avr32dd20 hank-kr1aa
0211 attiny1634 hank-noctigon-kr4
0212 attiny1634 hank-noctigon-kr4-nofet
0213 attiny1634 hank-noctigon-kr4-219
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.
+
diff --git a/hw/hank/kr1aa/anduril.h b/hw/hank/kr1aa/anduril.h
new file mode 100644
index 0000000..f3ed9ad
--- /dev/null
+++ b/hw/hank/kr1aa/anduril.h
@@ -0,0 +1,65 @@
+// Emisar / Noctigon KR1AA config options for Anduril
+// Copyright (C) 2026 Selene ToyKeeper
+// SPDX-License-Identifier: GPL-3.0-or-later
+#pragma once
+
+#define HWDEF_H hank/emisar-d3aa/hwdef.h
+#include "hank/anduril.h"
+#include "hank/emisar-d3aa/anduril.h"
+
+// wait this many ms at boot before testing the battery
+// (or doing anything else)
+// (to give the user more time to make a solid electrical connection)
+#define WEAK_BATTERY_TEST_DELAY 500
+
+#undef RAMP_SIZE
+#define RAMP_SIZE 150
+
+// 4 ramp segments:
+// - low 1.024V
+// - low 2.5 V
+// - high 1.024V
+// - high 2.5 V
+// 2nd gear starts at 23:
+// ./bin/dac-scale.py $( ./bin/level_calc.py 3.906 1 150 7135 3 0.01 1400 --pwm 285400 | grep PWM1 | cut -d : -f 2- )
+// top level for each "gear": 30 40 118 150
+// 2nd gear starts at 24:
+// ./bin/dac-scale.py $( ./bin/level_calc.py 3.856 1 150 7135 3 0.01 1400 --pwm 273200 | grep PWM1 | cut -d : -f 2- )
+// top level for each "gear": 30 40 117 150
+#undef PWM1_LEVELS
+#define PWM1_LEVELS \
+ 3, 5, 6, 9, 12, 16, 21, 28, 36, 46, 57, 71, 86, 105, 126, 150, 177, 208, 243, 282, 326, 374, 428, 487, 552, 623, 700, 785, 877, 977, \
+ 444, 491, 543, 598, 658, 722, 790, 862, 940,1023, \
+ 24, 26, 29, 31, 33, 36, 39, 42, 45, 48, 52, 55, 59, 63, 67, 71, 76, 81, 86, 91, 96, 102, 108, 114, 120, 127, 134, 141, 149, 157, 165, 173, 182, 191, 200, 210, 220, 230, 241, 252, 264, 276, 288, 301, 314, 327, 341, 355, 370, 385, 401, 417, 434, 451, 469, 487, 505, 525, 544, 564, 585, 607, 628, 651, 674, 698, 722, 747, 773, 799, 826, 853, 881, 910, 940, 970,1001, \
+ 423, 436, 450, 463, 478, 492, 507, 522, 538, 554, 570, 586, 603, 621, 638, 656, 675, 693, 712, 732, 752, 772, 793, 814, 836, 858, 880, 903, 926, 950, 974, 998,1023
+#undef PWM2_LEVELS
+#define PWM2_LEVELS \
+ V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, \
+ V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, \
+ V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, V10, \
+ V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25
+#define MAX_1x7135 40
+#undef MAX_1x7135
+#define HDR_ENABLE_LEVEL_MIN 41
+#define MAX_1x7135 40
+
+#undef DEFAULT_LEVEL
+#define DEFAULT_LEVEL 50
+
+// no PWM, so MCU clock speed can be slow
+#undef HALFSPEED_LEVEL
+#define HALFSPEED_LEVEL 41
+#undef QUARTERSPEED_LEVEL
+#define QUARTERSPEED_LEVEL 40 // seems to run fine at 10kHz/4, try reducing more?
+
+
+// AUX
+
+// there is no lighted button
+// (but it doesn't hurt to leave this enabled,
+// and then this firmware can be used on D3AA too)
+//#ifdef USE_BUTTON_LED
+//#undef USE_BUTTON_LED
+//#endif
+
+
diff --git a/hw/hank/kr1aa/arch b/hw/hank/kr1aa/arch
new file mode 100644
index 0000000..bcf4552
--- /dev/null
+++ b/hw/hank/kr1aa/arch
@@ -0,0 +1 @@
+avr32dd20
diff --git a/hw/hank/kr1aa/model b/hw/hank/kr1aa/model
new file mode 100644
index 0000000..cdc9591
--- /dev/null
+++ b/hw/hank/kr1aa/model
@@ -0,0 +1 @@
+0162
diff --git a/hw/hank/kr1aa/readme.md b/hw/hank/kr1aa/readme.md
new file mode 100644
index 0000000..247080b
--- /dev/null
+++ b/hw/hank/kr1aa/readme.md
@@ -0,0 +1,12 @@
+# Emisar / Noctigon KR1AA
+
+This is the same as the [D3AA](../emisar-d3aa) driver, but with the following
+changes:
+
+- Increased the time before measuring battery strength, to give the user more
+ time to tighten the tailcap first. The host has a reputation for being
+ difficult to tighten quickly enough to get a strong connection.
+
+- Tweaked the ramp shape slightly to eliminate a "gear change" zig-zag which
+ seems to occur on KR1AA but not D3AA.
+