![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
4-axis USB controller for FPV sims, based on NXP FRDM-K22F
main.cpp@0:9f5a70453c7c, 2020-03-05 (annotated)
- Committer:
- wue
- Date:
- Thu Mar 05 20:57:25 2020 +0000
- Revision:
- 0:9f5a70453c7c
???
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wue | 0:9f5a70453c7c | 1 | #include "mbed.h" |
wue | 0:9f5a70453c7c | 2 | #include "USBJoystick.h" |
wue | 0:9f5a70453c7c | 3 | DigitalOut led_red(LED_RED); |
wue | 0:9f5a70453c7c | 4 | DigitalOut led_green(LED_GREEN); |
wue | 0:9f5a70453c7c | 5 | DigitalIn sw2(SW2); |
wue | 0:9f5a70453c7c | 6 | DigitalIn sw3(SW3); |
wue | 0:9f5a70453c7c | 7 | Serial pc(USBTX, USBRX); |
wue | 0:9f5a70453c7c | 8 | |
wue | 0:9f5a70453c7c | 9 | AnalogIn throt(A0); |
wue | 0:9f5a70453c7c | 10 | AnalogIn yaw(A1); |
wue | 0:9f5a70453c7c | 11 | AnalogIn pitch(A2); |
wue | 0:9f5a70453c7c | 12 | AnalogIn roll(A3); |
wue | 0:9f5a70453c7c | 13 | |
wue | 0:9f5a70453c7c | 14 | USBJoystick joystick; |
wue | 0:9f5a70453c7c | 15 | |
wue | 0:9f5a70453c7c | 16 | int main() { |
wue | 0:9f5a70453c7c | 17 | int c; |
wue | 0:9f5a70453c7c | 18 | led_green = 1; |
wue | 0:9f5a70453c7c | 19 | led_red = 1; |
wue | 0:9f5a70453c7c | 20 | pc.baud(115200); |
wue | 0:9f5a70453c7c | 21 | pc.printf("Hello World from FRDM-K64F board.\n"); |
wue | 0:9f5a70453c7c | 22 | |
wue | 0:9f5a70453c7c | 23 | while (true) { |
wue | 0:9f5a70453c7c | 24 | c += 1; |
wue | 0:9f5a70453c7c | 25 | joystick.update( |
wue | 0:9f5a70453c7c | 26 | throt.read() * 32767.0, |
wue | 0:9f5a70453c7c | 27 | yaw.read() * 32767.0, |
wue | 0:9f5a70453c7c | 28 | pitch.read() * 32767.0, |
wue | 0:9f5a70453c7c | 29 | roll.read() * 32767.0 |
wue | 0:9f5a70453c7c | 30 | ); |
wue | 0:9f5a70453c7c | 31 | |
wue | 0:9f5a70453c7c | 32 | led_red = 1; |
wue | 0:9f5a70453c7c | 33 | wait(0.005); |
wue | 0:9f5a70453c7c | 34 | //led_red = 0; |
wue | 0:9f5a70453c7c | 35 | //wait(0.01); |
wue | 0:9f5a70453c7c | 36 | } |
wue | 0:9f5a70453c7c | 37 | } |