diff options
Diffstat (limited to 'spaghetti-monster')
| -rw-r--r-- | spaghetti-monster/anduril/MODELS | 5 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-blf-lantern-t1616.h | 18 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-blf-lantern.h | 23 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h | 62 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h | 84 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-ff-rot66.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-219.h | 10 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-fet.h | 63 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-nofet.h | 84 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-main.c | 4 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-ramping.c | 138 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-ramping.h | 8 |
13 files changed, 418 insertions, 85 deletions
diff --git a/spaghetti-monster/anduril/MODELS b/spaghetti-monster/anduril/MODELS index f4a0531..11f7dfa 100644 --- a/spaghetti-monster/anduril/MODELS +++ b/spaghetti-monster/anduril/MODELS @@ -11,6 +11,8 @@ Model numbers: 0132 emisar-d4s-219c 0133 emisar-d4sv2 0134 emisar-d4sv2-219 +0135 emisar-d4sv2-tintramp +0136 emisar-d4sv2-tintramp-fet 0141 emisar-d18 0142 emisar-d18-219 0211 noctigon-kr4 @@ -23,6 +25,9 @@ Model numbers: 0261 noctigon-k9.3 0262 noctigon-k9.3-nofet 0263 noctigon-k9.3-219 +0265 noctigon-k9.3-tintramp-nofet +0266 noctigon-k9.3-tintramp-fet +0267 noctigon-k9.3-tintramp-219 0311 fw3a 0312 fw3a-219 0313 fw3a-nofet diff --git a/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h b/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h index 51c3d6a..56c7275 100644 --- a/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h +++ b/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h @@ -1,12 +1,6 @@ // BLF Lantern config options for Anduril using the Attiny1616 #define MODEL_NUMBER "0622" -/* BLF Lantern pinout - * PB0 is 5000K channel - * PB1 is 3000K channel - */ - -// basically the same as a Q8... sort of -#include "hwdef-BLF_Q8-T1616.h" +#include "hwdef-BLF_LT1-t1616.h" // ATTINY: 1616 // the button lights up @@ -53,7 +47,7 @@ // LT1 can handle heat well, so don't limit simple mode #define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR -#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL +#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL #define SIMPLE_UI_STEPS RAMP_DISCRETE_STEPS #define USE_SOS_MODE @@ -65,14 +59,6 @@ #undef USE_THERMAL_REGULATION #endif -// also, the set_level_gradually() thing isn't compatible with tint ramping -// (but unsetting it here doesn't actually do anything, because the thermal -// regulation define enables it later... so this is mostly just a note to -// make this compatibility issue explicit) -#ifdef USE_SET_LEVEL_GRADUALLY -#undef USE_SET_LEVEL_GRADUALLY -#endif - // don't blink while ramping #ifdef BLINK_AT_RAMP_MIDDLE #undef BLINK_AT_RAMP_MIDDLE diff --git a/spaghetti-monster/anduril/cfg-blf-lantern.h b/spaghetti-monster/anduril/cfg-blf-lantern.h index 28c7dbb..48ed1f7 100644 --- a/spaghetti-monster/anduril/cfg-blf-lantern.h +++ b/spaghetti-monster/anduril/cfg-blf-lantern.h @@ -1,16 +1,7 @@ // BLF Lantern config options for Anduril #define MODEL_NUMBER "0621" -/* BLF Lantern pinout - * ---- - * Reset -|1 8|- VCC - * eswitch -|2 7|- powerbank enable? - * aux LED -|3 6|- PWM (5000K) - * GND -|4 5|- PWM (3000K) - * ---- - */ - -// basically the same as a Q8... sort of -#include "hwdef-BLF_Q8.h" +#include "hwdef-BLF_LT1.h" +// ATTINY: 85 // the button lights up #define USE_INDICATOR_LED @@ -56,7 +47,7 @@ // LT1 can handle heat well, so don't limit simple mode #define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR -#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL +#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL #define SIMPLE_UI_STEPS RAMP_DISCRETE_STEPS #define USE_SOS_MODE @@ -68,14 +59,6 @@ #undef USE_THERMAL_REGULATION #endif -// also, the set_level_gradually() thing isn't compatible with tint ramping -// (but unsetting it here doesn't actually do anything, because the thermal -// regulation define enables it later... so this is mostly just a note to -// make this compatibility issue explicit) -#ifdef USE_SET_LEVEL_GRADUALLY -#undef USE_SET_LEVEL_GRADUALLY -#endif - // don't blink while ramping #ifdef BLINK_AT_RAMP_MIDDLE #undef BLINK_AT_RAMP_MIDDLE 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 new file mode 100644 index 0000000..c170645 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h @@ -0,0 +1,84 @@ +// Emisar D4S V2 tint-ramping config options for Anduril (based on Noctigon K9.3) +#define MODEL_NUMBER "0135" +#include "hwdef-Emisar_D4Sv2-tintramp.h" +#include "hank-cfg.h" +// ATTINY: 1634 + +// this light has three aux LED channels: R, G, B +#define USE_AUX_RGB_LEDS +// the aux LEDs are front-facing, so turn them off while main LEDs are on +// it also has an independent LED in the button +#define USE_BUTTON_LED +// TODO: the whole "indicator LED" thing needs to be refactored into +// "aux LED(s)" and "button LED(s)" since they work a bit differently +// enabling this option breaks the button LED on D4v2.5 +#ifdef USE_INDICATOR_LED_WHILE_RAMPING +#undef USE_INDICATOR_LED_WHILE_RAMPING +#endif + +// has two channels of independent LEDs +#define USE_TINT_RAMPING +// how much to increase total brightness at middle tint +// (0 = 100% brightness, 64 = 200% brightness) +#define TINT_RAMPING_CORRECTION 0 // none, linear regulator doesn't need it + +// main LEDs +// output: unknown, 2000 lm? +// FET: absent / unused? +// 2nd LEDs +// output: unknown, 2000 lm? +#define RAMP_LENGTH 150 +// level_calc.py 5.01 1 150 7135 1 0.2 2000 --pwm dyn:74: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,32,35,37,40,42,45,47,50,53,56,59,62,65,68,71,74,77,80,83,86,89,91,94,96,98,100,102,104,105,106,107,107,107,106,105,103,101,98,94,90,84,78,71,63,54,44,33,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,13673,10738,15435,11908,8123,12779,14756,12240,13447,14013,11907,12263,12351,12261,12048,12926,12464,11972,12278,11704,11789,11180,11134,11013,10837,10620,10371,10100,10113,9793,9718,9376,9248,8898,8738,8560,8369,8168,7961,7749,7535,7321,7107,6895,6686,6480,6278,6080,5823,5639,5403,5178,4965,4763,4570,4346,4134,3936,3714,3507,3283,3074,2853,2648,2433,2211,2006,1776,1564,1351,1137,924,714,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 +#define DEFAULT_LEVEL 70 +#define MAX_1x7135 150 +#define HALFSPEED_LEVEL 10 +#define QUARTERSPEED_LEVEL 2 + +#define USE_MANUAL_MEMORY_TIMER_FOR_TINT +//#define DEFAULT_MANUAL_MEMORY DEFAULT_LEVEL +//#define DEFAULT_MANUAL_MEMORY_TIMER 10 + +#define RAMP_SMOOTH_FLOOR 10 // level 1 is unreliable (?) +#define RAMP_SMOOTH_CEIL 130 +// 10, 30, 50, [70], 90, 110, [130] +#define RAMP_DISCRETE_FLOOR 10 +#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL +#define RAMP_DISCRETE_STEPS 7 + +// safe limit highest regulated power (no FET or turbo) +#define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR +#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL +#define SIMPLE_UI_STEPS 5 + +// stop panicking at ~1500 lm +#define THERM_FASTER_LEVEL 140 +#define MIN_THERM_STEPDOWN 75 // should be above highest dyn_pwm level + +// use the brightest setting for strobe +#define STROBE_BRIGHTNESS MAX_LEVEL +// slow down party strobe; this driver can't pulse for 1ms or less +#define PARTY_STROBE_ONTIME 2 + +// the default of 26 looks a bit flat, so increase it +#define CANDLE_AMPLITUDE 40 + +// the power regulator is a bit slow, so push it harder for a quick response from off +#define DEFAULT_JUMP_START_LEVEL 21 +#define BLINK_BRIGHTNESS DEFAULT_LEVEL +#define BLINK_ONCE_TIME 12 // longer blink, since main LEDs are slow + +#define THERM_CAL_OFFSET 5 + +#ifdef BLINK_AT_RAMP_MIDDLE +#undef BLINK_AT_RAMP_MIDDLE +#endif + +// for consistency with KR4 (not otherwise necessary though) +#define USE_SOFT_FACTORY_RESET + + +// work around bizarre bug: lockout mode fails when set to solid color blinking +#define USE_K93_LOCKOUT_KLUDGE diff --git a/spaghetti-monster/anduril/cfg-ff-rot66.h b/spaghetti-monster/anduril/cfg-ff-rot66.h index 7e21fe7..48541a7 100644 --- a/spaghetti-monster/anduril/cfg-ff-rot66.h +++ b/spaghetti-monster/anduril/cfg-ff-rot66.h @@ -43,3 +43,5 @@ // too big, remove stuff to make room #undef USE_RAMP_AFTER_MOON_CONFIG +#undef USE_RAMP_SPEED_CONFIG +//#undef USE_2C_STYLE_CONFIG diff --git a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h index 962317e..86e8c26 100644 --- a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h +++ b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h @@ -53,4 +53,6 @@ // too big, remove stuff to make room +#undef USE_RAMP_AFTER_MOON_CONFIG #undef USE_RAMP_SPEED_CONFIG +//#undef USE_2C_STYLE_CONFIG diff --git a/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-219.h b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-219.h new file mode 100644 index 0000000..04efa83 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-219.h @@ -0,0 +1,10 @@ +// Noctigon K9.3 tint-ramping (reduced FET) config options for Anduril +#include "cfg-noctigon-k9.3-tintramp-fet.h" +#undef MODEL_NUMBER +#define MODEL_NUMBER "0267" +// ATTINY: 1634 + +// 85% FET power +#undef PWM2_LEVELS +#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,4,11,17,24,33,41,51,60,70,80,91,103,116,129,141,156,170,185,200,216 + diff --git a/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-fet.h b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-fet.h new file mode 100644 index 0000000..8535c57 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-fet.h @@ -0,0 +1,63 @@ +// Noctigon K9.3 tint-ramping (plus FET) config options for Anduril +#include "cfg-noctigon-k9.3-tintramp-nofet.h" +#undef MODEL_NUMBER +#define MODEL_NUMBER "0266" +// ATTINY: 1634 + +// enable the FET channel, even though it's ... kinda funky +#undef PWM_CHANNELS +#define PWM_CHANNELS 2 + +// main LEDs +// output: 3000 lm? +// FET: 5000 to 7500 lm +// 2nd LEDs +// output: 1500 lm? +#define RAMP_LENGTH 150 +// level_calc.py 5.01 1 130 7135 1 0.2 2000 --pwm dyn:64:16383:511 +// plus a FET segment +// level_calc.py 2 1 20 7135 5 1000.0 7000 --pwm 255 +// abstract ramp (power is split between both sets of LEDs) +// ','.join([str(511 - int(x*2.005)) for x in fet]) +#undef PWM1_LEVELS +// append: ,501,485,469,453,433,413,391,369,345,321,295,267,237,207,177,143,108,74,38,0 +#define PWM1_LEVELS 1,1,1,2,2,3,3,4,5,6,7,8,9,10,12,13,15,16,18,20,22,24,27,29,32,34,37,40,43,46,49,53,56,59,63,66,70,73,77,80,83,87,90,93,96,98,100,103,104,105,106,107,106,105,104,101,98,94,89,83,76,67,57,46,33,35,37,39,41,43,46,48,51,53,56,59,62,65,68,72,75,79,83,86,91,95,99,104,108,113,118,123,129,135,140,146,153,159,166,172,179,187,194,202,210,218,227,236,245,254,264,274,284,295,306,317,328,340,352,365,378,391,405,419,433,448,463,479,495,511,501,485,469,453,433,413,391,369,345,321,295,267,237,207,177,143,108,74,38,0 +#undef PWM_TOPS +// append: ,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511 +#define PWM_TOPS 16383,13233,9780,13825,9592,13434,9971,12020,12899,13192,13149,12898,12507,12022,12665,11981,12180,11421,11392,11246,11017,10730,10825,10433,10364,9926,9766,9564,9331,9075,8805,8692,8394,8095,7927,7625,7438,7142,6947,6664,6392,6202,5945,5699,5464,5186,4925,4726,4450,4194,3956,3734,3462,3212,2982,2717,2475,2230,1985,1741,1500,1244,996,755,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,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, +#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,5,13,21,29,39,49,60,71,83,95,108,122,137,152,167,184,201,218,236,255 +#undef DEFAULT_LEVEL +#define DEFAULT_LEVEL 70 +#undef MAX_1x7135 +#define MAX_1x7135 130 + +#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 ~3000 lm +#undef THERM_FASTER_LEVEL +#define THERM_FASTER_LEVEL 130 +#undef MIN_THERM_STEPDOWN +#define MIN_THERM_STEPDOWN 65 // 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-noctigon-k9.3-tintramp-nofet.h b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-nofet.h new file mode 100644 index 0000000..21ab415 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-nofet.h @@ -0,0 +1,84 @@ +// Noctigon K9.3 noFET tint-ramping config options for Anduril +#define MODEL_NUMBER "0265" +#include "hwdef-Emisar_D4Sv2-tintramp.h" +#include "hank-cfg.h" +// ATTINY: 1634 + +// this light has three aux LED channels: R, G, B +#define USE_AUX_RGB_LEDS +// the aux LEDs are front-facing, so turn them off while main LEDs are on +// it also has an independent LED in the button +#define USE_BUTTON_LED +// TODO: the whole "indicator LED" thing needs to be refactored into +// "aux LED(s)" and "button LED(s)" since they work a bit differently +// enabling this option breaks the button LED on D4v2.5 +#ifdef USE_INDICATOR_LED_WHILE_RAMPING +#undef USE_INDICATOR_LED_WHILE_RAMPING +#endif + +// has two channels of independent LEDs +#define USE_TINT_RAMPING +// how much to increase total brightness at middle tint +// (0 = 100% brightness, 64 = 200% brightness) +#define TINT_RAMPING_CORRECTION 0 // none, linear regulator doesn't need it + +// main LEDs +// output: 3000 lm? +// FET: disabled +// 2nd LEDs +// output: 1500 lm? +#define RAMP_LENGTH 150 +// level_calc.py 5.01 1 150 7135 1 0.2 2000 --pwm dyn:74: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,32,35,37,40,42,45,47,50,53,56,59,62,65,68,71,74,77,80,83,86,89,91,94,96,98,100,102,104,105,106,107,107,107,106,105,103,101,98,94,90,84,78,71,63,54,44,33,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,13673,10738,15435,11908,8123,12779,14756,12240,13447,14013,11907,12263,12351,12261,12048,12926,12464,11972,12278,11704,11789,11180,11134,11013,10837,10620,10371,10100,10113,9793,9718,9376,9248,8898,8738,8560,8369,8168,7961,7749,7535,7321,7107,6895,6686,6480,6278,6080,5823,5639,5403,5178,4965,4763,4570,4346,4134,3936,3714,3507,3283,3074,2853,2648,2433,2211,2006,1776,1564,1351,1137,924,714,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 +#define DEFAULT_LEVEL 70 +#define MAX_1x7135 150 +#define HALFSPEED_LEVEL 10 +#define QUARTERSPEED_LEVEL 2 + +#define USE_MANUAL_MEMORY_TIMER_FOR_TINT +//#define DEFAULT_MANUAL_MEMORY DEFAULT_LEVEL +//#define DEFAULT_MANUAL_MEMORY_TIMER 10 + +#define RAMP_SMOOTH_FLOOR 10 // level 1 is unreliable (?) +#define RAMP_SMOOTH_CEIL 130 +// 10, 30, 50, [70], 90, 110, [130] +#define RAMP_DISCRETE_FLOOR 10 +#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL +#define RAMP_DISCRETE_STEPS 7 + +// safe limit highest regulated power (no FET or turbo) +#define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR +#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL +#define SIMPLE_UI_STEPS 5 + +// stop panicking at ~2000 lm +#define THERM_FASTER_LEVEL 140 +#define MIN_THERM_STEPDOWN 75 // should be above highest dyn_pwm level + +// use the brightest setting for strobe +#define STROBE_BRIGHTNESS MAX_LEVEL +// slow down party strobe; this driver can't pulse for 1ms or less +#define PARTY_STROBE_ONTIME 2 + +// the default of 26 looks a bit flat, so increase it +#define CANDLE_AMPLITUDE 40 + +// the power regulator is a bit slow, so push it harder for a quick response from off +#define DEFAULT_JUMP_START_LEVEL 21 +#define BLINK_BRIGHTNESS DEFAULT_LEVEL +#define BLINK_ONCE_TIME 12 // longer blink, since main LEDs are slow + +#define THERM_CAL_OFFSET 9 + +#ifdef BLINK_AT_RAMP_MIDDLE +#undef BLINK_AT_RAMP_MIDDLE +#endif + +// for consistency with KR4 (not otherwise necessary though) +#define USE_SOFT_FACTORY_RESET + + +// work around bizarre bug: lockout mode fails when set to solid color blinking +#define USE_K93_LOCKOUT_KLUDGE diff --git a/spaghetti-monster/fsm-main.c b/spaghetti-monster/fsm-main.c index f3c319c..7031009 100644 --- a/spaghetti-monster/fsm-main.c +++ b/spaghetti-monster/fsm-main.c @@ -47,7 +47,9 @@ static inline void hw_setup() { TCCR0B = 0x01; // pre-scaler for timer (1 => 1, 2 => 8, 3 => 64...) TCCR0A = PHASE; #endif - #if PWM_CHANNELS >= 2 + // tint ramping needs second channel enabled, + // despite PWM_CHANNELS being only 1 + #if (PWM_CHANNELS >= 2) || defined(USE_TINT_RAMPING) DDRB |= (1 << PWM2_PIN); #endif #if PWM_CHANNELS >= 3 diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index 54ca45c..e8fcde7 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -89,6 +89,10 @@ void set_level(uint8_t level) { #if PWM_CHANNELS >= 4 PWM4_LVL = 0; #endif + #ifdef USE_TINT_RAMPING + TINT1_LVL = 0; + TINT2_LVL = 0; + #endif // disable the power channel, if relevant #ifdef LED_ENABLE_PIN LED_ENABLE_PORT &= ~(1 << LED_ENABLE_PIN); @@ -117,44 +121,6 @@ void set_level(uint8_t level) { // PWM array index = level - 1 level --; - #ifdef USE_TINT_RAMPING - #ifndef TINT_RAMPING_CORRECTION - #define TINT_RAMPING_CORRECTION 26 // 140% brightness at middle tint - #endif - // calculate actual PWM levels based on a single-channel ramp - // and a global tint value - uint8_t brightness = PWM_GET(pwm1_levels, level); - uint8_t warm_PWM, cool_PWM; - - // auto-tint modes - uint8_t mytint; - #if 1 - // perceptual by ramp level - if (tint == 0) { mytint = 255 * (uint16_t)level / RAMP_SIZE; } - else if (tint == 255) { mytint = 255 - (255 * (uint16_t)level / RAMP_SIZE); } - #else - // linear with power level - //if (tint == 0) { mytint = brightness; } - //else if (tint == 255) { mytint = 255 - brightness; } - #endif - // stretch 1-254 to fit 0-255 range (hits every value except 98 and 198) - else { mytint = (tint * 100 / 99) - 1; } - - // middle tints sag, so correct for that effect - uint16_t base_PWM = brightness; - // correction is only necessary when PWM is fast - if (level > HALFSPEED_LEVEL) { - base_PWM = brightness - + ((((uint16_t)brightness) * TINT_RAMPING_CORRECTION / 64) * triangle_wave(mytint) / 255); - } - - cool_PWM = (((uint16_t)mytint * (uint16_t)base_PWM) + 127) / 255; - warm_PWM = base_PWM - cool_PWM; - - PWM1_LVL = warm_PWM; - PWM2_LVL = cool_PWM; - #else // ifdef USE_TINT_RAMPING - #if PWM_CHANNELS >= 1 PWM1_LVL = PWM_GET(pwm1_levels, level); #endif @@ -168,8 +134,6 @@ void set_level(uint8_t level) { PWM4_LVL = PWM_GET(pwm4_levels, level); #endif - #endif // ifdef USE_TINT_RAMPING - #ifdef USE_DYN_PWM uint16_t top = PWM_GET(pwm_tops, level); #ifdef PWM1_CNT @@ -214,6 +178,10 @@ void set_level(uint8_t level) { } #endif } + #ifdef USE_TINT_RAMPING + update_tint(); + #endif + #ifdef PWM1_CNT prev_level = api_level; #endif @@ -236,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) @@ -244,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 @@ -251,14 +221,23 @@ void gradual_tick() { #if PWM_CHANNELS >= 1 target = PWM_GET(pwm1_levels, gt); - if ((gt < actual_level) // special case for FET-only turbo - && (PWM1_LVL == 0) // (bypass adjustment period for first step) - && (target == PWM_TOP)) PWM1_LVL = PWM_TOP; - else if (PWM1_LVL < target) PWM1_LVL ++; + #if PWM_CHANNELS > 1 + if ((gt < actual_level) // special case for FET-only turbo + && (PWM1_LVL == 0) // (bypass adjustment period for first step) + && (target == PWM_TOP)) PWM1_LVL = PWM_TOP; + else + #endif + if (PWM1_LVL < target) PWM1_LVL ++; else if (PWM1_LVL > target) PWM1_LVL --; #endif #if PWM_CHANNELS >= 2 target = PWM_GET(pwm2_levels, gt); + #if PWM_CHANNELS > 2 + if ((gt < actual_level) // special case for FET-only turbo + && (PWM2_LVL == 0) // (bypass adjustment period for first step) + && (target == PWM_TOP)) PWM2_LVL = PWM_TOP; + else + #endif if (PWM2_LVL < target) PWM2_LVL ++; else if (PWM2_LVL > target) PWM2_LVL --; #endif @@ -287,14 +266,77 @@ void gradual_tick() { #endif ) { - actual_level = gt + 1; + //actual_level = gt + 1; + set_level(gt + 1); } - #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 + +#if defined(USE_TINT_RAMPING) && (!defined(TINT_RAMP_TOGGLE_ONLY)) +void update_tint() { + #ifndef TINT_RAMPING_CORRECTION + #define TINT_RAMPING_CORRECTION 26 // 140% brightness at middle tint + #endif + + // calculate actual PWM levels based on a single-channel ramp + // and a global tint value + //PWM_DATATYPE brightness = PWM_GET(pwm1_levels, level); + PWM_DATATYPE brightness = PWM1_LVL; + PWM_DATATYPE warm_PWM, cool_PWM; + + // auto-tint modes + uint8_t mytint; + uint8_t level = actual_level - 1; + #if 1 + // perceptual by ramp level + if (tint == 0) { mytint = 255 * (uint16_t)level / RAMP_SIZE; } + else if (tint == 255) { mytint = 255 - (255 * (uint16_t)level / RAMP_SIZE); } + #else + // linear with power level + //if (tint == 0) { mytint = brightness; } + //else if (tint == 255) { mytint = 255 - brightness; } + #endif + // stretch 1-254 to fit 0-255 range (hits every value except 98 and 198) + else { mytint = (tint * 100 / 99) - 1; } + + // middle tints sag, so correct for that effect + PWM_DATATYPE2 base_PWM = brightness; + // correction is only necessary when PWM is fast + #if defined(TINT_RAMPING_CORRECTION) && (TINT_RAMPING_CORRECTION > 0) + if (level > HALFSPEED_LEVEL) { + base_PWM = brightness + + ((((PWM_DATATYPE2)brightness) * TINT_RAMPING_CORRECTION / 64) * triangle_wave(mytint) / 255); + } + #endif + + cool_PWM = (((PWM_DATATYPE2)mytint * (PWM_DATATYPE2)base_PWM) + 127) / 255; + warm_PWM = base_PWM - cool_PWM; + + TINT1_LVL = warm_PWM; + TINT2_LVL = cool_PWM; + + // disable the power channel, if relevant + #ifdef LED_ENABLE_PIN + if (! warm_PWM) + LED_ENABLE_PORT &= ~(1 << LED_ENABLE_PIN); + #endif + #ifdef LED2_ENABLE_PIN + if (! cool_PWM) + LED2_ENABLE_PORT &= ~(1 << LED2_ENABLE_PIN); + #endif +} +#endif // ifdef USE_TINT_RAMPING + + #endif // ifdef USE_RAMPING #endif diff --git a/spaghetti-monster/fsm-ramping.h b/spaghetti-monster/fsm-ramping.h index 7a4fa3b..c1f6064 100644 --- a/spaghetti-monster/fsm-ramping.h +++ b/spaghetti-monster/fsm-ramping.h @@ -42,6 +42,10 @@ inline void set_level_gradually(uint8_t lvl); void gradual_tick(); #endif +#if defined(USE_TINT_RAMPING) && (!defined(TINT_RAMP_TOGGLE_ONLY)) +void update_tint(); +#endif + // auto-detect the data type for PWM tables #ifndef PWM_BITS #define PWM_BITS 8 @@ -49,10 +53,14 @@ void gradual_tick(); #endif #if PWM_BITS <= 8 #define PWM_DATATYPE uint8_t +#define PWM_DATATYPE2 uint16_t #define PWM_TOP 255 #define PWM_GET(x,y) pgm_read_byte(x+y) #else #define PWM_DATATYPE uint16_t +#ifndef PWM_DATATYPE2 +#define PWM_DATATYPE2 uint32_t +#endif #ifndef PWM_TOP #define PWM_TOP 1023 // 10 bits by default #endif |
