Microbug / MicroBitDAL_SB2_TEST

Fork of MicroBitDALImageRewrite by Joe Finney

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MicroBit.h Source File

MicroBit.h

00001 /**
00002   * Class definition for a MicroBit device.
00003   *
00004   * Represents the device as a whole, and includes member variables to that reflect the components of the system.
00005   */
00006   
00007 #ifndef MICROBIT_H
00008 #define MICROBIT_H
00009 
00010 #include "mbed.h"
00011 #include "MicroBitCompat.h"
00012 #include "MicroBitMessageBus.h"
00013 #include "MicroBitButton.h"
00014 #include "MicroBitDisplay.h"
00015 #include "MicroBitImage.h"
00016 #include "MicroBitIO.h"
00017 #include "MicroBitLED.h"
00018 #include "MicroBitFiber.h"
00019 #include "BLEDevice.h"
00020 #include "DeviceInformationService.h"
00021 #include "DFUService.h"
00022 
00023 
00024 #define MICROBIT_IO_PINS                8            // TODO: Need to know how many. :-)
00025 
00026 // Enumeration of core components.
00027 #define MICROBIT_ID_LEFT_BUTTON         1
00028 #define MICROBIT_ID_RIGHT_BUTTON        2
00029 #define MICROBIT_ID_USER_LED            3
00030 #define MICROBIT_ID_DISPLAY             5
00031 #define MICROBIT_ID_IO_1                6
00032 #define MICROBIT_ID_IO_2                7
00033 #define MICROBIT_ID_IO_3                8
00034 #define MICROBIT_ID_IO_4                9
00035 #define MICROBIT_ID_IO_5                10
00036 #define MICROBIT_ID_IO_6                11
00037 #define MICROBIT_ID_IO_7                12
00038 #define MICROBIT_ID_IO_8                13
00039 
00040 // mBed pin assignments of core components.
00041 #define MICROBIT_PIN_USER_LED           P0_18
00042 #define MICROBIT_PIN_SDA                P0_22
00043 #define MICROBIT_PIN_SCL                P0_20
00044 
00045 
00046 class MicroBit
00047 {                                    
00048     public:
00049     
00050     // Device level Message Bus abstraction
00051     MicroBitMessageBus  MessageBus;      
00052 
00053     // Member variables to represent each of the core components on the device.
00054     //MicroBitLED         userLED;
00055     MicroBitDisplay     *display;
00056     //MicroBitButton      leftButton;
00057     //I2C                 i2c;
00058 /*
00059     MicroBitButton      rightButton;
00060 
00061     MicroBitIO          pins[MICROBIT_IO_PINS];
00062 */    
00063     // Bluetooth related member variables.
00064     BLEDevice                   *ble;
00065     DeviceInformationService    *ble_device_information_service;
00066     DFUService                  *ble_firmware_update_service;
00067     
00068     /**
00069       * Constructor. 
00070       * Create a representation of a MicroBit device.
00071       * @param messageBus callback function to receive MicroBitMessageBus events.
00072       */
00073     MicroBit();  
00074     
00075     void initDisplay();
00076     void initBLE();  
00077 };
00078 
00079 // Definition of the global instance of the MicroBit class.
00080 // Using this as a variation on the singleton pattern, just to make
00081 // code integration a littl bit easier for 3rd parties.
00082 extern MicroBit uBit;
00083 
00084 
00085 #endif
00086