-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoveEncoder.h
64 lines (49 loc) · 1.34 KB
/
RoveEncoder.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
#ifndef ROVEENCODER_H
#define ROVEENCODER_H
class RoveEncoder {
protected:
bool m_inverted = false;
float m_offsetDegrees = 0;
bool m_allowNegativeDegrees = false;
/**
* @brief Bound the input degree value between 0 and 360.
*
* @param degrees Value to be bounded.
* @return The equivalent angle [0, 360).
*/
float boundDegrees0_360(float degrees) const;
public:
/**
* @brief Configure whether to invert the encoder value when read.
*
* @param invert
*/
void configInvert(const bool& invert);
/**
* @brief Configure the offset to subtract when read, after invert is applied.
* Can be used to zero the encoder by calling configOffset(readDegrees()).
*
* @param offsetDegrees
*/
void configOffset(const float& offsetDegrees);
void configNegativeDegrees(const bool& enable);
/**
* @brief Calculate the offset that will make readDegrees() return the provided value.
*
* @param degrees
*/
void setDegrees(const float& degrees);
/**
* @brief Read the encoder value in radians.
*
* @return Current radian value.
*/
float readRadians() const;
/**
* @brief Read the encoder value in degrees.
*
* @return Current degree value.
*/
virtual float readDegrees() const = 0;
};
#endif