forked from simplefoc/Arduino-FOC-drivers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPacketCommander.h
More file actions
45 lines (28 loc) · 909 Bytes
/
PacketCommander.h
File metadata and controls
45 lines (28 loc) · 909 Bytes
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
#pragma once
#include "../SimpleFOCRegisters.h"
#if !defined(PACKETCOMMANDER_MAX_MOTORS)
#define PACKETCOMMANDER_MAX_MOTORS 4
#endif
class PacketCommander {
public:
PacketCommander(bool echo = false);
virtual ~PacketCommander();
void addMotor(FOCMotor* motor);
virtual void init(PacketIO& io);
virtual void run();
bool echo = true;
protected:
virtual bool commsToRegister(uint8_t reg);
virtual bool registerToComms(uint8_t reg);
virtual void handleRegisterPacket(bool write, uint8_t reg);
virtual bool handlePacket(Packet& packet);
FOCMotor* motors[PACKETCOMMANDER_MAX_MOTORS];
uint8_t numMotors = 0;
uint8_t curMotor = 0;
uint8_t curRegister = REG_STATUS;
bool commanderror = false;
bool lastcommanderror = false;
uint8_t lastcommandregister = REG_STATUS;
PacketIO* _io;
Packet curr_packet = Packet(0x00, 0x00);
};