test joystick demo
Dependencies: mbed QEI USBDevice USBJoystick
Diff: main.cpp
- Revision:
- 2:712ceeae4f56
- Parent:
- 0:e43878690c0e
- Child:
- 3:5edd4d529cfd
diff -r ffea10c89fec -r 712ceeae4f56 main.cpp --- a/main.cpp Mon Nov 11 07:52:43 2019 +0000 +++ b/main.cpp Tue Nov 12 07:17:38 2019 +0000 @@ -25,6 +25,7 @@ #include "mbed.h" #include "USBJoystick.h" +#include "QEI.h" //#define LANDTIGER 1 @@ -40,6 +41,9 @@ Ticker heartbeat; Serial pc(USBTX, USBRX); // tx, rx +//Use X4 encoding. +QEI wheel(PA_6, PA_7, NC, 30, QEI::X4_ENCODING); + // Heartbeat monitor void pulse() { heartbeatLED = !heartbeatLED; @@ -98,9 +102,10 @@ #endif i++; - x = cos((double)angle*3.14/180.0)*radius; // value -127 .. 128 - y = sin((double)angle*3.14/180.0)*radius; // value -127 .. 128 - angle += 3; + //x = cos((double)angle*3.14/180.0)*radius; // value -127 .. 128 + //y = sin((double)angle*3.14/180.0)*radius; // value -127 .. 128 + //angle += 3; + x = wheel.getPulses(); joystick.update(throttle, rudder, x, y, buttons, hat); wait(0.001);