updates
Dependencies: BLE_API mbed-dev-bin nRF51822
Fork of microbit-dal-eddystone by
Revision 47:69f452b1a5c9, committed 2016-07-13
- Comitter:
- LancasterUniversity
- Date:
- Wed Jul 13 12:18:26 2016 +0100
- Parent:
- 46:c5bb7af0a3f0
- Child:
- 48:34d1adb6771c
- Commit message:
- Synchronized with git rev deac0341
Author: James Devine
microbit-dal: panic now accepts codes in the range 0 - 999 [issue #129 ]
Issue #129 illustrated that panic is capable of accepting numbers in
the range 0-999 and should therefore not have an arbitrary range of
0-255.
Additionally, this commit introduces gaps between consecutive numbers
of the same value e.g. 999. As a result, the speed of panic has also
been reduced.
Changed in this revision
inc/core/MicroBitDevice.h | Show annotated file Show diff for this revision Revisions of this file |
source/core/MicroBitDevice.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/inc/core/MicroBitDevice.h Wed Jul 13 12:18:25 2016 +0100 +++ b/inc/core/MicroBitDevice.h Wed Jul 13 12:18:26 2016 +0100 @@ -76,7 +76,7 @@ /** * Disables all interrupts and user processing. * Displays "=(" and an accompanying status code on the default display. - * @param statusCode the appropriate status code - 0 means no code will be displayed. Status codes must be in the range 0-255. + * @param statusCode the appropriate status code, must be in the range 0-999. * * @code * microbit_panic(20); @@ -133,4 +133,4 @@ */ void microbit_seed_random(uint32_t seed); -#endif +#endif \ No newline at end of file
--- a/source/core/MicroBitDevice.cpp Wed Jul 13 12:18:25 2016 +0100 +++ b/source/core/MicroBitDevice.cpp Wed Jul 13 12:18:26 2016 +0100 @@ -159,7 +159,7 @@ /** * Disables all interrupts and user processing. * Displays "=(" and an accompanying status code on the default display. - * @param statusCode the appropriate status code - 0 means no code will be displayed. Status codes must be in the range 0-255. + * @param statusCode the appropriate status code, must be in the range 0-999. * * @code * microbit_panic(20); @@ -186,19 +186,18 @@ PortOut LEDMatrix(Port0, row_mask | col_mask); - if(statusCode < 0 || statusCode > 255) + if(statusCode < 0 || statusCode > 999) statusCode = 0; __disable_irq(); //stop ALL interrupts //point to the font stored in Flash - const unsigned char * fontLocation = MicroBitFont::defaultFont; + const unsigned char* fontLocation = MicroBitFont::defaultFont; //get individual digits of status code, and place it into a single array/ const uint8_t* chars[MICROBIT_PANIC_ERROR_CHARS] = { panicFace, fontLocation+((((statusCode/100 % 10)+48)-MICROBIT_FONT_ASCII_START) * 5), fontLocation+((((statusCode/10 % 10)+48)-MICROBIT_FONT_ASCII_START) * 5), fontLocation+((((statusCode % 10)+48)-MICROBIT_FONT_ASCII_START) * 5)}; - //enter infinite loop. while(count) { //iterate through our chars :) @@ -234,10 +233,13 @@ col_data = ~col_data << microbitMatrixMap.columnStart & col_mask; - LEDMatrix = col_data | row_data; + if(chars[characterCount] == chars[(characterCount - 1) % MICROBIT_PANIC_ERROR_CHARS] && outerCount < 50) + LEDMatrix = 0; + else + LEDMatrix = col_data | row_data; //burn cycles - i = 1000; + i = 2000; while(i>0) { // Check if the reset button has been pressed. Interrupts are disabled, so the normal method can't be relied upon... @@ -372,4 +374,4 @@ void microbit_seed_random(uint32_t seed) { random_value = seed; -} +} \ No newline at end of file