diff options
author | Othmar Gsenger <otti@wirdorange.org> | 2013-02-07 00:10:56 +0000 |
---|---|---|
committer | Othmar Gsenger <otti@wirdorange.org> | 2013-02-07 00:10:56 +0000 |
commit | f8157d5cf8fafcc069bad4832a015e460e8e82fe (patch) | |
tree | b37c4e2a71073f025ea47bb82f6c5cb4c7997a77 /usb-i2c-sl018/statemachine.c | |
parent | leave error (diff) |
statemachine complete?
git-svn-id: https://svn.spreadspace.org/avr/trunk@157 aa12f405-d877-488e-9caf-2d797e2a1cc7
Diffstat (limited to 'usb-i2c-sl018/statemachine.c')
-rw-r--r-- | usb-i2c-sl018/statemachine.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/usb-i2c-sl018/statemachine.c b/usb-i2c-sl018/statemachine.c index 26fbb8e..5a6b9c8 100644 --- a/usb-i2c-sl018/statemachine.c +++ b/usb-i2c-sl018/statemachine.c @@ -96,15 +96,46 @@ void statemachine_task_limits(void) } } -void statemachine_task_cmd(void) +void statemachine_task_event(void) { + if (state == closing || state == opening) + return; //waiting for action to finish event_t event = eventqueue_pop(); + switch(state) { + case closing: + case opening: + //Not possibe, fuck gcc + case reset: + case error: + printf("Error: Not accepting commands in state %d\n\r",state); + break; // Not accepting commands + case manual_movement: + case timeout_after_open: + case timeout_after_close: + case closed: + case opened: + switch(event) { + case none: + return; + case cmd_open: + return change_state(opening); + case cmd_close: + return change_state(closing); + case cmd_toggle: + case btn_toggle: + case card: + return change_state( + (state==closed || state == timeout_after_close) ? + opening: + closing); + } + } } void statemachine_task(void) { statemachine_task_limits(); - statemachine_task_cmd(); + statemachine_task_event(); } |