AR-610 Receiver
Revision 0:7450fa6b4ac5, committed 2019-03-06
- Comitter:
- lordofthestorm12
- Date:
- Wed Mar 06 17:26:54 2019 +0000
- Commit message:
- Receiver
Changed in this revision
AR610_LIB.cpp | Show annotated file Show diff for this revision Revisions of this file |
AR610_LIB.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AR610_LIB.cpp Wed Mar 06 17:26:54 2019 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" +#include "AR610_LIB.h" + +Receiver_obj::Receiver_obj(PinName _InterruptPin): _interruptin(_InterruptPin){ + + _interruptin.mode(PullUp); + _interruptin.rise(callback(this, &Receiver_obj::STARTTIMER)); + _interruptin.fall(callback(this, &Receiver_obj::STOPTIMER)); + + } + +double Receiver_obj::CurVal(){ + return _CurrentPulseWidth_us * CORVALRECIVER; + } + +void Receiver_obj::STARTTIMER(void){ + t_Runtime.reset(); + t_Runtime.start(); + } + +void Receiver_obj::STOPTIMER(void){ + _CurrentPulseWidth_us = t_Runtime; + t_Runtime.stop(); + } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AR610_LIB.h Wed Mar 06 17:26:54 2019 +0000 @@ -0,0 +1,50 @@ +/* +// --- DA Tschuchnik Danner --- Library für den AR-610 von Spektrum --- +// Throttle [1100us bis 1900us] +// Aile, Elev & Rudd [1200us bis 1800us] +// Coding by JuyN::GumM +*/ +// -------------- + +#ifndef AR610_LIB_H +#define AR610_LIB_H + +#include "mbed.h" + +#define CORVALRECIVER 1000000 + +// -------------- + +class Receiver_obj{ + + public: + + // * Konstrukt für den AR-610, übergabe als Interruptet-Pin für die Flankenerfassung des PPW-Signals... + Receiver_obj(PinName InterruptPin); + // * Erstellung des Dekonstruktors, grüundsätzlich nicht notwendig... + // ~Receiver_obj(); + + // * RETURN des korrigierten Wertes (um Faktor 10^6[ Kor von Float auf Int])... + double CurVal(); + + // * Startet den Timer wenn ein Interrupt am initialisierten Pin auftritt[steigende Flanke]... + void STARTTIMER(); + + // * Stoppt den Timer bei einer aufgetrettenen, fallenden Flanke und speichert diesen Wert in die Variable _CurrentPulseWidth_us... + void STOPTIMER(); + + // * Deklarierung des Pin's und des Timers... + private: + InterruptIn _interruptin; + Timer t_Runtime; + + // * Deklarierung der Variablen... + protected: + double _CurrentPulseWidth_us; + +}; + +// -------------- + + +#endif \ No newline at end of file