microbit: BUGFIX - Input validation in MicroBitDisplay::setBrightness()

Updates to MicroBitDisplay::setBrightness() to perform a NOP for out of bound parameters.
This aligns the functionality of the runtime with the TD simulator.
This commit is contained in:
Joe Finney 2015-08-19 23:36:17 +01:00
parent 58d24ab0a8
commit 0fec4ae87c
1 changed files with 3 additions and 6 deletions

View File

@ -658,13 +658,10 @@ void MicroBitDisplay::animate(MicroBitImage image, int delay, int stride, int st
* @endcode
*/
void MicroBitDisplay::setBrightness(int b)
{
{
//sanitise the brightness level
if(b < 0)
b = 0;
if (b > 255)
b = 255;
if(b < 0 || b > 255)
return;
this->brightness = b;
}