Isme have me mouse chalate h, jyada excite mat hona keep calm and roll on

Dependencies:   MMA8451Q TSI USBDevice mbed

Fork of LAB21_AccLed by IBS

main.cpp

Committer:
akashlal
Date:
2016-07-08
Revision:
1:ab380860081d
Parent:
0:5fc7faf6f68c

File content as of revision 1:ab380860081d:

#include "mbed.h"
#include "MMA8451Q.h"
#include "TSISensor.h"
#include "USBMouse.h"
#define MMA8451_I2C_ADDRESS (0x1d<<1)
MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
TSISensor tsi;
USBMouse mouse;
int main() 
{
    int16_t x, y;
    int s=10;
    float click=0;
    while(1) 
    {
        x = acc.getAccY()*-s;
        y = acc.getAccX()*s;
        mouse.move(x,-y);
        click=tsi.readPercentage();
        if(click>0&&click<=0.4)
        {
        mouse.press(MOUSE_RIGHT);
        }
        else
        {
        mouse.release(MOUSE_RIGHT);
        }
        if(click>=0.6)
        {
        mouse.press(MOUSE_LEFT);
        }
        else
        {
        mouse.release(MOUSE_LEFT);
        }
    }
}