Microbug / MicroBitDAL_SB2_TEST

Fork of MicroBitDALImageRewrite by Joe Finney

Committer:
finneyj
Date:
Tue Apr 28 18:32:34 2015 +0000
Revision:
2:6597fe50dc94
Parent:
1:3e0360107f98
Child:
4:f998ee705a20
Integrated a Cortex M0 Fiber scheduler.; Updated MessageBus to generated events to decouple event handlers from interrupt context through use of scheduled fibers.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
finneyj 0:47d8ba08580f 1 /**
finneyj 0:47d8ba08580f 2 * Class definition for a MicroBit device.
finneyj 0:47d8ba08580f 3 *
finneyj 0:47d8ba08580f 4 * Represents the device as a whole, and includes member variables to that reflect the components of the system.
finneyj 0:47d8ba08580f 5 */
finneyj 0:47d8ba08580f 6
finneyj 0:47d8ba08580f 7 #ifndef MICROBIT_H
finneyj 0:47d8ba08580f 8 #define MICROBIT_H
finneyj 0:47d8ba08580f 9
finneyj 0:47d8ba08580f 10 #include "mbed.h"
finneyj 1:3e0360107f98 11 #include "MicroBitMessageBus.h"
finneyj 0:47d8ba08580f 12 #include "MicroBitButton.h"
finneyj 0:47d8ba08580f 13 #include "MicroBitDisplay.h"
finneyj 0:47d8ba08580f 14 #include "MicroBitImage.h"
finneyj 0:47d8ba08580f 15 #include "MicroBitIO.h"
finneyj 0:47d8ba08580f 16 #include "MicroBitLED.h"
finneyj 2:6597fe50dc94 17 #include "MicroBitFiber.h"
finneyj 0:47d8ba08580f 18
finneyj 0:47d8ba08580f 19 #define MICROBIT_IO_PINS 8 // TODO: Need to know how many. :-)
finneyj 0:47d8ba08580f 20
finneyj 0:47d8ba08580f 21 // Enumeration of core components.
finneyj 0:47d8ba08580f 22 #define MICROBIT_ID_LEFT_BUTTON 1
finneyj 0:47d8ba08580f 23 #define MICROBIT_ID_RIGHT_BUTTON 2
finneyj 0:47d8ba08580f 24 #define MICROBIT_ID_USER_LED 3
finneyj 0:47d8ba08580f 25 #define MICROBIT_ID_DISPLAY 5
finneyj 0:47d8ba08580f 26 #define MICROBIT_ID_IO_1 6
finneyj 0:47d8ba08580f 27 #define MICROBIT_ID_IO_2 7
finneyj 0:47d8ba08580f 28 #define MICROBIT_ID_IO_3 8
finneyj 0:47d8ba08580f 29 #define MICROBIT_ID_IO_4 9
finneyj 0:47d8ba08580f 30 #define MICROBIT_ID_IO_5 10
finneyj 0:47d8ba08580f 31 #define MICROBIT_ID_IO_6 11
finneyj 0:47d8ba08580f 32 #define MICROBIT_ID_IO_7 12
finneyj 0:47d8ba08580f 33 #define MICROBIT_ID_IO_8 13
finneyj 0:47d8ba08580f 34
finneyj 0:47d8ba08580f 35 // mBed pin assignments of core components.
finneyj 0:47d8ba08580f 36 #define MICROBIT_PIN_USER_LED P0_18
finneyj 0:47d8ba08580f 37
finneyj 0:47d8ba08580f 38
finneyj 0:47d8ba08580f 39 class MicroBit
finneyj 0:47d8ba08580f 40 {
finneyj 1:3e0360107f98 41 // Internal constructor. The ARM compiler doesn't seem to support constructor chaining...
finneyj 1:3e0360107f98 42 void init();
finneyj 0:47d8ba08580f 43
finneyj 0:47d8ba08580f 44 public:
finneyj 1:3e0360107f98 45 static MicroBitMessageBus MessageBus;
finneyj 0:47d8ba08580f 46 //
finneyj 0:47d8ba08580f 47 // Add member variables to represent each of the core components on the device.
finneyj 0:47d8ba08580f 48 //
finneyj 0:47d8ba08580f 49
finneyj 0:47d8ba08580f 50 MicroBitLED userLED;
finneyj 0:47d8ba08580f 51 MicroBitDisplay display;
finneyj 1:3e0360107f98 52 MicroBitButton leftButton;
finneyj 0:47d8ba08580f 53 /*
finneyj 0:47d8ba08580f 54 MicroBitButton rightButton;
finneyj 1:3e0360107f98 55
finneyj 0:47d8ba08580f 56 MicroBitIO pins[MICROBIT_IO_PINS];
finneyj 0:47d8ba08580f 57 */
finneyj 0:47d8ba08580f 58
finneyj 0:47d8ba08580f 59 /**
finneyj 0:47d8ba08580f 60 * Constructor.
finneyj 0:47d8ba08580f 61 * Create a representation of a MicroBit device.
finneyj 0:47d8ba08580f 62 * @param messageBus callback function to receive MicroBitMessageBus events.
finneyj 0:47d8ba08580f 63 */
finneyj 1:3e0360107f98 64 MicroBit();
finneyj 0:47d8ba08580f 65 };
finneyj 0:47d8ba08580f 66
finneyj 0:47d8ba08580f 67 #endif
finneyj 0:47d8ba08580f 68