aboutsummaryrefslogtreecommitdiff
path: root/hw/hank
diff options
context:
space:
mode:
Diffstat (limited to 'hw/hank')
-rw-r--r--hw/hank/emisar-d3aa/anduril.h60
-rw-r--r--hw/hank/emisar-d3aa/hwdef.c14
-rw-r--r--hw/hank/emisar-d3aa/hwdef.h7
3 files changed, 35 insertions, 46 deletions
diff --git a/hw/hank/emisar-d3aa/anduril.h b/hw/hank/emisar-d3aa/anduril.h
index ca2ed65..a80557d 100644
--- a/hw/hank/emisar-d3aa/anduril.h
+++ b/hw/hank/emisar-d3aa/anduril.h
@@ -1,9 +1,10 @@
-// Emisar D3aa config options for Anduril
+// Emisar D3AA config options for Anduril
// Copyright (C) 2023 thefreeman, Selene ToyKeeper
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#define HWDEF_H hank/emisar-d3aa/hwdef.h
+#include "hank/anduril.h"
// HPRsense : 4.2+0.3+20 = 24.5mR
// Vsense=42.46mV, R1= 165k
@@ -21,36 +22,38 @@
// - high 2.5 V
// HDR ratio: 131.5
// PWM1: DAC Data
-// (level_calc.py 4.3287 1 150 7135 5 0.01 1400 --pwm 400000)
-// (top level for each "gear": 30 40 120 150)
+// 131.5 * 1024 * 2.5 = 336640 total dimming ratio
+// ./bin/dac-scale.py $( ./bin/level_calc.py 4.106 1 150 7135 3 0.01 1400 --pwm 336640 | grep PWM1 | cut -d : -f 2- )
+// top level for each "gear": 30 40 119 150
#define PWM1_LEVELS \
- 3,4,5,7,9,12,15,19,24,29,35,43,51,61,72,84,99,115,133,153,176,202,230,262,297,335,377,424,475,531,592,658,730,809,894,986, \
- 444,488,535,586,641,700,763,830,903,980,1023, \
- 20,22,24,26,28,30,32,35,37,40,43,46,49,52,56,60,63,68,72,77,81,86,92,97,103,109,115,122,129,136,143,151,159,168,177,186,196,206,216,227,239,250,263,275,289,302,316,331,346,362,379,396,413,432,450,470,490,511,532,555,578,602,626,651,678,705,733,761,791,821,853,885,919,953,989, \
- 420,435,451,467,484,501,519,537,556,575,595,615,636,657,679,702,725,749,773,798,824,850,877,905,933,962,992,1023
+ 3, 5, 6, 9, 12, 16, 21, 28, 35, 44, 55, 68, 83, 101, 121, 144, 170, 200, 234, 271, 313, 360, 412, 470, 534, 603, 680, 764, 855, 954, \
+ 434, 482, 534, 590, 650, 715, 784, 858, 938,1023, \
+ 20, 21, 23, 25, 27, 30, 32, 35, 37, 40, 43, 46, 49, 53, 56, 60, 64, 68, 73, 77, 82, 87, 93, 98, 104, 110, 116, 123, 129, 137, 144, 152, 160, 168, 177, 185, 195, 204, 214, 225, 235, 247, 258, 270, 282, 295, 308, 322, 336, 350, 365, 381, 396, 413, 430, 447, 465, 484, 503, 522, 543, 563, 585, 607, 629, 653, 677, 701, 726, 752, 779, 806, 834, 863, 892, 923, 954, 985,1018, \
+ 430, 444, 459, 473, 488, 504, 520, 536, 552, 569, 587, 604, 622, 641, 660, 679, 699, 719, 740, 761, 782, 804, 827, 849, 873, 897, 921, 946, 971, 997,1023
#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,V10,V10,V10,V10,V10,V10, \
- V25,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, \
- 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 47
-#define HDR_ENABLE_LEVEL_MIN 48
+ 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, 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
+#define MAX_1x7135 40
+#define HDR_ENABLE_LEVEL_MIN 41
+
#define DEFAULT_LEVEL 50
// no PWM, so MCU clock speed can be slow
#define HALFSPEED_LEVEL 41
-#define QUARTERSPEED_LEVEL 40 // seems to run fine at 10kHz/4, try reducing more
+#define QUARTERSPEED_LEVEL 40 // seems to run fine at 10kHz/4, try reducing more?
#define RAMP_SMOOTH_FLOOR 1
-#define RAMP_SMOOTH_CEIL 119 // 35% / 0.7A / 700 lm
-// 1 22 [44] 65 87 108 130
-#define RAMP_DISCRETE_FLOOR 1
-#define RAMP_DISCRETE_CEIL 119
+#define RAMP_SMOOTH_CEIL 130 // 50% power
+// 10 30 [50] 70 90 110 130
+#define RAMP_DISCRETE_FLOOR 10
+#define RAMP_DISCRETE_CEIL 130
#define RAMP_DISCRETE_STEPS 7
-// 20 [45] 70 95 120
-#define SIMPLE_UI_FLOOR 20
-#define SIMPLE_UI_CEIL 129 // 50% / ~1A / ~860 lm
+// 10 [40] 70 100 130
+#define SIMPLE_UI_FLOOR 10
+#define SIMPLE_UI_CEIL 130
#define SIMPLE_UI_STEPS 5
// don't blink mid-ramp
@@ -61,17 +64,12 @@
// thermal config
// temperature limit
-#define THERM_FASTER_LEVEL 129 // stop panicking at 50%/1A
+#define THERM_FASTER_LEVEL 130 // stop panicking at 50%/1A
#define MIN_THERM_STEPDOWN MAX_1x7135
// UI
-#define SIMPLE_UI_ACTIVE 0 // advanced UI by default, because prototype
-
-// allow Aux Config and Strobe Modes in Simple UI
-//#define USE_EXTENDED_SIMPLE_UI
-
// Allow 3C in Simple UI for switching between smooth and stepped ramping
#define USE_SIMPLE_UI_RAMPING_TOGGLE
@@ -88,7 +86,7 @@
// show each channel while it scroll by in the menu
#define USE_CONFIG_COLORS
-// blink numbers on the main LEDs by default
+// blink numbers on the main LEDs by default (but allow user to change it)
#define DEFAULT_BLINK_CHANNEL CM_MAIN
// use aux red + aux blue for police strobe
@@ -109,10 +107,8 @@
#define STROBE_OFF_LEVEL 1 // keep the regulator chip on between pulses
// smoother candle mode with bigger oscillations
-#define CANDLE_AMPLITUDE 40
+#define CANDLE_AMPLITUDE 33
-// enable 13H factory reset so it can be used on tail e-switch lights
+// added for convenience
#define USE_SOFT_FACTORY_RESET
-// TODO: disable lowpass while asleep; the MCU oversamples
-
diff --git a/hw/hank/emisar-d3aa/hwdef.c b/hw/hank/emisar-d3aa/hwdef.c
index a963bc2..e2fd315 100644
--- a/hw/hank/emisar-d3aa/hwdef.c
+++ b/hw/hank/emisar-d3aa/hwdef.c
@@ -84,17 +84,9 @@ bool gradual_tick_main(uint8_t gt) {
PWM1_DATATYPE dac_now = DAC_LVL >> 6; // register is left-aligned
PWM1_DATATYPE dac_next = PWM1_GET(gt);
- // adjust multiple times based on how far until the next level
- // (so it adjusts faster/coarser for big steps)
-
- int16_t diff = (dac_next - dac_now);
- if (diff < 0) diff = -diff;
-
- // ~70 max DAC levels per ramp step, 1 + (70 >> 3) = max 10
- uint8_t steps;
- steps = 1 + (diff >> 3);
- for (uint8_t i=0; i<=steps; i++)
- GRADUAL_ADJUST_SIMPLE(dac_next, dac_now);
+ // only adjust 1 dac level, max is 1023
+ // (but speed it up with "#define GRADUAL_ADJUST_SPEED 4" elsewhere)
+ GRADUAL_ADJUST_SIMPLE(dac_next, dac_now);
DAC_LVL = dac_now << 6;
diff --git a/hw/hank/emisar-d3aa/hwdef.h b/hw/hank/emisar-d3aa/hwdef.h
index a104fc2..56dd061 100644
--- a/hw/hank/emisar-d3aa/hwdef.h
+++ b/hw/hank/emisar-d3aa/hwdef.h
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
-/*
+/*
* NiMH/li-ion 9V2A boost driver based on MP3432
* with high dynamic range and DAC control + front aux RGB and button LED
*
@@ -26,7 +26,7 @@
* 16 PF7 UPDI
* 17 PA0 B: aux blue
* 18 PA1
- * 19 PA2 G: aux green
+ * 19 PA2 G: aux green
* 20 PA3 R: aux red
*
* BST EN enable the boost regulator and Op-Amp
@@ -36,7 +36,7 @@
* IN- NFET : pull up after BST enable to eliminate startup flash, pull down otherwise
* BATT LVL : Vbat * (100.0/(330+100))
* VDDIO2 : can be connected to BATT+ with a solder jumper for VDDIO2 voltage sensing
- *
+ *
*/
#define HWDEF_C hank/emisar-d3aa/hwdef.c
@@ -59,6 +59,7 @@ enum CHANNEL_MODES {
#define CHANNEL_MODES_ENABLED 0b0000000000000001
+// DAC max is 1023, Anduril is written for 255, so regulate at 4X speed
#undef GRADUAL_ADJUST_SPEED
#define GRADUAL_ADJUST_SPEED 4
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.