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