From a6ab0e6c1b29533ffab6e5551d5e730c40d1e06d Mon Sep 17 00:00:00 2001 From: Sam Kent <32453267+microbit-sam@users.noreply.github.com> Date: Fri, 4 May 2018 14:46:40 +0100 Subject: [PATCH] Added Partial Flashing (#1) * Enter BLE mode using a MicroBitEvent * Using Key/Value store rather than GPREGRET for Hard Reset persistance * Skip timeout * Updated tag * Updated tag * Updated tag * Updated tag * Removed Listener * Updated animation * Updated tag * Updated tag * Updated tag * Updated tag * Changed animation timing * Updated tag * Updated tag * Updated tag * Updated animation timing * Added incomplete flash flag * Updated tag * Removed Event Listener from MicroBit.h --- module.json | 2 +- source/MicroBit.cpp | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/module.json b/module.json index 8746791..5f56861 100644 --- a/module.json +++ b/module.json @@ -4,7 +4,7 @@ "description": "A simple to use collection of the most commonly used components in the micro:bit runtime", "license": "MIT", "dependencies": { - "microbit-dal": "lancaster-university/microbit-dal#v2.0.0-rc10" + "microbit-dal": "microbit-sam/microbit-dal#pf_v0.2.4" }, "extraIncludes": [ "inc" diff --git a/source/MicroBit.cpp b/source/MicroBit.cpp index 45fece1..39e8e32 100644 --- a/source/MicroBit.cpp +++ b/source/MicroBit.cpp @@ -130,16 +130,33 @@ void MicroBit::init() status |= MICROBIT_INITIALIZED; #if CONFIG_ENABLED(MICROBIT_BLE_PAIRING_MODE) - // Test if we need to enter BLE pairing mode... int i=0; + // Test if we need to enter BLE pairing mode + // If a BLEMode Key has been set boot straight into BLE mode + KeyValuePair* BLEMode = storage.get("BLEMode"); + KeyValuePair* flashIncomplete = storage.get("flashIncomplete"); sleep(100); - while (buttonA.isPressed() && buttonB.isPressed() && i<10) + // Animation + uint8_t x = 0; uint8_t y = 0; + while ((buttonA.isPressed() && buttonB.isPressed() && i<25) || BLEMode != NULL || flashIncomplete != NULL) { - sleep(100); - i++; + display.image.setPixelValue(x,y,255); + sleep(50); + i++; x++; - if (i == 10) + // Gradually fill screen + if(x == 5){ + y++; x = 0; + } + + if (i == 25 || BLEMode != NULL) { + // Remove KV if it exists + if(BLEMode != NULL){ + storage.remove("BLEMode"); + delete BLEMode; + } + #if CONFIG_ENABLED(MICROBIT_HEAP_ALLOCATOR) && CONFIG_ENABLED(MICROBIT_HEAP_REUSE_SD) microbit_create_heap(MICROBIT_SD_GATT_TABLE_START + MICROBIT_SD_GATT_TABLE_SIZE, MICROBIT_SD_LIMIT); #endif