diff options
| -rw-r--r-- | hwdef-BLF_Q8-T1616.h | 14 | ||||
| -rw-r--r-- | hwdef-Sofirn_SP10-Pro.h (renamed from hwdef-Sofirn_SP10S.h) | 48 | ||||
| -rw-r--r-- | hwdef-gchart-fet1-t1616.h | 17 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/MODELS | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-blf-lantern-t1616.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-blf-lantern.h | 6 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-blf-q8-t1616.h | 14 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-blf-q8.h | 14 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-sofirn-sp10-pro.h | 54 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-sofirn-sp10s.h | 28 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/factory-reset.c | 5 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.c | 10 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/version.h | 5 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-main.c | 13 | ||||
| -rw-r--r-- | tk-attiny.h | 16 |
15 files changed, 162 insertions, 87 deletions
diff --git a/hwdef-BLF_Q8-T1616.h b/hwdef-BLF_Q8-T1616.h index 2a0e6ff..d6ad760 100644 --- a/hwdef-BLF_Q8-T1616.h +++ b/hwdef-BLF_Q8-T1616.h @@ -61,8 +61,8 @@ Driver pinout: // ... so just hardcode it in each hwdef file instead inline void hwdef_setup() { - // set up the system clock to run at 5 MHz instead of the default 3.33 MHz - _PROTECTED_WRITE( CLKCTRL.MCLKCTRLB, CLKCTRL_PDIV_4X_gc | CLKCTRL_PEN_bm ); + // set up the system clock to run at 10 MHz instead of the default 3.33 MHz + _PROTECTED_WRITE( CLKCTRL.MCLKCTRLB, CLKCTRL_PDIV_2X_gc | CLKCTRL_PEN_bm ); //VPORTA.DIR = ...; VPORTB.DIR = PIN0_bm | PIN1_bm | PIN5_bm; // Outputs: Aux LED and PWMs @@ -91,8 +91,14 @@ inline void hwdef_setup() { PORTC.PIN3CTRL = PORT_PULLUPEN_bm; // set up the PWM - // TODO: add references to MCU documentation - TCA0.SINGLE.CTRLB = TCA_SINGLE_CMP0EN_bm | TCA_SINGLE_CMP1EN_bm | TCA_SINGLE_WGMODE_SINGLESLOPE_gc; + // https://ww1.microchip.com/downloads/en/DeviceDoc/ATtiny1614-16-17-DataSheet-DS40002204A.pdf + // PB0 is TCA0:WO0, use TCA_SINGLE_CMP0EN_bm + // PB1 is TCA0:WO1, use TCA_SINGLE_CMP1EN_bm + // PB2 is TCA0:WO2, use TCA_SINGLE_CMP2EN_bm + // For Fast (Single Slope) PWM use TCA_SINGLE_WGMODE_SINGLESLOPE_gc + // For Phase Correct (Dual Slope) PWM use TCA_SINGLE_WGMODE_DSBOTTOM_gc + // See the manual for other pins, clocks, configs, portmux, etc + TCA0.SINGLE.CTRLB = TCA_SINGLE_CMP0EN_bm | TCA_SINGLE_CMP1EN_bm | TCA_SINGLE_WGMODE_DSBOTTOM_gc; TCA0.SINGLE.PER = 255; TCA0.SINGLE.CTRLA = TCA_SINGLE_CLKSEL_DIV1_gc | TCA_SINGLE_ENABLE_bm; } diff --git a/hwdef-Sofirn_SP10S.h b/hwdef-Sofirn_SP10-Pro.h index 0ee3332..e35728c 100644 --- a/hwdef-Sofirn_SP10S.h +++ b/hwdef-Sofirn_SP10-Pro.h @@ -1,28 +1,14 @@ -#ifndef HWDEF_SOFIRN_SP10S_H -#define HWDEF_SOFIRN_SP10S_H +#ifndef HWDEF_SOFIRN_SP10_H +#define HWDEF_SOFIRN_SP10_H -// TODO: rename to sofirn-sp10s-gchart? - -/* gChart's PIC12 to ATTINY1616 v1 adapter for the SP10S -https://oshpark.com/shared_projects/b4IZEGSy - -PIC12 Pinout: -1 - VDD -2 - No Connect -3 - Low Channel FET (series 4.7K Ohms) -4 - Switch -5 - High Channel FET (main PWM) -6 - Voltage Divider (300K:100K Ohms) -7 - Boost chip enable -8 - GND +/* Sofirn SP10 Pro pinout ATTINY1616 Mapping: -2 - PA5 : (no connect) -3 - PB5 : TCA0 - WO2 Alternate MUX -4 - PB3 : (switch) -5 - PB0 : TCA0 - WO0 -6 - PB4 : ADC0 - AIN9 -7 - PA1 : (boost enable) +PB5 : PWM small channel (TCA0 - WO2 Alternate MUX) +PB3 : eSwitch +PB0 : PWM big channel (TCA0 - WO0) +PB4 : Voltage divider (ADC0 - AIN9) +PA1 : Boost Enable */ @@ -62,7 +48,7 @@ ATTINY1616 Mapping: #define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened #define DUAL_VOLTAGE_FLOOR 20 // for AA/14500 boost drivers, don't indicate low voltage if below this level -#define DUAL_VOLTAGE_LOW_LOW 07 // the lower voltage range's danger zone 0.7 volts +#define DUAL_VOLTAGE_LOW_LOW 9 // the lower voltage range's danger zone 0.9 volts (NiMH) #define ADMUX_VOLTAGE_DIVIDER ADC_MUXPOS_AIN9_gc // which ADC channel to read // Raw ADC readings at 4.4V and 2.2V @@ -83,8 +69,8 @@ ATTINY1616 Mapping: // ... so just hardcode it in each hwdef file instead inline void hwdef_setup() { - // set up the system clock to run at 5 MHz instead of the default 3.33 MHz - _PROTECTED_WRITE( CLKCTRL.MCLKCTRLB, CLKCTRL_PDIV_4X_gc | CLKCTRL_PEN_bm ); + // set up the system clock to run at 10 MHz instead of the default 3.33 MHz + _PROTECTED_WRITE( CLKCTRL.MCLKCTRLB, CLKCTRL_PDIV_2X_gc | CLKCTRL_PEN_bm ); VPORTA.DIR = PIN1_bm; // Boost enable pin VPORTB.DIR = PIN0_bm | PIN5_bm; // PWM pins as output @@ -107,15 +93,21 @@ inline void hwdef_setup() { //PORTB.PIN4CTRL = PORT_PULLUPEN_bm; // Voltage divider //PORTB.PIN5CTRL = PORT_PULLUPEN_bm; // Small PWM channel - //PORTC.PIN0CTRL = PORT_PULLUPEN_bm; connected to the ADC via airwire + PORTC.PIN0CTRL = PORT_PULLUPEN_bm; PORTC.PIN1CTRL = PORT_PULLUPEN_bm; PORTC.PIN2CTRL = PORT_PULLUPEN_bm; PORTC.PIN3CTRL = PORT_PULLUPEN_bm; // set up the PWM - // TODO: add references to MCU documentation + // https://ww1.microchip.com/downloads/en/DeviceDoc/ATtiny1614-16-17-DataSheet-DS40002204A.pdf + // PB0 is TCA0:WO0, use TCA_SINGLE_CMP0EN_bm + // PB1 is TCA0:WO1, use TCA_SINGLE_CMP1EN_bm + // PB2 is TCA0:WO2, use TCA_SINGLE_CMP2EN_bm + // For Fast (Single Slope) PWM use TCA_SINGLE_WGMODE_SINGLESLOPE_gc + // For Phase Correct (Dual Slope) PWM use TCA_SINGLE_WGMODE_DSBOTTOM_gc + // See the manual for other pins, clocks, configs, portmux, etc PORTMUX.CTRLC = PORTMUX_TCA02_ALTERNATE_gc; // Use alternate pin for TCA0:WO2 - TCA0.SINGLE.CTRLB = TCA_SINGLE_CMP0EN_bm | TCA_SINGLE_CMP2EN_bm | TCA_SINGLE_WGMODE_SINGLESLOPE_gc; + TCA0.SINGLE.CTRLB = TCA_SINGLE_CMP0EN_bm | TCA_SINGLE_CMP2EN_bm | TCA_SINGLE_WGMODE_DSBOTTOM_gc; TCA0.SINGLE.PER = 255; TCA0.SINGLE.CTRLA = TCA_SINGLE_CLKSEL_DIV1_gc | TCA_SINGLE_ENABLE_bm; } diff --git a/hwdef-gchart-fet1-t1616.h b/hwdef-gchart-fet1-t1616.h index 365ecd7..2435b99 100644 --- a/hwdef-gchart-fet1-t1616.h +++ b/hwdef-gchart-fet1-t1616.h @@ -60,8 +60,8 @@ Read voltage from VCC pin, has diode with ~0.4v drop // ... so just hardcode it in each hwdef file instead inline void hwdef_setup() { - // set up the system clock to run at 5 MHz instead of the default 3.33 MHz - _PROTECTED_WRITE( CLKCTRL.MCLKCTRLB, CLKCTRL_PDIV_4X_gc | CLKCTRL_PEN_bm ); + // set up the system clock to run at 10 MHz instead of the default 3.33 MHz + _PROTECTED_WRITE( CLKCTRL.MCLKCTRLB, CLKCTRL_PDIV_2X_gc | CLKCTRL_PEN_bm ); //VPORTA.DIR = 0b00000010; VPORTB.DIR = PIN0_bm | PIN1_bm | PIN3_bm; @@ -90,11 +90,14 @@ inline void hwdef_setup() { PORTC.PIN3CTRL = PORT_PULLUPEN_bm; // set up the PWM - // TODO: add references to MCU documentation - // TODO: measure 5 MHz fast PWM vs 10 MHz phase-correct, to see if it - // still has issues at 0/255 and 255/255 like older models did - // (and maybe switch to phase-correct@10MHz) - TCA0.SINGLE.CTRLB = TCA_SINGLE_CMP0EN_bm | TCA_SINGLE_CMP1EN_bm | TCA_SINGLE_WGMODE_SINGLESLOPE_gc; + // https://ww1.microchip.com/downloads/en/DeviceDoc/ATtiny1614-16-17-DataSheet-DS40002204A.pdf + // PB0 is TCA0:WO0, use TCA_SINGLE_CMP0EN_bm + // PB1 is TCA0:WO1, use TCA_SINGLE_CMP1EN_bm + // PB2 is TCA0:WO2, use TCA_SINGLE_CMP2EN_bm + // For Fast (Single Slope) PWM use TCA_SINGLE_WGMODE_SINGLESLOPE_gc + // For Phase Correct (Dual Slope) PWM use TCA_SINGLE_WGMODE_DSBOTTOM_gc + // See the manual for other pins, clocks, configs, portmux, etc + TCA0.SINGLE.CTRLB = TCA_SINGLE_CMP0EN_bm | TCA_SINGLE_CMP1EN_bm | TCA_SINGLE_WGMODE_DSBOTTOM_gc; TCA0.SINGLE.PER = 255; TCA0.SINGLE.CTRLA = TCA_SINGLE_CLKSEL_DIV1_gc | TCA_SINGLE_ENABLE_bm; } diff --git a/spaghetti-monster/anduril/MODELS b/spaghetti-monster/anduril/MODELS index 11f7dfa..7a2c438 100644 --- a/spaghetti-monster/anduril/MODELS +++ b/spaghetti-monster/anduril/MODELS @@ -49,7 +49,7 @@ Model numbers: 0614 sofirn-sp36-t1616 0621 blf-lantern 0622 blf-lantern-t1616 -0631 sofirn-sp10s +0631 sofirn-sp10-pro 1618 gchart-fet1-t1616 Duplicates: Missing: diff --git a/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h b/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h index 56c7275..06d5395 100644 --- a/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h +++ b/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h @@ -50,6 +50,9 @@ #define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL #define SIMPLE_UI_STEPS RAMP_DISCRETE_STEPS +// Allow 3C in Simple UI for switching between smooth and stepped ramping +#define USE_SIMPLE_UI_RAMPING_TOGGLE + #define USE_SOS_MODE #define USE_SOS_MODE_IN_BLINKY_GROUP diff --git a/spaghetti-monster/anduril/cfg-blf-lantern.h b/spaghetti-monster/anduril/cfg-blf-lantern.h index 48ed1f7..ff28a98 100644 --- a/spaghetti-monster/anduril/cfg-blf-lantern.h +++ b/spaghetti-monster/anduril/cfg-blf-lantern.h @@ -45,11 +45,17 @@ #define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL #define RAMP_DISCRETE_STEPS 5 +// Allow 3C in Simple UI for switching between smooth and stepped ramping +#define USE_SIMPLE_UI_RAMPING_TOGGLE + // 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_STEPS RAMP_DISCRETE_STEPS +// also at Sofirn's request, enable 2 click turbo +#define USE_2C_MAX_TURBO + #define USE_SOS_MODE #define USE_SOS_MODE_IN_BLINKY_GROUP diff --git a/spaghetti-monster/anduril/cfg-blf-q8-t1616.h b/spaghetti-monster/anduril/cfg-blf-q8-t1616.h index 002e8e3..340faa1 100644 --- a/spaghetti-monster/anduril/cfg-blf-q8-t1616.h +++ b/spaghetti-monster/anduril/cfg-blf-q8-t1616.h @@ -29,11 +29,21 @@ #define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL #define RAMP_DISCRETE_STEPS 7 -// safe limit ~50% power +// at Sofirn's request, use max (150) for the Simple UI ceiling #define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR -#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL +#define SIMPLE_UI_CEIL 150 #define SIMPLE_UI_STEPS 5 +// also at Sofirn's request, enable 2 click turbo +#define USE_2C_MAX_TURBO + +// enable SOS in the blinkies group +#define USE_SOS_MODE +#define USE_SOS_MODE_IN_BLINKY_GROUP + +// Allow 3C in Simple UI for switching between smooth and stepped ramping +#define USE_SIMPLE_UI_RAMPING_TOGGLE + // stop panicking at ~75% power or ~3000 lm, this light has high thermal mass #define THERM_FASTER_LEVEL (RAMP_SIZE*9/10) // throttle back faster when high diff --git a/spaghetti-monster/anduril/cfg-blf-q8.h b/spaghetti-monster/anduril/cfg-blf-q8.h index d4243ee..00bdd8a 100644 --- a/spaghetti-monster/anduril/cfg-blf-q8.h +++ b/spaghetti-monster/anduril/cfg-blf-q8.h @@ -28,11 +28,21 @@ #define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL #define RAMP_DISCRETE_STEPS 7 -// safe limit ~50% power +// at Sofirn's request, use max (150) for the Simple UI ceiling #define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR -#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL +#define SIMPLE_UI_CEIL 150 #define SIMPLE_UI_STEPS 5 +// also at Sofirn's request, enable 2 click turbo +#define USE_2C_MAX_TURBO + +// enable SOS in the blinkies group +#define USE_SOS_MODE +#define USE_SOS_MODE_IN_BLINKY_GROUP + +// Allow 3C in Simple UI for switching between smooth and stepped ramping +#define USE_SIMPLE_UI_RAMPING_TOGGLE + // stop panicking at ~75% power or ~3000 lm, this light has high thermal mass #define THERM_FASTER_LEVEL (RAMP_SIZE*9/10) // throttle back faster when high diff --git a/spaghetti-monster/anduril/cfg-sofirn-sp10-pro.h b/spaghetti-monster/anduril/cfg-sofirn-sp10-pro.h new file mode 100644 index 0000000..2d0ea7f --- /dev/null +++ b/spaghetti-monster/anduril/cfg-sofirn-sp10-pro.h @@ -0,0 +1,54 @@ +// Sofirn SP10 Pro config options for Anduril +#define MODEL_NUMBER "0631" +#include "hwdef-Sofirn_SP10-Pro.h" +// ATTINY: 1616 + +#undef BLINK_AT_RAMP_MIDDLE + +#define USE_DYNAMIC_UNDERCLOCKING + +// PWM is mostly a "ninth" ramp from level_calc.py but with some extra lower values at the beginning of the ramp +#define RAMP_LENGTH 150 +#define PWM1_LEVELS 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,6,6,6,7,7,7,8,8,8,9,9,10,10,10,11,11,12,12,13,14,14,15,16,16,17,18,18,19,20,21,22,23,24,25,26,27,28,29,30,31,33,34,35,37,38,40,41,43,45,46,48,50,52,54,56,58,60,63,65,67,70,73,75,78,81,84,87,90,93,97,100,104,107,111,115,119,123,128,132,137,141,146,151,156,162,167,173,179,185,191,197,204,210,217,224,232,239,247,255 + +#define MAX_1x7135 80 +#define HALFSPEED_LEVEL 14 +#define QUARTERSPEED_LEVEL 6 + +#define RAMP_SMOOTH_FLOOR 1 +#define RAMP_SMOOTH_CEIL 120 +#define RAMP_DISCRETE_FLOOR RAMP_SMOOTH_FLOOR +#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL +#define RAMP_DISCRETE_STEPS 7 + +// at Sofirn's request, use max (150) for the Simple UI ceiling +#define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR +#define SIMPLE_UI_CEIL 150 +#define SIMPLE_UI_STEPS 5 + +// also at Sofirn's request, enable 2 click turbo +#define USE_2C_MAX_TURBO + +// enable SOS in the blinkies group +#define USE_SOS_MODE +#define USE_SOS_MODE_IN_BLINKY_GROUP + +// Allow 3C in Simple UI for switching between smooth and stepped ramping +#define USE_SIMPLE_UI_RAMPING_TOGGLE + +// and finally, set the default ramp style to Stepped +#undef RAMP_STYLE +#define RAMP_STYLE 1 // 0 = smooth, 1 = stepped + +// stop panicking at ~30% power +#define THERM_FASTER_LEVEL 105 + +// slow down party strobe; this driver can't pulse for too short a time +#define PARTY_STROBE_ONTIME 6 + +// the default of 26 looks a bit flat, so increase it +#define CANDLE_AMPLITUDE 40 + +// enable 2 click turbo +#define DEFAULT_2C_STYLE 1 diff --git a/spaghetti-monster/anduril/cfg-sofirn-sp10s.h b/spaghetti-monster/anduril/cfg-sofirn-sp10s.h deleted file mode 100644 index 06720b6..0000000 --- a/spaghetti-monster/anduril/cfg-sofirn-sp10s.h +++ /dev/null @@ -1,28 +0,0 @@ -// gChart's custom SP10S driver config options for Anduril -#define MODEL_NUMBER "0631" -#include "hwdef-Sofirn_SP10S.h" -// ATTINY: 1616 - -#undef BLINK_AT_RAMP_MIDDLE - -#define USE_DYNAMIC_UNDERCLOCKING - -#define RAMP_LENGTH 150 -#define PWM1_LEVELS 20,30,41,54,69,87,106,128,152,179,209,242,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0 -#define PWM2_LEVELS 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,3,3,3,4,4,4,5,5,5,6,6,7,7,8,8,9,9,10,10,11,12,12,13,14,14,15,16,17,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,38,39,41,42,43,45,46,48,50,51,53,55,56,58,60,62,64,66,68,70,72,74,76,78,80,83,85,87,90,92,94,97,99,102,105,107,110,113,116,119,121,124,127,130,133,137,140,143,146,150,153,156,160,164,167,171,174,178,182,186,190,194,198,202,206,210,214,219,223,227,232,236,241,246,250,255 - -#define MAX_1x7135 13 -#define HALFSPEED_LEVEL 14 -#define QUARTERSPEED_LEVEL 6 - -#define RAMP_SMOOTH_FLOOR 1 -#define RAMP_SMOOTH_CEIL 120 -#define RAMP_DISCRETE_FLOOR 10 -#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL -#define RAMP_DISCRETE_STEPS 7 - -// stop panicking at ~30% power -#define THERM_FASTER_LEVEL 105 - -// enable 2 click turbo -#define DEFAULT_2C_STYLE 1 diff --git a/spaghetti-monster/anduril/factory-reset.c b/spaghetti-monster/anduril/factory-reset.c index 5377b09..ecb4cc2 100644 --- a/spaghetti-monster/anduril/factory-reset.c +++ b/spaghetti-monster/anduril/factory-reset.c @@ -43,7 +43,10 @@ void factory_reset() { } // explode, if button pressed long enough if (reset) { - #if defined(USE_THERMAL_REGULATION) && defined(USE_THERM_AUTOCALIBRATE) + // AVR 1-Series has factory calibrated thermal sensor, always remove the offset on reset + #if defined(USE_THERMAL_REGULATION) && defined(AVRXMEGA3) + thermal_config_save(1,temperature - therm_cal_offset); // this will cancel out the offset + #elif defined(USE_THERMAL_REGULATION) && defined(USE_THERM_AUTOCALIBRATE) // auto-calibrate temperature... assume current temperature is 21 C thermal_config_save(1, 21); #endif diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c index 6d85480..ce3f473 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -370,7 +370,8 @@ uint8_t steady_state(Event event, uint16_t arg) { #endif // ifdef USE_THERMAL_REGULATION ////////// Every action below here is blocked in the simple UI ////////// - #ifdef USE_SIMPLE_UI + // That is, unless we specifically want to enable 3C for smooth/stepped selection in Simple UI + #if defined(USE_SIMPLE_UI) && !defined(USE_SIMPLE_UI_RAMPING_TOGGLE) if (simple_ui_active) { return EVENT_NOT_HANDLED; } @@ -392,6 +393,13 @@ uint8_t steady_state(Event event, uint16_t arg) { return MISCHIEF_MANAGED; } + // If we allowed 3C in Simple UI, now block further actions + #if defined(USE_SIMPLE_UI) && defined(USE_SIMPLE_UI_RAMPING_TOGGLE) + if (simple_ui_active) { + return EVENT_NOT_HANDLED; + } + #endif + #ifndef USE_TINT_RAMPING // 3H: momentary turbo (on lights with no tint ramping) else if (event == EV_click3_hold) { diff --git a/spaghetti-monster/anduril/version.h b/spaghetti-monster/anduril/version.h index 8cf3c90..cb49013 100644 --- a/spaghetti-monster/anduril/version.h +++ b/spaghetti-monster/anduril/version.h @@ -1,4 +1 @@ -// this file is replaced automatically by the build script -// set your own date here if you're not using the build script -// otherwise, default to first human contact with the moon -#define VERSION_NUMBER "19690720" +#define VERSION_NUMBER "20210825" diff --git a/spaghetti-monster/fsm-main.c b/spaghetti-monster/fsm-main.c index 7031009..30b8a67 100644 --- a/spaghetti-monster/fsm-main.c +++ b/spaghetti-monster/fsm-main.c @@ -46,19 +46,30 @@ static inline void hw_setup() { DDRB |= (1 << PWM1_PIN); TCCR0B = 0x01; // pre-scaler for timer (1 => 1, 2 => 8, 3 => 64...) TCCR0A = PHASE; + #if (PWM1_PIN == PB4) // Second PWM counter is ... weird + TCCR1 = _BV (CS10); + GTCCR = _BV (COM1B1) | _BV (PWM1B); + OCR1C = 255; // Set ceiling value to maximum + #endif #endif // tint ramping needs second channel enabled, // despite PWM_CHANNELS being only 1 #if (PWM_CHANNELS >= 2) || defined(USE_TINT_RAMPING) DDRB |= (1 << PWM2_PIN); + #if (PWM2_PIN == PB4) // Second PWM counter is ... weird + TCCR1 = _BV (CS10); + GTCCR = _BV (COM1B1) | _BV (PWM1B); + OCR1C = 255; // Set ceiling value to maximum + #endif #endif #if PWM_CHANNELS >= 3 - // Second PWM counter is ... weird DDRB |= (1 << PWM3_PIN); + #if (PWM3_PIN == PB4) // Second PWM counter is ... weird TCCR1 = _BV (CS10); GTCCR = _BV (COM1B1) | _BV (PWM1B); OCR1C = 255; // Set ceiling value to maximum #endif + #endif #if PWM_CHANNELS >= 4 // 4th PWM channel is ... not actually supported in hardware :( DDRB |= (1 << PWM4_PIN); diff --git a/tk-attiny.h b/tk-attiny.h index ae70afd..110507b 100644 --- a/tk-attiny.h +++ b/tk-attiny.h @@ -73,7 +73,7 @@ //#define VOLTAGE_ADC_DIDR DIDR0 // set this in hwdef #elif (ATTINY == 412) || (ATTINY == 416) || (ATTINY == 417) || (ATTINY == 816) || (ATTINY == 817) || (ATTINY == 1616) || (ATTINY == 1617) || (ATTINY == 3216) || (ATTINY == 3217) #define AVRXMEGA3 - #define F_CPU 5000000UL + #define F_CPU 10000000UL #define BOGOMIPS (F_CPU/4000) #define EEPSIZE 128 #define DELAY_ZERO_TIME 1020 @@ -155,14 +155,14 @@ } typedef enum { - // Actual clock is 20 MHz, but assume that 5 MHz is the top speed and work from there + // Actual clock is 20 MHz, but assume that 10 MHz is the top speed and work from there // TODO: measure PWM speed and power use at 1.25/2.5/5/10 MHz, to determine which speeds are optimal - clock_div_1 = (CLKCTRL_PDIV_4X_gc | CLKCTRL_PEN_bm), // 5 MHz - clock_div_2 = (CLKCTRL_PDIV_8X_gc | CLKCTRL_PEN_bm), // 2.5 MHz - clock_div_4 = (CLKCTRL_PDIV_16X_gc | CLKCTRL_PEN_bm), // 1.25 MHz - clock_div_8 = (CLKCTRL_PDIV_32X_gc | CLKCTRL_PEN_bm), // 625 kHz - clock_div_16 = (CLKCTRL_PDIV_64X_gc | CLKCTRL_PEN_bm), // 312 kHz, max without changing to the 32 kHz ULP - clock_div_32 = (CLKCTRL_PDIV_64X_gc | CLKCTRL_PEN_bm), // 312 kHz + clock_div_1 = (CLKCTRL_PDIV_2X_gc | CLKCTRL_PEN_bm), // 10 MHz + clock_div_2 = (CLKCTRL_PDIV_4X_gc | CLKCTRL_PEN_bm), // 5 MHz + clock_div_4 = (CLKCTRL_PDIV_8X_gc | CLKCTRL_PEN_bm), // 2.5 MHz + clock_div_8 = (CLKCTRL_PDIV_16X_gc | CLKCTRL_PEN_bm), // 1.25 MHz + clock_div_16 = (CLKCTRL_PDIV_32X_gc | CLKCTRL_PEN_bm), // 625 kHz + clock_div_32 = (CLKCTRL_PDIV_64X_gc | CLKCTRL_PEN_bm), // 312 kHz, max without changing to the 32 kHz ULP clock_div_64 = (CLKCTRL_PDIV_64X_gc | CLKCTRL_PEN_bm), // 312 kHz clock_div_128 = (CLKCTRL_PDIV_64X_gc | CLKCTRL_PEN_bm), // 312 kHz clock_div_256 = (CLKCTRL_PDIV_64X_gc | CLKCTRL_PEN_bm) // 312 kHz |
