Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MicroBitDALImageRewrite by
Diff: inc/MicroBitButton.h
- Revision:
- 1:3e0360107f98
- Parent:
- 0:47d8ba08580f
--- a/inc/MicroBitButton.h Sun Apr 12 17:38:56 2015 +0000
+++ b/inc/MicroBitButton.h Thu Apr 16 13:50:24 2015 +0000
@@ -7,42 +7,44 @@
#ifndef MICROBIT_BUTTON_H
#define MICROBIT_BUTTON_H
+#include "mbed.h"
+
+#define MICROBIT_PIN_LEFT_BUTTON P0_23
+
+#define MICROBIT_BUTTON_EVT_DOWN 1
+#define MICROBIT_BUTTON_EVT_UP 2
+
+
+
class MicroBitButton
{
/**
* Unique, enumerated ID for this component.
* Used to track asynchronous events in the event bus.
*/
- int id;
- int state;
+
+ int id; // Event Bus ID
+ PinName name; // mBed pin name of this pin.
+ DigitalIn pin; // The mBed object looking after this pin at any point in time (may change!).
+ InterruptIn irq; // Handler to detect change events.
+
+ void rising(); // Interrupt on change handler
+ void falling(); // Interrupt on change handler
public:
/**
* Constructor.
* Create a pin representation with the given ID.
* @param id the ID of the new LED object.
+ * @param name the physical pin on the processor that this butotn is connected to.
*/
- MicroBitButton(int id, PinName pin);
+ MicroBitButton(int id, PinName name);
/**
* 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();
};
