From 268b2deacc7b65c7d9d2805d1e504cf94f5734ac Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 12 Oct 2018 16:16:02 -0600 Subject: Moved "off" mode's aux LED to config to "7 clicks from off". --- spaghetti-monster/anduril/anduril.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index 6e33610..300e32b 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -139,13 +139,20 @@ #define RAMP_LENGTH 150 // default, if not overridden in a driver cfg file #define MAX_BIKING_LEVEL 120 // should be 127 or less #define USE_BATTCHECK -#ifdef USE_MUGGLE_MODE + +// determine the highest number of clicks to handle +#ifdef USE_INDICATOR_LED +#define MAX_CLICKS 7 +#elif defined(USE_MUGGLE_MODE) #define MAX_CLICKS 6 -#define MUGGLE_FLOOR 22 -#define MUGGLE_CEILING (MAX_1x7135+20) #else #define MAX_CLICKS 5 #endif + +#if defined(USE_MUGGLE_MODE) +#define MUGGLE_FLOOR 22 +#define MUGGLE_CEILING (MAX_1x7135+20) +#endif #define USE_IDLE_MODE // reduce power use while awake and no tasks are pending #define USE_DYNAMIC_UNDERCLOCKING // cut clock speed at very low modes for better efficiency @@ -488,6 +495,24 @@ uint8_t off_state(EventPtr event, uint16_t arg) { return MISCHIEF_MANAGED; } #endif + #ifdef USE_INDICATOR_LED + // 7 clicks: change indicator LED mode + else if (event == EV_7clicks) { + uint8_t mode = (indicator_led_mode & 3) + 1; + #ifdef TICK_DURING_STANDBY + mode = mode & 3; + #else + mode = mode % 3; + #endif + #ifdef INDICATOR_LED_SKIP_LOW + if (mode == 1) { mode ++; } + #endif + indicator_led_mode = (indicator_led_mode & 0b11111100) | mode; + indicator_led(mode); + save_config(); + return MISCHIEF_MANAGED; + } + #endif return EVENT_NOT_HANDLED; } @@ -1198,6 +1223,7 @@ uint8_t lockout_state(EventPtr event, uint16_t arg) { save_config(); return MISCHIEF_MANAGED; } + #if 0 // old method, deprecated in favor of "7 clicks from off" // click, click, hold: rotate through indicator LED modes (off mode) else if (event == EV_click3_hold) { #ifndef USE_INDICATOR_LED_WHILE_RAMPING @@ -1230,6 +1256,7 @@ uint8_t lockout_state(EventPtr event, uint16_t arg) { return MISCHIEF_MANAGED; } #endif + #endif // 4 clicks: exit else if (event == EV_4clicks) { blink_confirm(1); -- cgit v1.2.3 From 565fb109ec5e7cf195914834523b1723da374e40 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Mon, 15 Oct 2018 15:08:17 -0600 Subject: cleaned up fsm baton UI a little, added a short manual --- spaghetti-monster/baton/baton-simpler.c | 40 +++++------- spaghetti-monster/baton/baton.c | 112 ++++++++++++++++++-------------- spaghetti-monster/baton/baton.txt | 21 ++++++ 3 files changed, 103 insertions(+), 70 deletions(-) create mode 100644 spaghetti-monster/baton/baton.txt diff --git a/spaghetti-monster/baton/baton-simpler.c b/spaghetti-monster/baton/baton-simpler.c index 96b0ea7..d4725ef 100644 --- a/spaghetti-monster/baton/baton-simpler.c +++ b/spaghetti-monster/baton/baton-simpler.c @@ -20,7 +20,6 @@ #define FSM_EMISAR_D4_DRIVER #define USE_LVP #define USE_THERMAL_REGULATION -#define DEFAULT_THERM_CEIL 45 #define USE_DELAY_MS #include "spaghetti-monster.h" @@ -59,6 +58,11 @@ uint8_t off_state(EventPtr event, uint16_t arg) { set_level(0); return EVENT_HANDLED; } + // hold (longer): go to lowest level + else if (event == EV_click1_hold) { + set_state(steady_state, 0); + return EVENT_HANDLED; + } // 1 click (before timeout): go to memorized level, but allow abort for double click else if (event == EV_click1_release) { set_level(memorized_level); @@ -79,11 +83,6 @@ uint8_t off_state(EventPtr event, uint16_t arg) { set_state(lockout_state, 0); return EVENT_HANDLED; } - // hold: go to lowest level - else if (event == EV_click1_hold) { - set_state(steady_state, 0); - return EVENT_HANDLED; - } return EVENT_NOT_HANDLED; } @@ -91,8 +90,8 @@ uint8_t steady_state(EventPtr event, uint16_t arg) { // turn LED on when we first enter the mode if (event == EV_enter_state) { // remember this level, unless it's moon or turbo - if ((arg > 0) && (arg < MAX_LEVEL)) - memorized_level = arg; + if ((arg > 0) && (arg < MAX_LEVEL)) memorized_level = arg; + // use the requested level even if not memorized #ifdef USE_THERMAL_REGULATION target_level = arg; #endif @@ -135,16 +134,12 @@ uint8_t steady_state(EventPtr event, uint16_t arg) { #ifdef USE_THERMAL_REGULATION // overheating: drop by 1 level else if (event == EV_temperature_high) { - if (actual_level > 1) { - set_level(actual_level - 1); - } + if (actual_level > 1) { set_level(actual_level - 1); } return EVENT_HANDLED; } // underheating: increase by 1 level if we're lower than the target else if (event == EV_temperature_low) { - if (actual_level < target_level) { - set_level(actual_level + 1); - } + if (actual_level < target_level) { set_level(actual_level + 1); } return EVENT_HANDLED; } #endif @@ -152,18 +147,14 @@ uint8_t steady_state(EventPtr event, uint16_t arg) { } uint8_t lockout_state(EventPtr event, uint16_t arg) { - // stay asleep while locked, but allow waking long enough to click 4 times + // stay asleep while locked if (event == EV_tick) { - static uint8_t ticks_spent_awake = 0; - ticks_spent_awake ++; - PWM1_LVL = 0; PWM2_LVL = 0; - if (ticks_spent_awake > 3 * TICKS_PER_SECOND) { - ticks_spent_awake = 0; - go_to_standby = 1; - } + PWM1_LVL = 0; PWM2_LVL = 0; // make sure emitters are off + // sleep 1 second after user stops pressing buttons + if (arg > TICKS_PER_SECOND) { go_to_standby = 1; } return MISCHIEF_MANAGED; } - // 4 clicks: exit + // 4 clicks: exit, and turn on at "low" level else if (event == EV_4clicks) { set_state(steady_state, 1); return MISCHIEF_MANAGED; @@ -175,6 +166,9 @@ void low_voltage() { // step down by one level or turn off if (actual_level > 0) { set_level(actual_level - 1); + #ifdef USE_THERMAL_REGULATION + target_level = actual_level; // don't let low temperature override LVP + #endif } else { set_state(off_state, 0); diff --git a/spaghetti-monster/baton/baton.c b/spaghetti-monster/baton/baton.c index 1266ddd..59a7196 100644 --- a/spaghetti-monster/baton/baton.c +++ b/spaghetti-monster/baton/baton.c @@ -20,22 +20,17 @@ #define FSM_EMISAR_D4_DRIVER #define USE_LVP #define USE_THERMAL_REGULATION -#define DEFAULT_THERM_CEIL 45 #define USE_DEBUG_BLINK #define USE_DELAY_MS #define USE_DELAY_4MS #define USE_DELAY_ZERO #include "spaghetti-monster.h" -// moon + ../../bin/level_calc.py 2 6 7135 18 10 150 FET 1 10 1500 -uint8_t pwm1_modes[] = { 3, 18, 110, 255, 255, 255, 0, }; -uint8_t pwm2_modes[] = { 0, 0, 0, 9, 58, 138, 255, }; -#define MAX_LEVEL (sizeof(pwm1_modes)-1) - // FSM states uint8_t off_state(EventPtr event, uint16_t arg); uint8_t steady_state(EventPtr event, uint16_t arg); uint8_t party_strobe_state(EventPtr event, uint16_t arg); +uint8_t lockout_state(EventPtr event, uint16_t arg); // brightness control uint8_t memorized_level = 1; @@ -44,93 +39,100 @@ uint8_t actual_level = 0; uint8_t target_level = 0; #endif +// moon + ../../bin/level_calc.py 2 6 7135 18 10 150 FET 1 10 1500 +uint8_t pwm1_levels[] = { 3, 18, 110, 255, 255, 255, 0, }; +uint8_t pwm2_levels[] = { 0, 0, 0, 9, 58, 138, 255, }; +#define MAX_LEVEL (sizeof(pwm1_levels)-1) + +// set LED brightness void set_level(uint8_t lvl) { actual_level = lvl; - PWM1_LVL = pwm1_modes[lvl]; - PWM2_LVL = pwm2_modes[lvl]; + PWM1_LVL = pwm1_levels[lvl]; + PWM2_LVL = pwm2_levels[lvl]; } uint8_t off_state(EventPtr event, uint16_t arg) { // turn emitter off when entering state if (event == EV_enter_state) { - PWM1_LVL = 0; - PWM2_LVL = 0; - // sleep while off (lower power use) - go_to_standby = 1; - return 0; + go_to_standby = 1; // sleep while off (lower power use) + return EVENT_HANDLED; } // hold (initially): go to lowest level, but allow abort for regular click else if (event == EV_click1_press) { set_level(0); - return 0; + return EVENT_HANDLED; + } + // hold (longer): go to lowest level + else if (event == EV_click1_hold) { + set_state(steady_state, 0); + return EVENT_HANDLED; } // 1 click (before timeout): go to memorized level, but allow abort for double click else if (event == EV_click1_release) { set_level(memorized_level); - return 0; + return EVENT_HANDLED; } // 1 click: regular mode else if (event == EV_1click) { set_state(steady_state, memorized_level); - return 0; + return EVENT_HANDLED; } // 2 clicks: highest mode else if (event == EV_2clicks) { set_state(steady_state, MAX_LEVEL); - return 0; + return EVENT_HANDLED; } // 3 clicks: strobe mode else if (event == EV_3clicks) { set_state(party_strobe_state, 255); - return 0; + return EVENT_HANDLED; } - // hold: go to lowest level - else if (event == EV_click1_hold) { - set_state(steady_state, 0); - return 0; + // 4 clicks: soft lockout + else if (event == EV_4clicks) { + set_state(lockout_state, 0); + return EVENT_HANDLED; } - return 1; + return EVENT_NOT_HANDLED; } uint8_t steady_state(EventPtr event, uint16_t arg) { // turn LED on when we first enter the mode if (event == EV_enter_state) { // remember this level, unless it's moon or turbo - if ((arg > 0) && (arg < MAX_LEVEL)) - memorized_level = arg; + if ((arg > 0) && (arg < MAX_LEVEL)) memorized_level = arg; // use the requested level even if not memorized #ifdef USE_THERMAL_REGULATION target_level = arg; #endif set_level(arg); - return 0; + return EVENT_HANDLED; } // 1 click: off else if (event == EV_1click) { set_state(off_state, 0); - return 0; + return EVENT_HANDLED; } // 2 clicks: go to/from highest level else if (event == EV_2clicks) { - if (actual_level < MAX_LEVEL) { + if (actual_level < MAX_LEVEL) { // go to turbo memorized_level = actual_level; // in case we're on moon #ifdef USE_THERMAL_REGULATION target_level = MAX_LEVEL; #endif set_level(MAX_LEVEL); } - else { + else { // return from turbo #ifdef USE_THERMAL_REGULATION target_level = memorized_level; #endif set_level(memorized_level); } - return 0; + return EVENT_HANDLED; } // 3 clicks: go to strobe modes else if (event == EV_3clicks) { set_state(party_strobe_state, 0xff); - return 0; + return EVENT_HANDLED; } // hold: change brightness else if (event == EV_click1_hold) { @@ -141,25 +143,21 @@ uint8_t steady_state(EventPtr event, uint16_t arg) { #endif set_level(memorized_level); } - return 0; + return EVENT_HANDLED; } #ifdef USE_THERMAL_REGULATION // overheating: drop by 1 level else if (event == EV_temperature_high) { - if (actual_level > 1) { - set_level(actual_level - 1); - } - return 0; + if (actual_level > 1) { set_level(actual_level - 1); } + return EVENT_HANDLED; } // underheating: increase by 1 level if we're lower than the target else if (event == EV_temperature_low) { - if (actual_level < target_level) { - set_level(actual_level + 1); - } - return 0; + if (actual_level < target_level) { set_level(actual_level + 1); } + return EVENT_HANDLED; } #endif - return 1; + return EVENT_NOT_HANDLED; } uint8_t party_strobe_state(EventPtr event, uint16_t arg) { @@ -168,7 +166,7 @@ uint8_t party_strobe_state(EventPtr event, uint16_t arg) { if (event == EV_enter_state) { if (arg < 64) between = arg; frames = 0; - return 0; + return MISCHIEF_MANAGED; } // tick: strobe the emitter else if (event == EV_tick) { @@ -182,17 +180,17 @@ uint8_t party_strobe_state(EventPtr event, uint16_t arg) { //frames = (frames + 1) % between; frames++; if (frames > between) frames = 0; - return 0; + return MISCHIEF_MANAGED; } // 1 click: off else if (event == EV_1click) { set_state(off_state, 0); - return 0; + return MISCHIEF_MANAGED; } // 2 clicks: go back to regular modes else if (event == EV_2clicks) { set_state(steady_state, memorized_level); - return 0; + return MISCHIEF_MANAGED; } // hold: change speed else if (event == EV_click1_hold) { @@ -200,9 +198,25 @@ uint8_t party_strobe_state(EventPtr event, uint16_t arg) { between = (between+1)%6; frames = 0; } - return 0; + return MISCHIEF_MANAGED; + } + return EVENT_NOT_HANDLED; +} + +uint8_t lockout_state(EventPtr event, uint16_t arg) { + // stay asleep while locked + if (event == EV_tick) { + PWM1_LVL = 0; PWM2_LVL = 0; // make sure emitters are off + // sleep 1 second after user stops pressing + if (arg > TICKS_PER_SECOND) { go_to_standby = 1; } + return MISCHIEF_MANAGED; + } + // 4 clicks: exit, and turn on at "low" level + else if (event == EV_4clicks) { + set_state(steady_state, 1); + return MISCHIEF_MANAGED; } - return 1; + return EVENT_NOT_HANDLED; } void low_voltage() { @@ -214,6 +228,10 @@ void low_voltage() { else if (current_state == steady_state) { if (actual_level > 0) { set_level(actual_level - 1); + #ifdef USE_THERMAL_REGULATION + target_level = actual_level; // don't let low temperature override LVP + #endif + } else { set_state(off_state, 0); diff --git a/spaghetti-monster/baton/baton.txt b/spaghetti-monster/baton/baton.txt new file mode 100644 index 0000000..2f0c22f --- /dev/null +++ b/spaghetti-monster/baton/baton.txt @@ -0,0 +1,21 @@ +This is a very simple clone of the Olight Baton interface. It is not +exact, but it has the basics. Mostly, it exists for the purposes of +demonstrating how to create interfaces in FSM. + +While off: + + - 1 click: Turn on (at memorized level). + - Hold: Turn on (at moon level). + - 2 clicks: Turn on (at highest level). + - 4 clicks: Soft lockout mode. + +While on: + + - 1 click: Turn off. + - Hold: Change the brightness. Goes up in steps, then wraps around. + - 2 clicks: Go to/from highest level. + +While locked: + + - 4 clicks: Exit lockout mode. + -- cgit v1.2.3 From fa9baf747b32e77e4a753dec99b7b6dc4795af1b Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Mon, 15 Oct 2018 15:09:34 -0600 Subject: removed more-complex baton UI (which only different by having a party strobe mode), replaced it with the simpler version (since this UI exists mostly as an example) --- spaghetti-monster/baton/baton-simpler.c | 188 -------------------------------- spaghetti-monster/baton/baton.c | 86 +++------------ 2 files changed, 13 insertions(+), 261 deletions(-) delete mode 100644 spaghetti-monster/baton/baton-simpler.c diff --git a/spaghetti-monster/baton/baton-simpler.c b/spaghetti-monster/baton/baton-simpler.c deleted file mode 100644 index d4725ef..0000000 --- a/spaghetti-monster/baton/baton-simpler.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Baton: Olight Baton-like UI for SpaghettiMonster. - * - * Copyright (C) 2017 Selene ToyKeeper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#define FSM_EMISAR_D4_DRIVER -#define USE_LVP -#define USE_THERMAL_REGULATION -#define USE_DELAY_MS -#include "spaghetti-monster.h" - -// FSM states -uint8_t off_state(EventPtr event, uint16_t arg); -uint8_t steady_state(EventPtr event, uint16_t arg); -uint8_t lockout_state(EventPtr event, uint16_t arg); - -// brightness control -uint8_t memorized_level = 1; -uint8_t actual_level = 0; -#ifdef USE_THERMAL_REGULATION -uint8_t target_level = 0; -#endif - -// moon + ../../bin/level_calc.py 2 6 7135 18 10 150 FET 1 10 1500 -uint8_t pwm1_levels[] = { 3, 18, 110, 255, 255, 255, 0, }; -uint8_t pwm2_levels[] = { 0, 0, 0, 9, 58, 138, 255, }; -#define MAX_LEVEL (sizeof(pwm1_levels)-1) - -// set LED brightness -void set_level(uint8_t lvl) { - actual_level = lvl; - PWM1_LVL = pwm1_levels[lvl]; - PWM2_LVL = pwm2_levels[lvl]; -} - -uint8_t off_state(EventPtr event, uint16_t arg) { - // turn emitter off when entering state - if (event == EV_enter_state) { - go_to_standby = 1; // sleep while off (lower power use) - return EVENT_HANDLED; - } - // hold (initially): go to lowest level, but allow abort for regular click - else if (event == EV_click1_press) { - set_level(0); - return EVENT_HANDLED; - } - // hold (longer): go to lowest level - else if (event == EV_click1_hold) { - set_state(steady_state, 0); - return EVENT_HANDLED; - } - // 1 click (before timeout): go to memorized level, but allow abort for double click - else if (event == EV_click1_release) { - set_level(memorized_level); - return EVENT_HANDLED; - } - // 1 click: regular mode - else if (event == EV_1click) { - set_state(steady_state, memorized_level); - return EVENT_HANDLED; - } - // 2 clicks: highest mode - else if (event == EV_2clicks) { - set_state(steady_state, MAX_LEVEL); - return EVENT_HANDLED; - } - // 4 clicks: soft lockout - else if (event == EV_4clicks) { - set_state(lockout_state, 0); - return EVENT_HANDLED; - } - return EVENT_NOT_HANDLED; -} - -uint8_t steady_state(EventPtr event, uint16_t arg) { - // turn LED on when we first enter the mode - if (event == EV_enter_state) { - // remember this level, unless it's moon or turbo - if ((arg > 0) && (arg < MAX_LEVEL)) memorized_level = arg; - // use the requested level even if not memorized - #ifdef USE_THERMAL_REGULATION - target_level = arg; - #endif - set_level(arg); - return EVENT_HANDLED; - } - // 1 click: off - else if (event == EV_1click) { - set_state(off_state, 0); - return EVENT_HANDLED; - } - // 2 clicks: go to/from highest level - else if (event == EV_2clicks) { - if (actual_level < MAX_LEVEL) { // go to turbo - memorized_level = actual_level; // in case we're on moon - #ifdef USE_THERMAL_REGULATION - target_level = MAX_LEVEL; - #endif - set_level(MAX_LEVEL); - } - else { // return from turbo - #ifdef USE_THERMAL_REGULATION - target_level = memorized_level; - #endif - set_level(memorized_level); - } - return EVENT_HANDLED; - } - // hold: change brightness - else if (event == EV_click1_hold) { - if ((arg % HOLD_TIMEOUT) == 0) { - memorized_level = (actual_level+1) % (MAX_LEVEL+1); - #ifdef USE_THERMAL_REGULATION - target_level = memorized_level; - #endif - set_level(memorized_level); - } - return EVENT_HANDLED; - } - #ifdef USE_THERMAL_REGULATION - // overheating: drop by 1 level - else if (event == EV_temperature_high) { - if (actual_level > 1) { set_level(actual_level - 1); } - return EVENT_HANDLED; - } - // underheating: increase by 1 level if we're lower than the target - else if (event == EV_temperature_low) { - if (actual_level < target_level) { set_level(actual_level + 1); } - return EVENT_HANDLED; - } - #endif - return EVENT_NOT_HANDLED; -} - -uint8_t lockout_state(EventPtr event, uint16_t arg) { - // stay asleep while locked - if (event == EV_tick) { - PWM1_LVL = 0; PWM2_LVL = 0; // make sure emitters are off - // sleep 1 second after user stops pressing buttons - if (arg > TICKS_PER_SECOND) { go_to_standby = 1; } - return MISCHIEF_MANAGED; - } - // 4 clicks: exit, and turn on at "low" level - else if (event == EV_4clicks) { - set_state(steady_state, 1); - return MISCHIEF_MANAGED; - } - return EVENT_NOT_HANDLED; -} - -void low_voltage() { - // step down by one level or turn off - if (actual_level > 0) { - set_level(actual_level - 1); - #ifdef USE_THERMAL_REGULATION - target_level = actual_level; // don't let low temperature override LVP - #endif - } - else { - set_state(off_state, 0); - } -} - -void setup() { - // blink when power is connected - set_level(MAX_LEVEL/2); - delay_ms(10); - set_level(0); - - push_state(off_state, 0); -} - -void loop() { -} diff --git a/spaghetti-monster/baton/baton.c b/spaghetti-monster/baton/baton.c index 59a7196..d4725ef 100644 --- a/spaghetti-monster/baton/baton.c +++ b/spaghetti-monster/baton/baton.c @@ -20,16 +20,12 @@ #define FSM_EMISAR_D4_DRIVER #define USE_LVP #define USE_THERMAL_REGULATION -#define USE_DEBUG_BLINK #define USE_DELAY_MS -#define USE_DELAY_4MS -#define USE_DELAY_ZERO #include "spaghetti-monster.h" // FSM states uint8_t off_state(EventPtr event, uint16_t arg); uint8_t steady_state(EventPtr event, uint16_t arg); -uint8_t party_strobe_state(EventPtr event, uint16_t arg); uint8_t lockout_state(EventPtr event, uint16_t arg); // brightness control @@ -82,11 +78,6 @@ uint8_t off_state(EventPtr event, uint16_t arg) { set_state(steady_state, MAX_LEVEL); return EVENT_HANDLED; } - // 3 clicks: strobe mode - else if (event == EV_3clicks) { - set_state(party_strobe_state, 255); - return EVENT_HANDLED; - } // 4 clicks: soft lockout else if (event == EV_4clicks) { set_state(lockout_state, 0); @@ -129,11 +120,6 @@ uint8_t steady_state(EventPtr event, uint16_t arg) { } return EVENT_HANDLED; } - // 3 clicks: go to strobe modes - else if (event == EV_3clicks) { - set_state(party_strobe_state, 0xff); - return EVENT_HANDLED; - } // hold: change brightness else if (event == EV_click1_hold) { if ((arg % HOLD_TIMEOUT) == 0) { @@ -160,54 +146,11 @@ uint8_t steady_state(EventPtr event, uint16_t arg) { return EVENT_NOT_HANDLED; } -uint8_t party_strobe_state(EventPtr event, uint16_t arg) { - static volatile uint8_t frames = 0; - static volatile uint8_t between = 2; - if (event == EV_enter_state) { - if (arg < 64) between = arg; - frames = 0; - return MISCHIEF_MANAGED; - } - // tick: strobe the emitter - else if (event == EV_tick) { - if (frames == 0) { - PWM1_LVL = 0; - PWM2_LVL = 255; - if (between < 3) delay_zero(); - else delay_ms(1); - PWM2_LVL = 0; - } - //frames = (frames + 1) % between; - frames++; - if (frames > between) frames = 0; - return MISCHIEF_MANAGED; - } - // 1 click: off - else if (event == EV_1click) { - set_state(off_state, 0); - return MISCHIEF_MANAGED; - } - // 2 clicks: go back to regular modes - else if (event == EV_2clicks) { - set_state(steady_state, memorized_level); - return MISCHIEF_MANAGED; - } - // hold: change speed - else if (event == EV_click1_hold) { - if ((arg % HOLD_TIMEOUT) == 0) { - between = (between+1)%6; - frames = 0; - } - return MISCHIEF_MANAGED; - } - return EVENT_NOT_HANDLED; -} - uint8_t lockout_state(EventPtr event, uint16_t arg) { // stay asleep while locked if (event == EV_tick) { PWM1_LVL = 0; PWM2_LVL = 0; // make sure emitters are off - // sleep 1 second after user stops pressing + // sleep 1 second after user stops pressing buttons if (arg > TICKS_PER_SECOND) { go_to_standby = 1; } return MISCHIEF_MANAGED; } @@ -220,29 +163,26 @@ uint8_t lockout_state(EventPtr event, uint16_t arg) { } void low_voltage() { - // "step down" from strobe to level 2 - if (current_state == party_strobe_state) { - set_state(steady_state, 1); - } - // in normal mode, step down by one level or turn off - else if (current_state == steady_state) { - if (actual_level > 0) { - set_level(actual_level - 1); + // step down by one level or turn off + if (actual_level > 0) { + set_level(actual_level - 1); #ifdef USE_THERMAL_REGULATION target_level = actual_level; // don't let low temperature override LVP #endif - - } - else { - set_state(off_state, 0); - } + } + else { + set_state(off_state, 0); } } void setup() { - debug_blink(2); + // blink when power is connected + set_level(MAX_LEVEL/2); + delay_ms(10); + set_level(0); push_state(off_state, 0); } -void loop() { } +void loop() { +} -- cgit v1.2.3 From a58ba65298350e9e7a2f8ce33645cdf1db5916cd Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 17 Oct 2018 23:46:10 -0600 Subject: PL47 doesn't need "low" mode for aux LED / switch LED --- spaghetti-monster/anduril/cfg-ff-pl47.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spaghetti-monster/anduril/cfg-ff-pl47.h b/spaghetti-monster/anduril/cfg-ff-pl47.h index d916e06..ef12964 100644 --- a/spaghetti-monster/anduril/cfg-ff-pl47.h +++ b/spaghetti-monster/anduril/cfg-ff-pl47.h @@ -17,7 +17,8 @@ // the "low" mode doesn't work on this light's aux LEDs // (but it does work on the switch LEDs) -//#define INDICATOR_LED_SKIP_LOW +// Fireflies wants to skip aux LED mode 1 (low) +#define INDICATOR_LED_SKIP_LOW // ... or if TICK_DURING_STANDBY is turned off: // off mode: high (2) -- cgit v1.2.3 From a19560f92e0ead081e494d58dd6cf36c170c85c0 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 17 Oct 2018 23:47:12 -0600 Subject: Initial untested support for the Sofirn SP36 (like a Q8 but smaller). --- spaghetti-monster/anduril/anduril.c | 4 ++++ spaghetti-monster/anduril/build-all.sh | 1 + 2 files changed, 5 insertions(+) diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index 300e32b..085c674 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -32,6 +32,7 @@ //#define FSM_FF_ROT66_DRIVER //#define FSM_FF_ROT66_219_DRIVER //#define FSM_FW3A_DRIVER +//#define FSM_SOFIRN_SP36_DRIVER #define USE_LVP // FIXME: won't build when this option is turned off @@ -114,6 +115,9 @@ #elif defined(FSM_FW3A_DRIVER) #include "cfg-fw3a.h" +#elif defined(FSM_SOFIRN_SP36_DRIVER) +#include "cfg-sofirn-sp36.h" + #endif diff --git a/spaghetti-monster/anduril/build-all.sh b/spaghetti-monster/anduril/build-all.sh index 9e2a83c..1a1363c 100755 --- a/spaghetti-monster/anduril/build-all.sh +++ b/spaghetti-monster/anduril/build-all.sh @@ -16,6 +16,7 @@ for TARGET in \ FF_ROT66 \ FF_ROT66_219 \ FW3A \ + SOFIRN_SP36 \ ; do echo "===== $TARGET =====" ../../../bin/build-85.sh "$UI" "-DFSM_${TARGET}_DRIVER" -- cgit v1.2.3 From aab4ec0543a7563ff08fbc2013bd414c03e25648 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 30 Oct 2018 00:42:43 -0600 Subject: Adjusted FF PL47 config. Made muggle floor/ceiling configurable per config file. --- spaghetti-monster/anduril/anduril.c | 4 ++++ spaghetti-monster/anduril/cfg-ff-pl47.h | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index 085c674..fd3c534 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -154,9 +154,13 @@ #endif #if defined(USE_MUGGLE_MODE) +#ifndef MUGGLE_FLOOR #define MUGGLE_FLOOR 22 +#endif +#ifndef MUGGLE_CEILING #define MUGGLE_CEILING (MAX_1x7135+20) #endif +#endif #define USE_IDLE_MODE // reduce power use while awake and no tasks are pending #define USE_DYNAMIC_UNDERCLOCKING // cut clock speed at very low modes for better efficiency diff --git a/spaghetti-monster/anduril/cfg-ff-pl47.h b/spaghetti-monster/anduril/cfg-ff-pl47.h index ef12964..d9431a1 100644 --- a/spaghetti-monster/anduril/cfg-ff-pl47.h +++ b/spaghetti-monster/anduril/cfg-ff-pl47.h @@ -39,15 +39,27 @@ #define HALFSPEED_LEVEL 13 #define QUARTERSPEED_LEVEL 6 -// ceiling is level 120/150 -#define RAMP_SMOOTH_CEIL (MAX_LEVEL*4/5) - // thermal regulation parameters #ifdef MIN_THERM_STEPDOWN #undef MIN_THERM_STEPDOWN // this should be lower, because 3x7135 instead of 1x7135 #endif #define MIN_THERM_STEPDOWN 60 // lowest value it'll step down to +// ceiling is level 120/150 +#define RAMP_SMOOTH_CEIL 120 + +// 10, 28, 46, 65, 83, 101, 120 (83 is highest regulated) +#define RAMP_DISCRETE_FLOOR 10 +#define RAMP_DISCRETE_CEIL 120 +#define RAMP_DISCRETE_STEPS 7 + +// ~25 lm to ~300 lm +#define MUGGLE_FLOOR 30 +#define MUGGLE_CEILING MAX_1x7135 +// ~50 lm to ~500 lm +//#define MUGGLE_FLOOR 40 +//#define MUGGLE_CEILING 90 + // regulate down faster when the FET is active, slower otherwise #define THERM_FASTER_LEVEL 130 // throttle back faster when high -- cgit v1.2.3 From 0110aa7f7988d54119ae085b5366918783b32901 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 2 Nov 2018 15:41:00 -0600 Subject: Corrected anduril.txt with the new aux LED button mappings. --- spaghetti-monster/anduril/anduril.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spaghetti-monster/anduril/anduril.txt b/spaghetti-monster/anduril/anduril.txt index 9cbef68..f0f0b4d 100644 --- a/spaghetti-monster/anduril/anduril.txt +++ b/spaghetti-monster/anduril/anduril.txt @@ -17,6 +17,9 @@ From off: * 4 clicks: lock-out * 5 clicks: momentary mode (disconnect power to exit) * 6 clicks: muggle mode + * On hardware with an indicator LED... + * 7 clicks: Change aux LED mode used in "off" mode. + (the modes are usually off/low/high/blinking) In steady mode: * 1 click: off @@ -111,8 +114,8 @@ Lockout mode: * Hold: momentary moon * 4 clicks: exit lockout (return to regular "off" mode) * On hardware with an indicator LED... - * 3 clicks: Change button brightness used in lockout mode. (low/high/off) - * Click, click, hold: Change button brightness used in "off" mode. + * 3 clicks: Change aux LED brightness used in lockout mode. + (the modes are usually off/low/high/blinking) Momentary mode: * Press button: Light on (at memorized level). -- cgit v1.2.3 From dcc52fdfc95e9b2621b46a18250051234891f563 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 3 Nov 2018 16:00:15 -0600 Subject: Renamed flash/build scripts to better indicate MCU type. --- bin/build-25.sh | 30 ------------------------------ bin/build-85.sh | 30 ------------------------------ bin/build-tiny13.sh | 30 ++++++++++++++++++++++++++++++ bin/build-tiny25.sh | 30 ++++++++++++++++++++++++++++++ bin/build-tiny85.sh | 30 ++++++++++++++++++++++++++++++ bin/build.sh | 30 ------------------------------ bin/flash-25.sh | 4 ---- bin/flash-85.sh | 4 ---- bin/flash-tiny13.bat | 1 + bin/flash-tiny13.sh | 3 +++ bin/flash-tiny25.sh | 4 ++++ bin/flash-tiny85.sh | 4 ++++ bin/flash.sh | 3 --- 13 files changed, 102 insertions(+), 101 deletions(-) delete mode 100755 bin/build-25.sh delete mode 100755 bin/build-85.sh create mode 100755 bin/build-tiny13.sh create mode 100755 bin/build-tiny25.sh create mode 100755 bin/build-tiny85.sh delete mode 100755 bin/build.sh delete mode 100755 bin/flash-25.sh delete mode 100755 bin/flash-85.sh create mode 100755 bin/flash-tiny13.bat create mode 100755 bin/flash-tiny13.sh create mode 100755 bin/flash-tiny25.sh create mode 100755 bin/flash-tiny85.sh delete mode 100755 bin/flash.sh diff --git a/bin/build-25.sh b/bin/build-25.sh deleted file mode 100755 index a775a0f..0000000 --- a/bin/build-25.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# Instead of using a Makefile, since most of the firmwares here build in the -# same exact way, here's a script to do the same thing - -export PROGRAM=$1 ; shift -export ATTINY=25 -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 OFLAGS="-Wall -g -Os -mmcu=$MCU" -export LDFLAGS= -export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' -export OBJS=$PROGRAM.o - -for arg in "$*" ; do - OTHERFLAGS="$OTHERFLAGS $arg" -done - -function run () { - echo $* - $* - if [ x"$?" != x0 ]; then exit 1 ; fi -} - -run $CC $OTHERFLAGS $CFLAGS -o $PROGRAM.o -c $PROGRAM.c -run $CC $OFLAGS $LDFLAGS -o $PROGRAM.elf $PROGRAM.o -run $OBJCOPY $OBJCOPYFLAGS $PROGRAM.elf $PROGRAM.hex -run avr-size -C --mcu=$MCU $PROGRAM.elf | grep Full diff --git a/bin/build-85.sh b/bin/build-85.sh deleted file mode 100755 index f0cf1b9..0000000 --- a/bin/build-85.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# Instead of using a Makefile, since most of the firmwares here build in the -# same exact way, here's a script to do the same thing - -export PROGRAM=$1 ; shift -export ATTINY=85 -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 OFLAGS="-Wall -g -Os -mmcu=$MCU" -export LDFLAGS= -export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' -export OBJS=$PROGRAM.o - -for arg in "$*" ; do - OTHERFLAGS="$OTHERFLAGS $arg" -done - -function run () { - echo $* - $* - if [ x"$?" != x0 ]; then exit 1 ; fi -} - -run $CC $OTHERFLAGS $CFLAGS -o $PROGRAM.o -c $PROGRAM.c -run $CC $OFLAGS $LDFLAGS -o $PROGRAM.elf $PROGRAM.o -run $OBJCOPY $OBJCOPYFLAGS $PROGRAM.elf $PROGRAM.hex -run avr-size -C --mcu=$MCU $PROGRAM.elf | grep Full diff --git a/bin/build-tiny13.sh b/bin/build-tiny13.sh new file mode 100755 index 0000000..c1f0446 --- /dev/null +++ b/bin/build-tiny13.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Instead of using a Makefile, since most of the firmwares here build in the +# same exact way, here's a script to do the same thing + +export PROGRAM=$1 ; shift +export ATTINY=13 +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 OFLAGS="-Wall -g -Os -mmcu=$MCU" +export LDFLAGS= +export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' +export OBJS=$PROGRAM.o + +for arg in "$*" ; do + OTHERFLAGS="$OTHERFLAGS $arg" +done + +function run () { + echo $* + $* + if [ x"$?" != x0 ]; then exit 1 ; fi +} + +run $CC $OTHERFLAGS $CFLAGS -o $PROGRAM.o -c $PROGRAM.c +run $CC $OFLAGS $LDFLAGS -o $PROGRAM.elf $PROGRAM.o +run $OBJCOPY $OBJCOPYFLAGS $PROGRAM.elf $PROGRAM.hex +run avr-size -C --mcu=$MCU $PROGRAM.elf | grep Full diff --git a/bin/build-tiny25.sh b/bin/build-tiny25.sh new file mode 100755 index 0000000..a775a0f --- /dev/null +++ b/bin/build-tiny25.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Instead of using a Makefile, since most of the firmwares here build in the +# same exact way, here's a script to do the same thing + +export PROGRAM=$1 ; shift +export ATTINY=25 +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 OFLAGS="-Wall -g -Os -mmcu=$MCU" +export LDFLAGS= +export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' +export OBJS=$PROGRAM.o + +for arg in "$*" ; do + OTHERFLAGS="$OTHERFLAGS $arg" +done + +function run () { + echo $* + $* + if [ x"$?" != x0 ]; then exit 1 ; fi +} + +run $CC $OTHERFLAGS $CFLAGS -o $PROGRAM.o -c $PROGRAM.c +run $CC $OFLAGS $LDFLAGS -o $PROGRAM.elf $PROGRAM.o +run $OBJCOPY $OBJCOPYFLAGS $PROGRAM.elf $PROGRAM.hex +run avr-size -C --mcu=$MCU $PROGRAM.elf | grep Full diff --git a/bin/build-tiny85.sh b/bin/build-tiny85.sh new file mode 100755 index 0000000..f0cf1b9 --- /dev/null +++ b/bin/build-tiny85.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Instead of using a Makefile, since most of the firmwares here build in the +# same exact way, here's a script to do the same thing + +export PROGRAM=$1 ; shift +export ATTINY=85 +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 OFLAGS="-Wall -g -Os -mmcu=$MCU" +export LDFLAGS= +export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' +export OBJS=$PROGRAM.o + +for arg in "$*" ; do + OTHERFLAGS="$OTHERFLAGS $arg" +done + +function run () { + echo $* + $* + if [ x"$?" != x0 ]; then exit 1 ; fi +} + +run $CC $OTHERFLAGS $CFLAGS -o $PROGRAM.o -c $PROGRAM.c +run $CC $OFLAGS $LDFLAGS -o $PROGRAM.elf $PROGRAM.o +run $OBJCOPY $OBJCOPYFLAGS $PROGRAM.elf $PROGRAM.hex +run avr-size -C --mcu=$MCU $PROGRAM.elf | grep Full diff --git a/bin/build.sh b/bin/build.sh deleted file mode 100755 index c1f0446..0000000 --- a/bin/build.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# Instead of using a Makefile, since most of the firmwares here build in the -# same exact way, here's a script to do the same thing - -export PROGRAM=$1 ; shift -export ATTINY=13 -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 OFLAGS="-Wall -g -Os -mmcu=$MCU" -export LDFLAGS= -export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' -export OBJS=$PROGRAM.o - -for arg in "$*" ; do - OTHERFLAGS="$OTHERFLAGS $arg" -done - -function run () { - echo $* - $* - if [ x"$?" != x0 ]; then exit 1 ; fi -} - -run $CC $OTHERFLAGS $CFLAGS -o $PROGRAM.o -c $PROGRAM.c -run $CC $OFLAGS $LDFLAGS -o $PROGRAM.elf $PROGRAM.o -run $OBJCOPY $OBJCOPYFLAGS $PROGRAM.elf $PROGRAM.hex -run avr-size -C --mcu=$MCU $PROGRAM.elf | grep Full diff --git a/bin/flash-25.sh b/bin/flash-25.sh deleted file mode 100755 index 0b24bb2..0000000 --- a/bin/flash-25.sh +++ /dev/null @@ -1,4 +0,0 @@ -#/bin/sh -FIRMWARE=$1 -avrdude -c usbasp -p t25 -u -U lfuse:w:0xd2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:$FIRMWARE -# http://www.engbedded.com/cgi-bin/fcx.cgi?P_PREV=ATtiny25&P=ATtiny25&M_LOW_0x3F=0x22&M_HIGH_0x07=0x07&M_HIGH_0x20=0x00&B_SUT1=P&B_SPIEN=P&B_CKSEL3=P&B_CKSEL2=P&B_CKSEL0=P&V_LOW=D2&V_HIGH=DF&V_EXTENDED=FF diff --git a/bin/flash-85.sh b/bin/flash-85.sh deleted file mode 100755 index 8d1636d..0000000 --- a/bin/flash-85.sh +++ /dev/null @@ -1,4 +0,0 @@ -#/bin/sh -FIRMWARE=$1 -avrdude -c usbasp -p t85 -u -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:$FIRMWARE -# http://www.engbedded.com/cgi-bin/fcx.cgi?P_PREV=ATtiny85&P=ATtiny85&M_LOW_0x3F=0x22&M_HIGH_0x07=0x06&M_HIGH_0x20=0x00&B_SPIEN=P&B_SUT0=P&B_CKSEL3=P&B_CKSEL2=P&B_CKSEL0=P&B_BODLEVEL0=P&V_LOW=E2&V_HIGH=DE&V_EXTENDED=FF diff --git a/bin/flash-tiny13.bat b/bin/flash-tiny13.bat new file mode 100755 index 0000000..5324ab6 --- /dev/null +++ b/bin/flash-tiny13.bat @@ -0,0 +1 @@ +avrdude -p t13 -c usbasp -u -Uflash:w:%1.hex:a -Ulfuse:w:0x75:m -Uhfuse:w:0xFF:m diff --git a/bin/flash-tiny13.sh b/bin/flash-tiny13.sh new file mode 100755 index 0000000..9c2ef82 --- /dev/null +++ b/bin/flash-tiny13.sh @@ -0,0 +1,3 @@ +#/bin/sh +FIRMWARE=$1 +avrdude -c usbasp -p t13 -u -Uflash:w:$FIRMWARE -Ulfuse:w:0x75:m -Uhfuse:w:0xFF:m diff --git a/bin/flash-tiny25.sh b/bin/flash-tiny25.sh new file mode 100755 index 0000000..0b24bb2 --- /dev/null +++ b/bin/flash-tiny25.sh @@ -0,0 +1,4 @@ +#/bin/sh +FIRMWARE=$1 +avrdude -c usbasp -p t25 -u -U lfuse:w:0xd2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:$FIRMWARE +# http://www.engbedded.com/cgi-bin/fcx.cgi?P_PREV=ATtiny25&P=ATtiny25&M_LOW_0x3F=0x22&M_HIGH_0x07=0x07&M_HIGH_0x20=0x00&B_SUT1=P&B_SPIEN=P&B_CKSEL3=P&B_CKSEL2=P&B_CKSEL0=P&V_LOW=D2&V_HIGH=DF&V_EXTENDED=FF diff --git a/bin/flash-tiny85.sh b/bin/flash-tiny85.sh new file mode 100755 index 0000000..8d1636d --- /dev/null +++ b/bin/flash-tiny85.sh @@ -0,0 +1,4 @@ +#/bin/sh +FIRMWARE=$1 +avrdude -c usbasp -p t85 -u -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:$FIRMWARE +# http://www.engbedded.com/cgi-bin/fcx.cgi?P_PREV=ATtiny85&P=ATtiny85&M_LOW_0x3F=0x22&M_HIGH_0x07=0x06&M_HIGH_0x20=0x00&B_SPIEN=P&B_SUT0=P&B_CKSEL3=P&B_CKSEL2=P&B_CKSEL0=P&B_BODLEVEL0=P&V_LOW=E2&V_HIGH=DE&V_EXTENDED=FF diff --git a/bin/flash.sh b/bin/flash.sh deleted file mode 100755 index 9c2ef82..0000000 --- a/bin/flash.sh +++ /dev/null @@ -1,3 +0,0 @@ -#/bin/sh -FIRMWARE=$1 -avrdude -c usbasp -p t13 -u -Uflash:w:$FIRMWARE -Ulfuse:w:0x75:m -Uhfuse:w:0xFF:m -- cgit v1.2.3 From 4df62bd9d7c3b7bbb9a62ab13b78d7f42da99958 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 3 Nov 2018 16:17:50 -0600 Subject: Split flashing scripts into firmware vs fuses, to help prevent accidental bricking. (some people had errors happen during the fuse parts, and ended up with bricks) --- bin/flash-tiny13-fuses.bat | 1 + bin/flash-tiny13-fuses.sh | 8 ++++++++ bin/flash-tiny13.bat | 2 +- bin/flash-tiny13.sh | 2 +- bin/flash-tiny25-fuses.sh | 8 ++++++++ bin/flash-tiny25.sh | 3 +-- bin/flash-tiny85-fuses.sh | 8 ++++++++ bin/flash-tiny85.sh | 3 +-- 8 files changed, 29 insertions(+), 6 deletions(-) create mode 100755 bin/flash-tiny13-fuses.bat create mode 100755 bin/flash-tiny13-fuses.sh create mode 100755 bin/flash-tiny25-fuses.sh create mode 100755 bin/flash-tiny85-fuses.sh diff --git a/bin/flash-tiny13-fuses.bat b/bin/flash-tiny13-fuses.bat new file mode 100755 index 0000000..cec982e --- /dev/null +++ b/bin/flash-tiny13-fuses.bat @@ -0,0 +1 @@ +avrdude -c usbasp -p t13 -u -Ulfuse:w:0x75:m -Uhfuse:w:0xFF:m diff --git a/bin/flash-tiny13-fuses.sh b/bin/flash-tiny13-fuses.sh new file mode 100755 index 0000000..fe479a8 --- /dev/null +++ b/bin/flash-tiny13-fuses.sh @@ -0,0 +1,8 @@ +#/bin/sh +# 4.8 MHz (~4.0 MHz actual), 4ms boot delay, enable flashing +# (everything else disabled) +# Use low fuse 0x75 for 4ms startup delay, +# or 0x79 for 64ms (useful on a twisty light) +avrdude -c usbasp -p t13 -u -Ulfuse:w:0x75:m -Uhfuse:w:0xFF:m + +# http://www.engbedded.com/cgi-bin/fcx.cgi?P_PREV=ATtiny13A&P=ATtiny13A&M_LOW_0x0F=0x05&M_LOW_0x80=0x00&M_HIGH_0x06=0x06&B_SPIEN=P&B_SUT1=P&B_CKSEL1=P&V_LOW=75&V_HIGH=FF&O_HEX=Apply+values diff --git a/bin/flash-tiny13.bat b/bin/flash-tiny13.bat index 5324ab6..db75fd8 100755 --- a/bin/flash-tiny13.bat +++ b/bin/flash-tiny13.bat @@ -1 +1 @@ -avrdude -p t13 -c usbasp -u -Uflash:w:%1.hex:a -Ulfuse:w:0x75:m -Uhfuse:w:0xFF:m +avrdude -p t13 -c usbasp -u -Uflash:w:%1:a diff --git a/bin/flash-tiny13.sh b/bin/flash-tiny13.sh index 9c2ef82..47b2bfe 100755 --- a/bin/flash-tiny13.sh +++ b/bin/flash-tiny13.sh @@ -1,3 +1,3 @@ #/bin/sh FIRMWARE=$1 -avrdude -c usbasp -p t13 -u -Uflash:w:$FIRMWARE -Ulfuse:w:0x75:m -Uhfuse:w:0xFF:m +avrdude -c usbasp -p t13 -u -Uflash:w:$FIRMWARE diff --git a/bin/flash-tiny25-fuses.sh b/bin/flash-tiny25-fuses.sh new file mode 100755 index 0000000..65d5b1d --- /dev/null +++ b/bin/flash-tiny25-fuses.sh @@ -0,0 +1,8 @@ +#/bin/sh +# 8 MHz, 4ms boot delay, enable flashing +# (everything else disabled) +# Use low fuse 0xD2 for 4ms startup delay, +# or 0xE2 for 64ms (useful on a twisty light) +avrdude -c usbasp -p t25 -u -U lfuse:w:0xd2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m + +# http://www.engbedded.com/cgi-bin/fcx.cgi?P_PREV=ATtiny25&P=ATtiny25&M_LOW_0x3F=0x22&M_HIGH_0x07=0x07&M_HIGH_0x20=0x00&B_SPIEN=P&B_SUT0=P&B_CKSEL3=P&B_CKSEL2=P&B_CKSEL0=P&V_LOW=E2&V_HIGH=DF&V_EXTENDED=FF&O_HEX=Apply+values diff --git a/bin/flash-tiny25.sh b/bin/flash-tiny25.sh index 0b24bb2..9975671 100755 --- a/bin/flash-tiny25.sh +++ b/bin/flash-tiny25.sh @@ -1,4 +1,3 @@ #/bin/sh FIRMWARE=$1 -avrdude -c usbasp -p t25 -u -U lfuse:w:0xd2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:$FIRMWARE -# http://www.engbedded.com/cgi-bin/fcx.cgi?P_PREV=ATtiny25&P=ATtiny25&M_LOW_0x3F=0x22&M_HIGH_0x07=0x07&M_HIGH_0x20=0x00&B_SUT1=P&B_SPIEN=P&B_CKSEL3=P&B_CKSEL2=P&B_CKSEL0=P&V_LOW=D2&V_HIGH=DF&V_EXTENDED=FF +avrdude -c usbasp -p t25 -u -Uflash:w:$FIRMWARE diff --git a/bin/flash-tiny85-fuses.sh b/bin/flash-tiny85-fuses.sh new file mode 100755 index 0000000..e517b2d --- /dev/null +++ b/bin/flash-tiny85-fuses.sh @@ -0,0 +1,8 @@ +#/bin/sh +# 8 MHz, 64ms boot delay, enable flashing +# (everything else disabled) +# Use low fuse 0xD2 for 4ms startup delay, +# or 0xE2 for 64ms (useful on a twisty light) +avrdude -c usbasp -p t85 -u -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m + +# http://www.engbedded.com/cgi-bin/fcx.cgi?P_PREV=ATtiny85&P=ATtiny85&M_LOW_0x3F=0x22&M_HIGH_0x07=0x07&M_HIGH_0x20=0x00&B_SPIEN=P&B_SUT0=P&B_CKSEL3=P&B_CKSEL2=P&B_CKSEL0=P&V_LOW=E2&V_HIGH=DF&V_EXTENDED=FF&O_HEX=Apply+values diff --git a/bin/flash-tiny85.sh b/bin/flash-tiny85.sh index 8d1636d..0f5a292 100755 --- a/bin/flash-tiny85.sh +++ b/bin/flash-tiny85.sh @@ -1,4 +1,3 @@ #/bin/sh FIRMWARE=$1 -avrdude -c usbasp -p t85 -u -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:$FIRMWARE -# http://www.engbedded.com/cgi-bin/fcx.cgi?P_PREV=ATtiny85&P=ATtiny85&M_LOW_0x3F=0x22&M_HIGH_0x07=0x06&M_HIGH_0x20=0x00&B_SPIEN=P&B_SUT0=P&B_CKSEL3=P&B_CKSEL2=P&B_CKSEL0=P&B_BODLEVEL0=P&V_LOW=E2&V_HIGH=DE&V_EXTENDED=FF +avrdude -c usbasp -p t85 -u -Uflash:w:$FIRMWARE -- cgit v1.2.3 From a8118a67a1eb5d9a0c400b3055d71be7d9f1ed54 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 3 Nov 2018 16:24:02 -0600 Subject: Reduced duplication across build scripts, replaced per-MCU scripts with a tiny wrapper for the main script. --- bin/build-tiny13.sh | 30 ++---------------------------- bin/build-tiny25.sh | 30 ++---------------------------- bin/build-tiny85.sh | 30 ++---------------------------- bin/build.sh | 30 ++++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 84 deletions(-) create mode 100755 bin/build.sh diff --git a/bin/build-tiny13.sh b/bin/build-tiny13.sh index c1f0446..d4b492f 100755 --- a/bin/build-tiny13.sh +++ b/bin/build-tiny13.sh @@ -1,30 +1,4 @@ #!/bin/bash -# Instead of using a Makefile, since most of the firmwares here build in the -# same exact way, here's a script to do the same thing - -export PROGRAM=$1 ; shift -export ATTINY=13 -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 OFLAGS="-Wall -g -Os -mmcu=$MCU" -export LDFLAGS= -export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' -export OBJS=$PROGRAM.o - -for arg in "$*" ; do - OTHERFLAGS="$OTHERFLAGS $arg" -done - -function run () { - echo $* - $* - if [ x"$?" != x0 ]; then exit 1 ; fi -} - -run $CC $OTHERFLAGS $CFLAGS -o $PROGRAM.o -c $PROGRAM.c -run $CC $OFLAGS $LDFLAGS -o $PROGRAM.elf $PROGRAM.o -run $OBJCOPY $OBJCOPYFLAGS $PROGRAM.elf $PROGRAM.hex -run avr-size -C --mcu=$MCU $PROGRAM.elf | grep Full +BASEDIR=$(dirname "$0") +$BASEDIR/build.sh 13 $* diff --git a/bin/build-tiny25.sh b/bin/build-tiny25.sh index a775a0f..779f1ef 100755 --- a/bin/build-tiny25.sh +++ b/bin/build-tiny25.sh @@ -1,30 +1,4 @@ #!/bin/bash -# Instead of using a Makefile, since most of the firmwares here build in the -# same exact way, here's a script to do the same thing - -export PROGRAM=$1 ; shift -export ATTINY=25 -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 OFLAGS="-Wall -g -Os -mmcu=$MCU" -export LDFLAGS= -export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' -export OBJS=$PROGRAM.o - -for arg in "$*" ; do - OTHERFLAGS="$OTHERFLAGS $arg" -done - -function run () { - echo $* - $* - if [ x"$?" != x0 ]; then exit 1 ; fi -} - -run $CC $OTHERFLAGS $CFLAGS -o $PROGRAM.o -c $PROGRAM.c -run $CC $OFLAGS $LDFLAGS -o $PROGRAM.elf $PROGRAM.o -run $OBJCOPY $OBJCOPYFLAGS $PROGRAM.elf $PROGRAM.hex -run avr-size -C --mcu=$MCU $PROGRAM.elf | grep Full +BASEDIR=$(dirname "$0") +$BASEDIR/build.sh 25 $* diff --git a/bin/build-tiny85.sh b/bin/build-tiny85.sh index f0cf1b9..6ee8397 100755 --- a/bin/build-tiny85.sh +++ b/bin/build-tiny85.sh @@ -1,30 +1,4 @@ #!/bin/bash -# Instead of using a Makefile, since most of the firmwares here build in the -# same exact way, here's a script to do the same thing - -export PROGRAM=$1 ; shift -export ATTINY=85 -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 OFLAGS="-Wall -g -Os -mmcu=$MCU" -export LDFLAGS= -export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' -export OBJS=$PROGRAM.o - -for arg in "$*" ; do - OTHERFLAGS="$OTHERFLAGS $arg" -done - -function run () { - echo $* - $* - if [ x"$?" != x0 ]; then exit 1 ; fi -} - -run $CC $OTHERFLAGS $CFLAGS -o $PROGRAM.o -c $PROGRAM.c -run $CC $OFLAGS $LDFLAGS -o $PROGRAM.elf $PROGRAM.o -run $OBJCOPY $OBJCOPYFLAGS $PROGRAM.elf $PROGRAM.hex -run avr-size -C --mcu=$MCU $PROGRAM.elf | grep Full +BASEDIR=$(dirname "$0") +$BASEDIR/build.sh 85 $* diff --git a/bin/build.sh b/bin/build.sh new file mode 100755 index 0000000..6920a3f --- /dev/null +++ b/bin/build.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Instead of using a Makefile, since most of the firmwares here build in the +# same exact way, here's a script to do the same thing + +export ATTINY=$1 ; shift +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 OFLAGS="-Wall -g -Os -mmcu=$MCU" +export LDFLAGS= +export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' +export OBJS=$PROGRAM.o + +for arg in "$*" ; do + OTHERFLAGS="$OTHERFLAGS $arg" +done + +function run () { + echo $* + $* + if [ x"$?" != x0 ]; then exit 1 ; fi +} + +run $CC $OTHERFLAGS $CFLAGS -o $PROGRAM.o -c $PROGRAM.c +run $CC $OFLAGS $LDFLAGS -o $PROGRAM.elf $PROGRAM.o +run $OBJCOPY $OBJCOPYFLAGS $PROGRAM.elf $PROGRAM.hex +run avr-size -C --mcu=$MCU $PROGRAM.elf | grep Full -- cgit v1.2.3 From 1756b0beae04f04b6072fcfd2bbe10fb2b4dd116 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 3 Nov 2018 16:41:45 -0600 Subject: added a wrapper to flash fuses and firmware at the same time, like the old scripts did --- bin/flash.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 bin/flash.sh diff --git a/bin/flash.sh b/bin/flash.sh new file mode 100755 index 0000000..019631a --- /dev/null +++ b/bin/flash.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Flashes both fuses and firmware. + +set -e + +BASEDIR=$(dirname "$0") +export ATTINY=$1 ; shift +export PROGRAM=$1 ; shift +if [ ! -f "$PROGRAM" ]; then PROGRAM="$PROGRAM".hex ; fi +$BASEDIR/flash-tiny"$ATTINY"-fuses.sh +$BASEDIR/flash-tiny"$ATTINY".sh "$PROGRAM" -- cgit v1.2.3 From 79155e4f242c10b7ffdf3fb31033576ee8626372 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 3 Nov 2018 16:42:26 -0600 Subject: Applied recent updates to FSM build scripts, and added some really simple Makefiles. --- spaghetti-monster/anduril/Makefile | 7 +++++++ spaghetti-monster/anduril/build-all.sh | 2 +- spaghetti-monster/rampingios/Makefile | 7 +++++++ spaghetti-monster/rampingios/build-all.sh | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 spaghetti-monster/anduril/Makefile create mode 100644 spaghetti-monster/rampingios/Makefile diff --git a/spaghetti-monster/anduril/Makefile b/spaghetti-monster/anduril/Makefile new file mode 100644 index 0000000..25c56fa --- /dev/null +++ b/spaghetti-monster/anduril/Makefile @@ -0,0 +1,7 @@ +all: + ./build-all.sh + +clean: + rm -f *.hex *~ *.elf *.o + +.phony: clean diff --git a/spaghetti-monster/anduril/build-all.sh b/spaghetti-monster/anduril/build-all.sh index 9e2a83c..68d32fb 100755 --- a/spaghetti-monster/anduril/build-all.sh +++ b/spaghetti-monster/anduril/build-all.sh @@ -18,6 +18,6 @@ for TARGET in \ FW3A \ ; do echo "===== $TARGET =====" - ../../../bin/build-85.sh "$UI" "-DFSM_${TARGET}_DRIVER" + ../../../bin/build.sh 85 "$UI" "-DFSM_${TARGET}_DRIVER" mv -f "$UI".hex "$UI".$TARGET.hex done diff --git a/spaghetti-monster/rampingios/Makefile b/spaghetti-monster/rampingios/Makefile new file mode 100644 index 0000000..8db198e --- /dev/null +++ b/spaghetti-monster/rampingios/Makefile @@ -0,0 +1,7 @@ +all: + ./build-all.sh + +clean: + rm -f *.hex cfg-*.h *~ *.elf *.o + +.phony: clean diff --git a/spaghetti-monster/rampingios/build-all.sh b/spaghetti-monster/rampingios/build-all.sh index 22597b7..5b75fe4 100755 --- a/spaghetti-monster/rampingios/build-all.sh +++ b/spaghetti-monster/rampingios/build-all.sh @@ -13,6 +13,6 @@ for TARGET in \ EMISAR_D4S_219C \ ; do echo "===== $TARGET =====" - ../../../bin/build-85.sh "$UI" "-DFSM_${TARGET}_DRIVER" + ../../../bin/build.sh 85 "$UI" "-DFSM_${TARGET}_DRIVER" mv -f "$UI".hex "$UI".$TARGET.hex done -- cgit v1.2.3 From f58d398e0d8889dac90f533b8099a328e7792802 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 3 Nov 2018 16:47:44 -0600 Subject: Added a help message to build.sh and flash.sh --- bin/build.sh | 6 ++++++ bin/flash.sh | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/bin/build.sh b/bin/build.sh index 6920a3f..ddd2a72 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -3,6 +3,12 @@ # Instead of using a Makefile, since most of the firmwares here build in the # same exact way, here's a script to do the same thing +if [ -z "$1" ]; then + echo "Usage: build.sh MCU myprogram" + echo "MCU is a number, like '13' for attiny13 or '841' for attiny841" + exit +fi + export ATTINY=$1 ; shift export PROGRAM=$1 ; shift export MCU=attiny$ATTINY diff --git a/bin/flash.sh b/bin/flash.sh index 019631a..0423c90 100755 --- a/bin/flash.sh +++ b/bin/flash.sh @@ -2,6 +2,13 @@ # Flashes both fuses and firmware. +if [ -z "$1" ]; then + echo "Usage: flash.sh MCU myprogram[.hex]" + echo "MCU is a number, like '13' for attiny13 or '841' for attiny841" + echo "The .hex suffix is optional." + exit +fi + set -e BASEDIR=$(dirname "$0") -- cgit v1.2.3 From 9e3e7a8e6a7c0ed3abe21b9ae24c07d8c13e3e93 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 3 Nov 2018 17:22:58 -0600 Subject: added missing ifdef which broke per-hardware ramp lengths --- spaghetti-monster/anduril/anduril.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index fd3c534..df478ee 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -140,7 +140,9 @@ /********* Configure SpaghettiMonster *********/ #define USE_DELAY_ZERO #define USE_RAMPING +#ifndef RAMP_LENGTH #define RAMP_LENGTH 150 // default, if not overridden in a driver cfg file +#endif #define MAX_BIKING_LEVEL 120 // should be 127 or less #define USE_BATTCHECK -- cgit v1.2.3 From 5699260c774749d9a6b1b5ad855a816806ed1be7 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 3 Nov 2018 18:46:57 -0600 Subject: forgot to add the Sofirn SP36 config file earlier, oops --- spaghetti-monster/anduril/cfg-sofirn-sp36.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 spaghetti-monster/anduril/cfg-sofirn-sp36.h diff --git a/spaghetti-monster/anduril/cfg-sofirn-sp36.h b/spaghetti-monster/anduril/cfg-sofirn-sp36.h new file mode 100644 index 0000000..11e3735 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-sofirn-sp36.h @@ -0,0 +1,16 @@ +// Sofirn SP36 (small Q8) config options for Anduril + +#define FSM_BLF_Q8_DRIVER +#include "cfg-blf-q8.h" + +// stop panicking at ~50% power or ~2000 lm +#ifdef THERM_FASTER_LEVEL +#undef THERM_FASTER_LEVEL +#endif +#define THERM_FASTER_LEVEL 125 + +// be extra-careful at high levels +#ifndef THERM_HARD_TURBO_DROP +#define THERM_HARD_TURBO_DROP +#endif + -- cgit v1.2.3 From 94ba77de5c2c4bf8df3f23ac9ab397a360a75e69 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 3 Nov 2018 18:55:31 -0600 Subject: Made it easier to override hwdef-*.h values in cfg-*.h files. --- hwdef-BLF_GT.h | 16 +++++++++++++++- hwdef-BLF_GT_Mini.h | 6 ++++++ hwdef-BLF_Q8.h | 13 +++++++------ hwdef-Emisar_D4.h | 16 ++++++++++++---- hwdef-FF_PL47.h | 29 ++++++++++++++--------------- hwdef-FF_ROT66.h | 15 ++++++++------- hwdef-FW3A.h | 22 +++++++++++++++++----- spaghetti-monster/anduril/cfg-blf-gt.h | 4 ---- spaghetti-monster/anduril/cfg-blf-q8.h | 4 ---- spaghetti-monster/anduril/cfg-emisar-d4.h | 3 --- spaghetti-monster/anduril/cfg-ff-pl47.h | 3 --- spaghetti-monster/anduril/cfg-ff-rot66.h | 4 ---- spaghetti-monster/anduril/cfg-fw3a.h | 4 ---- 13 files changed, 79 insertions(+), 60 deletions(-) diff --git a/hwdef-BLF_GT.h b/hwdef-BLF_GT.h index 1a05741..7dcc8a0 100644 --- a/hwdef-BLF_GT.h +++ b/hwdef-BLF_GT.h @@ -9,29 +9,43 @@ #define PWM_CHANNELS 2 +#ifndef AUXLED_PIN #define AUXLED_PIN PB4 // pin 3 +#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 #define USE_VOLTAGE_DIVIDER // use a voltage divider on pin 7, not VCC +#ifndef VOLTAGE_PIN #define VOLTAGE_PIN PB2 // pin 7, voltage ADC #define VOLTAGE_CHANNEL 0x01 // MUX 01 corresponds with PB2 +#define VOLTAGE_ADC_DIDR ADC1D // Digital input disable bit corresponding with PB2 // 1.1V reference, left-adjust, ADC1/PB2 //#define ADMUX_VOLTAGE_DIVIDER ((1 << V_REF) | (1 << ADLAR) | VOLTAGE_CHANNEL) // 1.1V reference, no left-adjust, ADC1/PB2 #define ADMUX_VOLTAGE_DIVIDER ((1 << V_REF) | VOLTAGE_CHANNEL) -#define VOLTAGE_ADC_DIDR ADC1D // Digital input disable bit corresponding with PB2 +#endif #define ADC_PRSCL 0x06 // clk/64 // Raw ADC readings at 4.4V and 2.2V (in-between, we assume values form a straight line) +#ifndef ADC_44 #define ADC_44 184 +#endif +#ifndef ADC_22 #define ADC_22 92 +#endif #define TEMP_CHANNEL 0b00001111 diff --git a/hwdef-BLF_GT_Mini.h b/hwdef-BLF_GT_Mini.h index 504c561..aacbca4 100644 --- a/hwdef-BLF_GT_Mini.h +++ b/hwdef-BLF_GT_Mini.h @@ -2,3 +2,9 @@ */ // exactly the same as a D1S, but with a lighted button #include "hwdef-Emisar_D1S.h" + +// lighted button +#ifndef AUXLED_PIN +#define AUXLED_PIN PB4 // pin 3 +#endif + diff --git a/hwdef-BLF_Q8.h b/hwdef-BLF_Q8.h index f00c392..6e13faf 100644 --- a/hwdef-BLF_Q8.h +++ b/hwdef-BLF_Q8.h @@ -1,16 +1,17 @@ /* BLF Q8 driver layout + * Q8 driver is the same as a D4, basically */ -// Q8 driver is the same as a D4, basically -#include "hwdef-Emisar_D4.h" // ... except the Q8 has a lighted button #ifndef AUXLED_PIN #define AUXLED_PIN PB4 // pin 3 #endif -// average drop across diode on this hardware -#ifdef VOLTAGE_FUDGE_FACTOR -#undef VOLTAGE_FUDGE_FACTOR -#endif +// ... and slightly different calibration +#ifndef VOLTAGE_FUDGE_FACTOR #define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V +#endif + +// Q8 driver is the same as a D4, basically +#include "hwdef-Emisar_D4.h" diff --git a/hwdef-Emisar_D4.h b/hwdef-Emisar_D4.h index 105d3b9..0dfcab9 100644 --- a/hwdef-Emisar_D4.h +++ b/hwdef-Emisar_D4.h @@ -9,24 +9,32 @@ #define PWM_CHANNELS 2 -#define AUXLED_PIN PB4 // pin 3 +//#define AUXLED_PIN PB4 // pin 3 +#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 // (FIXME: remove? not used?) -#define VOLTAGE_PIN PB2 // pin 7, voltage ADC -#define ADC_CHANNEL 0x01 // MUX 01 corresponds with PB2 -#define ADC_DIDR ADC1D // Digital input disable bit corresponding with PB2 +//#define VOLTAGE_PIN PB2 // pin 7, voltage ADC +//#define ADC_CHANNEL 0x01 // MUX 01 corresponds with PB2 +//#define ADC_DIDR ADC1D // Digital input disable bit corresponding with PB2 #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_DIDR ADC4D #define TEMP_CHANNEL 0b00001111 diff --git a/hwdef-FF_PL47.h b/hwdef-FF_PL47.h index 4189220..217ce45 100644 --- a/hwdef-FF_PL47.h +++ b/hwdef-FF_PL47.h @@ -1,24 +1,23 @@ /* Fireflies PL47 driver layout + * same as a D4S, basically, except ... */ -// same as a D4S, basically -#include "hwdef-Emisar_D4S.h" -#undef FSM_EMISAR_D4S_DRIVER -#undef FSM_EMISAR_D4_DRIVER -// ... except the PL47 has aux LEDs on pin 7 -#ifdef AUXLED_PIN -#undef AUXLED_PIN -#endif +// ... the PL47 has aux LEDs on pin 7 +#ifndef AUXLED_PIN #define AUXLED_PIN PB2 // pin 7 +#endif // ... and switch LEDs on pin 3 -#ifdef AUXLED2_PIN -#undef AUXLED2_PIN -#endif +#ifndef AUXLED2_PIN #define AUXLED2_PIN PB4 // pin 3 - -// average drop across diode on this hardware -#ifdef VOLTAGE_FUDGE_FACTOR -#undef VOLTAGE_FUDGE_FACTOR #endif + +// ... and slightly different calibration +#ifndef VOLTAGE_FUDGE_FACTOR #define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V +#endif + +#include "hwdef-Emisar_D4S.h" +#undef FSM_EMISAR_D4S_DRIVER +#undef FSM_EMISAR_D4_DRIVER + diff --git a/hwdef-FF_ROT66.h b/hwdef-FF_ROT66.h index 49947ab..0913a76 100644 --- a/hwdef-FF_ROT66.h +++ b/hwdef-FF_ROT66.h @@ -1,20 +1,21 @@ /* Fireflies ROT66 driver layout + * same as a FW3A, basically, except ... */ -// same as a FW3A, basically -#include "hwdef-FW3A.h" // ... except the ROT66 has a lighted button #ifndef AUXLED_PIN #define AUXLED_PIN PB2 // pin 7 #endif +// ... and slightly different calibration +#ifndef VOLTAGE_FUDGE_FACTOR +#define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V +#endif + +#include "hwdef-FW3A.h" + // ... and no optic nerve #ifdef VISION_PIN #undef VISION_PIN #endif -// average drop across diode on this hardware -#ifdef VOLTAGE_FUDGE_FACTOR -#undef VOLTAGE_FUDGE_FACTOR -#endif -#define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V diff --git a/hwdef-FW3A.h b/hwdef-FW3A.h index 5e253c7..8abab9a 100644 --- a/hwdef-FW3A.h +++ b/hwdef-FW3A.h @@ -9,23 +9,35 @@ #define PWM_CHANNELS 3 +#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 -#define PWM2_PIN PB1 // pin 6, FET PWM +#endif +#ifndef PWM2_PIN +#define PWM2_PIN PB1 // pin 6, 7x7135 PWM #define PWM2_LVL OCR0B // OCR0B is the output compare register for PB1 -#define PWM3_PIN PB4 // pin 3 -#define PWM3_LVL OCR1B +#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 +#ifndef VISION_PIN #define VISION_PIN PB2 // pin 7, optic nerve -#define ADC_CHANNEL 0x01 // MUX 01 corresponds with PB2 -#define ADC_DIDR ADC1D // Digital input disable bit corresponding with PB2 +//#define ADC_CHANNEL 0x01 // MUX 01 corresponds with PB2 +//#define ADC_DIDR ADC1D // Digital input disable bit corresponding with PB2 +#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_DIDR ADC4D #define TEMP_CHANNEL 0b00001111 diff --git a/spaghetti-monster/anduril/cfg-blf-gt.h b/spaghetti-monster/anduril/cfg-blf-gt.h index 369d028..a29d7e7 100644 --- a/spaghetti-monster/anduril/cfg-blf-gt.h +++ b/spaghetti-monster/anduril/cfg-blf-gt.h @@ -14,10 +14,6 @@ //#undef USE_SET_LEVEL_GRADUALLY -#ifdef RAMP_LENGTH -#undef RAMP_LENGTH -#endif - #define RAMP_LENGTH 150 // First 60 values: level_calc.py 1 60 7135 4 5.0 255 // Remainder: all 255 (buck driver at 100% duty cycle) diff --git a/spaghetti-monster/anduril/cfg-blf-q8.h b/spaghetti-monster/anduril/cfg-blf-q8.h index 269aae9..1b9b971 100644 --- a/spaghetti-monster/anduril/cfg-blf-q8.h +++ b/spaghetti-monster/anduril/cfg-blf-q8.h @@ -7,10 +7,6 @@ // enable blinking indicator LED while off #define TICK_DURING_STANDBY -#ifdef RAMP_LENGTH -#undef RAMP_LENGTH -#endif - // copied from Emisar D4 ramp // ../../bin/level_calc.py 1 65 7135 1 0.8 150 // ... mixed with this: diff --git a/spaghetti-monster/anduril/cfg-emisar-d4.h b/spaghetti-monster/anduril/cfg-emisar-d4.h index 251f81d..e83c62d 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d4.h +++ b/spaghetti-monster/anduril/cfg-emisar-d4.h @@ -1,8 +1,5 @@ // Emisar D4 config options for Anduril -#ifdef RAMP_LENGTH -#undef RAMP_LENGTH -#endif // ../../bin/level_calc.py 1 65 7135 1 0.8 150 // ... mixed with this: // ../../bin/level_calc.py 2 150 7135 4 0.33 150 FET 1 10 1500 diff --git a/spaghetti-monster/anduril/cfg-ff-pl47.h b/spaghetti-monster/anduril/cfg-ff-pl47.h index d9431a1..2e5647d 100644 --- a/spaghetti-monster/anduril/cfg-ff-pl47.h +++ b/spaghetti-monster/anduril/cfg-ff-pl47.h @@ -26,9 +26,6 @@ //#define INDICATOR_LED_DEFAULT_MODE ((0<<2) + 2) -#ifdef RAMP_LENGTH -#undef RAMP_LENGTH -#endif #define RAMP_LENGTH 150 // driver is a FET + 3x7135, ~400 lm at highest regulated level diff --git a/spaghetti-monster/anduril/cfg-ff-rot66.h b/spaghetti-monster/anduril/cfg-ff-rot66.h index c8e0d52..165b2ba 100644 --- a/spaghetti-monster/anduril/cfg-ff-rot66.h +++ b/spaghetti-monster/anduril/cfg-ff-rot66.h @@ -18,10 +18,6 @@ #define INDICATOR_LED_DEFAULT_MODE ((0<<2) + 2) -#ifdef RAMP_LENGTH -#undef RAMP_LENGTH -#endif - // driver is a FET+N+1, // where N=6 for the 219b version, // or N=13 for the XP-L HI version (this version) diff --git a/spaghetti-monster/anduril/cfg-fw3a.h b/spaghetti-monster/anduril/cfg-fw3a.h index 65f1e48..efa70ae 100644 --- a/spaghetti-monster/anduril/cfg-fw3a.h +++ b/spaghetti-monster/anduril/cfg-fw3a.h @@ -1,9 +1,5 @@ // FW3A config options for Anduril -#ifdef RAMP_LENGTH -#undef RAMP_LENGTH -#endif - // ../../bin/level_calc.py 1 65 7135 1 0.8 150 // ... mixed with this: // ../../../bin/level_calc.py 3 150 7135 1 0.33 150 7135 1 1 850 FET 1 10 1500 -- cgit v1.2.3