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
inc/MicroBit.h@4:f998ee705a20, 2015-05-15 (annotated)
- Committer:
- finneyj
- Date:
- Fri May 15 22:23:17 2015 +0000
- Revision:
- 4:f998ee705a20
- Parent:
- 2:6597fe50dc94
- Child:
- 5:8bf639bbedb5
SB2 support and minor bugfixes
Who changed what in which revision?
User | Revision | Line number | New 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 | 4:f998ee705a20 | 11 | #include "MicroBitCompat.h" |
finneyj | 1:3e0360107f98 | 12 | #include "MicroBitMessageBus.h" |
finneyj | 0:47d8ba08580f | 13 | #include "MicroBitButton.h" |
finneyj | 0:47d8ba08580f | 14 | #include "MicroBitDisplay.h" |
finneyj | 0:47d8ba08580f | 15 | #include "MicroBitImage.h" |
finneyj | 0:47d8ba08580f | 16 | #include "MicroBitIO.h" |
finneyj | 0:47d8ba08580f | 17 | #include "MicroBitLED.h" |
finneyj | 2:6597fe50dc94 | 18 | #include "MicroBitFiber.h" |
finneyj | 4:f998ee705a20 | 19 | #include "BLEDevice.h" |
finneyj | 4:f998ee705a20 | 20 | #include "DeviceInformationService.h" |
finneyj | 4:f998ee705a20 | 21 | #include "DFUService.h" |
finneyj | 0:47d8ba08580f | 22 | |
finneyj | 4:f998ee705a20 | 23 | |
finneyj | 4:f998ee705a20 | 24 | #define MICROBIT_IO_PINS 8 // TODO: Need to know how many. :-) |
finneyj | 0:47d8ba08580f | 25 | |
finneyj | 0:47d8ba08580f | 26 | // Enumeration of core components. |
finneyj | 0:47d8ba08580f | 27 | #define MICROBIT_ID_LEFT_BUTTON 1 |
finneyj | 0:47d8ba08580f | 28 | #define MICROBIT_ID_RIGHT_BUTTON 2 |
finneyj | 0:47d8ba08580f | 29 | #define MICROBIT_ID_USER_LED 3 |
finneyj | 0:47d8ba08580f | 30 | #define MICROBIT_ID_DISPLAY 5 |
finneyj | 0:47d8ba08580f | 31 | #define MICROBIT_ID_IO_1 6 |
finneyj | 0:47d8ba08580f | 32 | #define MICROBIT_ID_IO_2 7 |
finneyj | 0:47d8ba08580f | 33 | #define MICROBIT_ID_IO_3 8 |
finneyj | 0:47d8ba08580f | 34 | #define MICROBIT_ID_IO_4 9 |
finneyj | 0:47d8ba08580f | 35 | #define MICROBIT_ID_IO_5 10 |
finneyj | 0:47d8ba08580f | 36 | #define MICROBIT_ID_IO_6 11 |
finneyj | 0:47d8ba08580f | 37 | #define MICROBIT_ID_IO_7 12 |
finneyj | 0:47d8ba08580f | 38 | #define MICROBIT_ID_IO_8 13 |
finneyj | 0:47d8ba08580f | 39 | |
finneyj | 0:47d8ba08580f | 40 | // mBed pin assignments of core components. |
finneyj | 4:f998ee705a20 | 41 | #define MICROBIT_PIN_USER_LED P0_18 |
finneyj | 4:f998ee705a20 | 42 | #define MICROBIT_PIN_SDA P0_22 |
finneyj | 4:f998ee705a20 | 43 | #define MICROBIT_PIN_SCL P0_20 |
finneyj | 0:47d8ba08580f | 44 | |
finneyj | 0:47d8ba08580f | 45 | |
finneyj | 0:47d8ba08580f | 46 | class MicroBit |
finneyj | 4:f998ee705a20 | 47 | { |
finneyj | 0:47d8ba08580f | 48 | public: |
finneyj | 4:f998ee705a20 | 49 | |
finneyj | 4:f998ee705a20 | 50 | // Device level Message Bus abstraction |
finneyj | 4:f998ee705a20 | 51 | MicroBitMessageBus MessageBus; |
finneyj | 0:47d8ba08580f | 52 | |
finneyj | 4:f998ee705a20 | 53 | // Member variables to represent each of the core components on the device. |
finneyj | 4:f998ee705a20 | 54 | //MicroBitLED userLED; |
finneyj | 4:f998ee705a20 | 55 | MicroBitDisplay *display; |
finneyj | 4:f998ee705a20 | 56 | //MicroBitButton leftButton; |
finneyj | 4:f998ee705a20 | 57 | //I2C i2c; |
finneyj | 0:47d8ba08580f | 58 | /* |
finneyj | 0:47d8ba08580f | 59 | MicroBitButton rightButton; |
finneyj | 1:3e0360107f98 | 60 | |
finneyj | 0:47d8ba08580f | 61 | MicroBitIO pins[MICROBIT_IO_PINS]; |
finneyj | 0:47d8ba08580f | 62 | */ |
finneyj | 4:f998ee705a20 | 63 | // Bluetooth related member variables. |
finneyj | 4:f998ee705a20 | 64 | BLEDevice *ble; |
finneyj | 4:f998ee705a20 | 65 | DeviceInformationService *ble_device_information_service; |
finneyj | 4:f998ee705a20 | 66 | DFUService *ble_firmware_update_service; |
finneyj | 4:f998ee705a20 | 67 | |
finneyj | 0:47d8ba08580f | 68 | /** |
finneyj | 0:47d8ba08580f | 69 | * Constructor. |
finneyj | 0:47d8ba08580f | 70 | * Create a representation of a MicroBit device. |
finneyj | 0:47d8ba08580f | 71 | * @param messageBus callback function to receive MicroBitMessageBus events. |
finneyj | 0:47d8ba08580f | 72 | */ |
finneyj | 1:3e0360107f98 | 73 | MicroBit(); |
finneyj | 0:47d8ba08580f | 74 | }; |
finneyj | 0:47d8ba08580f | 75 | |
finneyj | 4:f998ee705a20 | 76 | // Definition of the global instance of the MicroBit class. |
finneyj | 4:f998ee705a20 | 77 | // Using this as a variation on the singleton pattern, just to make |
finneyj | 4:f998ee705a20 | 78 | // code integration a littl bit easier for 3rd parties. |
finneyj | 4:f998ee705a20 | 79 | extern MicroBit uBit; |
finneyj | 4:f998ee705a20 | 80 | |
finneyj | 4:f998ee705a20 | 81 | |
finneyj | 0:47d8ba08580f | 82 | #endif |
finneyj | 0:47d8ba08580f | 83 |