]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - src/eb_test/fsm.h
robofsm: Map 2012
[eurobot/public.git] / src / eb_test / fsm.h
1 #ifndef FSM_H
2 #define FSM_H
3
4 #include <types.h>
5 #include <stdbool.h>
6
7 // events of each state of state machine
8 enum event {
9         EVENT_ENTRY,
10         EVENT_DO,
11         EVENT_EXIT
12 }; 
13
14 struct fsm;
15
16 typedef void (*state_fcn)(struct fsm *fsm, enum event my_event);//pointer to function returning void and two input parametr
17
18 struct fsm {
19         state_fcn current_state;                // current state
20         state_fcn last_state;                   // last state
21         int32_t act_pos;                        // actual position
22         int32_t last_pos;                       // last position
23         int32_t delta;                          //indicate change betwen each move(should be used as absolute value)    
24         int32_t button1;
25         int32_t button2;
26         
27         
28         bool trigger_can_send;
29 };
30
31 void init_fsm(struct fsm *fsm, state_fcn initial_state);
32 void run_fsm(struct fsm *fsm);
33
34 #endif