aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-05-14 00:40:26 -0600
committerSelene ToyKeeper2019-05-14 00:40:26 -0600
commit5a46280fcad8f8f6f3da46195de835545ad48fbd (patch)
tree541f0418da953f3a5e6caf89e4e5160fba51e3ad
parentadded auto-tint modes, refactored some indicator blinks into "blip()", enable... (diff)
downloadanduril-5a46280fcad8f8f6f3da46195de835545ad48fbd.tar.gz
anduril-5a46280fcad8f8f6f3da46195de835545ad48fbd.tar.bz2
anduril-5a46280fcad8f8f6f3da46195de835545ad48fbd.zip
fixed bug where click-click-hold from off to strobes would also activate tint ramping when it shouldn't
-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;
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.