Arduboy2 Library
6.0.0
|
The main functions provided for writing sketches for the Arduboy, minus text output. More...
#include <Arduboy2.h>
Static Public Member Functions | |
static void | begin () |
Initialize the hardware, display the boot logo, provide boot utilities, etc. 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 void | bootLogo () |
Display the boot logo sequence using drawBitmap() . More... | |
static void | bootLogoCompressed () |
Display the boot logo sequence using drawCompressed() . More... | |
static void | bootLogoSpritesSelfMasked () |
Display the boot logo sequence using Sprites::drawSelfMasked() . More... | |
static void | bootLogoSpritesOverwrite () |
Display the boot logo sequence using Sprites::drawOverwrite() . More... | |
static void | bootLogoSpritesBSelfMasked () |
Display the boot logo sequence using SpritesB::drawSelfMasked() . More... | |
static void | bootLogoSpritesBOverwrite () |
Display the boot logo sequence using SpritesB::drawOverwrite() . 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 | clear () |
Clear the display buffer. 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 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, minus text output.
This class in inherited by Arduboy2, so if text output functions are required Arduboy2 should be used instead.
An Arduboy2Audio class object named audio
will be created by the Arduboy2Base class, so there is no need for a sketch itself to create an Arduboy2Audio object. Arduboy2Audio functions can be called using the Arduboy2 or Arduboy2Base audio
object.
Example:
Definition at line 211 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.
|
static |
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.
|
static |
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 31 of file Arduboy2.cpp.
|
static |
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.
|
static |
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 109 of file Arduboy2.cpp.
|
static |
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 119 of file Arduboy2.cpp.
|
static |
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.
|
static |
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 159 of file Arduboy2.cpp.
|
static |
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 149 of file Arduboy2.cpp.
|
static |
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 139 of file Arduboy2.cpp.
|
static |
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 129 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.
|
static |
Clear the display buffer.
The entire contents of the screen buffer are cleared to BLACK.
Definition at line 290 of file Arduboy2.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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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 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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
Fill the screen buffer with the specified color.
color | The fill color (optional; defaults to WHITE). |
Definition at line 618 of file Arduboy2.cpp.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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 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.
|
static |
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.
|
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
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.
|
static |
The bitmap for the ARDUBOY logo in drawBitmap()
format.
Definition at line 1472 of file Arduboy2.h.
|
static |
The bitmap for the ARDUBOY logo in drawCompressed()
format.
Definition at line 1479 of file Arduboy2.h.
|
static |
The bitmap for the ARDUBOY logo in Sprites
class drawSelfMasked()
or drawOverwrite()
format.
Definition at line 1488 of file Arduboy2.h.
|
static |
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.
|
static |
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 |
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.
|
static |
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.
|
static |
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.