aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spaghetti-monster/anduril/anduril.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index 1d7ecbd..6057bf0 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -864,12 +864,24 @@ uint8_t steady_state(Event event, uint16_t arg) {
uint8_t tint_ramping_state(Event event, uint16_t arg) {
static int8_t tint_ramp_direction = 1;
static uint8_t prev_tint = 0;
+ // don't activate auto-tint modes unless the user hits the edge
+ // and keeps pressing for a while
static uint8_t past_edge_counter = 0;
+ // bugfix: click-click-hold from off to strobes would invoke tint ramping
+ // in addition to changing state... so ignore any tint-ramp events which
+ // don't look like they were meant to be here
+ static uint8_t active = 0;
// click, click, hold: change the tint
if (event == EV_click3_hold) {
// reset at beginning of movement
- if (! arg) { past_edge_counter = 0; }
+ if (! arg) {
+ active = 1; // first frame means this is for us
+ past_edge_counter = 0; // doesn't start until user hits the edge
+ }
+ // ignore event if we weren't the ones who handled the first frame
+ if (! active) return EVENT_HANDLED;
+
// change normal tints
if ((tint_ramp_direction > 0) && (tint < 254)) {
tint += 1;
@@ -880,9 +892,10 @@ uint8_t tint_ramping_state(Event event, uint16_t arg) {
// if the user kept pressing long enough, go the final step
if (past_edge_counter == 64) {
past_edge_counter ++;
- tint ^= 1;
+ tint ^= 1; // 0 -> 1, 254 -> 255
blip();
}
+ // if tint change stalled, let user know we hit the edge
else if (prev_tint == tint) {
if (past_edge_counter == 0) blip();
// count up but don't wrap back to zero
@@ -895,6 +908,8 @@ uint8_t tint_ramping_state(Event event, uint16_t arg) {
// click, click, hold, release: reverse direction for next ramp
else if (event == EV_click3_hold_release) {
+ active = 0; // ignore next hold if it wasn't meant for us
+ // reverse
tint_ramp_direction = -tint_ramp_direction;
if (tint == 0) tint_ramp_direction = 1;
else if (tint == 255) tint_ramp_direction = -1;