Arduboy2 library version 5.0.0 has been released and is available through the Arduino Library Manager.
As usual, one main goal was to make more code space available to sketches.
- Classes BeepPin1 and BeepPin2 added. These can be used to play simple tones on the speaker. They are very code efficient.
- New example sketch BeepDemo demonstrates the use of the BeepPin classes.
- Class SpritesB added as an alternative to Sprites. This class has the same functions as Sprites but will produce less code in many cases (at the expense of slower execution speed). Thanks, @dxb (Delio Brignoli)
- The ability to eliminate the USB code that is normally included in the Arduino environment. This will free up a significant amount of code space but will require the user to do a manual reset in order to upload a new sketch. Thanks, @Dreamer3 (Josh Goebel) for the concept.
- The ability to set a flag in system EEPROM that will bypass the boot logo sequence and go straight to the sketch. New functions writeShowBootLogoFlag() and readShowBootLogoFlag() allow setting and reading this the flag.
- Example sketch SetNameAndID has been renamed to SetSystemEEPROM. The ability to set the “show boot logo” flag has been added to it. It can now also be used to erase the entire system EEPROM or user EEPROM areas.
- A new 2 parameter version of setRGBled() allows setting an individual RGB LED, given the color and brightness.
- New function freeRGBled(). Using setRGBled() will take over the RGB LED pins so that digitalWriteRGB() will no longer work. Calling freeRGBled() will restore the pins for use by digitalWriteRGB().
- New example sketch RGBled demonstrates the use of the RGB LED in both digital and analog modes.
- New function setFrameDuration() can set the frame rate as the time per frame (in milliseconds), as an alternative to using setFrameRate() to set the frame rate in frames per second.
- The loop at the end of the begin() function that waits for all buttons to be released has been replaced by function waitNoButtons(). This is to make it easier to add the functionality back in if boot() is used instead of begin().
Fixed a problem in the Sprites drawPlusMask() function that sometimes caused bitmaps to be drawn improperly. Thanks, @Dreamer3 (Josh Goebel)
The speed that the boot logo scrolls down has been increased, so that the actual sketch code begins faster.
The ArduBreakout example sketch has been modified to use the BeepPin1 class instead of Arduino tone().
Functions that have been refactored to optimize for size and usually speed:
paintScreen(), which is used by display(), has been re-written in assembler. Thanks, @Mr.Blinky and @veritazz (Michael Gollnick)
setRGBled() directly controls the hardware, instead of using the Arduino analogWrite() function.
bootLogoShell() and bootLogoText()
drawCompressed(). Thanks, @Pharap and @Mr.Blinky
buttonsState(). Thanks, @Mr.Blinky
begin() (by using display() instead of blank() to clear the display).
Minor clarifications and corrections to previous README.md and Doxygen documentation, plus:
- Thanks, @eried (Erwin Ried) for correcting a typo in the everyXFrames() example code.
- Added info on sketch EEPROM use to README.md
- Changed characters used for Sprites examples to make them more readable.
Some of the code savings available by using this release:
Just recompiling an existing sketch using this new release will reduce code size. Based on testing, typical savings will be about 150 bytes, compared to version 4.1.0, but it could be more or less depending on library functions that the sketch uses.
If a sketch uses more than one of the Sprites class functions, switching to SpritesB will save about 360 bytes, as long as the slower rendering speed of SpritesB is acceptable.
Sketches that currently use the setRGBled() function will see a significant reduction in code size, on the order of hundreds of bytes.
Removing the USB code will save about 2700 bytes or more but you should carefully consider if you need to do this, due to the inconvenience and possible frustration it can cause users because of the requirement to manually reset the Arduboy in order to upload a new sketch. Also, it’s recommended that some of the code freed up be used to add a menu item or prompt that allows the user to perform a reset using the DOWN button (by calling the new exitToBootloader() function).