Microbug / MicroBitDAL_SB2_TEST

Fork of MicroBitDALImageRewrite by Joe Finney

Committer:
finneyj
Date:
Sun Apr 12 17:38:56 2015 +0000
Revision:
0:47d8ba08580f
Child:
1:3e0360107f98
First draft implementation of core functionality. Includes:; ;   - OO model of microBit device.;   - Flexible geometry LD matirx driver.;   - Lazy, instatiation free I/O; ; Please note this code is largely untested.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
finneyj 0:47d8ba08580f 1 /**
finneyj 0:47d8ba08580f 2 * Class definition for MicroBit Button.
finneyj 0:47d8ba08580f 3 *
finneyj 0:47d8ba08580f 4 * Represents a single button on the device.
finneyj 0:47d8ba08580f 5 */
finneyj 0:47d8ba08580f 6
finneyj 0:47d8ba08580f 7 #ifndef MICROBIT_BUTTON_H
finneyj 0:47d8ba08580f 8 #define MICROBIT_BUTTON_H
finneyj 0:47d8ba08580f 9
finneyj 0:47d8ba08580f 10 class MicroBitButton
finneyj 0:47d8ba08580f 11 {
finneyj 0:47d8ba08580f 12 /**
finneyj 0:47d8ba08580f 13 * Unique, enumerated ID for this component.
finneyj 0:47d8ba08580f 14 * Used to track asynchronous events in the event bus.
finneyj 0:47d8ba08580f 15 */
finneyj 0:47d8ba08580f 16 int id;
finneyj 0:47d8ba08580f 17 int state;
finneyj 0:47d8ba08580f 18
finneyj 0:47d8ba08580f 19 public:
finneyj 0:47d8ba08580f 20 /**
finneyj 0:47d8ba08580f 21 * Constructor.
finneyj 0:47d8ba08580f 22 * Create a pin representation with the given ID.
finneyj 0:47d8ba08580f 23 * @param id the ID of the new LED object.
finneyj 0:47d8ba08580f 24 */
finneyj 0:47d8ba08580f 25 MicroBitButton(int id, PinName pin);
finneyj 0:47d8ba08580f 26
finneyj 0:47d8ba08580f 27 /**
finneyj 0:47d8ba08580f 28 * Tests if this Button is currently pressed.
finneyj 0:47d8ba08580f 29 * @return 1 if this button is pressed, 0 otherwise.
finneyj 0:47d8ba08580f 30 */
finneyj 0:47d8ba08580f 31 int isPressed();
finneyj 0:47d8ba08580f 32
finneyj 0:47d8ba08580f 33 /**
finneyj 0:47d8ba08580f 34 * Enables asynchronous callback events from this button.
finneyj 0:47d8ba08580f 35 * When enabled, all state change updates will be propogated
finneyj 0:47d8ba08580f 36 * along the MicroBitMessageBus using the device's ID.
finneyj 0:47d8ba08580f 37 */
finneyj 0:47d8ba08580f 38 void enableCallback();
finneyj 0:47d8ba08580f 39
finneyj 0:47d8ba08580f 40 /**
finneyj 0:47d8ba08580f 41 * Disables asynchronous callback events from this button.
finneyj 0:47d8ba08580f 42 * When disabled no state change updates will be propogated
finneyj 0:47d8ba08580f 43 * along the MicroBitMessageBus from this button.
finneyj 0:47d8ba08580f 44 */
finneyj 0:47d8ba08580f 45 void disableCallback();
finneyj 0:47d8ba08580f 46
finneyj 0:47d8ba08580f 47 };
finneyj 0:47d8ba08580f 48
finneyj 0:47d8ba08580f 49 #endif