-
Notifications
You must be signed in to change notification settings - Fork 1
/
Motor.h
146 lines (120 loc) · 2.63 KB
/
Motor.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
*This software includes the work that is distributed in the Apache License 2.0
*/
#ifndef MOTOR_H
#define MOTOR_H
/** A Motor is abstract base class for moving the motor
*/
class Motor
{
public:
enum State
{
Free,
CW, // Clock Wise
CCW, // Counter Clock Wise
Brake,
TotalState,
};
enum DutyCycleChangeLevel
{
OFF = 0,
Low = 2,
Middle = 4,
High = 6,
Max = 7,
TotalDutyCycleChangeLevel,
};
enum Control
{
SlowDecay,
MixedDecay,
FastDecay,
TotalControl,
};
Motor();
/** Initialize data
*
*/
void init();
/** Set the duty cycle
*
* @param duty_cycle duty cycle to set
*/
void duty_cycle(float value);
/** Return the duty cycle
*
* @returns
* the duty cycle
*/
float duty_cycle() const;
/** Set the state
*
* @param type state to set
*/
void state(int type);
/** Return the state
*
* @returns
* the state
*/
int state() const;
/** Set the rise level
*
* @param level rise level to set
*/
void rise_level(int level);
/** Return the rise level
*
* @returns
* the rise level
*/
int rise_level() const;
/** Set the fall level
*
* @param level fall level to set
*/
void fall_level(int level);
/** Return the fall level
*
* @returns
* the fall level
*/
int fall_level() const;
/** Set the pulse period
*
* @param pulse period to set
*/
void pulse_period(float seconds);
/** Set the pulse frequency
*
* @param pulse frequency to set
*/
void frequency(float hz);
/** Set the release time(ms)
*
* @param release time to set
*/
void release_time_ms(float ms);
/** Set the control(LAP, SMB...)
*
* @param decay to set
*/
void control(int value);
static const int default_state;
static const int default_duty_cycle_chenge_level;
static const float default_pulse_period;
static const float default_frequency;
static const float defalut_release_time_ms;
static const int default_control;
static const float max_pulse_period;
protected:
float _duty_cycle;
enum State _state;
enum DutyCycleChangeLevel _rise_level;
enum DutyCycleChangeLevel _fall_level;
float _pulse_period;
float _release_time_ms;
enum Control _control;
};
#endif