mirror of https://github.com/ARMmbed/mbed-os.git
USBHOST : add mouse test
parent
72dae26774
commit
815194a98b
|
|
@ -0,0 +1,34 @@
|
||||||
|
#include "mbed.h"
|
||||||
|
#include "USBHostMouse.h"
|
||||||
|
|
||||||
|
DigitalOut led(LED1);
|
||||||
|
|
||||||
|
void onMouseEvent(uint8_t buttons, int8_t x, int8_t y, int8_t z) {
|
||||||
|
printf("buttons: %d, x: %d, y: %d, z: %d\r\n", buttons, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mouse_task(void const *) {
|
||||||
|
|
||||||
|
USBHostMouse mouse;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
// try to connect a USB mouse
|
||||||
|
while(!mouse.connect())
|
||||||
|
Thread::wait(500);
|
||||||
|
|
||||||
|
// when connected, attach handler called on mouse event
|
||||||
|
mouse.attachEvent(onMouseEvent);
|
||||||
|
|
||||||
|
// wait until the mouse is disconnected
|
||||||
|
while(mouse.connected())
|
||||||
|
Thread::wait(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
Thread mouseTask(mouse_task, NULL, osPriorityNormal, 256 * 4);
|
||||||
|
while(1) {
|
||||||
|
led=!led;
|
||||||
|
Thread::wait(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1025,7 +1025,11 @@ TESTS = [
|
||||||
"source_dir": join(TEST_DIR, "usb", "host", "mass_storage"),
|
"source_dir": join(TEST_DIR, "usb", "host", "mass_storage"),
|
||||||
"dependencies": [MBED_LIBRARIES, USB_HOST_LIBRARIES, FAT_FS, RTOS],
|
"dependencies": [MBED_LIBRARIES, USB_HOST_LIBRARIES, FAT_FS, RTOS],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "USB_11", "description": "mouse",
|
||||||
|
"source_dir": join(TEST_DIR, "usb", "host", "mouse"),
|
||||||
|
"dependencies": [MBED_LIBRARIES, USB_HOST_LIBRARIES, RTOS],
|
||||||
|
},
|
||||||
# CMSIS DSP
|
# CMSIS DSP
|
||||||
{
|
{
|
||||||
"id": "CMSIS_DSP_1", "description": "FIR",
|
"id": "CMSIS_DSP_1", "description": "FIR",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue