A big red pulsating emergency stop button: actually a USB keyboard in disguise.

Dependencies:   Pulsator USBDevice mbed Debouncer

https://igcdn-photos-f-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-15/11208187_762945727138101_782976670_n.jpg

Revision:
2:617c7d2f754d
Parent:
1:6d520aa1463b
Child:
3:e69a72de6877
--- a/main.cpp	Mon Apr 27 14:38:25 2015 +0000
+++ b/main.cpp	Wed Apr 29 01:54:25 2015 +0000
@@ -7,12 +7,13 @@
 #define PI_BUTTON P0_7
 #define PO_LED P1_15
 
-#define BUTT_KEY '1'
-#define BUTT_DN KEY_CTRL | KEY_ALT
-#define BUTT_UP KEY_CTRL | KEY_ALT | KEY_SHIFT
+#define BUTT_DN_KEY '1'
+#define BUTT_DN_MOD KEY_CTRL | KEY_ALT
+#define BUTT_UP_KEY '1'
+#define BUTT_UP_MOD KEY_CTRL | KEY_ALT | KEY_SHIFT
 
-#define PERIOD_DN 0.25f
-#define PERIOD_UP 2.0f
+#define LED_PERIOD_DN 0.25f
+#define LED_PERIOD_UP 2.0f
 
 DigitalIn butt(PI_BUTTON, PullUp);
 USBKeyboard kbd;
@@ -24,7 +25,7 @@
 #define BRIEFLY 0.125f
 int main(void)
 {
-    led.active_high(false).fun(&flashing).period(PERIOD_UP) = true;
+    led.active_high(false).fun(&flashing).period(LED_PERIOD_UP) = true;
     while(!kbd.configured()) wait(BRIEFLY);
     led.fun(NULL);
 
@@ -32,7 +33,8 @@
     {
         if(now == butt) continue;
         now = !now;
-        kbd.keyCode(BUTT_KEY, now ? BUTT_UP : BUTT_DN);
-        led.period(now ? PERIOD_UP : PERIOD_DN);
+        now ? kbd.keyCode(BUTT_UP_KEY, BUTT_UP_MOD)
+            : kbd.keyCode(BUTT_DN_KEY, BUTT_DN_MOD);
+        led.period(now ? LED_PERIOD_UP : LED_PERIOD_DN);
     }
 }