microbit-samples: neatened up warning on event handlers.

This commit is contained in:
Devine 2016-08-04 15:14:40 +01:00
parent 549648d2f4
commit b573c615b1
2 changed files with 23 additions and 24 deletions

View File

@ -28,12 +28,12 @@ DEALINGS IN THE SOFTWARE.
MicroBit uBit;
// we use events abd the 'connected' variable to keep track of the status of the Bluetooth connection
void onConnected(MicroBitEvent e)
void onConnected(MicroBitEvent)
{
uBit.display.print("C");
}
void onDisconnected(MicroBitEvent e)
void onDisconnected(MicroBitEvent)
{
uBit.display.print("D");
}
@ -56,12 +56,12 @@ int main()
// "tx_power": 7, // Transmission power of the Bluetooth radio. A value of 0 - 7 with 0 the lowest power and 7 the highest power.
// "gatt_table_size": "0x700" // Amount of memory (in hex bytes) set aside for the Bluetooth GATT table
// "nested_heap_proportion": 0.75, // Reducing this can sometimes help make enough memory available for all the Bluetooth services you want. Only experiment with this as a last resort.
// MicrobitConfig.h in yotta_modules\microbit-dal\inc\core contains MICROBIT_BLE_SECURITY_LEVEL which can be set to SECURITY_MODE_ENCRYPTION_WITH_MITM for passkey authentication when
// pairing or SECURITY_MODE_ENCRYPTION_NO_MITM to use Just Works pairing.
// A cunning code to indicate during start-up the particular Bluetooth configuration in the build
//
//
// SERVICE CODES
// A: Accelerometer Service
// B: Button Service
@ -76,15 +76,15 @@ int main()
//
// PAIRING CONFIG
// Note that switching pairing on or off is achieved by setting "open" in config.json to 1 or 0 respectively
// P: PASSKEY
// J: Just Works
// N: No Pairing Required
//
// TX Power Level
// 0-7 taken from tx_power in config.json
// 0-7 taken from tx_power in config.json
// Services/Pairing Config/Power Level
uBit.display.scroll("BLE ABDILMT/P/0");
@ -95,12 +95,11 @@ int main()
new MicroBitButtonService(*uBit.ble);
new MicroBitIOPinService(*uBit.ble, uBit.io);
new MicroBitLEDService(*uBit.ble, uBit.display);
new MicroBitMagnetometerService(*uBit.ble, uBit.compass);
new MicroBitMagnetometerService(*uBit.ble, uBit.compass);
new MicroBitTemperatureService(*uBit.ble, uBit.thermometer);
// If main exits, there may still be other fibers running or registered event handlers etc.
// Simply release this fiber, which will mean we enter the scheduler. Worse case, we then
// sit in the idle task forever, in a power efficient sleep.
release_fiber();
}

View File

@ -34,30 +34,30 @@ MicroBitUARTService *uart;
int connected = 0;
void onConnected(MicroBitEvent e)
void onConnected(MicroBitEvent)
{
uBit.display.scroll("C");
connected = 1;
// mobile app will send ASCII strings terminated with the colon character
ManagedString eom(":");
while(1) {
ManagedString msg = uart->readUntil(eom);
uBit.display.scroll(msg);
}
}
void onDisconnected(MicroBitEvent e)
void onDisconnected(MicroBitEvent)
{
uBit.display.scroll("D");
connected = 0;
}
void onButtonA(MicroBitEvent e)
void onButtonA(MicroBitEvent)
{
if (connected == 0) {
return;
@ -66,7 +66,7 @@ void onButtonA(MicroBitEvent e)
uBit.display.scroll("Y");
}
void onButtonB(MicroBitEvent e)
void onButtonB(MicroBitEvent)
{
if (connected == 0) {
return;
@ -75,7 +75,7 @@ void onButtonB(MicroBitEvent e)
uBit.display.scroll("N");
}
void onButtonAB(MicroBitEvent e)
void onButtonAB(MicroBitEvent)
{
if (connected == 0) {
return;
@ -95,10 +95,10 @@ int main()
uBit.messageBus.listen(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, onButtonB);
uBit.messageBus.listen(MICROBIT_ID_BUTTON_AB, MICROBIT_BUTTON_EVT_CLICK, onButtonAB);
// Note GATT table size increased from default in MicroBitConfig.h
// #define MICROBIT_SD_GATT_TABLE_SIZE 0x500
uart = new MicroBitUARTService(*uBit.ble, 32, 32);
uart = new MicroBitUARTService(*uBit.ble, 32, 32);
uBit.display.scroll("UART ready");
// If main exits, there may still be other fibers running or registered event handlers etc.