aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spaghetti-monster/fsm-events.c7
-rw-r--r--spaghetti-monster/fsm-events.h2
-rw-r--r--spaghetti-monster/fsm-pcint.c4
-rw-r--r--spaghetti-monster/fsm-wdt.c4
4 files changed, 9 insertions, 8 deletions
diff --git a/spaghetti-monster/fsm-events.c b/spaghetti-monster/fsm-events.c
index ad869a6..93c38c9 100644
--- a/spaghetti-monster/fsm-events.c
+++ b/spaghetti-monster/fsm-events.c
@@ -25,6 +25,7 @@
void empty_event_sequence() {
current_event = EV_none;
+ ticks_since_last_event = 0;
// when the user completes an input sequence, interrupt any running timers
// to cancel any delays currently in progress
// This eliminates a whole bunch of extra code:
@@ -33,8 +34,9 @@ void empty_event_sequence() {
interrupt_nice_delays();
}
-uint8_t push_event(uint8_t ev_type) {
- ticks_since_last_event = 0; // something happened
+uint8_t push_event(uint8_t ev_type) { // only for use by PCINT_inner()
+ // don't do this here; do it in PCINT_inner() instead
+ //ticks_since_last_event = 0; // something happened
// only click events are sent to this function
current_event |= B_CLICK;
@@ -208,7 +210,6 @@ void emit(Event event, uint16_t arg) {
}
void emit_current_event(uint16_t arg) {
- ticks_since_last_event = arg;
emit(current_event, arg);
}
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index 871c6a1..f83d306 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -202,7 +202,7 @@ static volatile uint16_t ticks_since_last_event = 0;
void empty_event_sequence();
-uint8_t push_event(uint8_t ev_type);
+uint8_t push_event(uint8_t ev_type); // only for use by PCINT_inner()
#define EMISSION_QUEUE_LEN 16
diff --git a/spaghetti-monster/fsm-pcint.c b/spaghetti-monster/fsm-pcint.c
index eacc699..021a076 100644
--- a/spaghetti-monster/fsm-pcint.c
+++ b/spaghetti-monster/fsm-pcint.c
@@ -101,9 +101,9 @@ void PCINT_inner(uint8_t pressed) {
emit_current_event(0);
} else { // user released button
// how long was the button held?
- uint16_t ticks_since_last = ticks_since_last_event;
push_event(B_RELEASE);
- emit_current_event(ticks_since_last);
+ emit_current_event(ticks_since_last_event);
}
+ ticks_since_last_event = 0;
}
#endif
diff --git a/spaghetti-monster/fsm-wdt.c b/spaghetti-monster/fsm-wdt.c
index 94266c1..9e8d9af 100644
--- a/spaghetti-monster/fsm-wdt.c
+++ b/spaghetti-monster/fsm-wdt.c
@@ -150,6 +150,7 @@ void WDT_inner() {
// (first frame of a "hold" event)
else {
if (ticks_since_last >= HOLD_TIMEOUT) {
+ ticks_since_last_event = 0;
current_event |= B_HOLD;
emit_current_event(0);
}
@@ -160,9 +161,8 @@ void WDT_inner() {
else if (current_event) {
// "hold" event just ended
// no timeout required when releasing a long-press
- // TODO? move this logic to PCINT() and simplify things here?
if (current_event & B_HOLD) {
- //emit_current_event(0); // should have been emitted by PCINT_inner()
+ //emit_current_event(ticks_since_last); // should have been emitted by PCINT_inner()
empty_event_sequence();
}
// end and clear event after release timeout
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.