forked from RealTadango/FrSky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSPortHub.h
47 lines (43 loc) · 1.35 KB
/
SPortHub.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
#ifndef SPORTHUB_H
#define SPORTHUB_H
#include <SPort.h>
#include <Arduino.h>
#include <SoftwareSerial.h>
class SPortHub {
public:
#ifdef Serial_
SPortHub(int physicalId, Serial_& serial);
#elif HardwareSerial
SPortHub(int physicalId, HardwareSerial& serial);
#endif
SPortHub(int physicalId, int softwarePin);
void begin();
void handle();
void registerSensor(SPortSensor& sensor);
void sendCommand(int prim, int applicationId, int value);
void (*commandReceived)(int prim, int applicationId, int value);
int commandId;
private:
void SendData(sportData data, int prim);
void SendByte(byte b);
bool SendCommand();
bool SendSensor();
byte GetChecksum(byte data[], int start, int len);
#ifdef Serial_
Serial_* _hwStream;
#elif HardwareSerial
HardwareSerial* _hwStream;
#endif
SoftwareSerial* _swStream;
SPortSensor** _sensors;
int _physicalId;
int _softwarePin;
int _sensorIndex;
int _sensorCount;
bool _valid;
short _index;
byte _buffer[10];
int _commandPrim;
sportData _commandData;
};
#endif