Julio González
/
Nucleo_Usb_JoyMouse
Example of usb mouse on smt32 platform using a analog 2-axis joystick
Revision 8:427f11739ba4, committed 2017-05-09
- Comitter:
- julgonmej
- Date:
- Tue May 09 16:04:16 2017 +0000
- Parent:
- 7:bb9d609a8493
- Commit message:
- Small changes
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r bb9d609a8493 -r 427f11739ba4 main.cpp --- a/main.cpp Tue May 09 15:56:24 2017 +0000 +++ b/main.cpp Tue May 09 16:04:16 2017 +0000 @@ -1,9 +1,7 @@ #include "mbed.h" - +#include "USBMouse.h" #include <math.h> -#include "USBMouse.h" - USBMouse mouse(ABS_MOUSE); DigitalOut myled(LED1); @@ -11,10 +9,7 @@ AnalogIn ey(PC_3); DigitalIn click(PB_7, PullUp); -Serial mipc(USBTX, USBRX); - int main(void) { - mipc.printf("HOLA"); unsigned int x_center = (X_MAX_ABS - X_MIN_ABS)/2; unsigned int y_center = (Y_MAX_ABS - Y_MIN_ABS)/2; uint16_t x_screen = x_center; @@ -30,7 +25,6 @@ px = ex.read_u16(); py = ey.read_u16(); sw = !click.read(); - //mipc.printf("PALANCA X %d, PALANCA Y %d, BOTON %d\r\n", px, py, sw); if(px > 40000 || px < 25000) { x_screen += (px - 32768)/250; @@ -38,21 +32,16 @@ if(py > 40000 || py < 25000) { y_screen += (py - 32768)/250; } - //mipc.printf("PUNTO X %d, PUNTO Y %d\r\n", x_screen, y_screen); mouse.move(x_screen, y_screen); - mouse.update(x_screen, y_screen,0,0); if(!swOld && sw) { - //mouse.click(MOUSE_LEFT); mouse.update(x_screen, y_screen,1,0); swOld = 1; - //mipc.printf("CLICK"); } else if (swOld && !sw){ swOld = 0; mouse.update(x_screen, y_screen,0,0); } - //mouse.move(x_screen, y_screen); wait(0.007); } } \ No newline at end of file