Successful acro and level mode now! Relying on MPU9250 as base sensor. I'm working continuously on tuning and features :) NEWEST VERSION ON: https://github.com/MaEtUgR/FlyBed (CODE 100% compatible/copyable)
Diff: RC/RC_Channel.h
- Revision:
- 0:37f0c1e8fa66
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RC/RC_Channel.h Tue Sep 08 13:38:10 2015 +0000 @@ -0,0 +1,31 @@ +#ifndef RC_CHANNEL_H +#define RC_CHANNEL_H + +#include "mbed.h" + +class RC_Channel +{ + public: + RC_Channel(PinName mypin, int index); // NO p19/p20!!!!, they don't support InterruptIn + int read(); // read the last measured data + + private: + int index; // to know which channel of the RC an instance has (only for calibrations savings) + int time; // last measurement data + float scale; // calibration values + float offset; + + InterruptIn myinterrupt; // interrupt on the pin to react when signal falls or rises + void rise(); // start the time measurement when signal rises + void fall(); // stop the time mesurement and save the value when signal falls + Timer timer; // timer to measure the up time of the signal and if the signal timed out + + Ticker timeoutchecker; // Ticker to see if signal broke down + void timeoutcheck(); // to check for timeout, checked every second + + // Calibration value saving + void saveCalibrationValue(float * value, char * fileextension); + void loadCalibrationValue(float * value, char * fileextension); +}; + +#endif \ No newline at end of file