From 3fa9bb09c262a235b18c222e0fb2fb66e6c00362 Mon Sep 17 00:00:00 2001 From: James Devine Date: Tue, 2 Feb 2016 01:13:39 +0000 Subject: [PATCH] microbit: fixed an off by 10 bug Missed a zero in a previous commit, that caused a system lockup due to a missed timer event. This commit also changes the minimum display brightness to 4, to also minimise another feature that needs fixing in the future, where the timer does not interrupt in the expected time frame. --- inc/MicroBitConfig.h | 2 +- source/MicroBitDisplay.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/MicroBitConfig.h b/inc/MicroBitConfig.h index 64757bc..6292d5a 100644 --- a/inc/MicroBitConfig.h +++ b/inc/MicroBitConfig.h @@ -261,8 +261,8 @@ // Selects the minimum permissable brightness level for the device // in the region of 0 (off) to 255 (full brightness) -#define MICROBIT_DISPLAY_MINIMUM_BRIGHTNESS 2 #ifndef MICROBIT_DISPLAY_MINIMUM_BRIGHTNESS +#define MICROBIT_DISPLAY_MINIMUM_BRIGHTNESS 4 #endif // Selects the maximum permissable brightness level for the device diff --git a/source/MicroBitDisplay.cpp b/source/MicroBitDisplay.cpp index 48c93d2..b62c46f 100644 --- a/source/MicroBitDisplay.cpp +++ b/source/MicroBitDisplay.cpp @@ -147,7 +147,7 @@ void MicroBitDisplay::render() //timer does not have enough resolution for brightness of 1. 23.53 us if(brightness != MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS && brightness > MICROBIT_DISPLAY_MINIMUM_BRIGHTNESS) - renderTimer.attach_us(this, &MicroBitDisplay::renderFinish, (((brightness * 100) / (MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS)) * uBit.getTickPeriod())); + renderTimer.attach_us(this, &MicroBitDisplay::renderFinish, (((brightness * 1000) / (MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS)) * uBit.getTickPeriod())); //this will take around 23us to execute if(brightness <= MICROBIT_DISPLAY_MINIMUM_BRIGHTNESS)