Madpulse ROS Code
Dependencies: mbed ServoOut BNO055_fusion ros_lib_kinetic MadPulseIMU ServoIn
RC/RC_Channel.h@8:c07db2a00c8e, 2019-10-10 (annotated)
- Committer:
- jdawkins
- Date:
- Thu Oct 10 13:51:05 2019 +0000
- Revision:
- 8:c07db2a00c8e
- Parent:
- 5:c24490c61022
Changed the Messages Sent.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jdawkins | 5:c24490c61022 | 1 | #ifndef RC_CHANNEL_H |
jdawkins | 5:c24490c61022 | 2 | #define RC_CHANNEL_H |
jdawkins | 5:c24490c61022 | 3 | |
jdawkins | 5:c24490c61022 | 4 | #include "mbed.h" |
jdawkins | 5:c24490c61022 | 5 | |
jdawkins | 5:c24490c61022 | 6 | class RC_Channel |
jdawkins | 5:c24490c61022 | 7 | { |
jdawkins | 5:c24490c61022 | 8 | public: |
jdawkins | 5:c24490c61022 | 9 | RC_Channel(PinName mypin, int index); // NO p19/p20!!!!, they don't support InterruptIn |
jdawkins | 5:c24490c61022 | 10 | int read(); // read the last measured data |
jdawkins | 5:c24490c61022 | 11 | |
jdawkins | 5:c24490c61022 | 12 | private: |
jdawkins | 5:c24490c61022 | 13 | int index; // to know which channel of the RC an instance has (only for calibrations savings) |
jdawkins | 5:c24490c61022 | 14 | int time; // last measurement data |
jdawkins | 5:c24490c61022 | 15 | float scale; // calibration values |
jdawkins | 5:c24490c61022 | 16 | float offset; |
jdawkins | 5:c24490c61022 | 17 | |
jdawkins | 5:c24490c61022 | 18 | InterruptIn myinterrupt; // interrupt on the pin to react when signal falls or rises |
jdawkins | 5:c24490c61022 | 19 | void rise(); // start the time measurement when signal rises |
jdawkins | 5:c24490c61022 | 20 | void fall(); // stop the time mesurement and save the value when signal falls |
jdawkins | 5:c24490c61022 | 21 | Timer timer; // timer to measure the up time of the signal and if the signal timed out |
jdawkins | 5:c24490c61022 | 22 | |
jdawkins | 5:c24490c61022 | 23 | Ticker timeoutchecker; // Ticker to see if signal broke down |
jdawkins | 5:c24490c61022 | 24 | void timeoutcheck(); // to check for timeout, checked every second |
jdawkins | 5:c24490c61022 | 25 | |
jdawkins | 5:c24490c61022 | 26 | // Calibration value saving |
jdawkins | 5:c24490c61022 | 27 | void saveCalibrationValue(float * value, char * fileextension); |
jdawkins | 5:c24490c61022 | 28 | void loadCalibrationValue(float * value, char * fileextension); |
jdawkins | 5:c24490c61022 | 29 | }; |
jdawkins | 5:c24490c61022 | 30 | |
jdawkins | 5:c24490c61022 | 31 | #endif |