diff options
Diffstat (limited to '')
| -rw-r--r-- | spaghetti-monster/anduril/cfg-emisar-2ch.h | 1 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/channel-modes.c | 8 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/config-mode.c | 26 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/config-mode.h | 5 |
4 files changed, 34 insertions, 6 deletions
diff --git a/spaghetti-monster/anduril/cfg-emisar-2ch.h b/spaghetti-monster/anduril/cfg-emisar-2ch.h index 69e1524..4704072 100644 --- a/spaghetti-monster/anduril/cfg-emisar-2ch.h +++ b/spaghetti-monster/anduril/cfg-emisar-2ch.h @@ -27,6 +27,7 @@ //#define FACTORY_RESET_WARN_CHANNEL CM_CH2 //#define FACTORY_RESET_SUCCESS_CHANNEL CM_BOTH +#define USE_CONFIG_COLORS //#define CONFIG_WAITING_CHANNEL CM_CH2 //#define CONFIG_BLINK_CHANNEL CM_BOTH diff --git a/spaghetti-monster/anduril/channel-modes.c b/spaghetti-monster/anduril/channel-modes.c index b2985a1..76cbf7e 100644 --- a/spaghetti-monster/anduril/channel-modes.c +++ b/spaghetti-monster/anduril/channel-modes.c @@ -146,12 +146,18 @@ void channel_mode_config_save(uint8_t step, uint8_t value) { } uint8_t channel_mode_config_state(Event event, uint16_t arg) { + uint8_t ret; + // make config steps match channel modes + config_color_per_step = true; // 1 menu item per channel mode, to enable or disable that mode - return config_state_base( + ret = config_state_base( event, arg, NUM_CHANNEL_MODES, channel_mode_config_save ); + // no other menu needs this + config_color_per_step = false; + return ret; } #endif diff --git a/spaghetti-monster/anduril/config-mode.c b/spaghetti-monster/anduril/config-mode.c index 394998a..b8b3398 100644 --- a/spaghetti-monster/anduril/config-mode.c +++ b/spaghetti-monster/anduril/config-mode.c @@ -12,6 +12,13 @@ uint8_t number_entry_state(Event event, uint16_t arg); volatile uint8_t number_entry_value; +#if defined(USE_CONFIG_COLORS) && (NUM_CHANNEL_MODES > 1) +void set_chan_if(bool cond, uint8_t chan) { + if ((cond) && (chan != cfg.channel_mode)) + set_channel_mode(chan); +} +#endif + // allow the user to set a new value for a config option // can be called two ways: // - with a "click" action: Configures first menu item only. @@ -33,7 +40,7 @@ uint8_t config_state_base( static uint8_t orig_channel; #endif if (event == EV_enter_state) { - #ifdef USE_CONFIG_COLORS + #if defined(USE_CONFIG_COLORS) && (NUM_CHANNEL_MODES > 1) orig_channel = cfg.channel_mode; #endif config_step = 0; @@ -52,12 +59,17 @@ uint8_t config_state_base( #define B_ANY_HOLD_RELEASE (B_CLICK|B_HOLD|B_RELEASE|B_TIMEOUT) else if ((event & B_CLICK_FLAGS) == B_ANY_HOLD) { if (config_step <= num_config_steps) { + #if defined(USE_CONFIG_COLORS) && (NUM_CHANNEL_MODES > 1) + uint8_t chan = config_step - 1; + if (chan < NUM_CHANNEL_MODES) + set_chan_if(config_color_per_step, chan); + #endif if ((TICKS_PER_SECOND/10) == (arg % (TICKS_PER_SECOND*3/2))) { config_step ++; // blink when config step advances if (config_step <= num_config_steps) { #ifdef CONFIG_BLINK_CHANNEL - set_channel_mode(CONFIG_BLINK_CHANNEL); + set_chan_if(!config_color_per_step, CONFIG_BLINK_CHANNEL); #endif set_level(RAMP_SIZE * 3 / 8); } @@ -65,7 +77,7 @@ uint8_t config_state_base( else { // stay on at a low level to indicate menu is active #ifdef CONFIG_WAITING_CHANNEL - set_channel_mode(CONFIG_WAITING_CHANNEL); + set_chan_if(!config_color_per_step, CONFIG_WAITING_CHANNEL); #endif set_level(RAMP_SIZE * 1 / 8); } @@ -79,6 +91,10 @@ uint8_t config_state_base( else if ((event & B_CLICK_FLAGS) == B_ANY_HOLD_RELEASE) { // ask the user for a number, if they selected a menu item if (config_step && config_step <= num_config_steps) { + #if defined(USE_CONFIG_COLORS) && (NUM_CHANNEL_MODES > 1) + // put the colors back how they were + set_channel_mode(orig_channel); + #endif push_state(number_entry_state, 0); } // exit after falling out of end of menu @@ -96,7 +112,7 @@ uint8_t config_state_base( pop_state(); } - #ifdef USE_CONFIG_COLORS + #if defined(USE_CONFIG_COLORS) && (NUM_CHANNEL_MODES > 1) else if (event == EV_leave_state) { // put the colors back how they were set_channel_mode(orig_channel); @@ -140,7 +156,7 @@ uint8_t number_entry_state(Event event, uint16_t arg) { // except first frame (so we can see flashes after each click)) else if (arg) { #ifdef CONFIG_WAITING_CHANNEL - set_channel_mode(CONFIG_WAITING_CHANNEL); + set_chan_if(1, CONFIG_WAITING_CHANNEL); #endif set_level( (RAMP_SIZE/8) + ((arg&2)<<2) ); diff --git a/spaghetti-monster/anduril/config-mode.h b/spaghetti-monster/anduril/config-mode.h index 388c0a2..d4a7652 100644 --- a/spaghetti-monster/anduril/config-mode.h +++ b/spaghetti-monster/anduril/config-mode.h @@ -9,6 +9,11 @@ #define USE_CONFIG_COLORS #endif +#if NUM_CHANNEL_MODES > 1 +// when true, changes the channel mode for each config step +bool config_color_per_step = false; +#endif + // config menu uint8_t config_state_base( Event event, |
