Arduboy2 Library
6.0.0
|
The main functions provided for writing sketches for the Arduboy, including text output. More...
#include <Arduboy2.h>
Public Member Functions | |
void | begin () |
Initialize the hardware, display the boot logo, provide boot utilities, etc. More... | |
void | bootLogo () |
Display the boot logo sequence using drawBitmap() . More... | |
void | bootLogoCompressed () |
Display the boot logo sequence using drawCompressed() . More... | |
void | bootLogoSpritesSelfMasked () |
Display the boot logo sequence using Sprites::drawSelfMasked() . More... | |
void | bootLogoSpritesOverwrite () |
Display the boot logo sequence using Sprites::drawOverwrite() . More... | |
void | bootLogoSpritesBSelfMasked () |
Display the boot logo sequence using SpritesB::drawSelfMasked() . More... | |
void | bootLogoSpritesBOverwrite () |
Display the boot logo sequence using SpritesB::drawOverwrite() . More... | |
void | bootLogoText () |
Display the boot logo sequence using printed text instead of a bitmap. More... | |
void | bootLogoExtra () |
Show the unit name at the bottom of the boot logo screen. More... | |
virtual size_t | write (uint8_t) |
Write a single character at the current text cursor position. More... | |
Static Public Member Functions | |
static void | drawChar (int16_t x, int16_t y, uint8_t c, uint8_t color, uint8_t bg, uint8_t size) |
Draw a single character at the specified location in the screen buffer. More... | |
static void | setCursor (int16_t x, int16_t y) |
Set the location of the text cursor. More... | |
static void | setCursorX (int16_t x) |
Set the X coordinate of the text cursor location. More... | |
static void | setCursorY (int16_t y) |
Set the Y coordinate of the text cursor location. More... | |
static int16_t | getCursorX () |
Get the X coordinate of the current text cursor position. More... | |
static int16_t | getCursorY () |
Get the Y coordinate of the current text cursor position. More... | |
static void | setTextColor (uint8_t color) |
Set the text foreground color. More... | |
static uint8_t | getTextColor () |
Get the currently set text foreground color. More... | |
static void | setTextBackground (uint8_t bg) |
Set the text background color. More... | |
static uint8_t | getTextBackground () |
Get the currently set text background color. More... | |
static void | setTextSize (uint8_t s) |
Set the text character size. More... | |
static uint8_t | getTextSize () |
Get the currently set text size. More... | |
static void | setTextWrap (bool w) |
Set or disable text wrap mode. More... | |
static bool | getTextWrap () |
Get the currently set text wrap mode. More... | |
static void | setTextRawMode (bool raw) |
Set or disable text raw mode, allowing special characters to be displayed. More... | |
static bool | getTextRawMode () |
Get the current state of text raw mode. More... | |
static void | clear () |
Clear the display buffer and set the text cursor to location 0, 0. | |
static constexpr uint8_t | getCharacterWidth (uint8_t textSize=1) |
Get the width, in pixels, of a character in the library's font. More... | |
static constexpr uint8_t | getCharacterSpacing (uint8_t textSize=1) |
Get the number of pixels added after each character to provide spacing. More... | |
static constexpr uint8_t | getCharacterHeight (uint8_t textSize=1) |
Get the height, in pixels, of a character in the library's font. More... | |
static constexpr uint8_t | getLineSpacing (uint8_t textSize=1) |
Get the number of pixels added below each character to provide line spacing. More... | |
static void | beginDoFirst () |
Helper function that calls the inital functions used by begin() More... | |
static void | flashlight () |
Turn the RGB LED and display fully on to act as a small flashlight/torch. More... | |
static void | systemButtons () |
Handle buttons held on startup for system control. More... | |
static bool | bootLogoShell (void(&drawLogo)(int16_t)) |
Display the boot logo sequence using the provided function. More... | |
static void | waitNoButtons () |
Wait until all buttons have been released. More... | |
static void | fillScreen (uint8_t color=WHITE) |
Fill the screen buffer with the specified color. More... | |
static void | display () |
Copy the contents of the display buffer to the display. More... | |
static void | display (bool clear) |
Copy the contents of the display buffer to the display. The display buffer can optionally be cleared. More... | |
static void | drawPixel (int16_t x, int16_t y, uint8_t color=WHITE) |
Set a single pixel in the display buffer to the specified color. More... | |
static uint8_t | getPixel (uint8_t x, uint8_t y) |
Returns the state of the given pixel in the screen buffer. More... | |
static void | drawCircle (int16_t x0, int16_t y0, uint8_t r, uint8_t color=WHITE) |
Draw a circle of a given radius. More... | |
static void | fillCircle (int16_t x0, int16_t y0, uint8_t r, uint8_t color=WHITE) |
Draw a filled-in circle of a given radius. More... | |
static void | drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint8_t color=WHITE) |
Draw a line between two specified points. More... | |
static void | drawFastVLine (int16_t x, int16_t y, uint8_t h, uint8_t color=WHITE) |
Draw a vertical line. More... | |
static void | drawFastHLine (int16_t x, int16_t y, uint8_t w, uint8_t color=WHITE) |
Draw a horizontal line. More... | |
static void | drawRect (int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t color=WHITE) |
Draw a rectangle of a specified width and height. More... | |
static void | fillRect (int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t color=WHITE) |
Draw a filled-in rectangle of a specified width and height. More... | |
static void | drawRoundRect (int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t r, uint8_t color=WHITE) |
Draw a rectangle with rounded corners. More... | |
static void | fillRoundRect (int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t r, uint8_t color=WHITE) |
Draw a filled-in rectangle with rounded corners. More... | |
static void | drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color=WHITE) |
Draw a triangle given the coordinates of each corner. More... | |
static void | fillTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color=WHITE) |
Draw a filled-in triangle given the coordinates of each corner. More... | |
static void | drawBitmap (int16_t x, int16_t y, const uint8_t *bitmap, uint8_t w, uint8_t h, uint8_t color=WHITE) |
Draw a bitmap from an array in program memory. More... | |
static void | drawSlowXYBitmap (int16_t x, int16_t y, const uint8_t *bitmap, uint8_t w, uint8_t h, uint8_t color=WHITE) |
Draw a bitmap from a horizontally oriented array in program memory. More... | |
static void | drawCompressed (int16_t sx, int16_t sy, const uint8_t *bitmap, uint8_t color=WHITE) |
Draw a bitmap from an array of compressed data. More... | |
static uint8_t * | getBuffer () |
Get a pointer to the display buffer in RAM. More... | |
static void | initRandomSeed () |
Seed the random number generator with a random value. More... | |
static void | setFrameRate (uint8_t rate) |
Set the frame rate used by the frame control functions. More... | |
static void | setFrameDuration (uint8_t duration) |
Set the frame rate, used by the frame control functions, by giving the duration of each frame. More... | |
static bool | nextFrame () |
Indicate that it's time to render the next frame. More... | |
static bool | nextFrameDEV () |
Indicate that it's time to render the next frame, and visually indicate if the code is running slower than the desired frame rate. FOR USE DURING DEVELOPMENT More... | |
static bool | everyXFrames (uint8_t frames) |
Indicate if the specified number of frames has elapsed. More... | |
static int | cpuLoad () |
Return the load on the CPU as a percentage. More... | |
static bool | pressed (uint8_t buttons) |
Test if the all of the specified buttons are pressed. More... | |
static bool | anyPressed (uint8_t buttons) |
Test if any of the specified buttons are pressed. More... | |
static bool | notPressed (uint8_t buttons) |
Test if the specified buttons are not pressed. More... | |
static void | pollButtons () |
Poll the buttons and track their state over time. More... | |
static bool | justPressed (uint8_t button) |
Check if a button has just been pressed. More... | |
static bool | justReleased (uint8_t button) |
Check if a button has just been released. More... | |
static bool | collide (Point point, Rect rect) |
Test if a point falls within a rectangle. More... | |
static bool | collide (Rect rect1, Rect rect2) |
Test if a rectangle is intersecting with another rectangle. More... | |
static uint16_t | readUnitID () |
Read the unit ID from system EEPROM. More... | |
static void | writeUnitID (uint16_t id) |
Write a unit ID to system EEPROM. More... | |
static uint8_t | readUnitName (char *name) |
Read the unit name from system EEPROM. More... | |
static void | writeUnitName (const char *name) |
Write a unit name to system EEPROM. More... | |
static bool | readShowBootLogoFlag () |
Read the "Show Boot Logo" flag in system EEPROM. More... | |
static void | writeShowBootLogoFlag (bool val) |
Write the "Show Boot Logo" flag in system EEPROM. More... | |
static bool | readShowUnitNameFlag () |
Read the "Show Unit Name" flag in system EEPROM. More... | |
static void | writeShowUnitNameFlag (bool val) |
Write the "Show Unit Name" flag in system EEPROM. More... | |
static bool | readShowBootLogoLEDsFlag () |
Read the "Show LEDs with boot logo" flag in system EEPROM. More... | |
static void | writeShowBootLogoLEDsFlag (bool val) |
Write the "Show LEDs with boot logo" flag in system EEPROM. More... | |
static void | idle () |
Idle the CPU to save power. More... | |
static void | LCDDataMode () |
Put the display into data mode. More... | |
static void | LCDCommandMode () |
Put the display into command mode. More... | |
static void | SPItransfer (uint8_t data) |
Transfer a byte to the display. More... | |
static uint8_t | SPItransferAndRead (uint8_t data) |
Transfer a byte to, and read a byte from, the SPI bus. More... | |
static void | displayOff () |
Turn the display off. More... | |
static void | displayOn () |
Turn the display on. More... | |
static constexpr uint8_t | width () |
Get the width of the display in pixels. More... | |
static constexpr uint8_t | height () |
Get the height of the display in pixels. More... | |
static uint8_t | buttonsState () |
Get the current state of all buttons as a bitmask. More... | |
static void | paint8Pixels (uint8_t pixels) |
Paint 8 pixels vertically to the display. More... | |
static void | paintScreen (const uint8_t *image) |
Paints an entire image directly to the display from program memory. More... | |
static void | paintScreen (uint8_t image[], bool clear=false) |
Paints an entire image directly to the display from an array in RAM. More... | |
static void | blank () |
Blank the display screen by setting all pixels off. More... | |
static void | invert (bool inverse) |
Invert the entire display or set it back to normal. More... | |
static void | allPixelsOn (bool on) |
Turn all display pixels on or display the buffer contents. More... | |
static void | flipVertical (bool flipped) |
Flip the display vertically or set it back to normal. More... | |
static void | flipHorizontal (bool flipped) |
Flip the display horizontally or set it back to normal. More... | |
static void | sendLCDCommand (uint8_t command) |
Send a single command byte to the display. More... | |
static void | setRGBled (uint8_t red, uint8_t green, uint8_t blue) |
Set the light output of the RGB LED. More... | |
static void | setRGBled (uint8_t color, uint8_t val) |
Set the brightness of one of the RGB LEDs without affecting the others. More... | |
static void | freeRGBled () |
Relinquish analog control of the RGB LED. More... | |
static void | digitalWriteRGB (uint8_t red, uint8_t green, uint8_t blue) |
Set the RGB LEDs digitally, to either fully on or fully off. More... | |
static void | digitalWriteRGB (uint8_t color, uint8_t val) |
Set one of the RGB LEDs digitally, to either fully on or fully off. More... | |
static void | boot () |
Initialize the Arduboy's hardware. More... | |
static void | safeMode () |
Allow upload when the bootloader "magic number" could be corrupted. More... | |
static unsigned long | generateRandomSeed () |
Create a seed suitable for use with a pseudorandom number generator. More... | |
static void | delayShort (uint16_t ms) __attribute__((noinline)) |
Delay for the number of milliseconds, specified as a 16 bit value. More... | |
static void | exitToBootloader () |
Exit the sketch and start the bootloader. More... | |
Static Public Attributes | |
static const PROGMEM uint8_t | font5x7 [] |
The font used for text functions. More... | |
static Arduboy2Audio | audio |
An object created to provide audio control functions within this class. More... | |
static uint16_t | frameCount = 0 |
A counter which is incremented once per frame. More... | |
static uint8_t | currentButtonState = 0 |
Used by pollButtons() to hold the current button state. More... | |
static uint8_t | previousButtonState = 0 |
Used by pollButtons() to hold the previous button state. More... | |
static uint8_t | sBuffer [(HEIGHT *WIDTH)/8] |
The display buffer array in RAM. More... | |
static const PROGMEM uint8_t | arduboy_logo [] |
The bitmap for the ARDUBOY logo in drawBitmap() format. More... | |
static const PROGMEM uint8_t | arduboy_logo_compressed [] |
The bitmap for the ARDUBOY logo in drawCompressed() format. More... | |
static const PROGMEM uint8_t | arduboy_logo_sprite [] |
The bitmap for the ARDUBOY logo in Sprites class drawSelfMasked() or drawOverwrite() format. More... | |
The main functions provided for writing sketches for the Arduboy, including text output.
This class is derived from Arduboy2Base. It provides text output functions in addition to all the functions inherited from Arduboy2Base.
Definition at line 1575 of file Arduboy2.h.
|
staticinherited |
Turn all display pixels on or display the buffer contents.
on | true turns all pixels on. false displays the contents of the hardware display buffer. |
Calling this function with a value of true
will override the contents of the hardware display buffer and turn all pixels on. The contents of the hardware buffer will remain unchanged.
Calling this function with a value of false
will set the normal state of displaying the contents of the hardware display buffer.
Definition at line 422 of file Arduboy2Core.cpp.
|
staticinherited |
Test if any of the specified buttons are pressed.
buttons | A bit mask indicating which buttons to test. (Can be a single button) |
true
if one or more of the buttons in the provided mask are currently pressed.Read the state of the buttons and return true
if one or more of the buttons in the specified mask are being pressed.
Example: if (anyPressed(RIGHT_BUTTON | LEFT_BUTTON))
Definition at line 1017 of file Arduboy2.cpp.
void Arduboy2::begin | ( | ) |
Initialize the hardware, display the boot logo, provide boot utilities, etc.
This function should be called once near the start of the sketch, usually in setup()
, before using any other functions in this class. It initializes the display, displays the boot logo, provides "flashlight" and system control features and initializes audio control.
If it becomes necessary to free up some code space for use by the sketch, boot()
can be used instead of begin()
to allow the elimination of some of the things that aren't absolutely required.
See the README file or main page, in section Substitute or remove boot up features, for more details.
Definition at line 1170 of file Arduboy2.cpp.
|
staticinherited |
Helper function that calls the inital functions used by begin()
This function calls all the functions used by begin()
up to the point of calling bootLogo()
. It could be called by a sketch to make it easy to use one of the alternative bootLogo...()
functions or a user provided one.
For example, if a sketch uses Sprites
class functions but doesn't use drawBitmap()
, some program space may be saved by using the following in place of begin()
:
Definition at line 48 of file Arduboy2.cpp.
|
staticinherited |
Blank the display screen by setting all pixels off.
All pixels on the screen will be written with a value of 0 to turn them off.
Definition at line 400 of file Arduboy2Core.cpp.
|
staticinherited |
Initialize the Arduboy's hardware.
This function initializes the display, buttons, etc.
This function is called by begin()
so isn't normally called within a sketch. However, in order to free up some code space, by eliminating some of the start up features, it can be called in place of begin(). The functions that begin()
would call after boot()
can then be called to add back in some of the start up features as space permits.
See the README file or main page, in section Substitute or remove boot up features, for more details.
flashlight()
or safeMode()
be called after it to provide a means to upload a new sketch if the bootloader "magic number" problem is encountered.Definition at line 81 of file Arduboy2Core.cpp.
void Arduboy2::bootLogo | ( | ) |
Display the boot logo sequence using drawBitmap()
.
This function is called by begin()
and can be called by a sketch after boot()
.
The Arduboy logo scrolls down from the top of the screen to the center while the RGB LEDs light in sequence.
The bootLogoShell()
helper function is used to perform the actual sequence. The documentation for bootLogoShell()
provides details on how it operates.
Definition at line 1187 of file Arduboy2.cpp.
void Arduboy2::bootLogoCompressed | ( | ) |
Display the boot logo sequence using drawCompressed()
.
This function can be called by a sketch after boot()
as an alternative to bootLogo()
. This may reduce code size if the sketch itself uses drawCompressed()
.
Definition at line 1195 of file Arduboy2.cpp.
void Arduboy2::bootLogoExtra | ( | ) |
Show the unit name at the bottom of the boot logo screen.
This function is called by the bootLogo...()
functions if the logo sequence runs to completion.
If a unit name has been saved in system EEPROM, it will be displayed at the bottom of the screen. This function pauses for a short time to allow the name to be seen.
If the "Show Unit Name" flag in system EEPROM is cleared, this function will return without showing the unit name or pausing.
This function would not normally be called directly from within a sketch except from a sketch provided bootlogo...()
function that renders the boot logo using a function that's not part of the Arduboy2 library. The README file or main page describes how this would be done, at the end of the Substitute or remove boot up features section.
Definition at line 1282 of file Arduboy2.cpp.
|
staticinherited |
Display the boot logo sequence using the provided function.
drawLogo | A reference to a function which will draw the boot logo at the given Y position. |
true
if the sequence runs to completion. false
if the sequence is aborted or bypassed.This common function executes the sequence to display the boot logo. It is called by bootLogo()
and other similar functions which provide it with a reference to a function which will do the actual drawing of the logo.
This function calls bootLogoExtra()
after the logo stops scrolling down, which derived classes can implement to add additional information to the logo screen. The Arduboy2
class uses this to display the unit name.
If the RIGHT button is pressed while the logo is scrolling down, the boot logo sequence will be aborted. This can be useful for developers who wish to quickly start testing, or anyone else who is impatient and wants to go straight to the actual sketch.
If the "Show LEDs with boot logo" flag in system EEPROM is cleared, the RGB LEDs will not be flashed during the logo display sequence.
If the "Show Boot Logo" flag in system EEPROM is cleared, this function will return without executing the logo display sequence.
The prototype for the function provided to draw the logo is:
The y parameter is the Y offset for the top of the logo. It is expected that the logo will be 16 pixels high and centered horizontally. This will result in the logo stopping in the middle of the screen at the end of the sequence. If the logo height is not 16 pixels, the Y value can be adjusted to compensate.
Definition at line 171 of file Arduboy2.cpp.
void Arduboy2::bootLogoSpritesBOverwrite | ( | ) |
Display the boot logo sequence using SpritesB::drawOverwrite()
.
This function can be called by a sketch after boot()
as an alternative to bootLogo()
. This may reduce code size if the sketch itself uses SpritesB
class functions.
Definition at line 1227 of file Arduboy2.cpp.
void Arduboy2::bootLogoSpritesBSelfMasked | ( | ) |
Display the boot logo sequence using SpritesB::drawSelfMasked()
.
This function can be called by a sketch after boot()
as an alternative to bootLogo()
. This may reduce code size if the sketch itself uses SpritesB
class functions.
Definition at line 1219 of file Arduboy2.cpp.
void Arduboy2::bootLogoSpritesOverwrite | ( | ) |
Display the boot logo sequence using Sprites::drawOverwrite()
.
This function can be called by a sketch after boot()
as an alternative to bootLogo()
. This may reduce code size if the sketch itself uses Sprites
class functions.
Definition at line 1211 of file Arduboy2.cpp.
void Arduboy2::bootLogoSpritesSelfMasked | ( | ) |
Display the boot logo sequence using Sprites::drawSelfMasked()
.
This function can be called by a sketch after boot()
as an alternative to bootLogo()
. This may reduce code size if the sketch itself uses Sprites
class functions.
Definition at line 1203 of file Arduboy2.cpp.
void Arduboy2::bootLogoText | ( | ) |
Display the boot logo sequence using printed text instead of a bitmap.
This function can be called by a sketch after boot()
as an alternative to bootLogo()
.
The Arduboy logo scrolls down from the top of the screen to the center while the RGB LEDs light in sequence.
This function is the same as bootLogo()
except the logo is printed as text instead of being rendered as a bitmap. It can be used to save some code space in a case where the sketch is using the Print class functions to display text. However, the logo will not look as good when printed as text as it does with the bitmap used by bootLogo()
.
If the RIGHT button is pressed while the logo is scrolling down, the boot logo sequence will be aborted. This can be useful for developers who wish to quickly start testing, or anyone else who is impatient and wants to go straight to the actual sketch.
If the "Show LEDs with boot logo" flag in system EEPROM is cleared, the RGB LEDs will not be flashed during the logo display sequence.
If the "Show Boot Logo" flag in system EEPROM is cleared, this function will return without executing the logo display sequence.
Definition at line 1237 of file Arduboy2.cpp.
|
staticinherited |
Get the current state of all buttons as a bitmask.
The returned mask contains a bit for each button. For any pressed button, its bit will be 1. For released buttons their associated bits will be 0.
The following defined mask values should be used for the buttons:
LEFT_BUTTON, RIGHT_BUTTON, UP_BUTTON, DOWN_BUTTON, A_BUTTON, B_BUTTON
Definition at line 536 of file Arduboy2Core.cpp.
Test if a point falls within a rectangle.
point | A structure describing the location of the point. |
rect | A structure describing the location and size of the rectangle. |
true
if the specified point is within the specified rectangle.This function is intended to detemine if an object, whose boundaries are are defined by the given rectangle, is in contact with the given point.
Definition at line 1043 of file Arduboy2.cpp.
Test if a rectangle is intersecting with another rectangle.
rect1,rect2 | Structures describing the size and locations of the rectangles. |
true
if the first rectangle is intersecting the second.This function is intended to detemine if an object, whose boundaries are are defined by the given rectangle, is in contact with another rectangular object.
Definition at line 1049 of file Arduboy2.cpp.
|
staticinherited |
Return the load on the CPU as a percentage.
The returned value gives the time spent processing a frame as a percentage the total time allotted for a frame, as determined by the frame rate.
This function normally wouldn't be used in the final program. It is intended for use during program development as an aid in helping with frame timing.
Definition at line 278 of file Arduboy2.cpp.
|
staticinherited |
Delay for the number of milliseconds, specified as a 16 bit value.
ms | The delay in milliseconds. |
This function works the same as the Arduino delay()
function except the provided value is 16 bits long, so the maximum delay allowed is 65535 milliseconds (about 65.5 seconds). Using this function instead of Arduino delay()
will save a few bytes of code.
Definition at line 582 of file Arduboy2Core.cpp.
|
staticinherited |
Set one of the RGB LEDs digitally, to either fully on or fully off.
color | The name of the LED to set. The value given should be one of RED_LED, GREEN_LED or BLUE_LED. |
val | Indicates whether to turn the specified LED on or off. The value given should be RGB_ON or RGB_OFF. |
This 2 parameter version of the function will set a single LED within the RGB LED either fully on or fully off. See the description of the 3 parameter version of this function for more details on the RGB LED.
Definition at line 510 of file Arduboy2Core.cpp.
|
staticinherited |
Set the RGB LEDs digitally, to either fully on or fully off.
red,green,blue | Use value RGB_ON or RGB_OFF to set each LED. |
The RGB LED is actually individual red, green and blue LEDs placed very close together in a single package. This 3 parameter version of the function will set each LED either on or off, to set the RGB LED to 7 different colors at their highest brightness or turn it off.
The colors are as follows:
RED LED | GREEN LED | BLUE LED | COLOR |
---|---|---|---|
RGB_OFF | RGB_OFF | RGB_OFF | OFF |
RGB_OFF | RGB_OFF | RGB_ON | Blue |
RGB_OFF | RGB_ON | RGB_OFF | Green |
RGB_OFF | RGB_ON | RGB_ON | Cyan |
RGB_ON | RGB_OFF | RGB_OFF | Red |
RGB_ON | RGB_OFF | RGB_ON | Magenta |
RGB_ON | RGB_ON | RGB_OFF | Yellow |
RGB_ON | RGB_ON | RGB_ON | White |
freeRGBled()
function. Definition at line 496 of file Arduboy2Core.cpp.
|
staticinherited |
Copy the contents of the display buffer to the display.
The contents of the display buffer in RAM are copied to the display and will appear on the screen.
Definition at line 997 of file Arduboy2.cpp.
|
staticinherited |
Copy the contents of the display buffer to the display. The display buffer can optionally be cleared.
clear | If true the display buffer will be cleared to zero. The defined value CLEAR_BUFFER should be used instead of true to make it more meaningful. |
Operation is the same as calling display()
without parameters except additionally the display buffer will be cleared if the parameter evaluates to true
. (The defined value CLEAR_BUFFER
can be used for this)
Using display(CLEAR_BUFFER)
is faster and produces less code than calling display()
followed by clear()
.
Definition at line 1002 of file Arduboy2.cpp.
|
staticinherited |
Turn the display off.
The display will clear and be put into a low power mode. This can be used to extend battery life when a game is paused or when a sketch doesn't require anything to be displayed for a relatively long period of time.
Definition at line 295 of file Arduboy2Core.cpp.
|
staticinherited |
Turn the display on.
Used to power up and reinitialize the display after calling displayOff()
.
displayOff()
will have caused the display's buffer contents to be lost. The display will have to be re-painted, which is usually done by calling display()
.Definition at line 306 of file Arduboy2Core.cpp.
|
staticinherited |
Draw a bitmap from an array in program memory.
x | The X coordinate of the top left pixel affected by the bitmap. |
y | The Y coordinate of the top left pixel affected by the bitmap. |
bitmap | A pointer to the bitmap array in program memory. |
w | The width of the bitmap in pixels. |
h | The height of the bitmap in pixels. Must be a multiple of 8. |
color | The color of pixels for bits set to 1 in the bitmap. If the value is INVERT, bits set to 1 will invert the corresponding pixel. (optional; defaults to WHITE). |
Bits set to 1 in the provided bitmap array will have their corresponding pixel set to the specified color. For bits set to 0 in the array, the corresponding pixel will be left unchanged.
Each byte in the array specifies a vertical column of 8 pixels, with the least significant bit at the top. The height of the image must be a multiple of 8 pixels (8, 16, 24, 32, ...). The width can be any size.
The array must be located in program memory by using the PROGMEM modifier.
Definition at line 803 of file Arduboy2.cpp.
|
static |
Draw a single character at the specified location in the screen buffer.
x | The X coordinate, in pixels, for where to draw the character. |
y | The Y coordinate, in pixels, for where to draw the character. |
c | The value of the character to be drawn. |
color | the forground color of the character. |
bg | the background color of the character. |
size | The size of the character to draw. |
The specified character is drawn starting at the provided coordinate. The point specified by the X and Y coordinates will be the top left corner of the character. The character will be rendered using the library's font5x7
font.
write()
function to draw a character. Although it's available as a public function, it wouldn't normally be used. In most cases the Arduino Print class should be used for writing text.Definition at line 1334 of file Arduboy2.cpp.
|
staticinherited |
Draw a circle of a given radius.
x0 | The X coordinate of the circle's center. |
y0 | The Y coordinate of the circle's center. |
r | The radius of the circle in pixels. |
color | The circle's color (optional; defaults to WHITE). |
Definition at line 362 of file Arduboy2.cpp.
|
staticinherited |
Draw a bitmap from an array of compressed data.
sx | The X coordinate of the top left pixel affected by the bitmap. |
sy | The Y coordinate of the top left pixel affected by the bitmap. |
bitmap | A pointer to the compressed bitmap array in program memory. |
color | The color of pixels for bits set to 1 in the bitmap. (optional; defaults to WHITE). |
Draw a bitmap starting at the given coordinates using an array that has been compressed using an RLE algorthm implemented by Team A.R.G.
The height of the image must be a multiple of 8 pixels (8, 16, 24, 32, ...). The width can be any size.
Bits set to 1 in the provided bitmap array (after decoding) will have their corresponding pixel set to the specified color. For bits set to 0 in the array, the corresponding pixel will be left unchanged.
The array must be located in program memory by using the PROGMEM modifier.
Cabi
, which can convert a PNG bitmap image file to source code suitable for use with drawCompressed()
, is included in the extras
directory of the library.Definition at line 902 of file Arduboy2.cpp.
|
staticinherited |
Draw a horizontal line.
x | The X coordinate of the left start point. |
y | The Y coordinate of the left start point. |
w | The width of the line. |
color | The color of the line (optional; defaults to WHITE). |
Definition at line 557 of file Arduboy2.cpp.
|
staticinherited |
Draw a vertical line.
x | The X coordinate of the upper start point. |
y | The Y coordinate of the upper start point. |
h | The height of the line. |
color | The color of the line (optional; defaults to WHITE). |
Definition at line 547 of file Arduboy2.cpp.
|
staticinherited |
Draw a line between two specified points.
x0,x1 | The X coordinates of the line ends. |
y0,y1 | The Y coordinates of the line ends. |
color | The line's color (optional; defaults to WHITE). |
Draw a line from the start point to the end point using Bresenham's algorithm. The start and end points can be at any location with respect to the other.
Definition at line 487 of file Arduboy2.cpp.
|
staticinherited |
Set a single pixel in the display buffer to the specified color.
x | The X coordinate of the pixel. |
y | The Y coordinate of the pixel. |
color | The color of the pixel (optional; defaults to WHITE). |
The single pixel specified location in the display buffer is set to the specified color. The values WHITE or BLACK can be used for the color. If the color
parameter isn't included, the pixel will be set to WHITE.
Definition at line 295 of file Arduboy2.cpp.
|
staticinherited |
Draw a rectangle of a specified width and height.
x | The X coordinate of the upper left corner. |
y | The Y coordinate of the upper left corner. |
w | The width of the rectangle. |
h | The height of the rectangle. |
color | The color of the pixel (optional; defaults to WHITE). |
Definition at line 538 of file Arduboy2.cpp.
|
staticinherited |
Draw a rectangle with rounded corners.
x | The X coordinate of the left edge. |
y | The Y coordinate of the top edge. |
w | The width of the rectangle. |
h | The height of the rectangle. |
r | The radius of the semicircles forming the corners. |
color | The color of the rectangle (optional; defaults to WHITE). |
Definition at line 666 of file Arduboy2.cpp.
|
staticinherited |
Draw a bitmap from a horizontally oriented array in program memory.
x | The X coordinate of the top left pixel affected by the bitmap. |
y | The Y coordinate of the top left pixel affected by the bitmap. |
bitmap | A pointer to the bitmap array in program memory. |
w | The width of the bitmap in pixels. |
h | The height of the bitmap in pixels. |
color | The color of pixels for bits set to 1 in the bitmap. (optional; defaults to WHITE). |
Bits set to 1 in the provided bitmap array will have their corresponding pixel set to the specified color. For bits set to 0 in the array, the corresponding pixel will be left unchanged.
Each byte in the array specifies a horizontal row of 8 pixels, with the most significant bit at the left end of the row.
The array must be located in program memory by using the PROGMEM modifier.
drawBitmap()
, which uses bitmaps that are stored in a format that allows them to be directly written to the screen. It is recommended you use drawBitmap()
when possible.Definition at line 849 of file Arduboy2.cpp.
|
staticinherited |
Draw a triangle given the coordinates of each corner.
x0,x1,x2 | The X coordinates of the corners. |
y0,y1,y2 | The Y coordinates of the corners. |
color | The triangle's color (optional; defaults to WHITE). |
A triangle is drawn by specifying each of the three corner locations. The corners can be at any position with respect to the others.
Definition at line 692 of file Arduboy2.cpp.
|
staticinherited |
Indicate if the specified number of frames has elapsed.
frames | The desired number of elapsed frames. |
true
if the specified number of frames has elapsed.This function should be called with the same value each time for a given event. It will return true
if the given number of frames has elapsed since the previous frame in which it returned true
.
For example, if you wanted to fire a shot every 5 frames while the A button is being held down:
Definition at line 232 of file Arduboy2.cpp.
|
staticinherited |
Exit the sketch and start the bootloader.
The sketch will exit and the bootloader will be started in command mode. The effect will be similar to pressing the reset button.
This function is intended to be used to allow uploading a new sketch, when the USB code has been removed to gain more code space. Ideally, the sketch would present a "New Sketch Upload" menu or prompt telling the user to "Press and hold the DOWN button when the procedure to upload a new sketch has been initiated". The sketch would then wait for the DOWN button to be pressed and then call this function.
Definition at line 587 of file Arduboy2Core.cpp.
|
staticinherited |
Draw a filled-in circle of a given radius.
x0 | The X coordinate of the circle's center. |
y0 | The Y coordinate of the circle's center. |
r | The radius of the circle in pixels. |
color | The circle's color (optional; defaults to WHITE). |
Definition at line 444 of file Arduboy2.cpp.
|
staticinherited |
Draw a filled-in rectangle of a specified width and height.
x | The X coordinate of the upper left corner. |
y | The Y coordinate of the upper left corner. |
w | The width of the rectangle. |
h | The height of the rectangle. |
color | The color of the pixel (optional; defaults to WHITE). |
Definition at line 608 of file Arduboy2.cpp.
|
staticinherited |
Draw a filled-in rectangle with rounded corners.
x | The X coordinate of the left edge. |
y | The Y coordinate of the top edge. |
w | The width of the rectangle. |
h | The height of the rectangle. |
r | The radius of the semicircles forming the corners. |
color | The color of the rectangle (optional; defaults to WHITE). |
Definition at line 681 of file Arduboy2.cpp.
|
staticinherited |
Fill the screen buffer with the specified color.
color | The fill color (optional; defaults to WHITE). |
Definition at line 618 of file Arduboy2.cpp.
|
staticinherited |
Draw a filled-in triangle given the coordinates of each corner.
x0,x1,x2 | The X coordinates of the corners. |
y0,y1,y2 | The Y coordinates of the corners. |
color | The triangle's color (optional; defaults to WHITE). |
A triangle is drawn by specifying each of the three corner locations. The corners can be at any position with respect to the others.
Definition at line 700 of file Arduboy2.cpp.
|
staticinherited |
Turn the RGB LED and display fully on to act as a small flashlight/torch.
Checks if the UP button is pressed and if so turns the RGB LED and all display pixels fully on. If the UP button is detected, this function does not exit. The Arduboy must be restarted after flashlight mode is used.
This function is called by begin()
and should be called by a sketch after boot()
unless safeMode()
is called instead.
This function also contains code to address a problem with uploading a new sketch, for sketches that interfere with the bootloader "magic number". This problem occurs with certain sketches that use large amounts of RAM. Being in flashlight mode when uploading a new sketch can fix this problem.
Therefore, for sketches that use boot()
instead of begin()
, a call to flashlight()
should be included after calling boot()
. If program space is limited, safeMode()
can be used instead of flashlight()
.
Definition at line 62 of file Arduboy2.cpp.
|
staticinherited |
Flip the display horizontally or set it back to normal.
flipped | true will set horizontal flip mode. false will set normal horizontal orientation. |
Calling this function with a value of true
will cause the X coordinate to start at the left edge of the display instead of the right, effectively flipping the display horizontally.
Once in horizontal flip mode, it will remain this way until normal horizontal mode is set by calling this function with a value of false
.
Definition at line 434 of file Arduboy2Core.cpp.
|
staticinherited |
Flip the display vertically or set it back to normal.
flipped | true will set vertical flip mode. false will set normal vertical orientation. |
Calling this function with a value of true
will cause the Y coordinate to start at the bottom edge of the display instead of the top, effectively flipping the display vertically.
Once in vertical flip mode, it will remain this way until normal vertical mode is set by calling this function with a value of false
.
Definition at line 428 of file Arduboy2Core.cpp.
|
staticinherited |
Relinquish analog control of the RGB LED.
Using the RGB LED in analog mode prevents further use of the LED in digital mode. This function will restore the pins used for the LED, so it can be used in digital mode.
Definition at line 487 of file Arduboy2Core.cpp.
|
staticinherited |
Create a seed suitable for use with a pseudorandom number generator.
The returned value will be a random value derived from entropy from an ADC reading of a floating pin combined with the microseconds since boot.
Definition at line 564 of file Arduboy2Core.cpp.
|
staticinherited |
Get a pointer to the display buffer in RAM.
The location of the display buffer in RAM, which is displayed using display()
, can be gotten using this function. The buffer can then be read and directly manipulated.
sBuffer
, is public. A sketch can access it directly. Doing so may be more efficient than accessing it via the pointer returned by getBuffer()
.Definition at line 1007 of file Arduboy2.cpp.
|
inlinestaticconstexpr |
Get the height, in pixels, of a character in the library's font.
textSize | The text size the character would be drawn at (optional; defaults to 1). |
Returns the height, in pixels, that a character will occupy when drawn using the library text functions. The result will be based on the provided text size, or size 1 if not included.
Definition at line 2129 of file Arduboy2.h.
|
inlinestaticconstexpr |
Get the number of pixels added after each character to provide spacing.
textSize | The text size the character would be drawn at (optional; defaults to 1). |
Returns the number of pixels added to the right of each character, to provide spacing, when drawn by the library text functions. The result will be based on the provided text size, or size 1 if not included.
Definition at line 2108 of file Arduboy2.h.
|
inlinestaticconstexpr |
Get the width, in pixels, of a character in the library's font.
textSize | The text size the character would be drawn at (optional; defaults to 1). |
Returns the width, in pixels, occupied by a character in the font used by the library for text functions. The result will be based on the provided text size, or size 1 if not included. Since the font is monospaced, all characters will occupy the same width for a given text size.
The width does not include the spacing added after each character by the library text functions. The getCharacterSpacing()
function can be used to obtain the character spacing value.
Definition at line 2086 of file Arduboy2.h.
|
static |
Get the X coordinate of the current text cursor position.
The X coordinate returned is a pixel location with 0 indicating the leftmost column.
Definition at line 1433 of file Arduboy2.cpp.
|
static |
Get the Y coordinate of the current text cursor position.
The Y coordinate returned is a pixel location with 0 indicating the topmost row.
Definition at line 1438 of file Arduboy2.cpp.
|
inlinestaticconstexpr |
Get the number of pixels added below each character to provide line spacing.
textSize | The text size the character would be drawn at (optional; defaults to 1). |
Returns the number of pixels added below each character, to provide spacing for wrapped lines, when drawn by the library text functions. The result will be based on the provided text size, or size 1 if not included.
Definition at line 2158 of file Arduboy2.h.
|
staticinherited |
Returns the state of the given pixel in the screen buffer.
x | The X coordinate of the pixel. |
y | The Y coordinate of the pixel. |
Definition at line 355 of file Arduboy2.cpp.
|
static |
Get the currently set text background color.
Definition at line 1458 of file Arduboy2.cpp.
|
static |
Get the currently set text foreground color.
Definition at line 1448 of file Arduboy2.cpp.
|
static |
Get the current state of text raw mode.
true
if text raw mode is enabled, false
if disabled.Definition at line 1489 of file Arduboy2.cpp.
|
static |
Get the currently set text size.
Definition at line 1469 of file Arduboy2.cpp.
|
static |
Get the currently set text wrap mode.
true
if text wrapping is on, false
if wrapping is off.Definition at line 1479 of file Arduboy2.cpp.
|
inlinestaticconstexprinherited |
Get the height of the display in pixels.
Definition at line 471 of file Arduboy2Core.h.
|
staticinherited |
Idle the CPU to save power.
This puts the CPU in idle sleep mode. You should call this as often as you can for the best power savings. The timer 0 overflow interrupt will wake up the chip every 1ms, so even at 60 FPS a well written app should be able to sleep maybe half the time in between rendering it's own frames.
Definition at line 278 of file Arduboy2Core.cpp.
|
staticinherited |
Seed the random number generator with a random value.
The Arduino pseudorandom number generator is seeded with the random value returned from a call to generateRandomSeed()
.
Definition at line 283 of file Arduboy2.cpp.
|
staticinherited |
Invert the entire display or set it back to normal.
inverse | true will invert the display. false will set the display to no-inverted. |
Calling this function with a value of true
will set the display to inverted mode. A pixel with a value of 0 will be on and a pixel set to 1 will be off.
Once in inverted mode, the display will remain this way until it is set back to non-inverted mode by calling this function with false
.
Definition at line 415 of file Arduboy2Core.cpp.
|
staticinherited |
Check if a button has just been pressed.
button | The button to test for. Only one button should be specified. |
true
if the specified button has just been pressed.Return true
if the given button was pressed between the latest call to pollButtons()
and previous call to pollButtons()
. If the button has been held down over multiple polls, this function will return false
.
There is no need to check for the release of the button since it must have been released for this function to return true
when pressed again.
This function should only be used to test a single button.
Definition at line 1033 of file Arduboy2.cpp.
|
staticinherited |
Check if a button has just been released.
button | The button to test for. Only one button should be specified. |
true
if the specified button has just been released.Return true
if the given button, having previously been pressed, was released between the latest call to pollButtons()
and previous call to pollButtons()
. If the button has remained released over multiple polls, this function will return false
.
There is no need to check for the button having been pressed since it must have been previously pressed for this function to return true
upon release.
This function should only be used to test a single button.
Definition at line 1038 of file Arduboy2.cpp.
|
staticinherited |
Put the display into command mode.
When placed in command mode, data that is sent to the display will be treated as commands.
See the SSD1306 controller and OLED display documents for available commands and command sequences.
Links:
Definition at line 225 of file Arduboy2Core.cpp.
|
staticinherited |
Put the display into data mode.
When placed in data mode, data that is sent to the display will be considered as data to be displayed.
Definition at line 220 of file Arduboy2Core.cpp.
|
staticinherited |
Indicate that it's time to render the next frame.
true
if it's time for the next frame.When this function returns true
, the amount of time has elapsed to display the next frame, as specified by setFrameRate()
or setFrameDuration()
.
This function will normally be called at the start of the rendering loop which would wait for true
to be returned before rendering and displaying the next frame.
example:
Definition at line 237 of file Arduboy2.cpp.
|
staticinherited |
Indicate that it's time to render the next frame, and visually indicate if the code is running slower than the desired frame rate. FOR USE DURING DEVELOPMENT
true
if it's time for the next frame.This function is intended to be used in place of nextFrame()
during the development of a sketch. It does the same thing as nextFrame()
but additionally will light the yellow TX LED (at the bottom, to the left of the USB connector) whenever a frame takes longer to generate than the time allotted per frame, as determined by the setFrameRate()
or setFrameDuration()
function.
Therefore, whenever the TX LED comes on (while not communicating over USB), it indicates that the sketch is running slower than the desired rate set by setFrameRate()
or setFrameDuration()
. In this case the developer may wish to set a slower frame rate, or reduce or optimize the code for such frames.
nextFrameDEV()
calls be restored to nextFrame()
.Definition at line 265 of file Arduboy2.cpp.
|
staticinherited |
Test if the specified buttons are not pressed.
buttons | A bit mask indicating which buttons to test. (Can be a single button) |
true
if all buttons in the provided mask are currently released.Read the state of the buttons and return true
if all the buttons in the specified mask are currently released.
Example: if (notPressed(UP_BUTTON))
Definition at line 1022 of file Arduboy2.cpp.
|
staticinherited |
Paint 8 pixels vertically to the display.
pixels | A byte whose bits specify a vertical column of 8 pixels. |
A byte representing a vertical column of 8 pixels is written to the display at the current page and column address. The address is then incremented. The page/column address will wrap to the start of the display (the top left) when it increments past the end (lower right).
The least significant bit represents the top pixel in the column. A bit set to 1 is lit, 0 is unlit.
Example:
X = lit pixels, . = unlit pixels blank() paint8Pixels() 0xFF, 0, 0xF0, 0, 0x0F v TOP LEFT corner (8x9) v TOP LEFT corner . . . . . . . . (page 1) X . . . X . . . (page 1) . . . . . . . . X . . . X . . . . . . . . . . . X . . . X . . . . . . . . . . . X . . . X . . . . . . . . . . . X . X . . . . . . . . . . . . . X . X . . . . . . . . . . . . . X . X . . . . . . . . . . . . . (end of page 1) X . X . . . . . (end of page 1) . . . . . . . . (page 2) . . . . . . . . (page 2)
Definition at line 314 of file Arduboy2Core.cpp.
|
staticinherited |
Paints an entire image directly to the display from program memory.
image | A byte array in program memory representing the entire contents of the display. |
The contents of the specified array in program memory is written to the display. Each byte in the array represents a vertical column of 8 pixels with the least significant bit at the top. The bytes are written starting at the top left, progressing horizontally and wrapping at the end of each row, to the bottom right. The size of the array must exactly match the number of pixels in the entire display.
Definition at line 319 of file Arduboy2Core.cpp.
|
staticinherited |
Paints an entire image directly to the display from an array in RAM.
image | A byte array in RAM representing the entire contents of the display. |
clear | If true the array in RAM will be cleared to zeros upon return from this function. If false the RAM buffer will remain unchanged. (optional; defaults to false ) |
The contents of the specified array in RAM is written to the display. Each byte in the array represents a vertical column of 8 pixels with the least significant bit at the top. The bytes are written starting at the top left, progressing horizontally and wrapping at the end of each row, to the bottom right. The size of the array must exactly match the number of pixels in the entire display.
If parameter clear
is set to true
the RAM array will be cleared to zeros after its contents are written to the display.
Definition at line 333 of file Arduboy2Core.cpp.
|
staticinherited |
Poll the buttons and track their state over time.
Read and save the current state of the buttons and also keep track of the button state when this function was previously called. These states are used by the justPressed()
and justReleased()
functions to determine if a button has changed state between now and the previous call to pollButtons()
.
This function should be called once at the start of each new frame.
The justPressed()
and justReleased()
functions rely on this function.
example:
Definition at line 1027 of file Arduboy2.cpp.
|
staticinherited |
Test if the all of the specified buttons are pressed.
buttons | A bit mask indicating which buttons to test. (Can be a single button) |
true
if all buttons in the provided mask are currently pressed.Read the state of the buttons and return true
if all of the buttons in the specified mask are being pressed.
Example: if (pressed(LEFT_BUTTON | A_BUTTON))
Definition at line 1012 of file Arduboy2.cpp.
|
staticinherited |
Read the "Show Boot Logo" flag in system EEPROM.
true
if the flag is set to indicate that the boot logo sequence should be displayed. false
if the flag is set to not display the boot logo sequence.The "Show Boot Logo" flag is used to determine whether the system boot logo sequence is to be displayed when the system boots up. This function returns the value of this flag.
Definition at line 1105 of file Arduboy2.cpp.
|
staticinherited |
Read the "Show LEDs with boot logo" flag in system EEPROM.
true
if the flag is set to indicate that the RGB LEDs should be flashed. false
if the flag is set to leave the LEDs off.The "Show LEDs with boot logo" flag is used to determine whether the RGB LEDs should be flashed in sequence while the boot logo is being displayed. This function returns the value of this flag.
Definition at line 1131 of file Arduboy2.cpp.
|
staticinherited |
Read the "Show Unit Name" flag in system EEPROM.
true
if the flag is set to indicate that the unit name should be displayed. false
if the flag is set to not display the unit name.The "Show Unit Name" flag is used to determine whether the system unit name is to be displayed at the end of the boot logo sequence. This function returns the value of this flag.
Definition at line 1118 of file Arduboy2.cpp.
|
staticinherited |
Read the unit ID from system EEPROM.
This function reads the unit ID that has been set in system EEPROM. The ID can be any value. It is intended to allow different units to be uniquely identified.
Definition at line 1057 of file Arduboy2.cpp.
|
staticinherited |
Read the unit name from system EEPROM.
name | A pointer to the first element of a char array in which the unit name will be written. The name will be up to ARDUBOY_UNIT_NAME_LEN characters in length and additionally terminated with a null (0x00) character, so the provided array MUST be at least ARDUBOY_UNIT_NAME_BUFFER_SIZE characters long. Using ARDUBOY_UNIT_NAME_BUFFER_SIZE to specify the array length is the proper way to do this, although any array larger than ARDUBOY_UNIT_NAME_BUFFER_SIZE is also acceptable. |
ARDUBOY_UNIT_NAME_LEN
inclusive).This function reads the unit name that has been set in system EEPROM. The name represents characters in the library's font5x7
font. It can contain any values except 0xFF and the null (0x00) terminator value, plus the ASCII newline/line feed character (\n
, 0x0A, inverse white circle) and ASCII carriage return character (\r
, 0x0D, musical eighth note).
The name can be used for any purpose. It could identify the owner or give the unit itself a nickname. A sketch could use it to automatically fill in a name or initials in a high score table, or display it as the "player" when the opponent is the computer.
ARDUBOY_UNIT_NAME_BUFFER_SIZE
should be used to allocate an array to hold the unit name string, instead of using a hard coded value for the size. For example, to allocate a buffer and read the unit name into it: Definition at line 1069 of file Arduboy2.cpp.
|
staticinherited |
Allow upload when the bootloader "magic number" could be corrupted.
If the UP button is held when this function is entered, the RGB LED will be lit and timer 0 will be disabled, then the sketch will remain in a tight loop. This is to address a problem with uploading a new sketch, for sketches that interfere with the bootloader "magic number". The problem occurs with certain sketches that use large amounts of RAM.
This function should be called after boot()
in sketches that don't call flashlight()
.
It is intended to replace the flashlight()
function when more program space is required. If possible, it is more desirable to use flashlight()
, so that the actual flashlight feature isn't lost.
Definition at line 259 of file Arduboy2Core.cpp.
|
staticinherited |
Send a single command byte to the display.
command | The command byte to send to the display. |
The display will be set to command mode then the specified command byte will be sent. The display will then be set to data mode. Multi-byte commands can be sent by calling this function multiple times.
Definition at line 406 of file Arduboy2Core.cpp.
|
static |
Set the location of the text cursor.
x | The X (horizontal) coordinate, in pixels, for the new location of the text cursor. |
y | The Y (vertical) coordinate, in pixels, for the new location of the text cursor. |
The location of the text cursor is set the the specified coordinates. The coordinates are in pixels. Since the coordinates can specify any pixel location, the text does not have to be placed on specific rows. As with all drawing functions, location 0, 0 is the top left corner of the display. The cursor location represents the top left corner of the next character written.
Definition at line 1417 of file Arduboy2.cpp.
|
static |
Set the X coordinate of the text cursor location.
x | The X (horizontal) coordinate, in pixels, for the new location of the text cursor. |
The X coordinate for the location of the text cursor is set to the specified value, leaving the Y coordinate unchanged. For more details about the text cursor, see the setCursor()
function.
Definition at line 1423 of file Arduboy2.cpp.
|
static |
Set the Y coordinate of the text cursor location.
y | The Y (vertical) coordinate, in pixels, for the new location of the text cursor. |
The Y coordinate for the location of the text cursor is set to the specified value, leaving the X coordinate unchanged. For more details about the text cursor, see the setCursor()
function.
Definition at line 1428 of file Arduboy2.cpp.
|
staticinherited |
Set the frame rate, used by the frame control functions, by giving the duration of each frame.
duration | The desired duration of each frame in milliseconds. |
Set the frame rate by specifying the duration of each frame in milliseconds. This is used by nextFrame()
to update frames at a given rate. If this function or setFrameRate()
isn't used, the default will be 16ms per frame.
Normally, the frame rate would be set to the desired value once, at the start of the game, but it can be changed at any time to alter the frame update rate.
Definition at line 227 of file Arduboy2.cpp.
|
staticinherited |
Set the frame rate used by the frame control functions.
rate | The desired frame rate in frames per second. |
Set the frame rate, in frames per second, used by nextFrame()
to update frames at a given rate. If this function or setFrameDuration()
isn't used, the default rate will be 60 (actually 62.5; see note below).
Normally, the frame rate would be set to the desired value once, at the start of the game, but it can be changed at any time to alter the frame update rate.
The given rate is internally converted to a frame duration in milliseconds, rounded down to the nearest integer. Therefore, the actual rate will be equal to or higher than the rate given.
For example, 60 FPS would be 16.67ms per frame. This will be rounded down to 16ms, giving an actual frame rate of 62.5 FPS.
Definition at line 222 of file Arduboy2.cpp.
|
staticinherited |
Set the brightness of one of the RGB LEDs without affecting the others.
color | The name of the LED to set. The value given should be one of RED_LED, GREEN_LED or BLUE_LED. |
val | The brightness value for the LED, from 0 to 255. |
This 2 parameter version of the function will set the brightness of a single LED within the RGB LED without affecting the current brightness of the other two. See the description of the 3 parameter version of this function for more details on the RGB LED.
Definition at line 463 of file Arduboy2Core.cpp.
|
staticinherited |
Set the light output of the RGB LED.
red,green,blue | The brightness value for each LED. |
The RGB LED is actually individual red, green and blue LEDs placed very close together in a single package. By setting the brightness of each LED, the RGB LED can show various colors and intensities. The brightness of each LED can be set to a value from 0 (fully off) to 255 (fully on).
Definition at line 441 of file Arduboy2Core.cpp.
|
static |
Set the text background color.
bg | The background color to be used for following text. The values WHITE or BLACK should be used. |
The background pixels of following characters will be set to the specified color.
However, if the background color is set to be the same as the text color, the background will be transparent. Only the foreground pixels will be drawn. The background pixels will remain as they were before the character was drawn.
Definition at line 1453 of file Arduboy2.cpp.
|
static |
Set the text foreground color.
color | The color to be used for following text. The values WHITE or BLACK should be used. |
Definition at line 1443 of file Arduboy2.cpp.
|
static |
Set or disable text raw mode, allowing special characters to be displayed.
raw | true enables text raw mode. false disables it. |
In text raw mode, character values that would normally be treated specially will instead be displayed. The special characters are:
\n
, 0x0A, inverse white circle).\r
, 0x0D, musical eighth note).All other characters can be displayed regardless of whether raw mode is enabled or not.
Definition at line 1484 of file Arduboy2.cpp.
|
static |
Set the text character size.
s | The text size multiplier. Must be 1 or higher. |
Setting a text size of 1 will result in standard size characters with one pixel for each bit in the bitmap for a character. The value specified is a multiplier. A value of 2 will double the width and height. A value of 3 will triple the dimensions, etc.
Definition at line 1463 of file Arduboy2.cpp.
|
static |
Set or disable text wrap mode.
w | true enables text wrap mode. false disables it. |
Text wrap mode is enabled by specifying true
. In wrap mode, if a character to be drawn would end up partially or fully past the right edge of the screen (based on the current text size), it will be placed at the start of the next line. The text cursor will be adjusted accordingly.
If wrap mode is disabled, characters will always be written at the current text cursor position. A character near the right edge of the screen may only be partially displayed and characters drawn at a position past the right edge of the screen will remain off screen.
Definition at line 1474 of file Arduboy2.cpp.
|
staticinherited |
Transfer a byte to the display.
data | The byte to be sent to the display. |
Transfer one byte to the display over the SPI port and wait for the transfer to complete. The byte will either be interpreted as a command or as data to be placed on the screen, depending on the command/data mode.
Definition at line 239 of file Arduboy2Core.cpp.
|
staticinherited |
Transfer a byte to, and read a byte from, the SPI bus.
data | The byte to be sent. |
This function does the same as the SPItransfer()
function but also reads and returns the byte of data that was received during the transfer.
This function is of no use for a standard Arduboy, since only the display is connected to the SPI bus and data cannot be received from the display. It has been provided for use with homemade or expanded units that have had additional peripherals added to the SPI bus that are capable of sending data.
Definition at line 253 of file Arduboy2Core.cpp.
|
staticinherited |
Handle buttons held on startup for system control.
This function is called by begin()
and can be called by a sketch after boot()
.
Hold the B button when booting to enter system control mode. The B button must be held continuously to remain in this mode. Then, pressing other buttons will perform system control functions:
Definition at line 83 of file Arduboy2.cpp.
|
staticinherited |
Wait until all buttons have been released.
This function is called by begin()
and can be called by a sketch after boot()
.
It won't return unless no buttons are being pressed. A short delay is performed each time before testing the state of the buttons to do a simple button debounce.
This function is called at the end of begin()
to make sure no buttons used to perform system start up actions are still being pressed, to prevent them from erroneously being detected by the sketch code itself.
Definition at line 213 of file Arduboy2.cpp.
|
inlinestaticconstexprinherited |
Get the width of the display in pixels.
Definition at line 464 of file Arduboy2Core.h.
|
virtual |
Write a single character at the current text cursor position.
c | The value of the character to be written. |
This is the Arduboy implemetation of the Arduino virtual write()
function. The single character specified is written to the the screen buffer at the current text cursor position or possibly the start of the next line if text wrap mode is on. The text cursor is then set to the next character position.
Characters are rendered using the library's font5x7
font. Two character values are handled specially:
\n
, 0x0A, inverse white circle). This will move the text cursor position to the start of the next line, based on the current text size.\r
, 0x0D, musical eighth note). This character will be ignored.To override the special handling of the above values, to allow the characters they represent to be printed, text raw mode can be selected using the setTextRawMode()
function.
Definition at line 1311 of file Arduboy2.cpp.
|
staticinherited |
Write the "Show Boot Logo" flag in system EEPROM.
val | If true the flag is set to indicate that the boot logo sequence should be displayed. If false the flag is set to not display the boot logo sequence. |
The "Show Boot Logo" flag is used to determine whether the system boot logo sequence is to be displayed when the system boots up. This function allows the flag to be saved with the desired value.
Definition at line 1110 of file Arduboy2.cpp.
|
staticinherited |
Write the "Show LEDs with boot logo" flag in system EEPROM.
val | If true the flag is set to indicate that the RGB LEDs should be flashed. If false the flag is set to leave the LEDs off. |
The "Show LEDs with boot logo" flag is used to determine whether the RGB LEDs should be flashed in sequence while the boot logo is being displayed. This function allows the flag to be saved with the desired value.
Definition at line 1136 of file Arduboy2.cpp.
|
staticinherited |
Write the "Show Unit Name" flag in system EEPROM.
val | If true the flag is set to indicate that the unit name should be displayed. If false the flag is set to not display the unit name. |
The "Show Unit Name" flag is used to determine whether the system unit name is to be displayed at the end of the boot logo sequence. This function allows the flag to be saved with the desired value.
Definition at line 1123 of file Arduboy2.cpp.
|
staticinherited |
Write a unit ID to system EEPROM.
id | The value of the unit ID to be stored in system EEPROM. |
This function writes a unit ID to a reserved location in system EEPROM. The ID can be any value. It is intended to allow different units to be uniquely identified.
Definition at line 1063 of file Arduboy2.cpp.
|
staticinherited |
Write a unit name to system EEPROM.
name | A pointer to the first element of a C-style null-terminated string containing the unit name to be saved. The name can be up to ARDUBOY_UNIT_NAME_LEN characters long and must be terminated with a null (0x00) character. |
This function writes a unit name to a reserved area in system EEPROM. The name represents characters in the library's font5x7
font. It can contain any values except 0xFF and the null (0x00) terminator value, plus the ASCII newline/line feed character (\n
, 0x0A, inverse white circle) and ASCII carriage return character (\r
, 0x0D, musical eighth note) because of their special use by the library's text handling functions.
The name can be used for any purpose. It could identify the owner or give the unit itself a nickname. A sketch could use it to automatically fill in a name or initials in a high score table, or display it as the "player" when the opponent is the computer.
ARDUBOY_UNIT_NAME_BUFFER_SIZE
should be used to allocate an array to hold the unit name string, instead of using a hard coded value for the size.Definition at line 1089 of file Arduboy2.cpp.
|
staticinherited |
The bitmap for the ARDUBOY logo in drawBitmap()
format.
Definition at line 1472 of file Arduboy2.h.
|
staticinherited |
The bitmap for the ARDUBOY logo in drawCompressed()
format.
Definition at line 1479 of file Arduboy2.h.
|
staticinherited |
The bitmap for the ARDUBOY logo in Sprites
class drawSelfMasked()
or drawOverwrite()
format.
Definition at line 1488 of file Arduboy2.h.
|
staticinherited |
An object created to provide audio control functions within this class.
This object is created to eliminate the need for a sketch to create an Arduboy2Audio class object itself.
Definition at line 227 of file Arduboy2.h.
|
staticinherited |
Used by pollButtons()
to hold the current button state.
Holds the last button state read by the pollButtons()
function.
A sketch normally does not need to read or manipulate this variable and just lets pollButtons()
handle it. Access to it is provided for special circumstances. See previousButtonState
for further discussion.
Definition at line 1395 of file Arduboy2.h.
|
static |
The font used for text functions.
This is a 5 pixel by 7 pixel font. Each character is actually coded as 8 pixels high to allow a 1 pixel descender below the baseline. Many symbols also use the 8th pixel. The library functions add a 1 pixel space after each character to separate them, so characters written at size 1 will occupy a 6 x 8 pixel area when drawn.
The character set represented is code page 437, also known as OEM 437, OEM-US, PC-8 or DOS Latin US. This is an 8 bit set which includes all printable ASCII characters plus many accented characters, symbols and line drawing characters.
The data for this font is from file glcdfont.c
in the Adafruit GFX graphics library.
The library's text functions, except drawChar()
, handle two character values specially:
\n
, 0x0A, inverse white circle). This will move the text cursor position to the start of the next line, based on the current text size.\r
, 0x0D, musical eighth note). This character will be ignored.To override the special handling of the above values, to allow the characters they represent to be printed, text raw mode can be selected using the setTextRawMode()
function.
Definition at line 2208 of file Arduboy2.h.
|
staticinherited |
A counter which is incremented once per frame.
This counter is incremented once per frame when using the nextFrame()
function. It will wrap to zero when it reaches its maximum value.
It could be used to have an event occur for a given number of frames, or a given number of frames later, in a way that wouldn't be quantized the way that using everyXFrames()
might.
example:
This counter could also be used to determine the number of frames that have elapsed between events but the possibility of the counter wrapping would have to be accounted for.
Definition at line 1381 of file Arduboy2.h.
|
staticinherited |
Used by pollButtons()
to hold the previous button state.
Holds the button state saved by the pollButtons()
function from the previous to last call to it.
A sketch normally does not need to read or manipulate this variable and just lets pollButtons()
handle it. Access to it is provided for special circumstances.
For example, the time between calls to pollButtons()
must be long enough to allow sufficient time to "debounce" the buttons. pollButtons()
is normally called once every frame but at a high frame rate the time between frames may be too short for this. Calling pollButtons()
every 2nd frame could provide a long enough time but then a call to justPressed()
in each frame would make it look like a button was pressed twice. To remedy this, after justPressed()
detects a press, previousButtonState
could be modified to acknowledge the button press.
Definition at line 1451 of file Arduboy2.h.
|
staticinherited |
The display buffer array in RAM.
The display buffer (also known as the screen buffer) contains an image bitmap of the desired contents of the display, which is written to the display using the display()
function. The drawing functions of this library manipulate the contents of the display buffer. A sketch can also access the display buffer directly.
Definition at line 1465 of file Arduboy2.h.