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.
Instead of PWM, basic digital output is used to control the RGB LED in the
bootLogo() and flashlight() functions. This reduces code size for sketches
which don't use the setRGBled() function. In bootLogo(), instead of dimming
the red LED, the red then green then blue LEDs are lit in sequence at full
brightness.
digitalWriteRGB() was added as a public function and is also used for the
changes above.
Checks if the "B" button is being held down when begin() is called.
If so, waits for other buttons to be pressed to control system functions.
Functions implemented:
"UP" button: Set "sound enabled" in EEPROM.
"DOWN" button: Set "sound disabled" (mute) in EEPROM.
Based on Arduboy library V1.2 development as of April 2, 2016
- Class Arduboy2 replaces class Arduboy.
- Removed files ab_printer.h and ab_printer.cpp. Integrated their
functionality into class Arduboy2 (as with Arduboy V1.1).
- Added new text functions:
- getCursorX(), getCursorY() to get the current cursor position.
- setTextColor(), setTextBackground() to allow inverted text
(black on white).
- clear() is overridden to set the cursor to 0, 0 in addition to clearing
the screen buffer.
- New Class: Arduboy2Base which contains most of the Arduboy functions and
is inherited by Arduboy2. It doesn't inherit Print, and doesn't include
text display and cursor control functions. Using it instead of Arduboy2,
in sketches that don't use text functions, frees up some code space.
- Function drawChar() is in Arduboy2 instead of Arduboy2Base.
- Made setRGBled() static. Not making it static was an oversight.
("Tunes" functions are still moved to the separate ArduboyPlaytune library,
as they were in Arduboy V1.2)
previosly timing was calculating the next frame based on now + duration
when the correct timing should have been last_frame + duration.
This would have the effect of slowing the game down the higher your CPU
usage. A 0% CPU usage game would play at the request frame rate,
but a 100% CPU usage game would play at only half the requested frame rate.
(RR is render time below)
Timing with the bug:
60FPs requested, 35FPs actual, 3 frames, 87ms.
| 29ms | 29ms | 29ms |
| RR 12ms + 17ms sleep | RR 12ms + 17ms sleep | RR 12ms + 17ms sleep |
Timing after the fix:
60FPs, 60FPs actual, 3 frames, 51ms.
| 17ms | 17ms | 17ms |
| RR 12ms + sleep | RR 12ms + sleep | RR 12ms + sleep |
After this fix you may need to change your games timing mechanics or
adjust your frame rate (to slow things back down). Your game will run
faster after this fix, even if you were using "100% CPU" before.
Scroll down "Arduboy" logo was removed because the library now
provides a similar logo.
setup() and loop() moved to the beginning of the code.
Minor changes and cleanup.