-
Notifications
You must be signed in to change notification settings - Fork 0
/
sbus.h
40 lines (34 loc) · 872 Bytes
/
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
/* based on https://github.com/george-hawkins/arduino-sbus
* modified for STM32
*/
#ifndef SBUS_h
#define SBUS_h
#include <Arduino.h>
#define SBUS_FAILSAFE_INACTIVE 0
#define SBUS_FAILSAFE_ACTIVE 1
#define SBUS_STARTBYTE 0x0f
#define SBUS_ENDBYTE 0x00
class SBUS {
public:
SBUS(HardwareSerial & serial) : _serial (serial) {}
void begin();
void begin(int initValue);
bool process();
int getChannel(int channel);
int getNormalizedChannel(int channel);
int getFailsafeStatus();
int getFrameLoss();
long getGoodFrames();
long getLostFrames();
long getDecoderErrorFrames();
long long getLastTime();
private:
HardwareSerial & _serial;
int _channels[18];
int _failsafe;
long _goodFrames;
long _lostFrames;
long _decoderErrorFrames;
long long _lastGoodFrame;
};
#endif