aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-events.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2018-09-01 18:06:39 -0600
committerSelene ToyKeeper2018-09-01 18:06:39 -0600
commita572e004ae2439f89237eae5223c21e5cd9b282d (patch)
tree6eeac51cb55bd0faf6e6215f24e0dabbc43a2531 /spaghetti-monster/fsm-events.c
parentFirst Anduril build for Fireflies ROT66. (diff)
parentReduced ROM size another 10 bytes by removing redundant call to nearest_level(). (diff)
downloadanduril-a572e004ae2439f89237eae5223c21e5cd9b282d.tar.gz
anduril-a572e004ae2439f89237eae5223c21e5cd9b282d.tar.bz2
anduril-a572e004ae2439f89237eae5223c21e5cd9b282d.zip
merged updates/fixes from fsm branch
Diffstat (limited to 'spaghetti-monster/fsm-events.c')
-rw-r--r--spaghetti-monster/fsm-events.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/spaghetti-monster/fsm-events.c b/spaghetti-monster/fsm-events.c
index aa5c3d6..c71e822 100644
--- a/spaghetti-monster/fsm-events.c
+++ b/spaghetti-monster/fsm-events.c
@@ -160,11 +160,15 @@ uint8_t nice_delay_ms(uint16_t ms) {
_delay_loop_2(BOGOMIPS*98/100);
#endif // ifdef USE_DYNAMIC_UNDERCLOCKING
- process_emissions();
if ((nice_delay_interrupt) || (old_state != current_state)) {
- //nice_delay_interrupt = 0;
return 0; // state changed; abort
}
+ // handle events only afterward, so that any collapsed delays will
+ // finish running the UI's loop() code before taking any further actions
+ // (this helps make sure code runs in the correct order)
+ // (otherwise, a new state's EV_enter runs before the old state's
+ // loop() has finished, and things can get weird)
+ process_emissions();
}
return 1;
}