-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFUTABA_SBUS.h
49 lines (33 loc) · 1.09 KB
/
FUTABA_SBUS.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
// [email protected], 05/2014
#ifndef FUTABA_SBUS_h
#define FUTABA_SBUS_h
#include <Arduino.h>
#define SBUS_SIGNAL_OK 0x00
#define SBUS_SIGNAL_LOST 0x01
#define SBUS_SIGNAL_FAILSAFE 0x02
class FUTABA_SBUS
{
public:
void begin(void);
void ProcessInput(void);
bool FetchChannelData(int16_t *pTarget, uint8_t &rStatusByte);
bool IsDataAvailable() const { return m_bDataAvailable; }
private:
void ItlStartReadingPayload();
void ItlAbortReadingPayload();
void ItlFinishReadingPayload();
void ItlSuccessfullReadPayload();
/// Tries to resync by reading bytes until the searched byte is found and consumed
/// returns true if searched byte was found and consumed, false if no data is left and it was not found
bool ItlResyncTo(uint8_t nSearchedByte);
bool m_bDataAvailable;
bool m_bIsReadingPayload;
int m_iCurBufferIndex;
// A temporary buffer, used to
// process the input data. If the line is
// completely received and valid, it is copied to m_pReadSBusData
uint8_t m_pTempInBuffer[25];
// The latest read sbus data
uint8_t m_pReadSBusData[25];
};
#endif