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

Add alternate number entry that allows multiples of 10 #11

Open
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions hw/hank/emisar-d1v2/7135-fet/anduril.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// so it's unlikely that anyone needs this, but it doesn't hurt anything)
#define USE_AUX_RGB_LEDS
#define USE_AUX_RGB_LEDS_WHILE_ON 25
#define USE_NUMBER_ENTRY_BIGNUM
#define USE_INDICATOR_LED_WHILE_RAMPING

// safe limit ~50% power
Expand Down
1 change: 1 addition & 0 deletions hw/hank/emisar-d1v2/linear-fet/anduril.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// the aux LEDs are in the button, so use them while main LEDs are on
#define USE_AUX_RGB_LEDS
#define USE_AUX_RGB_LEDS_WHILE_ON 25
#define USE_NUMBER_ENTRY_BIGNUM
#define USE_INDICATOR_LED_WHILE_RAMPING

// safe limit: max regulated power
Expand Down
1 change: 1 addition & 0 deletions hw/hank/emisar-d1v2/nofet/anduril.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// the aux LEDs are in the button, so use them while main LEDs are on
#define USE_AUX_RGB_LEDS
#define USE_AUX_RGB_LEDS_WHILE_ON 25
#define USE_NUMBER_ENTRY_BIGNUM
#define USE_INDICATOR_LED_WHILE_RAMPING

// safe limit: same as regular ramp
Expand Down
2 changes: 2 additions & 0 deletions hw/hank/emisar-d4k-3ch/anduril.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// turn on the aux LEDs while main LEDs are on
// (in case there's a RGB button)
#define USE_AUX_RGB_LEDS_WHILE_ON 40
#define USE_NUMBER_ENTRY_BIGNUM
#define USE_INDICATOR_LED_WHILE_RAMPING

// channel modes...
Expand Down Expand Up @@ -102,3 +103,4 @@
// for consistency with KR4 (not otherwise necessary though)
#define USE_SOFT_FACTORY_RESET

#define USE_NUMBER_ENTRY_BIGNUM
1 change: 1 addition & 0 deletions hw/hank/noctigon-k1/anduril.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// this light has three aux LED channels: R, G, B
#define USE_AUX_RGB_LEDS
#define USE_AUX_RGB_LEDS_WHILE_ON 5
#define USE_NUMBER_ENTRY_BIGNUM
#define USE_INDICATOR_LED_WHILE_RAMPING


Expand Down
1 change: 1 addition & 0 deletions hw/hank/noctigon-k1/boost/anduril.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// this light has three aux LED channels: R, G, B
#define USE_AUX_RGB_LEDS
#define USE_AUX_RGB_LEDS_WHILE_ON 25
#define USE_NUMBER_ENTRY_BIGNUM
#define USE_INDICATOR_LED_WHILE_RAMPING

#if 0 // old, 10-bit PWM method
Expand Down
1 change: 1 addition & 0 deletions hw/hank/noctigon-k1/sbt90/anduril.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// this light has three aux LED channels: R, G, B
#define USE_AUX_RGB_LEDS
#define USE_AUX_RGB_LEDS_WHILE_ON 10
#define USE_NUMBER_ENTRY_BIGNUM
#define USE_INDICATOR_LED_WHILE_RAMPING


Expand Down
1 change: 1 addition & 0 deletions hw/wurkkos/fc13/anduril.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@

// turn on the aux LEDs while main LEDs are on
#define USE_AUX_RGB_LEDS_WHILE_ON 20
#define USE_NUMBER_ENTRY_BIGNUM
#define USE_INDICATOR_LED_WHILE_RAMPING

1 change: 1 addition & 0 deletions hw/wurkkos/ts11/anduril.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
// (but not until the main LEDs are bright enough to overpower the aux)
// (setting this lower makes an annoying effect on some levels)
#define USE_AUX_RGB_LEDS_WHILE_ON 50
#define USE_NUMBER_ENTRY_BIGNUM
#define USE_INDICATOR_LED_WHILE_RAMPING

43 changes: 38 additions & 5 deletions ui/anduril/config-mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,16 @@ uint8_t config_state_base(

uint8_t number_entry_state(Event event, uint16_t arg) {
static uint8_t entry_step;
#ifdef USE_NUMBER_ENTRY_BIGNUM
uint8_t bignum_steps = 0;
#endif

if (event == EV_enter_state) {
number_entry_value = 0;
entry_step = 0;
#ifdef USE_NUMBER_ENTRY_BIGNUM
bignum_steps = 0;
#endif
set_level(0); // initial pause should be dark
}

Expand Down Expand Up @@ -170,17 +176,18 @@ uint8_t number_entry_state(Event event, uint16_t arg) {
return EVENT_HANDLED;
}

// #ifndef USE_NUMBER_ENTRY_BIGNUM
// count clicks: click = +1, hold = +10
else if ((event == EV_click1_release)
#ifdef USE_NUMBER_ENTRY_PLUS10
#if defined(USE_NUMBER_ENTRY_PLUS10) && !defined(USE_NUMBER_ENTRY_BIGNUM)
|| (event == EV_click1_hold_release)
#endif
) {
entry_step = 1; // in case user clicked during initial delay
#ifdef USE_NUMBER_ENTRY_PLUS10
if (event == EV_click1_hold_release) number_entry_value += 10;
else
#endif
#if defined(USE_NUMBER_ENTRY_PLUS10) && !defined(USE_NUMBER_ENTRY_BIGNUM)
if (event == EV_click1_hold_release) number_entry_value += 10;
else
#endif
number_entry_value ++; // update the result
empty_event_sequence(); // reset FSM's click count
#ifdef CONFIG_BLINK_CHANNEL
Expand All @@ -189,6 +196,32 @@ uint8_t number_entry_state(Event event, uint16_t arg) {
set_level(RAMP_SIZE/2); // flash briefly
return EVENT_HANDLED;
}
#ifdef USE_NUMBER_ENTRY_BIGNUM
else if (event == EV_click1_hold){
if ((arg % (TICKS_PER_SECOND) == 0)){ // loop (roughly) every 1 second
// increment by 10 on the first pass (for a single hold for +10), then skip an increment
// for ~2 seconds to give a buffer for overholding, then start incrementing +10 each time
if ((!bignum_steps) || (bignum_steps > 3)){
//first time round. We don't rely on `arg` here as it will eventually wrap back round.
if (bignum_steps) bignum_steps++; //increment from 0 to activate the delay, but only the very first time
blip();
number_entry_value += 10;
}
else {
//second time round only, skip to give a delay before starting to add additional increments of 10
bignum_steps++; //increment again so we keep adding 10 each cycle
}
}
else return EVENT_HANDLED;
}
else if (event == EV_click1_hold_release){
#ifdef CONFIG_BLINK_CHANNEL
set_channel_mode(CONFIG_BLINK_CHANNEL);
#endif
set_level(RAMP_SIZE/2); // flash briefly
return EVENT_HANDLED;
}
#endif

// eat all other events; don't pass any through to parent
return EVENT_HANDLED;
Expand Down