Henk Meewis / Mbed 2 deprecated USB_serial_LED_controller

Dependencies:   mbed

Fork of frdm_echo by Henk Meewis

Revision:
13:019e24491f32
Parent:
12:b846b64e3980
Child:
14:73ef945b8def
--- a/main.cpp	Thu Apr 17 15:38:08 2014 +0000
+++ b/main.cpp	Fri Apr 18 21:33:57 2014 +0000
@@ -1,19 +1,35 @@
 // Print "Hello World" to the PC
 
+// push buttons:
+// sw2 on PTC6
+// sw3 on PTA4
+
 #include "mbed.h"
 #include "shell.h"
 #include "LEDColors.h"
+#include "PushButtons.h"
 
 Ticker *scanTicker;
 Shell *usbSerialShell;
 LEDColors *ledColors;
+PushButtons *pushButtons;
 
 bool scanUSBSerialRxFlag;
 
+void pushButtonPressed()
+{
+    if(pushButtons->getPressed(pb2)) ledColors->flash(lcBlue, 10);    
+    if(pushButtons->getPressed(pb3)) ledColors->flash(lcGreen, 10);    
+    if(pushButtons->getJustPressed(pb2)) usbSerialShell->reportPushButtonPress(pb2);
+    if(pushButtons->getJustPressed(pb3)) usbSerialShell->reportPushButtonPress(pb3);
+}
+//-----------------------------------------------------------------------------
+
 void at10msTick()
 {
     scanUSBSerialRxFlag = true;
     ledColors->tick10ms();
+    if(pushButtons->tick10ms()) pushButtonPressed();
 }
 //-----------------------------------------------------------------------------
 
@@ -31,6 +47,7 @@
     scanUSBSerialRxFlag = false;
     
     ledColors = new LEDColors();
+    pushButtons = new PushButtons();
 }
 //-----------------------------------------------------------------------------