Skip to content

Commit

Permalink
Add alternate number entry that allows multiples of 10
Browse files Browse the repository at this point in the history
In number entry mode, when holding for +10, keep holding and it will
addd additional increments of 10. Added to lights with
USE_AUX_RGB_LEDS_WHILE_ON with use for configurable RGB voltage aux (see
PR #10) in mind.
  • Loading branch information
SiteRelEnby committed Nov 7, 2023
1 parent b97b232 commit d2c8578
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 10 deletions.
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

45 changes: 39 additions & 6 deletions ui/anduril/config-mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void set_chan_if(bool cond, uint8_t chan) {
// should give a buzzing prompt to enter a number. Click N times
// at the prompt to set the new value to N.
// after completing this process, config state calls the savefunc callback
// and then returns to caller/parent state
// and then eturns to caller/parent state
uint8_t config_state_base(
Event event,
uint16_t arg,
Expand Down 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
5 changes: 1 addition & 4 deletions ui/anduril/version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
// this file is replaced automatically by the build script
// set your own date here if you're not using the build script
// otherwise, default to first human contact with the moon
#define VERSION_NUMBER "1969-07-20"
#define VERSION_NUMBER "2023-11-07"

0 comments on commit d2c8578

Please sign in to comment.