aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-07-12 23:36:00 -0600
committerSelene ToyKeeper2020-07-12 23:36:00 -0600
commitd65c37ca280de190ab3a9dc48d39cf27ed7d70a0 (patch)
tree24e9bcc846583e789eef7bdbb8af3e645d506713 /spaghetti-monster
parentmoved all config modes and aux LED config actions to 7C / 7H (diff)
downloadanduril-d65c37ca280de190ab3a9dc48d39cf27ed7d70a0.tar.gz
anduril-d65c37ca280de190ab3a9dc48d39cf27ed7d70a0.tar.bz2
anduril-d65c37ca280de190ab3a9dc48d39cf27ed7d70a0.zip
fixed bug: button release events were sending 0 as the arg instead of the number of ticks the button was held
(bug had no effect in any current UIs, but I needed it fixed for a feature I want to add)
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/fsm-pcint.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/spaghetti-monster/fsm-pcint.c b/spaghetti-monster/fsm-pcint.c
index d362633..eacc699 100644
--- a/spaghetti-monster/fsm-pcint.c
+++ b/spaghetti-monster/fsm-pcint.c
@@ -93,18 +93,17 @@ ISR(PCINT0_vect) {
// should only be called from PCINT and/or WDT
// (is a separate function to reduce code duplication)
void PCINT_inner(uint8_t pressed) {
- uint8_t pushed;
+ button_last_state = pressed;
- if (pressed) {
- pushed = push_event(B_PRESS);
- } else {
- pushed = push_event(B_RELEASE);
- }
-
- // send event to the current state callback
- if (pushed) {
- button_last_state = pressed;
+ // register the change, and send event to the current state callback
+ if (pressed) { // user pressed button
+ push_event(B_PRESS);
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);
}
}
#endif
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.