a
Dependencies: mbed
PPM/PPMOut.h@1:dd6e70abeb8e, 2018-05-25 (annotated)
- Committer:
- halusis
- Date:
- Fri May 25 08:09:17 2018 +0000
- Revision:
- 1:dd6e70abeb8e
- Parent:
- 0:f0b20f502059
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
halusis | 0:f0b20f502059 | 1 | #ifndef CH_PPM_OUT |
halusis | 0:f0b20f502059 | 2 | #define CH_PPM_OUT |
halusis | 0:f0b20f502059 | 3 | |
halusis | 0:f0b20f502059 | 4 | class PpmOut{ |
halusis | 0:f0b20f502059 | 5 | public: |
halusis | 0:f0b20f502059 | 6 | static const uint8_t MAX_CHANNELS = 8; |
halusis | 0:f0b20f502059 | 7 | static const uint16_t CHANNEL_SYNC = 300; // us |
halusis | 0:f0b20f502059 | 8 | static const uint16_t CHANNEL_PAD_SYNC = 1000 - CHANNEL_SYNC; // us |
halusis | 0:f0b20f502059 | 9 | static const uint16_t FRAME_SYNC = 5000; // us |
halusis | 0:f0b20f502059 | 10 | static const uint16_t FRAME_LEN = 20000; // us |
halusis | 0:f0b20f502059 | 11 | static const uint16_t MAX_CHANNEL_VALUE = 1980; // us |
halusis | 0:f0b20f502059 | 12 | static const uint16_t MIN_CHANNEL_VALUE = 1020; |
halusis | 0:f0b20f502059 | 13 | static const uint16_t DOTS = MAX_CHANNELS*2+2; // two dots per channel + FRAME_SYNC |
halusis | 0:f0b20f502059 | 14 | |
halusis | 0:f0b20f502059 | 15 | /* Will start the PPM output */ |
halusis | 0:f0b20f502059 | 16 | PpmOut(PinName pin, uint8_t channel_number); |
halusis | 0:f0b20f502059 | 17 | /* Values go from MIN_CHANNEL_VALUE to MAX_CHANNEL_VALUE */ |
halusis | 0:f0b20f502059 | 18 | void setChannel(int channel_no, uint16_t value); |
halusis | 0:f0b20f502059 | 19 | |
halusis | 0:f0b20f502059 | 20 | private: |
halusis | 0:f0b20f502059 | 21 | /* These are the time dots where the signal changes the value |
halusis | 0:f0b20f502059 | 22 | from 0 to 1 and in reverse */ |
halusis | 0:f0b20f502059 | 23 | uint16_t dots[DOTS]; |
halusis | 0:f0b20f502059 | 24 | Timeout timeout; |
halusis | 0:f0b20f502059 | 25 | DigitalOut ppm; |
halusis | 0:f0b20f502059 | 26 | uint8_t current_dot; |
halusis | 0:f0b20f502059 | 27 | uint8_t channel_number; |
halusis | 0:f0b20f502059 | 28 | uint16_t frame_length; |
halusis | 0:f0b20f502059 | 29 | uint16_t pulse_out; |
halusis | 0:f0b20f502059 | 30 | |
halusis | 0:f0b20f502059 | 31 | void attimeout(); |
halusis | 0:f0b20f502059 | 32 | inline void resetChannels(); |
halusis | 0:f0b20f502059 | 33 | inline void setFrameSync(); |
halusis | 0:f0b20f502059 | 34 | }; |
halusis | 0:f0b20f502059 | 35 | |
halusis | 0:f0b20f502059 | 36 | #endif // CH_PPM_OUT |