microbit: Added MicroBitLEDService
One of the standard services defiend with the Bluetooth SIG. Allows remote control of the LED matrix display over BLE.
This commit is contained in:
parent
574b408cd1
commit
7e18131849
4 changed files with 24 additions and 5 deletions
|
@ -5,9 +5,6 @@
|
|||
#include "MicroBitConfig.h"
|
||||
#include "MicroBitPanic.h"
|
||||
|
||||
#include "ble/BLE.h"
|
||||
#include "ble/services/DeviceInformationService.h"
|
||||
|
||||
#include "ErrorNo.h"
|
||||
|
||||
#include "MicroBitHeapAllocator.h"
|
||||
|
@ -31,8 +28,11 @@
|
|||
#include "MicroBitCompass.h"
|
||||
#include "MicroBitAccelerometer.h"
|
||||
|
||||
#include "ble/BLE.h"
|
||||
#include "ble/services/DeviceInformationService.h"
|
||||
#include "MicroBitDFUService.h"
|
||||
#include "MicroBitEventService.h"
|
||||
#include "MicroBitLEDService.h"
|
||||
#include "ExternalEvents.h"
|
||||
|
||||
// MicroBit::flags values
|
||||
|
@ -137,7 +137,7 @@ class MicroBit
|
|||
BLEDevice *ble;
|
||||
MicroBitDFUService *ble_firmware_update_service;
|
||||
MicroBitEventService *ble_event_service;
|
||||
|
||||
MicroBitLEDService *ble_led_service;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
|
@ -136,9 +136,23 @@
|
|||
// This enables the standard BLE device information service.
|
||||
// Set '1' to enable.
|
||||
#ifndef MICROBIT_BLE_DEVICE_INFORMATION_SERVICE
|
||||
#define MICROBIT_BLE_DEVICE_INFORMATION_SERVICE 1
|
||||
#define MICROBIT_BLE_DEVICE_INFORMATION_SERVICE 0
|
||||
#endif
|
||||
|
||||
|
||||
// Enable/Disable BLE Service: MicroBitLEDService
|
||||
// This enables the control and the LED matrix display via BLE.
|
||||
// Set '1' to enable.
|
||||
#ifndef MICROBIT_BLE_LED_SERVICE
|
||||
#define MICROBIT_BLE_LED_SERVICE 1
|
||||
#endif
|
||||
|
||||
|
||||
// Defines the maximum length strong that can be written to the
|
||||
// display over BLE.
|
||||
#ifndef MICROBIT_BLE_MAXIMUM_SCROLLTEXT
|
||||
#define MICROBIT_BLE_MAXIMUM_SCROLLTEXT 20
|
||||
#endif
|
||||
//
|
||||
// Accelerometer options
|
||||
//
|
||||
|
|
|
@ -28,6 +28,7 @@ set(YOTTA_AUTO_MICROBIT-DAL_CPP_FILES
|
|||
"MicroBitHeapAllocator.cpp"
|
||||
"ble-services/MicroBitDFUService.cpp"
|
||||
"ble-services/MicroBitEventService.cpp"
|
||||
"ble-services/MicroBitLEDService.cpp"
|
||||
)
|
||||
|
||||
if (YOTTA_CFG_MICROBIT_CONFIGFILE)
|
||||
|
|
|
@ -117,6 +117,10 @@ void MicroBit::init()
|
|||
ble_event_service = new MicroBitEventService(*ble);
|
||||
#endif
|
||||
|
||||
#if CONFIG_ENABLED(MICROBIT_BLE_LED_SERVICE)
|
||||
ble_led_service = new MicroBitLEDService(*ble);
|
||||
#endif
|
||||
|
||||
// Setup advertising.
|
||||
ble->accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
|
||||
ble->accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)MICROBIT_BLE_DEVICE_NAME, sizeof(MICROBIT_BLE_DEVICE_NAME));
|
||||
|
|
Loading…
Reference in a new issue