Microbug / MicroBitDAL_SB2_TEST

Fork of MicroBitDALImageRewrite by Joe Finney

Revision:
0:47d8ba08580f
Child:
1:3e0360107f98
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/MicroBitButton.h	Sun Apr 12 17:38:56 2015 +0000
@@ -0,0 +1,49 @@
+/**
+  * Class definition for MicroBit Button.
+  *
+  * Represents a single button on the device.
+  */
+  
+#ifndef MICROBIT_BUTTON_H
+#define MICROBIT_BUTTON_H
+
+class MicroBitButton
+{
+    /**
+      * Unique, enumerated ID for this component. 
+      * Used to track asynchronous events in the event bus.
+      */
+    int id;
+    int state;
+    
+    public:
+    /**
+      * Constructor. 
+      * Create a pin representation with the given ID.
+      * @param id the ID of the new LED object.
+      */
+    MicroBitButton(int id, PinName pin);
+    
+    /**
+      * Tests if this Button is currently pressed.
+      * @return 1 if this button is pressed, 0 otherwise.
+      */
+    int isPressed();
+
+     /**
+      * Enables asynchronous callback events from this button.
+      * When enabled, all state change updates will be propogated 
+      * along the MicroBitMessageBus using the device's ID.
+      */    
+    void enableCallback();
+    
+     /**
+      * Disables asynchronous callback events from this button.
+      * When disabled no state change updates will be propogated 
+      * along the MicroBitMessageBus from this button.
+      */    
+    void disableCallback();
+    
+};
+
+#endif