-
Notifications
You must be signed in to change notification settings - Fork 0
/
point_fsm.h
70 lines (50 loc) · 1.41 KB
/
point_fsm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//-----------------------------------------------------------------------------
#include <math.h>
#include <stdio.h>
#include "tools.h"
//-----------------------------------------------------------------------------
typedef struct point{
float x;
float y;
} point_t;
//-----------------------------------------------------------------------------
typedef enum{
DEG_ONE,
DEG_FOUR,
DEG_THIRTEEN,
DEG_SEVEN,
DEG_TWENTY,
NUM_STATES
} state_t;
//-----------------------------------------------------------------------------
typedef enum{
ENTERING_STATE,
TIMER_EXPIRED,
NUM_EVENTS
} event_t;
//-----------------------------------------------------------------------------
class point_fsm{
/*----------------------------------
* Values
*--------------------------------*/
public:
static double conversion_ratio;
private:
struct timeval last_exec_time;
state_t current_state;
point_t point;
/*----------------------------------
* Methods
*--------------------------------*/
public:
point_fsm();
void run();
void reset();
static double deg_to_radians(double degrees);
void update_with_event(event_t event);
private:
void update_machine_internal(event_t event);
void get_point(int degrees, point_t * point);
void point_str(point_t point, char * buf);
};
//-----------------------------------------------------------------------------