FRDM-K64 USB air mouse demo

Dependencies:   FXOS8700Q USBDevice mbed

Fork of FRDM-K64_USB by Augusto Panecatl

USB air mouse demo modified USB Analog Joystick with Low Power Mode Demo

main.cpp

Committer:
julioefajardo
Date:
2015-06-22
Revision:
1:b9ea91c4c533
Parent:
0:d50fb46005fd
Child:
2:cb6377d909e0

File content as of revision 1:b9ea91c4c533:

#include "mbed.h"
#include "USBMouse.h"

DigitalIn RightClick(PTC6);
DigitalIn LeftClick(PTA4);
DigitalIn Click(PTC10);
DigitalOut BlueLed(LED3);

USBMouse mouse;

AnalogIn AnIn0(A0);
AnalogIn AnIn1(A1);

int main() 
{
    float posx, posy; 
    float pposx, pposy;
    int16_t x = 0;
    int16_t y = 0;
    Click.mode(PullUp);
    
    while (1) 
    {
        if(LeftClick) mouse.release(MOUSE_LEFT);
        else mouse.press(MOUSE_LEFT);
        
        if(RightClick) mouse.release(MOUSE_RIGHT);
        else mouse.press(MOUSE_RIGHT);
        
        BlueLed = Click;
        
        posx=AnIn0.read();
        posy=AnIn1.read();
        x = -800*(posx-pposx);
        y = 800*(posy-pposy);

        mouse.move(x, y);
        
        pposx = posx;
        pposy = posy;
              
        wait(0.01);
    }
}