Lightweight FlyBed1, structure based on KK-Board Firmware First this one should work, then I can get more complex FlyBed1 working :)

Dependencies:   mbed MODI2C

Committer:
maetugr
Date:
Thu Nov 19 18:52:48 2015 +0000
Revision:
3:9cde4e9740fc
Parent:
0:d51bf879e9df
corrected a comment

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maetugr 0:d51bf879e9df 1 #ifndef RC_CHANNEL_H
maetugr 0:d51bf879e9df 2 #define RC_CHANNEL_H
maetugr 0:d51bf879e9df 3
maetugr 0:d51bf879e9df 4 #include "mbed.h"
maetugr 0:d51bf879e9df 5
maetugr 0:d51bf879e9df 6 class RC_Channel
maetugr 0:d51bf879e9df 7 {
maetugr 0:d51bf879e9df 8 public:
maetugr 0:d51bf879e9df 9 RC_Channel(PinName mypin, int index); // NO p19/p20!!!!, they don't support InterruptIn
maetugr 0:d51bf879e9df 10 int read(); // read the last measured data
maetugr 0:d51bf879e9df 11
maetugr 0:d51bf879e9df 12 private:
maetugr 0:d51bf879e9df 13 int index; // to know which channel of the RC an instance has (only for calibrations savings)
maetugr 0:d51bf879e9df 14 int time; // last measurement data
maetugr 0:d51bf879e9df 15 float scale; // calibration values
maetugr 0:d51bf879e9df 16 float offset;
maetugr 0:d51bf879e9df 17
maetugr 0:d51bf879e9df 18 InterruptIn myinterrupt; // interrupt on the pin to react when signal falls or rises
maetugr 0:d51bf879e9df 19 void rise(); // start the time measurement when signal rises
maetugr 0:d51bf879e9df 20 void fall(); // stop the time mesurement and save the value when signal falls
maetugr 0:d51bf879e9df 21 Timer timer; // timer to measure the up time of the signal and if the signal timed out
maetugr 0:d51bf879e9df 22
maetugr 0:d51bf879e9df 23 Ticker timeoutchecker; // Ticker to see if signal broke down
maetugr 0:d51bf879e9df 24 void timeoutcheck(); // to check for timeout, checked every second
maetugr 0:d51bf879e9df 25
maetugr 0:d51bf879e9df 26 // Calibration value saving
maetugr 0:d51bf879e9df 27 void saveCalibrationValue(float * value, char * fileextension);
maetugr 0:d51bf879e9df 28 void loadCalibrationValue(float * value, char * fileextension);
maetugr 0:d51bf879e9df 29 };
maetugr 0:d51bf879e9df 30
maetugr 0:d51bf879e9df 31 #endif