keypad shield

Dependencies:   mbed TextLCD

Files at this revision

API Documentation at this revision

Comitter:
duchonic
Date:
Mon Aug 05 18:26:58 2019 +0000
Parent:
3:eac680851b92
Commit message:
first

Changed in this revision

USBHost.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r eac680851b92 -r c2cdba0bae47 USBHost.lib
--- a/USBHost.lib	Fri Jul 26 03:34:02 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/mbed_official/code/USBHost/#7c3b59bb364e
diff -r eac680851b92 -r c2cdba0bae47 main.cpp
--- a/main.cpp	Fri Jul 26 03:34:02 2019 +0000
+++ b/main.cpp	Mon Aug 05 18:26:58 2019 +0000
@@ -1,69 +1,27 @@
 #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);
+TextLCD lcd(D8, D9, D4, D5, D6, D7); // LCD (RS, E, D4, D5, D6, D7);
 PwmOut backlight(D10);  // Backlight LCD
 
-void onMouseEvent(uint8_t buttons, int8_t x, int8_t y, int8_t 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 *)
-{
-    USBHostMouse mouse;
-
-    printf("Mouse started\r\n");
-
-    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);
-        }
-
-        printf("Mouse disconnected\r\n");
-    }
-}
-
 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) {
+        lcd.cls();
+        lcd.locate(1,0);
+        lcd.printf("%f", button.read());
+        wait(1);
         led1 = !led1;
-        Thread::wait(100);
     }
 }