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:
parent
58d24ab0a8
commit
0fec4ae87c
|
@ -658,13 +658,10 @@ void MicroBitDisplay::animate(MicroBitImage image, int delay, int stride, int st
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
void MicroBitDisplay::setBrightness(int b)
|
void MicroBitDisplay::setBrightness(int b)
|
||||||
{
|
{
|
||||||
//sanitise the brightness level
|
//sanitise the brightness level
|
||||||
if(b < 0)
|
if(b < 0 || b > 255)
|
||||||
b = 0;
|
return;
|
||||||
|
|
||||||
if (b > 255)
|
|
||||||
b = 255;
|
|
||||||
|
|
||||||
this->brightness = b;
|
this->brightness = b;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue