Go to the documentation of this file.
37 #define ARDUBOY_LIB_VER 60000
52 #define ARDUBOY_UNIT_NAME_LEN 6
65 #define ARDUBOY_UNIT_NAME_BUFFER_SIZE (ARDUBOY_UNIT_NAME_LEN + 1)
75 #define EEPROM_STORAGE_SPACE_START 16
91 #define CLEAR_BUFFER true
94 //=============================================
213 friend class Arduboy2Ex;
526 static void drawPixel(int16_t x, int16_t y, uint8_t color =
WHITE);
536 static uint8_t
getPixel(uint8_t x, uint8_t y);
548 static void drawCircle(int16_t x0, int16_t y0, uint8_t r, uint8_t color =
WHITE);
560 static void fillCircle(int16_t x0, int16_t y0, uint8_t r, uint8_t color =
WHITE);
576 static void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint8_t color =
WHITE);
613 static void drawRect(int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t color =
WHITE);
626 static void fillRect(int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t color =
WHITE);
640 static void drawRoundRect(int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t r, uint8_t color =
WHITE);
654 static void fillRoundRect(int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t r, uint8_t color =
WHITE);
669 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);
684 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);
711 static void drawBitmap(int16_t x, int16_t y,
const uint8_t *bitmap, uint8_t w, uint8_t h, uint8_t color =
WHITE);
742 static void drawSlowXYBitmap(int16_t x, int16_t y,
const uint8_t *bitmap, uint8_t w, uint8_t h, uint8_t color =
WHITE);
773 static void drawCompressed(int16_t sx, int16_t sy,
const uint8_t *bitmap, uint8_t color =
WHITE);
984 static bool pressed(uint8_t buttons);
1492 static void sysCtrlSound(uint8_t buttons, uint8_t led, uint8_t eeVal);
1495 static void drawLogoBitmap(int16_t y);
1496 static void drawLogoCompressed(int16_t y);
1497 static void drawLogoSpritesSelfMasked(int16_t y);
1498 static void drawLogoSpritesOverwrite(int16_t y);
1499 static void drawLogoSpritesBSelfMasked(int16_t y);
1500 static void drawLogoSpritesBOverwrite(int16_t y);
1503 static void drawCircleHelper(int16_t x0, int16_t y0, uint8_t r, uint8_t corners,
1504 uint8_t color =
WHITE);
1508 static void fillCircleHelper(int16_t x0, int16_t y0, uint8_t r,
1509 uint8_t sides, int16_t delta, uint8_t color =
WHITE);
1512 class BitStreamReader;
1515 static void swapInt16(int16_t& a, int16_t& b);
1518 static uint8_t eachFrameMillis;
1519 static uint8_t thisFrameStart;
1520 static uint8_t lastFrameDurationMs;
1521 static bool justRendered;
1529 static constexpr uint16_t eepromSysFlags = 1;
1531 static constexpr uint16_t eepromAudioOnOff = 2;
1534 static constexpr uint16_t eepromUnitID = 8;
1538 static constexpr uint16_t eepromUnitName = 10;
1543 static constexpr uint8_t sysFlagUnameBit = 0;
1544 static constexpr uint8_t sysFlagUnameMask = _BV(sysFlagUnameBit);
1546 static constexpr uint8_t sysFlagShowLogoBit = 1;
1547 static constexpr uint8_t sysFlagShowLogoMask = _BV(sysFlagShowLogoBit);
1549 static constexpr uint8_t sysFlagShowLogoLEDsBit = 2;
1550 static constexpr uint8_t sysFlagShowLogoLEDsMask = _BV(sysFlagShowLogoLEDsBit);
1577 friend class Arduboy2Ex;
1825 virtual size_t write(uint8_t);
1852 static void drawChar(int16_t x, int16_t y, uint8_t c, uint8_t color, uint8_t bg, uint8_t size);
1872 static void setCursor(int16_t x, int16_t y);
2062 static void clear();
2088 return characterWidth * textSize;
2110 return characterSpacing * textSize;
2131 return characterHeight * textSize;
2160 return lineSpacing * textSize;
2211 static int16_t cursor_x;
2212 static int16_t cursor_y;
2213 static uint8_t textColor;
2214 static uint8_t textBackground;
2215 static uint8_t textSize;
2216 static bool textWrap;
2217 static bool textRaw;
2221 static constexpr uint8_t characterWidth = 5;
2222 static constexpr uint8_t characterHeight = 8;
2224 static constexpr uint8_t characterSpacing = 1;
2226 static constexpr uint8_t lineSpacing = 0;
2228 static constexpr uint8_t fullCharacterWidth = characterWidth + characterSpacing;
2229 static constexpr uint8_t fullCharacterHeight = characterHeight + lineSpacing;
static void drawFastVLine(int16_t x, int16_t y, uint8_t h, uint8_t color=WHITE)
Draw a vertical line.
static constexpr uint8_t getCharacterSpacing(uint8_t textSize=1)
Get the number of pixels added after each character to provide spacing.
static void display()
Copy the contents of the display buffer to the display.
A class for drawing animated sprites from image and mask bitmaps.
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.
static uint8_t previousButtonState
Used by pollButtons() to hold the previous button state.
static void pollButtons()
Poll the buttons and track their state over time.
static void bootLogoSpritesSelfMasked()
Display the boot logo sequence using Sprites::drawSelfMasked().
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.
The main functions provided for writing sketches for the Arduboy, including text output.
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.
Lower level functions generally dealing directly with the hardware.
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.
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.
void bootLogoSpritesBOverwrite()
Display the boot logo sequence using SpritesB::drawOverwrite().
Point()=default
The default constructor.
static bool everyXFrames(uint8_t frames)
Indicate if the specified number of frames has elapsed.
static void initRandomSeed()
Seed the random number generator with a random value.
static bool justPressed(uint8_t button)
Check if a button has just been pressed.
static void drawCircle(int16_t x0, int16_t y0, uint8_t r, uint8_t color=WHITE)
Draw a circle of a given radius.
static void clear()
Clear the display buffer.
static uint8_t currentButtonState
Used by pollButtons() to hold the current button state.
static uint8_t getTextBackground()
Get the currently set text background color.
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.
constexpr Point(int16_t x, int16_t y)
The fully initializing constructor.
static void setTextBackground(uint8_t bg)
Set the text background color.
static void setTextColor(uint8_t color)
Set the text foreground color.
void bootLogoSpritesSelfMasked()
Display the boot logo sequence using Sprites::drawSelfMasked().
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.
static int cpuLoad()
Return the load on the CPU as a percentage.
The Arduboy2Audio class for speaker and sound control.
static uint8_t sBuffer[(HEIGHT *WIDTH)/8]
The display buffer array in RAM.
constexpr Rect(int16_t x, int16_t y, uint8_t width, uint8_t height)
The fully initializing constructor.
static bool nextFrameDEV()
Indicate that it's time to render the next frame, and visually indicate if the code is running slower...
static void writeShowBootLogoFlag(bool val)
Write the "Show Boot Logo" flag in system EEPROM.
static void writeUnitID(uint16_t id)
Write a unit ID to system EEPROM.
static bool collide(Point point, Rect rect)
Test if a point falls within a rectangle.
virtual size_t write(uint8_t)
Write a single character at the current text cursor position.
static void setTextWrap(bool w)
Set or disable text wrap mode.
void bootLogoSpritesBSelfMasked()
Display the boot logo sequence using SpritesB::drawSelfMasked().
static void setTextRawMode(bool raw)
Set or disable text raw mode, allowing special characters to be displayed.
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.
static void bootLogoCompressed()
Display the boot logo sequence using drawCompressed().
static const PROGMEM uint8_t font5x7[]
The font used for text functions.
static Arduboy2Audio audio
An object created to provide audio control functions within this class.
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.
static bool nextFrame()
Indicate that it's time to render the next frame.
static constexpr uint8_t getCharacterHeight(uint8_t textSize=1)
Get the height, in pixels, of a character in the library's font.
static bool notPressed(uint8_t buttons)
Test if the specified buttons are not pressed.
static constexpr uint8_t getCharacterWidth(uint8_t textSize=1)
Get the width, in pixels, of a character in the library's font.
static const PROGMEM uint8_t arduboy_logo_sprite[]
The bitmap for the ARDUBOY logo in Sprites class drawSelfMasked() or drawOverwrite() format.
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.
static void bootLogoSpritesBOverwrite()
Display the boot logo sequence using SpritesB::drawOverwrite().
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.
void bootLogoSpritesOverwrite()
Display the boot logo sequence using Sprites::drawOverwrite().
The Arduboy2Core class for Arduboy hardware initilization and control.
static uint8_t * getBuffer()
Get a pointer to the display buffer in RAM.
void begin()
Initialize the hardware, display the boot logo, provide boot utilities, etc.
static uint16_t frameCount
A counter which is incremented once per frame.
static bool pressed(uint8_t buttons)
Test if the all of the specified buttons are pressed.
static void bootLogoSpritesBSelfMasked()
Display the boot logo sequence using SpritesB::drawSelfMasked().
static uint8_t getPixel(uint8_t x, uint8_t y)
Returns the state of the given pixel in the screen buffer.
void bootLogo()
Display the boot logo sequence using drawBitmap().
An object to define a single point for collision functions.
Rect()=default
The default constructor.
static void clear()
Clear the display buffer and set the text cursor to location 0, 0.
static uint8_t getTextSize()
Get the currently set text size.
The main functions provided for writing sketches for the Arduboy, minus text output.
Provide speaker and sound control.
static void begin()
Initialize the hardware, display the boot logo, provide boot utilities, etc.
static int16_t getCursorX()
Get the X coordinate of the current text cursor position.
static void setFrameDuration(uint8_t duration)
Set the frame rate, used by the frame control functions, by giving the duration of each frame.
A class for drawing animated sprites from image and mask bitmaps. Optimized for small code size.
static void bootLogoSpritesOverwrite()
Display the boot logo sequence using Sprites::drawOverwrite().
static constexpr uint8_t getLineSpacing(uint8_t textSize=1)
Get the number of pixels added below each character to provide line spacing.
static const PROGMEM uint8_t arduboy_logo_compressed[]
The bitmap for the ARDUBOY logo in drawCompressed() format.
static bool anyPressed(uint8_t buttons)
Test if any of the specified buttons are pressed.
static void bootLogo()
Display the boot logo sequence using drawBitmap().
static uint8_t readUnitName(char *name)
Read the unit name from system EEPROM.
void bootLogoText()
Display the boot logo sequence using printed text instead of a bitmap.
static void flashlight()
Turn the RGB LED and display fully on to act as a small flashlight/torch.
The Arduino Print class is available for writing text to the screen buffer.
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.
static bool readShowBootLogoFlag()
Read the "Show Boot Logo" flag in system EEPROM.
void bootLogoCompressed()
Display the boot logo sequence using drawCompressed().
static void setTextSize(uint8_t s)
Set the text character size.
static void setCursor(int16_t x, int16_t y)
Set the location of the text cursor.
static void setCursorY(int16_t y)
Set the Y coordinate of the text cursor location.
static uint8_t getTextColor()
Get the currently set text foreground color.
static void setCursorX(int16_t x)
Set the X coordinate of the text cursor location.
Classes to generate simple square wave tones on the Arduboy speaker pins.
static void waitNoButtons()
Wait until all buttons have been released.
static bool getTextWrap()
Get the currently set text wrap mode.
static uint16_t readUnitID()
Read the unit ID from system EEPROM.
static void systemButtons()
Handle buttons held on startup for system control.
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.
static bool readShowBootLogoLEDsFlag()
Read the "Show LEDs with boot logo" flag in system EEPROM.
static bool readShowUnitNameFlag()
Read the "Show Unit Name" flag in system EEPROM.
static void setFrameRate(uint8_t rate)
Set the frame rate used by the frame control functions.
static void drawFastHLine(int16_t x, int16_t y, uint8_t w, uint8_t color=WHITE)
Draw a horizontal line.
static void writeShowBootLogoLEDsFlag(bool val)
Write the "Show LEDs with boot logo" flag in system EEPROM.
A rectangle object for collision functions.
static void writeUnitName(const char *name)
Write a unit name to system EEPROM.
static void fillScreen(uint8_t color=WHITE)
Fill the screen buffer with the specified color.
static bool justReleased(uint8_t button)
Check if a button has just been released.
static void writeShowUnitNameFlag(bool val)
Write the "Show Unit Name" flag in system EEPROM.
static const PROGMEM uint8_t arduboy_logo[]
The bitmap for the ARDUBOY logo in drawBitmap() format.
static int16_t getCursorY()
Get the Y coordinate of the current text cursor position.
static void beginDoFirst()
Helper function that calls the inital functions used by begin()
static bool getTextRawMode()
Get the current state of text raw mode.
void bootLogoExtra()
Show the unit name at the bottom of the boot logo screen.
static bool bootLogoShell(void(&drawLogo)(int16_t))
Display the boot logo sequence using the provided function.