forked from Candas1/Split_Hoverboard_SimpleFOC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PilotI2c.h
54 lines (40 loc) · 958 Bytes
/
PilotI2c.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
#ifndef PILOT_I2C_h
#define PILOT_I2C_h
#include "Pilot.h"
#define CMD1_Speed 1
struct __attribute((__packed__)) Server2Hover1
{
uint16_t iCmd = 0;
float fValue = 3.14;
};
struct __attribute((__packed__)) Server2Hover2
{
uint16_t iCmd = 0;
float fValue1 = 3.14;
float fValue2 = 42.0;
};
#define HOVERSTATUS_Ready 1
struct __attribute((__packed__)) Hover2Server
{
byte iVersion = 0;
uint16_t iCmdLast = 0;
byte iStatus = 0;
float fCurrent1 = 0;
float fRpm1 = 0;
} ;
class PilotI2c : public Pilot
{
public:
PilotI2c(Hoverboard& r);
Server2Hover1 oMaster2Slave1;
Server2Hover2 oMaster2Slave2;
Hover2Server oSlave2Master;
void init(){init(8);};
void init(byte iI2cAdress);
unsigned int iRequests = 0; // log how often requestEvent() is called
unsigned int iReceived = 0; // log how often receiveEvent() is called
void RequestEvent();
void ReceiveEvent(int iAvail);
protected:
};
#endif // PILOT_I2C_h