This is mainly to reduce code size.
The write() function in class Arduboy2 has to remain virtual,
so functions that result in it eventually being called could
not be made static.
The members of the Point and Rect structures could not be made static
due to their intended use as having multiple instances.
Also to reduce code size, bootLogoExtra() was made non-virtual.
This meant that the begin() and bootLogo...() functions in the
Arduboy2Base class had to have duplicate or equivalent functions
added to the Arduboy2 class.
Related documentation was updated and some minor changes were made to
non-related documentation.
- Functions write() and drawChar() were refactored for smaller code
size and to make text wrapping operate more like what would normally
be expected.
- A new flag variable, textRaw, has been added, along with functions
setTextRawMode() and getTextRawMode() to set and read it.
When set, the write() function will render the value \n (0x0a) as
an "inverse white circle" instead of handling it as a newline and
render value \r (0x0d) as a "musical eighth note" instead of
ignoring it.
- Spacing added at the end of each character is no longer factored in
when determining if a character will fit on screen at the end of
a line.
- Checking if line wrap is neccessary is done before drawing a
character, instead of doing it after drawing to prepare for the
next character. This fixed a problem with requested line feeds
interacting with wrapping, resulting in unexpected blank lines.
- Fixed a bug that caused the drawing of characters with a transparent
background to not work properly. (This is selected by setting the
background color to be the same as the text color.)
- Added new functions getCharacterWidth() getCharacterHeight()
getCharacterSpacing() getLineSpacing() to programmatically get
the dimensions of a character, given the desired text size.
- Functions write() and drawChar() are now able to render a font of
any character size, and with any character and line spacing, by
setting variables characterWidth characterHeight characterSpacing
and lineSpacing, and providing a matching font array. This doesn't
affect their use with this library but has been done for the sake
of code portability.
Suggested by @MrBlinky
Same as SPItransfer() but also returns the byte received.
Provided for use with homemade or expanded units that have had
additional peripherals added to the SPI bus that are capable of
sending data.
Includes some suggestions and guidance by @Pharap
API:
- Rename non-API function swap() to swapInt16()
- Make swapInt16(), drawCircleHelper(), fillCircleHelper() and
struct BitStreamReader protected members of Arduboy2Base
- Add #define ARDUBOY_UNIT_NAME_BUFFER_SIZE for the size of a buffer
to hold a Unit Name
- Move the position of the PROGMEM keyword for lcdBootProgram[]
for consistency
Documentation:
- Remove absolute values referring to a Unit Name
- More details relating to the use of the Unit Name
- More details relating to the font and text functions
- Other minor documentation changes and spelling corrections
The call to generateRandomSeed() in initRandomSeed() was missing
parentheses.
Added keyword for generateRandomSeed.
Minor code changes, and documentation changes and additions.
Flag SYS_FLAG_SHOW_LOGO_LEDS added to EEPROM_SYS_FLAGS.
The boot logo functions check the flag and leave the RGB LED off if
the flag isn't set.
Added functions writeShowBootLogoLEDsFlag() and
readShowBootLogoLEDsFlag() for writing and reading the
SYS_FLAG_SHOW_LOGO_LEDS flag.
Example sketch SetSystemEEPROM modified to allow setting the
SYS_FLAG_SHOW_LOGO_LEDS flag.
Flag SYS_FLAG_SHOW_LOGO added to EEPROM_SYS_FLAGS. The boot logo
functions check the flag and bypass the logo sequence if the flag
isn't set.
Added functions writeShowBootLogoFlag() and readShowBootLogoFlag()
for writing and reading the SYS_FLAG_SHOW_LOGO flag.
Renamed example sketch SetNameAndID to SetSystemEEPROM and added
the ability to set the SYS_FLAG_SHOW_LOGO flag, plus menus to reset
the system and user EEPROM areas.
The SpritesB class has functions identical to those in Sprites.
When used in place of Sprites it will usually reduce code size (at the
expense of slower execution speed). Code size reduction is accomplished
by factoring all draw modes into the same loop.
Modifications made to the Sprites class to create this class made by
@dxxb (Delio Brignoli).
Creation of the SpritesB class and documentation by
@MLXXXp (Scott Allen).
Also, bootLogoSpritesBSelfMasked() and bootLogoSpritesBOverwrite()
alternative boot logo functions added by @MLXXXp.
Macro ARDUBOY_NO_USB will provide a substitute main() which will cause
the compiler to leave out the USB code. The macro also adds a check
for the DOWN button being pressed and, if so, will call the new
exitToBootloader() function.
New function exitToBootloader() will invoke the bootloader in command
mode, similar to pressing reset.
- setRGBled() has been rewritten to directly control the hardware
instead of using the Arduino analogWrite() function.
- Added a two parameter version of setRGBled() that sets the brightness
of one LED without affecting the others.
- Added function freeRGBled() for freeing the PWM control of the LEDs
so they can be used digitally.
- Added example sketch RGBled.
New function waitNoButtons() replaces the code at the end of begin()
that waits for all buttons to be released. This is to make it easier
to add back this functionality when using boot() in place of begin().
Same as Arduino delay() except takes a 16 bit value.
Mainly added to save some code in the library but can be used by
sketches for the same purpose.
Also changed a delay in bootLogoText() to match a previous change in
bootLogo()
displayOff() puts the display in low power mode.
displayOn() re-initializes the display after displayOff() is used.
The SPI initialization code was separated from the display
initialization code to facilitate the new functions.
New functions bootLogoCompressed(), bootLogoSpritesSelfMasked() and
bootLogoSpritesOverwrite() can be used in place of bootLogo() to
reduce code size in cases where their drawing functions are shared
with the same functions used by the sketch.
New function bootLogoShell() added to provide common code for the
above functions.
Also, the Sprites class functions, and functions used for drawing the
logos, were made static.
- Added a flag in system EEPROM to indicate if the unit name
should be displayed at the end of the boot logo sequence.
Function bootLogoExtra() displays the unit name only if the
flag is set.
- Added functions writeShowUnitNameFlag() and readShowUnitNameFlag()
to write and read the "Show Unit Name" flag in EEPROM.
- Enhanced the SetNameAndID example sketch to allow setting the
"Show Unit Name" flag in EEPROM.
- Timer 0 is disabled in flashlight() and safeMode() in case its
variables overlap the bootloader "magic key" location.
- Flashlight mode never exits if invoked.
- Made safeMode() public for use as a smaller code size alternative
to flashlight().
This eliminates calls to pinMode(), digitalWrite(), functions to
initialize hardware, etc.
New 2 parameter version of digitalWriteRGB() added, which sets an
individual RGB LED on or off digitally.
New function SPItransfer() added to replace Arduino SPI.transfer().
Also:
- Changes to show the unit name on the boot logo screen
- Added new example sketch SetNameAndID to allow setting the name and ID
- Updated the LICENSE.txt file and made changes to include it in the
Doxygen generated documentation
The Sprites class has been given direct access to the screen buffer so it
doesn't need a pointer to been given to it.
Also updated README.md and keywords.txt, and made minor indent changes in
the .h files.