diff options
| -rw-r--r-- | hwdef-Emisar_D4v2.h | 12 | ||||
| -rw-r--r-- | hwdef-Noctigon_KR4.h | 15 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/anduril.c | 8 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-d18.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-d4sv2.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-d4v2.5-219.h | 12 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-d4v2.5-nofet.h | 48 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-d4v2.5.h | 70 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-ramping.c | 4 |
9 files changed, 155 insertions, 18 deletions
diff --git a/hwdef-Emisar_D4v2.h b/hwdef-Emisar_D4v2.h index fc95e22..e118ed5 100644 --- a/hwdef-Emisar_D4v2.h +++ b/hwdef-Emisar_D4v2.h @@ -56,12 +56,12 @@ #endif // this light has aux LEDs under the optic -#define AUXLED_R_PIN PA5 // pin 2 -#define AUXLED_G_PIN PA4 // pin 3 -#define AUXLED_B_PIN PA3 // pin 4 -#define AUXLED_RGB_PORT PORTA // PORTA or PORTB or PORTC -#define AUXLED_RGB_DDR DDRA // DDRA or DDRB or DDRC -#define AUXLED_RGB_PUE PUEA // PUEA or PUEB or PUEC +#define AUXLED_R_PIN PA5 // pin 2 +#define AUXLED_G_PIN PA4 // pin 3 +#define AUXLED_B_PIN PA3 // pin 4 +#define AUXLED_RGB_PORT PORTA // PORTA or PORTB or PORTC +#define AUXLED_RGB_DDR DDRA // DDRA or DDRB or DDRC +#define AUXLED_RGB_PUE PUEA // PUEA or PUEB or PUEC #define BUTTON_LED_PIN PA1 // pin 6 #define BUTTON_LED_PORT PORTA // for all "PA" pins diff --git a/hwdef-Noctigon_KR4.h b/hwdef-Noctigon_KR4.h index 073fe27..feb49e6 100644 --- a/hwdef-Noctigon_KR4.h +++ b/hwdef-Noctigon_KR4.h @@ -1,14 +1,14 @@ #ifndef HWDEF_NOCTIGON_KR4_H #define HWDEF_NOCTIGON_KR4_H -/* Noctigon KR4 driver layout (attiny1634) +/* Noctigon KR4 / D4V2.5 driver layout (attiny1634) * * Pin / Name / Function * 1 PA6 FET PWM (direct drive) (PWM1B) * 2 PA5 R: red aux LED (PWM0B) * 3 PA4 G: green aux LED * 4 PA3 B: blue aux LED - * 5 PA2 (none) + * 5 PA2 button LED (D4V2.5 only) * 6 PA1 (none) * 7 PA0 (none) * 8 GND GND @@ -82,11 +82,10 @@ #define ADMUX_VOLTAGE_DIVIDER 0b10000110 #define ADC_PRSCL 0x07 // clk/128 -// TODO: calibrate this // Raw ADC readings at 4.4V and 2.2V // calibrate the voltage readout here // estimated / calculated values are: -// (voltage - D1) * (R2/(R2+R1) * 256 / 1.1) +// (voltage - D1) * (R2/(R2+R1) * 1024 / 1.1) // D1, R1, R2 = 0, 330, 100 #ifndef ADC_44 //#define ADC_44 981 // raw value at 4.40V @@ -105,6 +104,11 @@ #define AUXLED_RGB_DDR DDRA // DDRA or DDRB or DDRC #define AUXLED_RGB_PUE PUEA // PUEA or PUEB or PUEC +#define BUTTON_LED_PIN PA2 // pin 5 +#define BUTTON_LED_PORT PORTA // for all "PA" pins +#define BUTTON_LED_DDR DDRA // for all "PA" pins +#define BUTTON_LED_PUE PUEA // for all "PA" pins + // with so many pins, doing this all with #ifdefs gets awkward... // ... so just hardcode it in each hwdef file instead inline void hwdef_setup() { @@ -112,11 +116,12 @@ inline void hwdef_setup() { // Opamp level and Opamp on/off DDRB = (1 << PWM1_PIN) | (1 << LED_ENABLE_PIN); - // DD FET PWM, aux R/G/B + // DD FET PWM, aux R/G/B, button LED DDRA = (1 << PWM2_PIN) | (1 << AUXLED_R_PIN) | (1 << AUXLED_G_PIN) | (1 << AUXLED_B_PIN) + | (1 << BUTTON_LED_PIN) ; // configure PWM diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index 01904dc..085f4a3 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -105,6 +105,11 @@ #include incfile(CONFIGFILE) +// brightness to use when no memory is set +#ifndef DEFAULT_LEVEL +#define DEFAULT_LEVEL MAX_1x7135 +#endif + // thermal properties, if not defined per-driver #ifndef MIN_THERM_STEPDOWN #define MIN_THERM_STEPDOWN MAX_1x7135 // lowest value it'll step down to @@ -415,9 +420,6 @@ void save_config_wl(); #endif // brightness control -#ifndef DEFAULT_LEVEL -#define DEFAULT_LEVEL MAX_1x7135 -#endif uint8_t memorized_level = DEFAULT_LEVEL; #ifdef USE_MANUAL_MEMORY uint8_t manual_memory = 0; diff --git a/spaghetti-monster/anduril/cfg-emisar-d18.h b/spaghetti-monster/anduril/cfg-emisar-d18.h index 155a747..72f0589 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d18.h +++ b/spaghetti-monster/anduril/cfg-emisar-d18.h @@ -28,7 +28,7 @@ #define QUARTERSPEED_LEVEL 6 // start at ~2000 lm after battery change, not ~150 lm (at Emisar's request) -#define DEFAULT_LEVEL MAX_Nx7135 +//#define DEFAULT_LEVEL MAX_Nx7135 // higher floor than default, and stop at highest regulated level #define RAMP_DISCRETE_FLOOR 25 diff --git a/spaghetti-monster/anduril/cfg-emisar-d4sv2.h b/spaghetti-monster/anduril/cfg-emisar-d4sv2.h index c578c4a..0f3a217 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d4sv2.h +++ b/spaghetti-monster/anduril/cfg-emisar-d4sv2.h @@ -33,7 +33,7 @@ #define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL #define RAMP_DISCRETE_STEPS 7 -#define DEFAULT_LEVEL MAX_Nx7135 +//#define DEFAULT_LEVEL MAX_Nx7135 #define STROBE_BRIGHTNESS MAX_LEVEL #define MUGGLE_FLOOR RAMP_DISCRETE_FLOOR diff --git a/spaghetti-monster/anduril/cfg-emisar-d4v2.5-219.h b/spaghetti-monster/anduril/cfg-emisar-d4v2.5-219.h new file mode 100644 index 0000000..c0a5b17 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-emisar-d4v2.5-219.h @@ -0,0 +1,12 @@ +// Emisar D4v2.5 (75% FET) config options for Anduril +// (adapted from cfg-noctigon-kr4-219.h) +#include "cfg-emisar-d4v2.5.h" +// ATTINY: 1634 + +// don't turn off first channel at turbo level +#undef PWM1_LEVELS +#define PWM1_LEVELS 0,0,1,1,2,2,3,3,4,4,5,6,7,8,9,10,11,13,14,15,17,19,20,22,24,26,28,30,33,35,38,40,43,46,49,52,55,59,62,66,70,74,78,82,86,91,96,100,105,111,116,121,127,133,139,145,151,158,165,172,179,186,193,201,209,217,225,234,243,251,261,270,280,289,299,310,320,331,342,353,364,376,388,400,412,425,438,451,464,478,492,506,521,536,551,566,582,597,614,630,647,664,681,699,717,735,754,772,792,811,831,851,871,892,913,935,956,978,1001,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023 +// 75% 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,17,39,60,82,104,126,149,172,195,219,243,268,293,318,343,369,396,422,449,476,504,531,560,588,617,646,676,706,737,768 + diff --git a/spaghetti-monster/anduril/cfg-emisar-d4v2.5-nofet.h b/spaghetti-monster/anduril/cfg-emisar-d4v2.5-nofet.h new file mode 100644 index 0000000..175774c --- /dev/null +++ b/spaghetti-monster/anduril/cfg-emisar-d4v2.5-nofet.h @@ -0,0 +1,48 @@ +// Emisar D4v2.5 (fetless) config options for Anduril +// (adapted from cfg-noctigon-kr4-nofet.h) +#include "cfg-emisar-d4v2.5.h" +// ATTINY: 1634 + +// brightness w/ SST-20 4000K LEDs: +// 0/1023: 0.35 lm +// 1/1023: 2.56 lm +// max regulated: 1740 lm +// level_calc.py 3.0 1 150 7135 0 5 1740 +#undef PWM_CHANNELS +#define PWM_CHANNELS 1 +#define RAMP_LENGTH 150 +#undef PWM1_LEVELS +#define PWM1_LEVELS 0,0,1,1,2,2,3,3,4,4,5,5,6,7,8,9,10,11,12,13,15,16,17,18,20,21,23,24,26,27,29,31,33,35,37,39,41,43,45,48,50,53,55,58,61,63,66,69,72,75,79,82,85,89,92,96,100,104,108,112,116,120,125,129,134,138,143,148,153,158,163,169,174,180,185,191,197,203,209,215,222,228,235,242,248,255,263,270,277,285,292,300,308,316,324,333,341,350,359,368,377,386,395,405,414,424,434,444,454,465,475,486,497,508,519,531,542,554,566,578,590,603,615,628,641,654,667,680,694,708,722,736,750,765,779,794,809,825,840,856,872,888,904,920,937,954,971,988,1005,1023 +#undef PWM2_LEVELS +#undef DEFAULT_LEVEL +#define DEFAULT_LEVEL 50 +#undef MAX_1x7135 +#define MAX_1x7135 150 + +#undef RAMP_SMOOTH_FLOOR +#undef RAMP_SMOOTH_CEIL +#undef RAMP_DISCRETE_FLOOR +#undef RAMP_DISCRETE_CEIL +#undef RAMP_DISCRETE_STEPS + +#define RAMP_SMOOTH_FLOOR 3 // level 1 is unreliable +#define RAMP_SMOOTH_CEIL 130 +// 10, 30, [50], 70, 90, 110, 130 (plus [150] on turbo) +#define RAMP_DISCRETE_FLOOR 10 +#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL +#define RAMP_DISCRETE_STEPS 7 + +#undef MUGGLE_FLOOR +#undef MUGGLE_CEILING +#define MUGGLE_FLOOR RAMP_DISCRETE_FLOOR +#define MUGGLE_CEILING 70 + +// make candle mode wobble more +#define CANDLE_AMPLITUDE 32 + +// stop panicking at ~90% power or ~1600 lm +#undef THERM_FASTER_LEVEL +#define THERM_FASTER_LEVEL 143 +#undef MIN_THERM_STEPDOWN +#define MIN_THERM_STEPDOWN DEFAULT_LEVEL + diff --git a/spaghetti-monster/anduril/cfg-emisar-d4v2.5.h b/spaghetti-monster/anduril/cfg-emisar-d4v2.5.h new file mode 100644 index 0000000..bc0cf60 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-emisar-d4v2.5.h @@ -0,0 +1,70 @@ +// Emisar D4v2.5 config options for Anduril +// (uses KR4 driver, plus a button LED) +#include "hwdef-Noctigon_KR4.h" +// ATTINY: 1634 + +// this light has three aux LED channels: R, G, B +#define USE_AUX_RGB_LEDS +// it also has an independent LED in the button +#define USE_BUTTON_LED +// the aux LEDs are front-facing, so turn them off while main LEDs are on +// TODO: the whole "indicator LED" thing needs to be refactored into +// "aux LED(s)" and "button LED(s)" since they work a bit differently +//#define USE_AUX_RGB_LEDS_WHILE_ON +#ifdef USE_INDICATOR_LED_WHILE_RAMPING +#undef USE_INDICATOR_LED_WHILE_RAMPING +#endif +#define RGB_LED_OFF_DEFAULT 0x17 // low, rainbow +#define RGB_LED_LOCKOUT_DEFAULT 0x37 // blinking, rainbow +#define RGB_RAINBOW_SPEED 0x03 // half a second per color + +// enable blinking aux LEDs +#define TICK_DURING_STANDBY +#define STANDBY_TICK_SPEED 3 // every 0.128 s +//#define STANDBY_TICK_SPEED 4 // every 0.256 s +//#define STANDBY_TICK_SPEED 5 // every 0.512 s + + +// copied from Noctigon KR4 +// brightness w/ SST-20 4000K LEDs: +// 0/1023: 0.35 lm +// 1/1023: 2.56 lm +// max regulated: 1740 lm +// FET: ~3700 lm +// maxreg at 130: level_calc.py cube 2 150 7135 0 2.5 1740 FET 1 10 2565 +// maxreg at 120: level_calc.py cube 2 150 7135 0 2.5 1740 FET 1 10 3190 +#define RAMP_LENGTH 150 +#define PWM1_LEVELS 0,0,1,1,2,2,3,3,4,4,5,6,7,8,9,10,11,13,14,15,17,19,20,22,24,26,28,30,33,35,38,40,43,46,49,52,55,59,62,66,70,74,78,82,86,91,96,100,105,111,116,121,127,133,139,145,151,158,165,172,179,186,193,201,209,217,225,234,243,251,261,270,280,289,299,310,320,331,342,353,364,376,388,400,412,425,438,451,464,478,492,506,521,536,551,566,582,597,614,630,647,664,681,699,717,735,754,772,792,811,831,851,871,892,913,935,956,978,1001,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,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,22,51,79,109,138,168,198,229,260,292,324,357,390,423,457,492,527,562,598,634,671,708,746,784,822,861,901,941,982,1023 +#define DEFAULT_LEVEL 46 +#define MAX_1x7135 120 +#define HALFSPEED_LEVEL 10 +#define QUARTERSPEED_LEVEL 2 + +#define RAMP_SMOOTH_FLOOR 3 // level 1 is unreliable +#define RAMP_SMOOTH_CEIL 120 +// 10, 28, [46], 65, 83, 101, [120] +#define RAMP_DISCRETE_FLOOR 10 +#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL +#define RAMP_DISCRETE_STEPS 7 + +#define MUGGLE_FLOOR RAMP_DISCRETE_FLOOR +#define MUGGLE_CEILING 65 + +// stop panicking at ~25% power or ~1000 lm +#define THERM_FASTER_LEVEL 100 +#define MIN_THERM_STEPDOWN DEFAULT_LEVEL +#define THERM_NEXT_WARNING_THRESHOLD 16 // accumulate less error before adjusting +#define THERM_RESPONSE_MAGNITUDE 128 // bigger adjustments + +// easier access to thermal config mode +#define USE_TENCLICK_THERMAL_CONFIG + +// slow down party strobe; this driver can't pulse for 1ms or less +// (only needed on no-FET build) +//#define PARTY_STROBE_ONTIME 2 + +#define THERM_CAL_OFFSET 5 + +// allow 13H reset for consistency with KR4 +#define USE_SOFT_FACTORY_RESET diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index bae601e..c3ad8b4 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -33,7 +33,7 @@ void set_level(uint8_t level) { #ifdef USE_INDICATOR_LED_WHILE_RAMPING #ifdef USE_INDICATOR_LED if (! go_to_standby) - indicator_led((level > 0) + (level > MAX_1x7135)); + indicator_led((level > 0) + (level > DEFAULT_LEVEL)); #endif //if (level > MAX_1x7135) indicator_led(2); //else if (level > 0) indicator_led(1); @@ -47,7 +47,7 @@ void set_level(uint8_t level) { #ifdef USE_AUX_RGB_LEDS rgb_led_set(0); #ifdef USE_BUTTON_LED - button_led_set((level > 0) + (level > MAX_1x7135)); + button_led_set((level > 0) + (level > DEFAULT_LEVEL)); #endif #endif } |
