Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: Select previous channel mode with 4C, optionally instead of 4C ramp -> lock #50

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/anduril-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ While the light is on, a few actions are available:
- `3H`: Tint ramping (only when current channel has adjustable tint).
- `4H`: Momentary turbo, when `3H` is mapped to tint.

- `4C`: Go to lockout mode.
- `4C`: Go to lockout mode. On some lights with multiple channel modes, this
can instead be configured to select the previous channel. See 10H for
details.

- `5C`: Go to momentary mode.
- `5H`: Start a sunset timer. Details are below in the Sunset Timer section.
Expand Down Expand Up @@ -274,6 +276,10 @@ While the light is on, a few actions are available:
- Item 5: Configure "smooth steps".
0: Disable smooth steps.
1: Enable smooth steps.
- Item 6: Configure the function of 4C when in ramp mode (only on lights
with more than one defined channel mode)
0: 4C switches off the light and enters lockout mode.
1: 4C selects the previous channel mode.

Memory determines which brightness level the light goes to with 1 click
from off. There are three types of brightness memory to choose from:
Expand Down
1 change: 1 addition & 0 deletions hw/hank/emisar-2ch/anduril.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@
#undef BLINK_AT_RAMP_MIDDLE
#endif

#define USE_PREVIOUS_CHANNEL
1 change: 1 addition & 0 deletions hw/hank/noctigon-k9.3/anduril.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@
#undef BLINK_AT_RAMP_MIDDLE
#endif

#define USE_PREVIOUS_CHANNEL
1 change: 1 addition & 0 deletions hw/hank/noctigon-m44/anduril.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,4 @@
// for consistency with KR4 (not otherwise necessary though)
#define USE_SOFT_FACTORY_RESET

#define USE_PREVIOUS_CHANNEL
26 changes: 26 additions & 0 deletions ui/anduril/channel-modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,32 @@ uint8_t channel_mode_state(Event event, uint16_t arg) {
}
#endif // if NUM_CHANNEL_MODES > 1

#ifdef USE_PREVIOUS_CHANNEL
if (
(event == EV_4clicks)
#ifndef PREVIOUS_CHANNEL_REPLACES_LOCKOUT
&& (cfg.previous_channel_enabled)
#endif
){
uint8_t next = cfg.channel_mode;
uint8_t count = 0;
do {
count ++;
if (next > 0){ next--; }
else if (next == 0) { next = (NUM_CHANNEL_MODES - 1); }
} while ((! channel_mode_enabled(next)) && count < NUM_CHANNEL_MODES);
// if mode hasn't changed, abort
if (cfg.channel_mode == next)
return EVENT_NOT_HANDLED;

set_channel_mode(next);
// remember after battery changes
cfg.channel_mode = channel_mode;
save_config();
return EVENT_HANDLED;
}
#endif

#ifdef USE_CUSTOM_CHANNEL_3H_MODES
// defer to mode-specific function if defined
else if (channel_3H_modes[channel_mode]) {
Expand Down
4 changes: 4 additions & 0 deletions ui/anduril/load-save-config-fsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ typedef struct Config {
#ifdef DEFAULT_BLINK_CHANNEL
uint8_t blink_channel;
#endif

#if (defined(USE_PREVIOUS_CHANNEL) && !defined(PREVIOUS_CHANNEL_REPLACES_LOCKOUT))
uint8_t previous_channel_enabled;
#endif
#endif
#ifdef USE_CHANNEL_MODE_ARGS
// this is an array, needs a few bytes
Expand Down
3 changes: 3 additions & 0 deletions ui/anduril/load-save-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ Config cfg = {
// blink numbers in a specific channel (user configurable)
.blink_channel = DEFAULT_BLINK_CHANNEL,
#endif
#if (defined(USE_PREVIOUS_CHANNEL) && !defined(PREVIOUS_CHANNEL_REPLACES_LOCKOUT))
.previous_channel_enabled = 0,
#endif
#endif
#ifdef USE_CHANNEL_MODE_ARGS
// one byte of extra data per channel mode, like for tint value
Expand Down
19 changes: 15 additions & 4 deletions ui/anduril/ramp-mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,18 @@ uint8_t steady_state(Event event, uint16_t arg) {
return EVENT_HANDLED;
}

#ifdef USE_LOCKOUT_MODE
// 4 clicks: shortcut to lockout mode
else if (event == EV_4clicks) {
#if defined(USE_LOCKOUT_MODE) && !defined(PREVIOUS_CHANNEL_REPLACES_LOCKOUT)
#ifdef USE_PREVIOUS_CHANNEL
else if ((event == EV_4clicks) && (!cfg.previous_channel_enabled))
#else
else if (event == EV_4clicks)
#endif //ifdef USE_PREVIOUS_CHANNEL
{
set_level(0);
set_state(lockout_state, 0);
return EVENT_HANDLED;
}
#endif
#endif //ifdef USE_LOCKOUT_MODE

// hold: change brightness (brighter, dimmer)
// click, hold: change brightness (dimmer)
Expand Down Expand Up @@ -612,6 +616,13 @@ void ramp_extras_config_save(uint8_t step, uint8_t value) {
cfg.smooth_steps_style = value;
}
#endif

#if (defined(USE_PREVIOUS_CHANNEL) && !defined(PREVIOUS_CHANNEL_REPLACES_LOCKOUT))
else if (previous_channel_enabled_config_step == step) {
cfg.previous_channel_enabled = value;
}
#endif

}

uint8_t ramp_extras_config_state(Event event, uint16_t arg) {
Expand Down
3 changes: 3 additions & 0 deletions ui/anduril/ramp-mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ typedef enum {
#ifdef USE_SMOOTH_STEPS
smooth_steps_style_config_step,
#endif
#if (defined(USE_PREVIOUS_CHANNEL) && !defined(PREVIOUS_CHANNEL_REPLACES_LOCKOUT))
previous_channel_enabled_config_step,
#endif
ramp_extras_config_num_steps
} ramp_extras_config_steps_e;
#endif
Expand Down
Loading