-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAS5600.h
67 lines (53 loc) · 965 Bytes
/
AS5600.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
// Chiba Institute of Technology
#ifndef ASS5600_H
#define ASS5600_H
#include "mbed.h"
#include "AS5600.h"
/** Class to measure angle using an absolute encoder AS5600
*
* Exmaple
* @code
*
* // Display Angle (Button 1: Reset Angle)
* #include "mbed.h"
* #include "AS5600.h"
*
* BusOut led(LED1, LED2, LED3, LED4);
* BusIn sw(SW1, SW2);
* AS5600 as5600(I2C_SDA, I2C_SCL);
*
* int main() {
* led = 0;
* sw.mode(PullUp);
* while(1) {
* float angle = as5600;
* printf("%f\r\n", angle);
* if (sw[0] == 0) as5600 = 0;
* wait(0.5);
* }
*}
*/
class AS5600
{
public:
AS5600(PinName i2c_sda, PinName i2c_scl);
void updateAngle();
float getAngleRad();
float getAngleDeg();
int getError();
void write(float value);
float read();
AS5600& operator= (double value) {
write(value);
return *this;
}
operator float(){
return read();
}
private:
I2C i2c;
float angle;
float angle0;
int error;
};
#endif