The major version number has been incremented only because there's a
chance that a sketch that sets text wrap on will behave differently,
due to the changes in the way wrapping is now handled.
The variables currentButtonState and previousButtonState used by
pollButtons(), justPressed() and justReleased() have been made public.
This allows them to be manipulated if circumstances require it.
The documentation added for previousButtonState includes an example.
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 @yyyc514 (Josh Goebel)
The generateRandomSeed() function was moved from the Arduboy2Base class
to the Arduboy2Core class, since it deals directly with hardware.
It was also made static.
Some related documentation was changed.
Issues discovered and fixes developed by @Pharap
The Sprites classes relied on the behavior of 16 bit integer arithmetic
for operations that cause an overflow; specifically (ofs + WIDTH)
calculations for an index into the screen buffer. This would cause
problems if the code was ported to an environment in which the basic
integer type (i.e. "int") is larger than 16 bits.
Also, there was code that assumed little endianness for a technique
used to retrieve the high byte a 16 bit value. This would cause
problems if the code was ported to a big endian architecture.
The changes made are strictly for the sake of improved portability and
better programming practices. They don’t affect code compiled for the
Arduboy in any way.
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.
Changed the writeUnitName() parameter from
"char* name" to "const char* name".
This will prevent warnings or errors when a string literal or
an array of type "const char" is passed to it.
The lcdBootProgram[] array, containing the commands to initialize
the OLED display, isn't considered to be part of the API.
To enforce this, and to avoid the possibility of conflicts from
other code using the same name, it has been changed from being a
global variable to a protected member of the Arduboy2Core class.
Suggested and developed by @Pharap
The mainNoUSB() function was never intended to be used directly in
sketches. To help prevent this, it has been made a private member of
a new class, Arduboy2NoUSB, which declares main() as a friend.
The ARDUBOY_NO_USB macro has been modified appropriately.
The Arduboy2Core class now inherits Arduboy2NoUSB, for sketches that
improperly have their own main() which calls the old version of
mainNoUSB() instead of using the ARDUBOY_NO_USB macro.
Also added file sample.png in the cabi directory, which is used
for the example sketch in the Cabi README.md file
Also added a note referring to Cabi in the documentation for
drawCompressed()
Macro defines for system EEPROM access that were not intended to be
part of the API have been made into protected constexpr variables of
the Arduboy2Base class.
Issue reported by @MrBlinky
For drawBitmap(), drawSlowXYBitmap() and drawCompressed() the initial
check for the bitmap being entirely off screen would sometimes consider
a bitmap to be partially on screen when it is only one pixel above or
to the left of the screen. This would result in unnecessarily doing the
work to draw the bitmap when none of it would be visible.
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
Problem:
The overloading of `Print::write` was previously causing the other
overloads of `write` to be hidden.
For more information on this behaviour, see the following
StackOverflow question:
https://stackoverflow.com/questions/1628768
Solution:
The solution uses a `using`-declaration to bring the `Print::write`
overloads into `Arduboy2`'s scope.
For more information on this usage of a `using`-declaration, see the
following cppreference page:
https://en.cppreference.com/w/cpp/language/using_declaration#In_class_definition
The new compiler in Arduino IDE 1.8.6/1.8.7 has an optimization glitch
where it fails to see the difference between a data structure in RAM
and in PROGMEM when the data is the same and optimizes one out.
drawPixel() is unable to fetch the correct pixel mask from the
bitshift_left array in PROGMEM causing junk to be drawn.
The bitshift_left[] array has now been optimised out and drawPixel()
will function properly. The optimization uses the same number of cycles
and saves 6 bytes.
drawPixel() has also been made static so the Arduboy object pointer is
no longer needlesly passed on to drawPixel() saving more bytes.
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.