FRDM-K64 USB Mouse basic example using mbed

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

FRDM-K64 USB Mouse basic example using mbed

FRDM-K64 USB Mouse basic example using mbed

Here you will find both the code and project files for the USB Mouse project. In this project the USB module is configured as a device, the X and Y coordinates to move the cursor are obtained from the accelerometer measurements. Once the code is loaded it is necessary to disconnect the USB cable from the J26 USB connector and plug it to the K64 USB connector. Once the device enumerates you can use it as an air mouse.

The left and right click buttons have not been enabled.

To compile the project you must import the following libraries:

  • USBMouse.h
  • FXOS8700Q.h

Code:

#include "mbed.h"

#include "USBMouse.h"

#include "FXOS8700Q.h"

//I2C lines for FXOS8700Q accelerometer/magnetometer

FXOS8700Q_acc acc( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1);

USBMouse mouse;

int main()

{

    acc.enable();

    float faX, faY, faZ;

    int16_t x = 0;

    int16_t y = 0;

 

    while (1)

    {

        //acc.getAxis(acc_data);

        acc.getX(&faX);

        acc.getY(&faY);

        x = 10*faX;

        y = 10*faY;

     

        mouse.move(x, y);

        wait(0.001);

    }

}

附件
无评分
版本历史
最后更新:
‎06-27-2014 11:44 AM
更新人: