From c02f0f97ad67e28335a18a060e859f1c05c30906 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 18 May 2019 03:26:25 -0600 Subject: added link to HQ ProgKey, since it's increasingly important for newer drivers --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index 3cb27e9..6a63e5b 100644 --- a/README +++ b/README @@ -28,6 +28,7 @@ Some useful hardware for flashing firmware: http://www.fasttech.com/product/1002900-atmega-attiny-51-avr-isp-usbasp-usb-programmer http://www.fasttech.com/product/1011800-40-pin-splittable-ribbon-cable-20cm http://www.digikey.com/product-detail/en/5250/501-1311-ND/745102 + HQ ProgKey: http://budgetlightforum.com/node/63230 Ratus' guide: https://redd.it/8g5l5w (prices checked 2018-05-01) -- cgit v1.2.3 From b5d3675b555b1ea87cf2ced6f3c70087e32828d0 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 15 Jun 2019 17:44:06 -0600 Subject: Added setup info for Fedora. --- README | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README b/README index 6a63e5b..1e6e842 100644 --- a/README +++ b/README @@ -70,6 +70,12 @@ To set up an attiny dev environment on Ubuntu (13.10): Optional: (make avrdude usable by non-root users, is a security risk) sudo chmod u+s $(which avrdude) +To set up an attiny dev environment on Fedora (30): + + sudo dnf install flex byacc bison gcc libusb libusb-devel glibc-devel + sudo dnf install avr-gcc avr-libc avr-binutils + sudo dnf install avrdude + Building/installing attiny dev tools on other UNIX systems (in general): http://www.ladyada.net/learn/avr/setup-unix.html -- cgit v1.2.3 From c7b6a22af23fb611c66d3f6c5d6e9a934589f0ca Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 28 Jun 2019 03:41:42 -0600 Subject: added support for Mateminco MF01-Mini --- hwdef-Mateminco_MF01-Mini.h | 51 ++++++++++++++++++ .../anduril/cfg-mateminco-mf01-mini.h | 61 ++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 hwdef-Mateminco_MF01-Mini.h create mode 100644 spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h diff --git a/hwdef-Mateminco_MF01-Mini.h b/hwdef-Mateminco_MF01-Mini.h new file mode 100644 index 0000000..9b29776 --- /dev/null +++ b/hwdef-Mateminco_MF01-Mini.h @@ -0,0 +1,51 @@ +#ifndef HWDEF_MF01_MINI_H +#define HWDEF_MF01_MINI_H + +/* MF01-Mini driver layout + * ---- + * Reset -|1 8|- VCC + * eswitch -|2 7|- aux LEDs + * FET PWM -|3 6|- PWM (7x7135) + * GND -|4 5|- PWM (1x7135) + * ---- + */ + +#define PWM_CHANNELS 3 + +#ifndef AUXLED_PIN +#define AUXLED_PIN PB2 // pin 7 +#endif + +#ifndef SWITCH_PIN +#define SWITCH_PIN PB3 // pin 2 +#define SWITCH_PCINT PCINT3 // pin 2 pin change interrupt +#endif + +#ifndef PWM1_PIN +#define PWM1_PIN PB0 // pin 5, 1x7135 PWM +#define PWM1_LVL OCR0A // OCR0A is the output compare register for PB0 +#endif +#ifndef PWM2_PIN +#define PWM2_PIN PB1 // pin 6, FET PWM +#define PWM2_LVL OCR0B // OCR0B is the output compare register for PB1 +#endif +#ifndef PWM3_PIN +#define PWM3_PIN PB4 // pin 3, FET PWM +#define PWM3_LVL OCR1B // OCR1B is the output compare register for PB4 +#endif + +#define ADC_PRSCL 0x06 // clk/64 + +// average drop across diode on this hardware +#ifndef VOLTAGE_FUDGE_FACTOR +#define VOLTAGE_FUDGE_FACTOR 5 // add 0.25V +#endif + +#define TEMP_CHANNEL 0b00001111 + +#define FAST 0xA3 // fast PWM both channels +#define PHASE 0xA1 // phase-correct PWM both channels + +#define LAYOUT_DEFINED + +#endif diff --git a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h new file mode 100644 index 0000000..2d1e5c7 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h @@ -0,0 +1,61 @@ +// Mateminco/Astrolux MF01-Mini options for Anduril +#include "hwdef-Mateminco_MF01-Mini.h" + +// the button lights up +#define USE_INDICATOR_LED +#define INDICATOR_LED_SKIP_LOW // low mode doesn't work on this driver +// the button is visible while main LEDs are on +//#define USE_INDICATOR_LED_WHILE_RAMPING +// enable blinking indicator LED while off +#define TICK_DURING_STANDBY +#define STANDBY_TICK_SPEED 3 // every 0.128 s +#define USE_FANCIER_BLINKING_INDICATOR +// off mode: high (2) +// lockout: blinking (3) +#define INDICATOR_LED_DEFAULT_MODE ((3<<2) + 2) + + +// don't blink during ramp, it's irrelevant and annoying on this light +#define BLINK_AT_RAMP_CEILING +#undef BLINK_AT_RAMP_MIDDLE +#undef BLINK_AT_RAMP_FLOOR + +// measured brightness with Sofirn 5500mAh cell at 3.97V: +// moon: 0.3 lm +// channel 1: 113 lm +// channel 2: 718 lm +// channel 3: 3500 lm +// ../../../bin/level_calc.py ninth 3 150 7135 1 2.5 115.65 7135 11 5 708.65 FET 1 10 3500 +// (plus some manual tweaks for a smoother ramp) +#define RAMP_LENGTH 150 +#define PWM1_LEVELS 1,1,2,2,3,3,4,5,5,6,7,8,9,9,10,14,15,16,17,18,19,20,21,22,24,26,28,30,32,34,37,39,42,45,48,51,54,58,62,65,69,74,78,83,88,93,98,104,110,116,123,130,137,145,153,161,170,179,188,198,208,219,231,243,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,13,16,18,20,23,25,28,31,34,37,40,43,47,50,54,58,62,66,70,75,80,85,90,95,100,106,112,118,125,131,138,145,153,161,169,177,185,194,204,213,223,233,244,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 PWM3_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,3,6,10,13,17,21,24,28,33,37,41,46,50,55,60,66,71,76,82,88,94,101,107,114,121,128,135,143,151,159,167,176,185,194,203,213,223,233,244,255 +#define MAX_1x7135 65 // ~113 lm +#define MAX_Nx7135 110 +#define HALFSPEED_LEVEL 16 +#define QUARTERSPEED_LEVEL 8 + +#define RAMP_SMOOTH_FLOOR 1 // ~0.3 lm +#define RAMP_SMOOTH_CEIL 130 // ~??? lm +// 14/135/6 = 14, 38, 62, 86, [110], 135 +// 20/110/7 = 20, 35, 50, [65], 80, 95, [110] +// 15/130/7 = 15, 34, 53, 72, 91, [110], 130 +#if 1 +#define RAMP_DISCRETE_FLOOR 15 // ~?? lm +#define RAMP_DISCRETE_CEIL 130 // ~??? lm +#define RAMP_DISCRETE_STEPS 7 // ??, ??, ... lm +#else // testing only; for calibrating the ramp in detail +#define RAMP_DISCRETE_FLOOR 1 // ~?? lm +#define RAMP_DISCRETE_CEIL 150 // ~??? lm +#define RAMP_DISCRETE_STEPS 150 // ??, ??, ... lm +#endif + + +#define USE_TENCLICK_THERMAL_CONFIG // by request +#define THERM_FASTER_LEVEL 130 // throttle back faster when high +//#define THERM_HARD_TURBO_DROP // this light is massively overpowered +#define THERMAL_WARNING_SECONDS 1 // FIXME: increase by 2 after merging newer code +//#define THERMAL_UPDATE_SPEED 1 +//#define THERM_PREDICTION_STRENGTH 4 + -- cgit v1.2.3 From 3f89c8d35619e37fd6d80b75a7574c7802b3556b Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 31 Jul 2019 14:47:19 -0600 Subject: mf01-mini: enable aux LED low mode --- spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h index 2d1e5c7..e5db4f4 100644 --- a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h +++ b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h @@ -3,16 +3,16 @@ // the button lights up #define USE_INDICATOR_LED -#define INDICATOR_LED_SKIP_LOW // low mode doesn't work on this driver +//#define INDICATOR_LED_SKIP_LOW // low mode doesn't work on this driver // the button is visible while main LEDs are on //#define USE_INDICATOR_LED_WHILE_RAMPING // enable blinking indicator LED while off #define TICK_DURING_STANDBY #define STANDBY_TICK_SPEED 3 // every 0.128 s #define USE_FANCIER_BLINKING_INDICATOR -// off mode: high (2) +// off mode: low (1) // lockout: blinking (3) -#define INDICATOR_LED_DEFAULT_MODE ((3<<2) + 2) +#define INDICATOR_LED_DEFAULT_MODE ((3<<2) + 1) // don't blink during ramp, it's irrelevant and annoying on this light -- cgit v1.2.3 From 64da1475d73d5d021f125209360c024518fc1751 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Mon, 26 Aug 2019 16:31:12 -0600 Subject: just cleaning up some comments --- hwdef-Mateminco_MF01-Mini.h | 2 +- spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/hwdef-Mateminco_MF01-Mini.h b/hwdef-Mateminco_MF01-Mini.h index 9b29776..6c420d7 100644 --- a/hwdef-Mateminco_MF01-Mini.h +++ b/hwdef-Mateminco_MF01-Mini.h @@ -26,7 +26,7 @@ #define PWM1_LVL OCR0A // OCR0A is the output compare register for PB0 #endif #ifndef PWM2_PIN -#define PWM2_PIN PB1 // pin 6, FET PWM +#define PWM2_PIN PB1 // pin 6, 7x7135 PWM #define PWM2_LVL OCR0B // OCR0B is the output compare register for PB1 #endif #ifndef PWM3_PIN diff --git a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h index e5db4f4..bbf751b 100644 --- a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h +++ b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h @@ -40,16 +40,10 @@ #define RAMP_SMOOTH_CEIL 130 // ~??? lm // 14/135/6 = 14, 38, 62, 86, [110], 135 // 20/110/7 = 20, 35, 50, [65], 80, 95, [110] -// 15/130/7 = 15, 34, 53, 72, 91, [110], 130 -#if 1 +// 15/130/7 = 15, 34, 53, 72, 91, [110], 130 <-- #define RAMP_DISCRETE_FLOOR 15 // ~?? lm #define RAMP_DISCRETE_CEIL 130 // ~??? lm #define RAMP_DISCRETE_STEPS 7 // ??, ??, ... lm -#else // testing only; for calibrating the ramp in detail -#define RAMP_DISCRETE_FLOOR 1 // ~?? lm -#define RAMP_DISCRETE_CEIL 150 // ~??? lm -#define RAMP_DISCRETE_STEPS 150 // ??, ??, ... lm -#endif #define USE_TENCLICK_THERMAL_CONFIG // by request -- cgit v1.2.3 From a67ba8d52f04fc74d90f1885325f76cec04546f4 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 28 Aug 2019 02:28:01 -0600 Subject: added arbitrary ramp shape powers to level_calc.py, to more easily hit specific values --- bin/level_calc.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/level_calc.py b/bin/level_calc.py index f16f8ce..6f07621 100755 --- a/bin/level_calc.py +++ b/bin/level_calc.py @@ -14,7 +14,7 @@ def main(args): """ # Get parameters from the user questions_main = [ - (str, 'ramp_shape', 'cube', 'Ramp shape? [cube, square, fifth, seventh, ninth, log]'), + (str, 'ramp_shape', 'cube', 'Ramp shape? [cube, square, fifth, seventh, ninth, log, N.NN]'), (int, 'num_channels', 1, 'How many power channels?'), (int, 'num_levels', 4, 'How many total levels do you want?'), ] @@ -179,11 +179,19 @@ shapes = dict( ) def power(x): - return shapes[ramp_shape][0](x) + try: + factor = float(ramp_shape) + return math.pow(x, factor) + except ValueError: + return shapes[ramp_shape][0](x) def invpower(x): - return shapes[ramp_shape][1](x) + try: + factor = float(ramp_shape) + return math.pow(x, 1.0 / factor) + except ValueError: + return shapes[ramp_shape][1](x) def input_text(): -- cgit v1.2.3 From 62223a6e1c304d3e5952a0a7138b75dc3c232dfc Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Thu, 29 Aug 2019 04:57:54 -0600 Subject: added Emisar D4S V2 support --- hwdef-Emisar_D4Sv2.h | 124 +++++++++++++++++++++++ spaghetti-monster/anduril/cfg-emisar-d4sv2-219.h | 10 ++ spaghetti-monster/anduril/cfg-emisar-d4sv2.h | 63 ++++++++++++ 3 files changed, 197 insertions(+) create mode 100644 hwdef-Emisar_D4Sv2.h create mode 100644 spaghetti-monster/anduril/cfg-emisar-d4sv2-219.h create mode 100644 spaghetti-monster/anduril/cfg-emisar-d4sv2.h diff --git a/hwdef-Emisar_D4Sv2.h b/hwdef-Emisar_D4Sv2.h new file mode 100644 index 0000000..8341e21 --- /dev/null +++ b/hwdef-Emisar_D4Sv2.h @@ -0,0 +1,124 @@ +#ifndef HWDEF_EMISAR_D4SV2_H +#define HWDEF_EMISAR_D4SV2_H + +/* Emisar D4v2 driver layout (attiny1634) + * (same layout as D4v2, except it's a FET+3+1 instead of FET+1) + * + * Pin / Name / Function + * 1 PA6 FET PWM (PWM1B) + * 2 PA5 red aux LED (PWM0B) + * 3 PA4 green aux LED + * 4 PA3 blue aux LED + * 5 PA2 e-switch + * 6 PA1 (none) + * 7 PA0 (none) + * 8 GND GND + * 9 VCC VCC + * 10 PC5 (none) + * 11 PC4 (none) + * 12 PC3 RESET + * 13 PC2 (none) + * 14 PC1 SCK + * 15 PC0 3x7135 PWM (PWM0A) + * 16 PB3 1x7135 PWM (PWM1A) + * 17 PB2 MISO + * 18 PB1 MOSI + * 19 PB0 (none) + * 20 PA7 (none) + * ADC12 thermal sensor + */ + +#ifdef ATTINY +#undef ATTINY +#endif +#define ATTINY 1634 +#include + +#define SWITCH_PIN PA2 // pin 5 +#define SWITCH_PCINT PCINT2 // pin 5 pin change interrupt +#define SWITCH_PCIE PCIE0 // PCIE0 is for PCINT[7:0] +#define SWITCH_PCMSK PCMSK0 // PCMSK0 is for PCINT[7:0] +#define SWITCH_PORT PINA // PINA or PINB or PINC + +#define PWM_CHANNELS 3 + +#define PWM1_PIN PB3 // pin 16, 1x7135 PWM +#define PWM1_LVL OCR1A // OCR1A is the output compare register for PB3 + +#define PWM2_PIN PC0 // pin 15, 3x7135 PWM +#define PWM2_LVL OCR0A // OCR0A is the output compare register for PC0 + +#define PWM3_PIN PA6 // pin 1, FET PWM +#define PWM3_LVL OCR1B // OCR1B is the output compare register for PB1 + + +#define ADC_PRSCL 0x06 // clk/64 + +// average drop across diode on this hardware +#ifndef VOLTAGE_FUDGE_FACTOR +#define VOLTAGE_FUDGE_FACTOR 4 // add 0.20V (measured 0.22V) +#endif + +#define TEMP_CHANNEL 0b00001111 + +// 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 + +// with so many pins, doing this all with #ifdefs gets awkward... +// ... so just hardcode it in each hwdef file instead +inline void hwdef_setup() { + // enable output ports + // FET, aux R/G/B + DDRA = (1 << PWM3_PIN) + | (1 << AUXLED_R_PIN) + | (1 << AUXLED_G_PIN) + | (1 << AUXLED_B_PIN) + ; + // 1x7135 + DDRB = (1 << PWM1_PIN); + // 3x7135 + DDRC = (1 << PWM2_PIN); + + // configure PWM + // Setup PWM. F_pwm = F_clkio / 2 / N / TOP, where N = prescale factor, TOP = top of counter + // pre-scale for timer: N = 1 + // WGM1[3:0]: 0,0,0,1: PWM, Phase Correct, 8-bit (DS table 12-5) + // CS1[2:0]: 0,0,1: clk/1 (No prescaling) (DS table 12-6) + // COM1A[1:0]: 1,0: PWM OC1A in the normal direction (DS table 12-4) + // COM1B[1:0]: 1,0: PWM OC1B in the normal direction (DS table 12-4) + TCCR1A = (0<= channel.modes[i-1]) \ + and (channels[cnum+1].modes[i] == 0): + i += 1 + print('Ch%i max: %i (%.2f/255)' % (cnum, i, channel.modes[i-1])) + def get_value(text, default, args): """Get input from the user, or from the command line args.""" -- cgit v1.2.3 From 2fcf49ed1f04d560ae2f422aa85e626147089171 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 15 Sep 2019 15:37:12 -0600 Subject: added some ideas for stuff to do, updated the UI diagram to show the stepped ramp mode differently --- spaghetti-monster/anduril/anduril-ui.png | Bin 286759 -> 281904 bytes spaghetti-monster/anduril/anduril.svg | 238 ++++++++++++++++++++++++------- spaghetti-monster/anduril/anduril.txt | 6 + 3 files changed, 195 insertions(+), 49 deletions(-) diff --git a/spaghetti-monster/anduril/anduril-ui.png b/spaghetti-monster/anduril/anduril-ui.png index 3c032bc..70f6be0 100644 Binary files a/spaghetti-monster/anduril/anduril-ui.png and b/spaghetti-monster/anduril/anduril-ui.png differ diff --git a/spaghetti-monster/anduril/anduril.svg b/spaghetti-monster/anduril/anduril.svg index 36840a4..d58e478 100644 --- a/spaghetti-monster/anduril/anduril.svg +++ b/spaghetti-monster/anduril/anduril.svg @@ -22,6 +22,49 @@ inkscape:export-ydpi="109.75774"> + + + + + + + + + @@ -57,7 +100,7 @@ @@ -1896,16 +1939,6 @@ style="fill-rule:evenodd;stroke:#000000;stroke-width:0.42666668pt" inkscape:connector-curvature="0" /> - + + + + + + + + inkscape:snap-bbox-midpoints="true" + inkscape:snap-midpoints="true" + inkscape:snap-object-midpoints="true" + inkscape:object-paths="true" + inkscape:snap-intersection-paths="true"> + + + - Ceil Floor @@ -3245,22 +3354,16 @@ - 6 Clicks + transform="translate(-191.75097,7.3367765)"> + transform="translate(-281.95292,43.516866)"> @@ -4289,7 +4392,7 @@ sodipodi:nodetypes="cc" /> @@ -4639,11 +4742,11 @@ 3C 3C @@ -4799,5 +4902,42 @@ x="1091.5458" y="1212.6874" id="tspan43995-1">Factory Reset: Loosen tailcap, Hold button, Tighten tailcap, Hold 3s (or 13H from Off) + 3C + + + + + + diff --git a/spaghetti-monster/anduril/anduril.txt b/spaghetti-monster/anduril/anduril.txt index db73cdb..0a3dc4c 100644 --- a/spaghetti-monster/anduril/anduril.txt +++ b/spaghetti-monster/anduril/anduril.txt @@ -162,6 +162,12 @@ Indicator LED / aux LED support: TODO: + - change 6C to 6H for exiting muggle mode? + - move muggle mode from 6C to ... 8C or something? + - add 4H from lockout to turn light on and start ramping up? + - move config modes to 5C instead of 4C, and move manual memory to 4C? + - remove beacon config mode, and use a hold to set timing instead? + - rewrite muggle mode to split it into on and off states * save settings in eeprom * decide on "hold until hot" or "click N times" for thermal config mode * test thermal regulation on an actual light -- cgit v1.2.3 From 87f5095f52e8e9ccb30ee4ff4beda75ef5b11baa Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 18 Sep 2019 16:17:27 -0600 Subject: added a compile flag to fix compatibility with GCC 7/8/9's new semantics for "inline" (should fix builds on newer compilers, I think) --- bin/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/build.sh b/bin/build.sh index 192fa30..fbb24ea 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -14,9 +14,9 @@ export PROGRAM=$1 ; shift export MCU=attiny$ATTINY export CC=avr-gcc export OBJCOPY=avr-objcopy -export CFLAGS="-Wall -g -Os -mmcu=$MCU -c -std=gnu99 -DATTINY=$ATTINY -I.. -I../.. -I../../.. -fshort-enums" +export CFLAGS="-Wall -g -Os -mmcu=$MCU -c -std=gnu99 -fgnu89-inline -DATTINY=$ATTINY -I.. -I../.. -I../../.. -fshort-enums" export OFLAGS="-Wall -g -Os -mmcu=$MCU" -export LDFLAGS= +export LDFLAGS="-fgnu89-inline" export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' export OBJS=$PROGRAM.o -- cgit v1.2.3 From dc8ec8b1817591e929555dcf6ae7302bbec758e8 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 24 Sep 2019 00:00:39 -0600 Subject: made the maximum number of clicks 15 instead of 14 --- spaghetti-monster/fsm-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spaghetti-monster/fsm-events.c b/spaghetti-monster/fsm-events.c index 362a5cc..f35607d 100644 --- a/spaghetti-monster/fsm-events.c +++ b/spaghetti-monster/fsm-events.c @@ -42,7 +42,7 @@ uint8_t push_event(uint8_t ev_type) { // set press flag current_event |= B_PRESS; // increase click counter - if ((current_event & B_COUNT) < (B_COUNT-1)) { + if ((current_event & B_COUNT) < (B_COUNT)) { current_event ++; } return 1; // event pushed, even if max clicks already reached -- cgit v1.2.3 From 4948fc7cfb09d5d9bf7f899917f5aa7d274f1a1a Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 24 Sep 2019 00:01:31 -0600 Subject: sped up blink_digit() a little bit, because it was annoyingly slow --- spaghetti-monster/fsm-misc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index 8e88cbd..0a3cdca 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -41,20 +41,21 @@ void auto_clock_speed() { #endif #if defined(USE_BLINK_NUM) || defined(USE_BLINK_DIGIT) +#define BLINK_SPEED 1000 uint8_t blink_digit(uint8_t num) { //StatePtr old_state = current_state; // "zero" digit gets a single short blink - uint8_t ontime = 200; + uint8_t ontime = BLINK_SPEED * 2 / 10; if (!num) { ontime = 8; num ++; } for (; num>0; num--) { set_level(BLINK_BRIGHTNESS); nice_delay_ms(ontime); set_level(0); - nice_delay_ms(400); + nice_delay_ms(BLINK_SPEED * 3 / 10); } - return nice_delay_ms(600); + return nice_delay_ms(BLINK_SPEED * 5 / 10); } #endif -- cgit v1.2.3 From e2b727acfce7bc19843cdcc7f327efc9c61230d8 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 24 Sep 2019 00:32:53 -0600 Subject: added a version check function on 15+ clicks from off, added a safety ramp-down if button is held too long at ceiling (also removed muggle mode from a couple build targets because it doesn't fit, not enough ROM) --- spaghetti-monster/anduril/anduril.c | 38 ++++++++++++++++++++++ spaghetti-monster/anduril/build-all.sh | 2 ++ spaghetti-monster/anduril/cfg-emisar-d18.h | 6 ++++ .../anduril/cfg-mateminco-mf01-mini.h | 6 ++++ 4 files changed, 52 insertions(+) diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index 8ab66f5..1505f59 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -35,6 +35,8 @@ // (currently incompatible with factory reset) //#define START_AT_MEMORIZED_LEVEL +// include a function to blink out the firmware version +#define USE_VERSION_CHECK // short blip when crossing from "click" to "hold" from off // (helps the user hit moon mode exactly, instead of holding too long @@ -483,6 +485,11 @@ uint8_t triangle_wave(uint8_t phase); volatile uint8_t beacon_seconds = 2; #endif +#ifdef USE_VERSION_CHECK +#include "version.h" +const PROGMEM uint8_t version_number[] = VERSION_NUMBER; +uint8_t version_check_state(Event event, uint16_t arg); +#endif uint8_t off_state(Event event, uint16_t arg) { // turn emitter off when entering state @@ -682,6 +689,13 @@ uint8_t off_state(Event event, uint16_t arg) { return MISCHIEF_MANAGED; } #endif + #ifdef USE_VERSION_CHECK + // 15+ clicks: show the version number + else if (event == EV_15clicks) { + set_state(version_check_state, 0); + return MISCHIEF_MANAGED; + } + #endif #if defined(USE_FACTORY_RESET) && defined(USE_SOFT_FACTORY_RESET) // 13 clicks and hold the last click: invoke factory reset (reboot) else if (event == EV_click13_hold) { @@ -792,6 +806,10 @@ uint8_t steady_state(Event event, uint16_t arg) { // (off->hold->stepped_min->release causes this state) else if (actual_level <= mode_min) { ramp_direction = 1; } } + // if the button is stuck, err on the side of safety and ramp down + else if ((arg > TICKS_PER_SECOND * 5) && (actual_level >= mode_max)) { + ramp_direction = -1; + } memorized_level = nearest_level((int16_t)actual_level \ + (ramp_step_size * ramp_direction)); #else @@ -1956,6 +1974,13 @@ uint8_t muggle_state(Event event, uint16_t arg) { #endif +#ifdef USE_VERSION_CHECK +uint8_t version_check_state(Event event, uint16_t arg) { + return EVENT_NOT_HANDLED; +} +#endif + + // ask the user for a sequence of numbers, then save them and return to caller uint8_t config_state_base(Event event, uint16_t arg, uint8_t num_config_steps, @@ -2558,6 +2583,19 @@ void loop() { if (0) {} + #ifdef USE_VERSION_CHECK + else if (state == version_check_state) { + for (uint8_t i=0; i version.h + for TARGET in cfg-*.h ; do NAME=$(echo "$TARGET" | perl -ne '/cfg-(.*).h/ && print "$1\n";') echo "===== $NAME =====" diff --git a/spaghetti-monster/anduril/cfg-emisar-d18.h b/spaghetti-monster/anduril/cfg-emisar-d18.h index 16fbacd..02e8f01 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d18.h +++ b/spaghetti-monster/anduril/cfg-emisar-d18.h @@ -16,6 +16,12 @@ #define USE_TENCLICK_THERMAL_CONFIG +// save space, and remove a mode which doesn't make much sense on this light +#ifdef USE_MUGGLE_MODE +#undef USE_MUGGLE_MODE +#endif + + // level_calc.py seventh 3 150 7135 1 1.4 117.99 7135 6 1 1706.86 FET 3 10 13000 // (designed to make 1x hit at level 50, and Nx hit at level 100) #define RAMP_LENGTH 150 diff --git a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h index bbf751b..a1d366d 100644 --- a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h +++ b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h @@ -15,6 +15,12 @@ #define INDICATOR_LED_DEFAULT_MODE ((3<<2) + 1) +// doesn't quite fit +#ifdef USE_MUGGLE_MODE +#undef USE_MUGGLE_MODE +#endif + + // don't blink during ramp, it's irrelevant and annoying on this light #define BLINK_AT_RAMP_CEILING #undef BLINK_AT_RAMP_MIDDLE -- cgit v1.2.3 From a86db913783008a14996415e09183a1097ab5389 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 28 Sep 2019 23:25:54 -0600 Subject: after safety ramp-down, if the button remains stuck, lock the light --- spaghetti-monster/anduril/anduril.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index 1505f59..48f4ac1 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -810,6 +810,11 @@ uint8_t steady_state(Event event, uint16_t arg) { else if ((arg > TICKS_PER_SECOND * 5) && (actual_level >= mode_max)) { ramp_direction = -1; } + // if the button is still stuck, lock the light + else if ((arg > TICKS_PER_SECOND * 10) && (actual_level <= mode_min)) { + blip(); + set_state(lockout_state, 0); + } memorized_level = nearest_level((int16_t)actual_level \ + (ramp_step_size * ramp_direction)); #else @@ -2589,10 +2594,13 @@ void loop() { blink_digit(pgm_read_byte(version_number + i) - '0'); nice_delay_ms(300); } - set_state(off_state, 0); // FIXME: when user interrupts with button, "off" takes an extra click // before it'll turn back on, because the click to cancel gets sent // to the "off" state instead of version_check_state + //while (button_is_pressed()) {} + //empty_event_sequence(); + + set_state(off_state, 0); } #endif // #ifdef USE_VERSION_CHECK -- cgit v1.2.3 From 06d75ac58143cf3dccd981975f20d589895de5b3 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 2 Oct 2019 00:02:27 -0600 Subject: added a default version.h for people who don't use the build script --- spaghetti-monster/anduril/version.h | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 spaghetti-monster/anduril/version.h diff --git a/spaghetti-monster/anduril/version.h b/spaghetti-monster/anduril/version.h new file mode 100644 index 0000000..8cf3c90 --- /dev/null +++ b/spaghetti-monster/anduril/version.h @@ -0,0 +1,4 @@ +// 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" -- cgit v1.2.3 From fcc0cf099618c57e5a0635d35111bf75e1a2164e Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 2 Oct 2019 18:22:52 -0600 Subject: made lantern's muggle mode brighter (matches default stepped ramp level 4 of 5) and made the floor slightly lower (almost as low as level 1 of 5) because this light doesn't run hot enough for the previous limit to make sense (was roughly step 2.9 of 5) --- spaghetti-monster/anduril/cfg-blf-lantern.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spaghetti-monster/anduril/cfg-blf-lantern.h b/spaghetti-monster/anduril/cfg-blf-lantern.h index 9467397..bf183eb 100644 --- a/spaghetti-monster/anduril/cfg-blf-lantern.h +++ b/spaghetti-monster/anduril/cfg-blf-lantern.h @@ -51,6 +51,9 @@ #define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL #define RAMP_DISCRETE_STEPS 5 +#define MUGGLE_FLOOR 15 // about 20 lm +#define MUGGLE_CEILING 115 // about 350 lm + // the sensor (attiny85) is nowhere near the emitters // so thermal regulation can't work #ifdef USE_THERMAL_REGULATION -- cgit v1.2.3