aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--hwdef-Emisar_D4Sv2-tintramp.h16
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h62
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h4
-rw-r--r--spaghetti-monster/fsm-ramping.c19
4 files changed, 86 insertions, 15 deletions
diff --git a/hwdef-Emisar_D4Sv2-tintramp.h b/hwdef-Emisar_D4Sv2-tintramp.h
index 64550c3..76f6097 100644
--- a/hwdef-Emisar_D4Sv2-tintramp.h
+++ b/hwdef-Emisar_D4Sv2-tintramp.h
@@ -19,7 +19,7 @@
* 12 PC3 RESET
* 13 PC2 (none)
* 14 PC1 SCK
- * 15 PC0 main LED PWM (FET) (PWM0A) (unused because tint ramping)
+ * 15 PC0 main LED PWM (FET) (PWM0A) (unused on some models because tint ramping)
* 16 PB3 main LED PWM (linear) (PWM1A)
* 17 PB2 MISO
* 18 PB1 MOSI / battery voltage (ADC6)
@@ -63,11 +63,15 @@ uint16_t PWM1_LVL;
#define TINT1_LVL OCR1A // OCR1A is the output compare register for PB3
#define PWM1_CNT TCNT1 // for dynamic PWM, reset phase
-#define PWM2_PIN PA6 // pin 1, 2nd LED Opamp reference
+// gah, this driver is weird...
+// two linear channels are treated as one,
+// while there's also a FET on one channel for turbo on half the LEDs
+// so the FET needs to be "PWM2" but the second linear is "TINT2"
+#define PWM3_PIN PA6 // pin 1, 2nd LED Opamp reference
#define TINT2_LVL OCR1B // OCR1B is the output compare register for PA6
-//#define PWM3_PIN PC0 // pin 15, DD FET PWM
-//#define PWM3_LVL OCR0A // OCR0A is the output compare register for PC0
+#define PWM2_PIN PC0 // pin 15, DD FET PWM
+#define PWM2_LVL OCR0A // OCR0A is the output compare register for PC0
// PWM parameters of both channels are tied together because they share a counter
#define PWM1_TOP ICR1 // holds the TOP value for for variable-resolution PWM
@@ -126,9 +130,9 @@ uint16_t PWM1_LVL;
// ... so just hardcode it in each hwdef file instead
inline void hwdef_setup() {
// enable output ports
- //DDRC = (1 << PWM3_PIN);
+ DDRC = (1 << PWM2_PIN);
DDRB = (1 << PWM1_PIN);
- DDRA = (1 << PWM2_PIN)
+ DDRA = (1 << PWM3_PIN)
| (1 << AUXLED_R_PIN)
| (1 << AUXLED_G_PIN)
| (1 << AUXLED_B_PIN)
diff --git a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h
new file mode 100644
index 0000000..3c638a7
--- /dev/null
+++ b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h
@@ -0,0 +1,62 @@
+// Emisar D4S V2 tint-ramping (plus FET) config options for Anduril (based on Noctigon K9.3)
+#include "cfg-emisar-d4sv2-tintramp.h"
+#undef MODEL_NUMBER
+#define MODEL_NUMBER "0136"
+// ATTINY: 1634
+
+// enable the FET channel, even though it's ... kinda funky
+#undef PWM_CHANNELS
+#define PWM_CHANNELS 2
+
+// main LEDs
+// output: unknown, 2000 lm?
+// FET: unknown, 3000 lm?
+// 2nd LEDs
+// output: unknown, 2000 lm?
+#define RAMP_LENGTH 150
+// level_calc.py 5.01 1 140 7135 1 0.2 2000 --pwm dyn:69:16383:511
+// plus a FET segment
+// level_calc.py 2 1 10 7135 5 50.0 3000 --pwm 255
+// abstract ramp (power is split between both sets of LEDs)
+// append: ,500,482,456,420,374,318,252,178,94,0
+#undef PWM1_LEVELS
+#define PWM1_LEVELS 1,1,1,2,2,3,3,4,5,5,6,7,8,9,10,12,13,14,16,18,19,21,23,25,27,30,32,35,37,40,43,45,48,51,54,58,61,64,67,70,74,77,80,83,86,89,92,95,97,99,101,103,105,106,106,107,106,106,104,102,100,96,92,87,81,73,65,56,45,33,35,37,39,41,43,45,47,49,52,54,57,59,62,65,68,71,74,78,81,85,89,92,96,100,105,109,114,118,123,128,133,139,144,150,156,162,168,175,181,188,195,202,210,217,225,233,242,250,259,268,278,287,297,307,318,328,339,351,362,374,386,399,412,425,438,452,466,481,496,511,500,482,456,420,374,318,252,178,94,0
+// append: ,511,511,511,511,511,511,511,511,511,511
+#undef PWM_TOPS
+#define PWM_TOPS 16383,13469,10296,14694,10845,14620,11496,13507,14400,11954,12507,12676,12605,12376,12036,12805,12240,11650,11882,11933,11243,11155,10988,10763,10497,10569,10223,10164,9781,9646,9475,9071,8870,8652,8422,8330,8077,7823,7569,7318,7169,6919,6676,6439,6209,5986,5770,5561,5305,5063,4834,4618,4413,4180,3925,3723,3468,3264,3016,2787,2576,2333,2111,1885,1658,1412,1189,968,734,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511
+// prepend: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+#define PWM2_LEVELS 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,14,27,45,68,96,129,166,208,255
+#undef DEFAULT_LEVEL
+#define DEFAULT_LEVEL 70
+#undef MAX_1x7135
+#define MAX_1x7135 140
+
+#undef RAMP_SMOOTH_FLOOR
+#define RAMP_SMOOTH_FLOOR 10 // level 1 is unreliable (?)
+#undef RAMP_SMOOTH_CEIL
+#define RAMP_SMOOTH_CEIL 130
+// 10, 30, 50, [70], 90, 110, [130]
+#undef RAMP_DISCRETE_FLOOR
+#define RAMP_DISCRETE_FLOOR 10
+#undef RAMP_DISCRETE_CEIL
+#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL
+#undef RAMP_DISCRETE_STEPS
+#define RAMP_DISCRETE_STEPS 7
+
+// safe limit highest regulated power (no FET or turbo)
+#undef SIMPLE_UI_FLOOR
+#define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR
+#undef SIMPLE_UI_CEIL
+#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL
+#undef SIMPLE_UI_STEPS
+#define SIMPLE_UI_STEPS 5
+
+// stop panicking at ~2000 lm
+#undef THERM_FASTER_LEVEL
+#define THERM_FASTER_LEVEL 140
+#undef MIN_THERM_STEPDOWN
+#define MIN_THERM_STEPDOWN 70 // should be above highest dyn_pwm level
+
+// speed up party strobe; the FET is really fast
+#undef PARTY_STROBE_ONTIME
+
diff --git a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h
index abec6bb..67de5aa 100644
--- a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h
+++ b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h
@@ -28,7 +28,7 @@
// 2nd LEDs
// output: unknown, 2000 lm?
#define RAMP_LENGTH 150
-// level_calc.py 5.01 1 150 7135 1 0.2 2000 --pwm dyn:80:16383:511
+// level_calc.py 5.01 1 150 7135 1 0.2 2000 --pwm dyn:75:16383:511
// abstract ramp (power is split between both sets of LEDs)
#define PWM1_LEVELS 1,1,1,2,2,2,3,4,4,5,6,6,7,8,9,10,12,13,14,16,17,19,20,22,24,26,28,30,33,35,37,40,43,45,48,51,54,57,60,63,66,69,72,75,78,82,85,88,91,93,96,99,101,103,106,107,109,110,111,112,112,112,111,110,108,105,102,98,94,88,82,74,66,57,46,35,37,38,40,42,44,46,48,50,53,55,57,60,63,65,68,71,74,77,80,83,87,90,94,98,102,106,110,114,118,123,128,132,137,142,148,153,159,164,170,176,183,189,196,202,209,216,224,231,239,247,255,263,272,281,290,299,309,318,328,339,349,360,371,382,394,406,418,430,443,456,469,483,497,511
#define PWM_TOPS 16383,13675,10740,15439,11908,8117,12779,14760,12239,13449,14017,11902,12260,12349,12259,12045,12929,12466,11970,12281,11704,11791,11178,11133,11013,10837,10619,10370,10425,10113,9792,9719,9603,9248,9093,8917,8725,8521,8309,8091,7870,7648,7425,7204,6985,6855,6638,6425,6218,5952,5760,5573,5339,5116,4952,4704,4513,4292,4084,3889,3673,3470,3252,3048,2833,2608,2401,2187,1989,1767,1563,1339,1134,929,711,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511
@@ -55,7 +55,7 @@
// stop panicking at ~1500 lm
#define THERM_FASTER_LEVEL 140
-#define MIN_THERM_STEPDOWN 80
+#define MIN_THERM_STEPDOWN 75 // should be above highest dyn_pwm level
// use the brightest setting for strobe
#define STROBE_BRIGHTNESS MAX_LEVEL
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c
index c3a5147..50907ec 100644
--- a/spaghetti-monster/fsm-ramping.c
+++ b/spaghetti-monster/fsm-ramping.c
@@ -204,6 +204,7 @@ void gradual_tick() {
if (gt < actual_level) gt = actual_level - 1;
else if (gt > actual_level) gt = actual_level + 1;
+ /*
#ifdef LED_ENABLE_PIN_LEVEL_MIN
// only enable during part of the ramp
if ((gt >= LED_ENABLE_PIN_LEVEL_MIN)
@@ -212,6 +213,7 @@ void gradual_tick() {
else // disable during other parts of the ramp
LED_ENABLE_PORT &= ~(1 << LED_ENABLE_PIN);
#endif
+ */
gt --; // convert 1-based number to 0-based
@@ -255,14 +257,17 @@ void gradual_tick() {
#endif
)
{
- actual_level = gt + 1;
+ //actual_level = gt + 1;
+ set_level(gt + 1);
}
- #ifdef USE_TINT_RAMPING
- update_tint();
- #endif
- #ifdef USE_DYNAMIC_UNDERCLOCKING
- auto_clock_speed();
- #endif
+ // is handled in set_level()
+ //#ifdef USE_TINT_RAMPING
+ //update_tint();
+ //#endif
+ // is handled in set_level()
+ //#ifdef USE_DYNAMIC_UNDERCLOCKING
+ //auto_clock_speed();
+ //#endif
}
#endif // ifdef OVERRIDE_GRADUAL_TICK
#endif // ifdef USE_SET_LEVEL_GRADUALLY