usb mouse input

Dependencies:   mbed TextLCD USBHost

Revision:
2:c1f316e932bc
Parent:
1:643faa48282f
diff -r 643faa48282f -r c1f316e932bc main.cpp
--- a/main.cpp	Thu Jul 25 06:53:04 2019 +0000
+++ b/main.cpp	Fri Jul 26 03:30:26 2019 +0000
@@ -1,11 +1,26 @@
 #include "mbed.h"
 #include "USBHostMouse.h"
+#include "TextLCD.h"
 
 DigitalOut led1(LED1);
+Serial pc(SERIAL_TX, SERIAL_RX); 
+AnalogIn button(A0);    // Init button (SELECT, LEFT, UP, DOWN, RIGHT)
+// LCD (RS, E, D4, D5, D6, D7);
+TextLCD lcd(D8, D9, D4, D5, D6, D7);
+PwmOut backlight(D10);  // Backlight LCD
 
 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);
+    static int buttonState =  0;
+    
+    if (buttons != buttonState){
+        buttonState = buttons;
+        
+        lcd.cls();                      // Clear LCD
+        lcd.locate(1,0);                // Set locate (1 row, 2 column)
+        printf("Buttons: %d, x: %d, y: %d, z: %d\r\n", buttons, x, y, z);
+        lcd.printf("Buttons: %d", buttons);   
+    }
 }
 
 void mouse_task(void const *)
@@ -35,9 +50,20 @@
 
 int main()
 {
+    // Set backlight period and duty cycle 
+    backlight.period(0.002);
+    backlight = 1;
+    
+    
+    lcd.cls();                      // Clear LCD
+    lcd.locate(1,0);                // Set locate (1 row, 2 column)
+    lcd.printf("LCD Key Shield");
+    wait(1);
+    
+    
     Thread mouseTask(mouse_task, NULL, osPriorityNormal, 1024* 4);
     while(1) {
         led1 = !led1;
-        Thread::wait(500);
+        Thread::wait(100);
     }
 }