Library to use remote control Spektrum AR6210
AR6210.h@0:9a1f7660704d, 2013-11-20 (annotated)
- Committer:
- Joram
- Date:
- Wed Nov 20 10:26:54 2013 +0000
- Revision:
- 0:9a1f7660704d
- Child:
- 1:25aad26619fb
Initial import AR6210
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Joram | 0:9a1f7660704d | 1 | #pragma once |
Joram | 0:9a1f7660704d | 2 | // Original code: https://mbed.org/users/BlazeX/code/AR8000/ |
Joram | 0:9a1f7660704d | 3 | // Modified by Joram Querner for Spektrum AR6210 |
Joram | 0:9a1f7660704d | 4 | |
Joram | 0:9a1f7660704d | 5 | // Interrupt callback |
Joram | 0:9a1f7660704d | 6 | #define AR6210_RISE_FALL(Ch)\ |
Joram | 0:9a1f7660704d | 7 | void Rise##Ch()\ |
Joram | 0:9a1f7660704d | 8 | {\ |
Joram | 0:9a1f7660704d | 9 | LastRise[Ch]= Time.read_us();\ |
Joram | 0:9a1f7660704d | 10 | }\ |
Joram | 0:9a1f7660704d | 11 | void Fall##Ch()\ |
Joram | 0:9a1f7660704d | 12 | {\ |
Joram | 0:9a1f7660704d | 13 | int dT= Time.read_us() - LastRise[Ch];\ |
Joram | 0:9a1f7660704d | 14 | if(dT > 900 && dT < 2100)\ |
Joram | 0:9a1f7660704d | 15 | dTime[Ch]= dT;\ |
Joram | 0:9a1f7660704d | 16 | } |
Joram | 0:9a1f7660704d | 17 | |
Joram | 0:9a1f7660704d | 18 | |
Joram | 0:9a1f7660704d | 19 | class AR6210 |
Joram | 0:9a1f7660704d | 20 | { |
Joram | 0:9a1f7660704d | 21 | private: |
Joram | 0:9a1f7660704d | 22 | InterruptIn ChInt0; |
Joram | 0:9a1f7660704d | 23 | InterruptIn ChInt1; |
Joram | 0:9a1f7660704d | 24 | InterruptIn ChInt2; |
Joram | 0:9a1f7660704d | 25 | InterruptIn ChInt3; |
Joram | 0:9a1f7660704d | 26 | InterruptIn ChInt4; |
Joram | 0:9a1f7660704d | 27 | InterruptIn ChInt5; |
Joram | 0:9a1f7660704d | 28 | |
Joram | 0:9a1f7660704d | 29 | Timer Time; |
Joram | 0:9a1f7660704d | 30 | volatile int LastRise[6]; //Zeitpunkt der letzten steigende Flanke |
Joram | 0:9a1f7660704d | 31 | volatile int dTime[6]; //Pulsdauer in us [1000...2000] |
Joram | 0:9a1f7660704d | 32 | |
Joram | 0:9a1f7660704d | 33 | public: |
Joram | 0:9a1f7660704d | 34 | int RawChannels[6]; //Rohdaten [1000...2000] |
Joram | 0:9a1f7660704d | 35 | |
Joram | 0:9a1f7660704d | 36 | //Die Steuerbefehle |
Joram | 0:9a1f7660704d | 37 | float Throttle; //0=Aus, 1=Vollgas |
Joram | 0:9a1f7660704d | 38 | float Aileron; //-1=Links, 0=Nichts, +1=Rechts |
Joram | 0:9a1f7660704d | 39 | float Elevator; //-1=Sinken, 0=Nichts, +1=Steigen |
Joram | 0:9a1f7660704d | 40 | float Rudder; //-1=Links, 0=Nichts, +1=Rechts |
Joram | 0:9a1f7660704d | 41 | |
Joram | 0:9a1f7660704d | 42 | float Gear; //-1...+1 Left Trim |
Joram | 0:9a1f7660704d | 43 | float Aux; //-1...+1 Right Trim |
Joram | 0:9a1f7660704d | 44 | |
Joram | 0:9a1f7660704d | 45 | //Initialisieren |
Joram | 0:9a1f7660704d | 46 | AR6210(); |
Joram | 0:9a1f7660704d | 47 | void init(); |
Joram | 0:9a1f7660704d | 48 | void update(); |
Joram | 0:9a1f7660704d | 49 | |
Joram | 0:9a1f7660704d | 50 | //Interrupt-Callbacks definieren |
Joram | 0:9a1f7660704d | 51 | AR6210_RISE_FALL(0); |
Joram | 0:9a1f7660704d | 52 | AR6210_RISE_FALL(1); |
Joram | 0:9a1f7660704d | 53 | AR6210_RISE_FALL(2); |
Joram | 0:9a1f7660704d | 54 | AR6210_RISE_FALL(3); |
Joram | 0:9a1f7660704d | 55 | AR6210_RISE_FALL(4); |
Joram | 0:9a1f7660704d | 56 | AR6210_RISE_FALL(5); |
Joram | 0:9a1f7660704d | 57 | }; |