-
Notifications
You must be signed in to change notification settings - Fork 0
/
PPMEncoder.h
47 lines (33 loc) · 897 Bytes
/
PPMEncoder.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 _PPMEncoder_h_
#define _PPMEncoder_h_
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#define PPM_DEFAULT_CHANNELS 8
#define PPM_PULSE_LENGTH_uS 400
//#define PPM_FRAME_LENGTH_uS 22500
#define PPM_FRAME_LENGTH_uS 20000
class PPMEncoder {
private:
int16_t channels[10];
uint16_t elapsedUs;
uint8_t numChannels;
uint8_t currentChannel;
byte outputPin;
boolean state;
uint8_t onState;
uint8_t offState;
public:
static const uint16_t MIN = 1000;
static const uint16_t MAX = 2000;
void setChannel(uint8_t channel, uint16_t value);
void setChannelPercent(uint8_t channel, uint8_t percent);
void begin(uint8_t pin);
void begin(uint8_t pin, uint8_t ch);
void begin(uint8_t pin, uint8_t ch, boolean inverted);
void interrupt();
};
extern PPMEncoder ppmEncoder;
#endif