diff options
| author | Selene ToyKeeper | 2018-06-24 18:55:19 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2018-06-24 18:55:19 -0600 |
| commit | 809a397855a2a5ff9fdb327a7a30aa639f829b51 (patch) | |
| tree | 5b6e6aa62d47afb2be7503731bc429dec9388b12 /spaghetti-monster | |
| parent | Added script to build all supported Anduril targets. (diff) | |
| download | anduril-809a397855a2a5ff9fdb327a7a30aa639f829b51.tar.gz anduril-809a397855a2a5ff9fdb327a7a30aa639f829b51.tar.bz2 anduril-809a397855a2a5ff9fdb327a7a30aa639f829b51.zip | |
Moved driver-specific details to separate header files.
General code cleanup and notes.
Fixed build when thermal regulation is turned off.
May have fixed (or at least improved) issue with main LED interfering with aux LEDs during aux LED config.
Diffstat (limited to 'spaghetti-monster')
| -rw-r--r-- | spaghetti-monster/anduril/anduril.c | 87 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-blf-gt.h | 25 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-blf-q8.h | 9 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-d4.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-fw3a.h | 2 |
5 files changed, 88 insertions, 37 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index 3d25c8c..abd3ed8 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -25,7 +25,8 @@ //#define FSM_FW3A_DRIVER //#define FSM_BLF_GT_DRIVER -#define USE_LVP +#define USE_LVP // FIXME: won't build when this option is turned off + #define USE_THERMAL_REGULATION #define DEFAULT_THERM_CEIL 50 #define MIN_THERM_STEPDOWN MAX_1x7135 // lowest value it'll step down to @@ -34,19 +35,35 @@ #else #define THERM_DOUBLE_SPEED_LEVEL (RAMP_LENGTH*4/5) // throttle back faster when high #endif -#define USE_SET_LEVEL_GRADUALLY +#ifdef USE_THERMAL_REGULATION +#define USE_SET_LEVEL_GRADUALLY // isn't used except for thermal adjustments +#endif + +// short blips while ramping #define BLINK_AT_CHANNEL_BOUNDARIES //#define BLINK_AT_RAMP_FLOOR #define BLINK_AT_RAMP_CEILING -//#define BLINK_AT_STEPS +//#define BLINK_AT_STEPS // whenever a discrete ramp mode is passed in smooth mode + +// ramp down via regular button hold if a ramp-up ended <1s ago +// ("hold, release, hold" ramps down instead of up) +#define USE_REVERSING + +// battery readout style (pick one) #define BATTCHECK_VpT +//#define BATTCHECK_8bars // FIXME: breaks build +//#define BATTCHECK_4bars // FIXME: breaks build + +// enable/disable various modes #define USE_LIGHTNING_MODE #define USE_CANDLE_MODE +#define USE_MUGGLE_MODE + #define GOODNIGHT_TIME 60 // minutes (approximately) #define GOODNIGHT_LEVEL 24 // ~11 lm -#define USE_REVERSING + +// dual-switch support (second switch is a tail clicky) //#define START_AT_MEMORIZED_LEVEL -#define USE_MUGGLE_MODE /********* Configure SpaghettiMonster *********/ #define USE_DELAY_ZERO @@ -61,35 +78,29 @@ #else #define MAX_CLICKS 5 #endif -#define USE_IDLE_MODE +#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 +// full FET strobe can be a bit much... use max regulated level instead, +// if there's a bright enough regulated level +#ifdef MAX_Nx7135 +#define STROBE_BRIGHTNESS MAX_Nx7135 +#else +#define STROBE_BRIGHTNESS MAX_LEVEL +#endif + // specific settings for known driver types -#ifdef FSM_BLF_Q8_DRIVER -#define USE_INDICATOR_LED -#define USE_INDICATOR_LED_WHILE_RAMPING -#define TICK_DURING_STANDBY -#define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V +#if defined(FSM_BLF_GT_DRIVER) +#include "cfg-blf-gt.h" + +#elif FSM_BLF_Q8_DRIVER +#include "cfg-blf-q8.h" #elif defined(FSM_EMISAR_D4_DRIVER) -#define VOLTAGE_FUDGE_FACTOR 5 // add 0.25V +#include "cfg-emisar-d4.h" #elif defined(FSM_FW3A_DRIVER) -#define VOLTAGE_FUDGE_FACTOR 5 // add 0.25V - -#elif defined(FSM_BLF_GT_DRIVER) -#define USE_INDICATOR_LED -#define USE_INDICATOR_LED_WHILE_RAMPING -#define TICK_DURING_STANDBY -#undef BLINK_AT_CHANNEL_BOUNDARIES -#undef BLINK_AT_RAMP_CEILING -#undef BLINK_AT_RAMP_FLOOR -//#undef USE_SET_LEVEL_GRADUALLY -#define RAMP_SMOOTH_FLOOR 1 -#define RAMP_SMOOTH_CEIL POWER_80PX -#define RAMP_DISCRETE_FLOOR 1 -#define RAMP_DISCRETE_CEIL POWER_80PX -#define RAMP_DISCRETE_STEPS 7 +#include "cfg-fw3a.h" #endif @@ -126,14 +137,6 @@ #endif #define NUM_STROBES (NUM_STROBES_BASE+ADD_LIGHTNING_STROBE+ADD_CANDLE_MODE) -// full FET strobe can be a bit much... use max regulated level instead, -// if there's a bright enough regulated level -#ifdef MAX_Nx7135 -#define STROBE_BRIGHTNESS MAX_Nx7135 -#else -#define STROBE_BRIGHTNESS MAX_LEVEL -#endif - #include "spaghetti-monster.h" @@ -225,8 +228,7 @@ uint8_t ramp_discrete_step_size; // don't set this #ifdef USE_INDICATOR_LED // bits 2-3 control lockout mode // bits 0-1 control "off" mode -// modes are: 0=off, 1=low, 2=high -// (TODO: 3=blinking) +// modes are: 0=off, 1=low, 2=high, 3=blinking (if TICK_DURING_STANDBY enabled) //uint8_t indicator_led_mode = (1<<2) + 2; uint8_t indicator_led_mode = (2<<2) + 1; #endif @@ -671,6 +673,9 @@ uint8_t strobe_state(EventPtr event, uint16_t arg) { // (maybe I should just make it nonvolatile?) uint8_t st = strobe_type; #ifdef USE_CANDLE_MODE + // FIXME: make candle variance magnitude a compile-time option, + // since 20 is sometimes too much or too little, + // depending on the driver type and ramp shape //#define MAX_CANDLE_LEVEL (RAMP_SIZE-8-6-4) #define MAX_CANDLE_LEVEL (RAMP_SIZE/2) static uint8_t candle_wave1 = 0; @@ -954,6 +959,8 @@ uint8_t lockout_state(EventPtr event, uint16_t arg) { // momentary(ish) moon mode during lockout // not all presses will be counted; // it depends on what is in the master event_sequences table + // FIXME: maybe do this only if arg == 0? + // (so it'll only get turned on once, instead of every frame) uint8_t last = 0; for(uint8_t i=0; pgm_read_byte(event + i) && (i<EV_MAX_LEN); i++) last = pgm_read_byte(event + i); @@ -1017,6 +1024,12 @@ uint8_t lockout_state(EventPtr event, uint16_t arg) { } // click, click, hold: rotate through indicator LED modes (off mode) else if (event == EV_click3_hold) { + #ifndef USE_INDICATOR_LED_WHILE_RAMPING + // if main LED obscures aux LEDs, turn it off + // FIXME: might not work, since it was turned on just a few clock + // cycles ago at beginning of this function + set_level(0); + #endif #ifdef TICK_DURING_STANDBY uint8_t mode = (arg >> 5) & 3; #else diff --git a/spaghetti-monster/anduril/cfg-blf-gt.h b/spaghetti-monster/anduril/cfg-blf-gt.h new file mode 100644 index 0000000..e5ce2a1 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-blf-gt.h @@ -0,0 +1,25 @@ +// the button lights up +#define USE_INDICATOR_LED +// 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 + +// not relevant for this driver type +//#define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V + +// don't blink during ramp, it's irrelevant and annoying on this light +#undef BLINK_AT_CHANNEL_BOUNDARIES +#undef BLINK_AT_RAMP_CEILING +#undef BLINK_AT_RAMP_FLOOR + +//#undef USE_SET_LEVEL_GRADUALLY + +// use 2.0 A as the ceiling, 2.5 A only for turbo +// start both ramps at the bottom; even moon throws a long way on the GT +#define RAMP_SMOOTH_FLOOR 1 +#define RAMP_SMOOTH_CEIL POWER_80PX +#define RAMP_DISCRETE_FLOOR 1 +#define RAMP_DISCRETE_CEIL POWER_80PX +#define RAMP_DISCRETE_STEPS 7 + diff --git a/spaghetti-monster/anduril/cfg-blf-q8.h b/spaghetti-monster/anduril/cfg-blf-q8.h new file mode 100644 index 0000000..379fca2 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-blf-q8.h @@ -0,0 +1,9 @@ +// the button lights up +#define USE_INDICATOR_LED +// 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 + +// average drop across diode on this hardware +#define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V diff --git a/spaghetti-monster/anduril/cfg-emisar-d4.h b/spaghetti-monster/anduril/cfg-emisar-d4.h new file mode 100644 index 0000000..4074f01 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-emisar-d4.h @@ -0,0 +1,2 @@ +// average drop across diode on this hardware +#define VOLTAGE_FUDGE_FACTOR 5 // add 0.25V diff --git a/spaghetti-monster/anduril/cfg-fw3a.h b/spaghetti-monster/anduril/cfg-fw3a.h new file mode 100644 index 0000000..4074f01 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-fw3a.h @@ -0,0 +1,2 @@ +// average drop across diode on this hardware +#define VOLTAGE_FUDGE_FACTOR 5 // add 0.25V |
