~toykeeper/flashlight-firmware/trunk

« back to all changes in this revision

Viewing changes to ToyKeeper/spaghetti-monster/fsm-events.c

  • Committer: Selene Scriven
  • Date: 2018-08-23 05:46:32 UTC
  • mfrom: (211.1.10 zeroflow-fixes)
  • Revision ID: bzr@toykeeper.net-20180823054632-9s89y33nuxbmy6m5
merged in zeroflow's fixes and my related changes:
- fixed main emitters coming on while changing aux LED mode
- made strobe group mode selection more configurable at compile time
- refactored eeprom indexes in the same manner as strobe indexes,
  for cleaner and more robust code
- added -fshort-enums to compile options for smaller ROM size
- made interrupt_nice_delays() automatic every time the user completes
  a button press sequence, so all delays collapse until the next trip
  through main()...  this reduces ROM size and simplifies code and
  eliminates risk of not responding right away

Tested on D4 and D4S.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
 
40
40
void empty_event_sequence() {
41
41
    for(uint8_t i=0; i<EV_MAX_LEN; i++) current_event[i] = 0;
 
42
    // when the user completes an input sequence, interrupt any running timers
 
43
    // to cancel any delays currently in progress
 
44
    // This eliminates a whole bunch of extra code:
 
45
    //   before: if (! nice_delay_ms(ms)) {break;}
 
46
    //   after: nice_delay_ms(ms);
 
47
    interrupt_nice_delays();
42
48
}
43
49
 
44
50
uint8_t push_event(uint8_t ev_type) {
156
162
 
157
163
        process_emissions();
158
164
        if ((nice_delay_interrupt) || (old_state != current_state)) {
159
 
            nice_delay_interrupt = 0;
 
165
            //nice_delay_interrupt = 0;
160
166
            return 0;  // state changed; abort
161
167
        }
162
168
    }