From f7915cd0a914afca16a20d6aa2fbda3734357c45 Mon Sep 17 00:00:00 2001 From: Scott Allen Date: Wed, 15 Jun 2016 13:25:57 -0400 Subject: [PATCH] Turn on all display pixels in "flashlight" mode Mainly to give an indication that the device is in "flashlight" mode for units that have the RGB LED installed reversed. Also, the test for the UP button is moved to within flashlight() itself. --- src/Arduboy2.cpp | 14 +++++++++----- src/Arduboy2.h | 9 +++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Arduboy2.cpp b/src/Arduboy2.cpp index c59c5c1..7d750a7 100644 --- a/src/Arduboy2.cpp +++ b/src/Arduboy2.cpp @@ -33,10 +33,7 @@ void Arduboy2Base::begin() blank(); // blank the display - // utils - if(pressed(UP_BUTTON)) { - flashlight(); - } + flashlight(); // light the RGB LED and screen if UP button is being held. // check for and handle buttons held during start up for system control systemButtons(); @@ -48,12 +45,19 @@ void Arduboy2Base::begin() void Arduboy2Base::flashlight() { - // sendLCDCommand(OLED_ALL_PIXELS_ON); // smaller than allPixelsOn() + if(!pressed(UP_BUTTON)) { + return; + } + + sendLCDCommand(OLED_ALL_PIXELS_ON); // smaller than allPixelsOn() digitalWriteRGB(RGB_ON, RGB_ON, RGB_ON); + while(!pressed(DOWN_BUTTON)) { idle(); } + digitalWriteRGB(RGB_OFF, RGB_OFF, RGB_OFF); + sendLCDCommand(OLED_PIXELS_FROM_RAM); } void Arduboy2Base::systemButtons() { diff --git a/src/Arduboy2.h b/src/Arduboy2.h index 747e1cc..cc34837 100644 --- a/src/Arduboy2.h +++ b/src/Arduboy2.h @@ -74,10 +74,11 @@ public: /// Flashlight mode /** - * Hold up key when booting to enable, press down key to exit - * or simply turn off your Arduboy. Your sketches can also - * call this at any time. It goes into a tight loop until the - * down buttn is pressed. + * Turn the RGB LED and screen fully on. Called in the begin() function. + * + * Hold the UP button when booting to enable. Press the DOWN button to exit + * or simply turn off your Arduboy. It goes into a tight loop until the + * DOWN button is pressed. */ void flashlight();