Refactor API code. Clarify and enhance user docs.

Includes some suggestions and guidance by @Pharap

API:
- Rename non-API function swap() to swapInt16()
- Make swapInt16(), drawCircleHelper(), fillCircleHelper() and
  struct BitStreamReader protected members of Arduboy2Base
- Add #define ARDUBOY_UNIT_NAME_BUFFER_SIZE for the size of a buffer
  to hold a Unit Name
- Move the position of the PROGMEM keyword for lcdBootProgram[]
  for consistency

Documentation:
- Remove absolute values referring to a Unit Name
- More details relating to the use of the Unit Name
- More details relating to the font and text functions
- Other minor documentation changes and spelling corrections
This commit is contained in:
Scott Allen 2020-06-18 17:37:33 -04:00
parent b854e2295f
commit 53096d87bf
11 changed files with 174 additions and 106 deletions

View File

@ -8,7 +8,7 @@ Software License Agreements
Licensed under the BSD 3-clause license: Licensed under the BSD 3-clause license:
Arduboy2 library: Arduboy2 library:
Copyright (c) 2016-2018, Scott Allen Copyright (c) 2016-2020, Scott Allen
All rights reserved. All rights reserved.
The Arduboy2 library was forked from the Arduboy library: The Arduboy2 library was forked from the Arduboy library:

View File

@ -43,7 +43,7 @@ At the start of the sketch, the **ARDUBOY** logo scrolls down from the top of th
The RGB LED lights red then green then blue while the logo is scrolling. (If your Arduboy is one of those that has the RGB LED installed incorrectly, then it will light blue then off then red). For users who do not wish to have the RGB LED flash during the boot logo sequence, a flag can be set in system EEPROM to have it remain off. The included *SetSystemEEPROM* example sketch can be used to set this flag. The RGB LED lights red then green then blue while the logo is scrolling. (If your Arduboy is one of those that has the RGB LED installed incorrectly, then it will light blue then off then red). For users who do not wish to have the RGB LED flash during the boot logo sequence, a flag can be set in system EEPROM to have it remain off. The included *SetSystemEEPROM* example sketch can be used to set this flag.
A user settable *unit name* of up to 6 characters can be saved in system EEPROM memory. If set, this name will be briefly displayed at the bottom of the boot logo screen, after the logo stops scrolling down. This feature is only available if the *Arduboy2* class is used, not the *Arduboy2Base* class. This is because it requires the text display functions, which are only available in the *Arduboy2* class. A flag in system EEPROM controls whether or not the *unit name* is displayed on the boot logo screen, regardless of whether the *unit name* itself has been set. The included *SetSystemEEPROM* example sketch can be used to set both the *unit name* and this flag. A user settable *unit name* can be saved in system EEPROM memory. If set, this name will be briefly displayed at the bottom of the boot logo screen, after the logo stops scrolling down. This feature is only available if the *Arduboy2* class is used, not the *Arduboy2Base* class. This is because it requires the text display functions, which are only available in the *Arduboy2* class. A flag in system EEPROM controls whether or not the *unit name* is displayed on the boot logo screen, regardless of whether the *unit name* itself has been set. The included *SetSystemEEPROM* example sketch can be used to set both the *unit name* and this flag.
Once the logo display sequence completes, the sketch continues. Once the logo display sequence completes, the sketch continues.
@ -109,9 +109,9 @@ Sample sketches have been included with the library as examples of how to use it
More information on writing sketches for the Arduboy can be found in the [Arduboy Community Forum](http://community.arduboy.com/). More information on writing sketches for the Arduboy can be found in the [Arduboy Community Forum](http://community.arduboy.com/).
### Using EEPROM in a sketch ### Using EEPROM in a sketch <- THIS IS IMPORTANT!
The Arduboy2 library reserves an area at the start of EEPROM for storing system information, such as the current audio mute state and the Unit Name and Unit ID. A sketch **must not** use this reserved area for its own purposes. A sketch may use any EEPROM past this reserved area. The first EEPROM address available for sketch use is given as the defined value *EEPROM_STORAGE_SPACE_START* The Arduboy2 library reserves an area at the start of EEPROM for storing system information, such as the current audio mute state and the Unit Name and Unit ID. A sketch **MUST NOT** use this reserved area for its own purposes. A sketch may use any EEPROM past this reserved area. The first EEPROM address available for sketch use is given as the defined value *EEPROM_STORAGE_SPACE_START*
### Audio control functions ### Audio control functions

View File

@ -298,7 +298,7 @@ void screenSaveName(), screenSaveID(), screenResetSys(), screenResetUser();
Arduboy2 arduboy; Arduboy2 arduboy;
char unitName[ARDUBOY_UNIT_NAME_LEN + 1]; char unitName[ARDUBOY_UNIT_NAME_BUFFER_SIZE];
byte nameIndex; byte nameIndex;
uint16_t unitID; uint16_t unitID;

View File

@ -1,6 +1,6 @@
# File Descriptions # File Descriptions
Documentation for files contained in this repository which aren't self explanatory. Documentation for files contained in this repository that aren't self explanatory.
### /library.properties ### /library.properties

View File

@ -134,6 +134,7 @@ drawSelfMasked KEYWORD2
ARDUBOY_LIB_VER LITERAL1 ARDUBOY_LIB_VER LITERAL1
ARDUBOY_UNIT_NAME_LEN LITERAL1 ARDUBOY_UNIT_NAME_LEN LITERAL1
ARDUBOY_UNIT_NAME_BUFFER_SIZE LITERAL1
EEPROM_STORAGE_SPACE_START LITERAL1 EEPROM_STORAGE_SPACE_START LITERAL1

View File

@ -504,13 +504,13 @@ void Arduboy2Base::drawLine
// bresenham's algorithm - thx wikpedia // bresenham's algorithm - thx wikpedia
bool steep = abs(y1 - y0) > abs(x1 - x0); bool steep = abs(y1 - y0) > abs(x1 - x0);
if (steep) { if (steep) {
swap(x0, y0); swapInt16(x0, y0);
swap(x1, y1); swapInt16(x1, y1);
} }
if (x0 > x1) { if (x0 > x1) {
swap(x0, x1); swapInt16(x0, x1);
swap(y0, y1); swapInt16(y0, y1);
} }
int16_t dx, dy; int16_t dx, dy;
@ -719,15 +719,15 @@ void Arduboy2Base::fillTriangle
// Sort coordinates by Y order (y2 >= y1 >= y0) // Sort coordinates by Y order (y2 >= y1 >= y0)
if (y0 > y1) if (y0 > y1)
{ {
swap(y0, y1); swap(x0, x1); swapInt16(y0, y1); swapInt16(x0, x1);
} }
if (y1 > y2) if (y1 > y2)
{ {
swap(y2, y1); swap(x2, x1); swapInt16(y2, y1); swapInt16(x2, x1);
} }
if (y0 > y1) if (y0 > y1)
{ {
swap(y0, y1); swap(x0, x1); swapInt16(y0, y1); swapInt16(x0, x1);
} }
if(y0 == y2) if(y0 == y2)
@ -787,7 +787,7 @@ void Arduboy2Base::fillTriangle
if(a > b) if(a > b)
{ {
swap(a,b); swapInt16(a,b);
} }
drawFastHLine(a, y, b-a+1, color); drawFastHLine(a, y, b-a+1, color);
@ -807,7 +807,7 @@ void Arduboy2Base::fillTriangle
if(a > b) if(a > b)
{ {
swap(a,b); swapInt16(a,b);
} }
drawFastHLine(a, y, b-a+1, color); drawFastHLine(a, y, b-a+1, color);
@ -879,7 +879,7 @@ void Arduboy2Base::drawSlowXYBitmap
// Helper for drawCompressed() // Helper for drawCompressed()
struct BitStreamReader struct Arduboy2Base::BitStreamReader
{ {
const uint8_t *source; const uint8_t *source;
uint16_t sourceIndex; uint16_t sourceIndex;
@ -1149,7 +1149,7 @@ void Arduboy2Base::writeShowBootLogoLEDsFlag(bool val)
EEPROM.update(EEPROM_SYS_FLAGS, flags); EEPROM.update(EEPROM_SYS_FLAGS, flags);
} }
void Arduboy2Base::swap(int16_t& a, int16_t& b) void Arduboy2Base::swapInt16(int16_t& a, int16_t& b)
{ {
int16_t temp = a; int16_t temp = a;
a = b; a = b;

View File

@ -29,22 +29,47 @@
* \code{.cpp} * \code{.cpp}
* // If the library is version 2.1.0 or higher * // If the library is version 2.1.0 or higher
* #if ARDUBOY_LIB_VER >= 20100 * #if ARDUBOY_LIB_VER >= 20100
* // ... code that make use of a new feature added to V2.1.0 * // ... code that makes use of a new feature added to V2.1.0
* #endif * #endif
* \endcode * \endcode
*/ */
#define ARDUBOY_LIB_VER 50201 #define ARDUBOY_LIB_VER 50201
// EEPROM settings // EEPROM settings
#define ARDUBOY_UNIT_NAME_LEN 6 /**< The maximum length of the unit name string. */ /** \brief
* The maximum number of characters in an unterminated unit name.
*
* \details
* This value represents the maximum number of characters in a unit name
* **NOT including** the necessary null character required to store the
* unit name as a C-style null-terminated string. To specify the size of a
* `char` array large enough to store a null-terminated string holding a
* unit name, please use `ARDUBOY_UNIT_NAME_BUFFER_SIZE` instead.
*
* \see ARDUBOY_UNIT_NAME_BUFFER_SIZE
*/
#define ARDUBOY_UNIT_NAME_LEN 6
/** \brief
* The mininum number of characters required to store a
* null-terminated unit name.
*
* \details
* This value should be used to specify the size of a `char` array large enough
* to store a C-style null-terminated string holding a unit name.
*
* \see Arduboy2Base::readUnitName() Arduboy2Base::writeUnitName()
* ARDUBOY_UNIT_NAME_LEN
*/
#define ARDUBOY_UNIT_NAME_BUFFER_SIZE (ARDUBOY_UNIT_NAME_LEN + 1)
#define EEPROM_VERSION 0 #define EEPROM_VERSION 0
#define EEPROM_SYS_FLAGS 1 #define EEPROM_SYS_FLAGS 1
#define EEPROM_AUDIO_ON_OFF 2 #define EEPROM_AUDIO_ON_OFF 2
#define EEPROM_UNIT_ID 8 // A uint16_t binary unit ID #define EEPROM_UNIT_ID 8 // A uint16_t binary unit ID
#define EEPROM_UNIT_NAME 10 // An up to 6 character unit name. Cannot contain #define EEPROM_UNIT_NAME 10 // An up to 6 character unit name
// 0x00 or 0xFF. Lengths less than 6 are padded // Cannot contain 0x00, 0xFF, 0x0A, 0x0D
// with 0x00 // Lengths less than 6 are padded with 0x00
// EEPROM_SYS_FLAGS values // EEPROM_SYS_FLAGS values
#define SYS_FLAG_UNAME 0 // Display the unit name on the logo screen #define SYS_FLAG_UNAME 0 // Display the unit name on the logo screen
@ -506,10 +531,6 @@ class Arduboy2Base : public Arduboy2Core
*/ */
void drawCircle(int16_t x0, int16_t y0, uint8_t r, uint8_t color = WHITE); void drawCircle(int16_t x0, int16_t y0, uint8_t r, uint8_t color = WHITE);
// Draw one or more "corners" of a circle.
// (Not officially part of the API)
void drawCircleHelper(int16_t x0, int16_t y0, uint8_t r, uint8_t corners, uint8_t color = WHITE);
/** \brief /** \brief
* Draw a filled-in circle of a given radius. * Draw a filled-in circle of a given radius.
* *
@ -520,11 +541,6 @@ class Arduboy2Base : public Arduboy2Core
*/ */
void fillCircle(int16_t x0, int16_t y0, uint8_t r, uint8_t color = WHITE); void fillCircle(int16_t x0, int16_t y0, uint8_t r, uint8_t color = WHITE);
// Draw one or both vertical halves of a filled-in circle or
// rounded rectangle edge.
// (Not officially part of the API)
void fillCircleHelper(int16_t x0, int16_t y0, uint8_t r, uint8_t sides, int16_t delta, uint8_t color = WHITE);
/** \brief /** \brief
* Draw a line between two specified points. * Draw a line between two specified points.
* *
@ -768,9 +784,6 @@ class Arduboy2Base : public Arduboy2Core
*/ */
void initRandomSeed(); void initRandomSeed();
// Swap the values of two int16_t variables passed by reference.
void swap(int16_t& a, int16_t& b);
/** \brief /** \brief
* Set the frame rate used by the frame control functions. * Set the frame rate used by the frame control functions.
* *
@ -935,7 +948,7 @@ class Arduboy2Base : public Arduboy2Core
* Read the state of the buttons and return `true` if all the buttons in the * Read the state of the buttons and return `true` if all the buttons in the
* specified mask are being pressed. * specified mask are being pressed.
* *
* Example: `if (pressed(LEFT_BUTTON + A_BUTTON))` * Example: `if (pressed(LEFT_BUTTON | A_BUTTON))`
* *
* \note * \note
* This function does not perform any button debouncing. * This function does not perform any button debouncing.
@ -1111,16 +1124,24 @@ class Arduboy2Base : public Arduboy2Core
/** \brief /** \brief
* Read the unit name from system EEPROM. * Read the unit name from system EEPROM.
* *
* \param name A pointer to a string array variable where the unit name will * \param name A pointer to the first element of a `char` array in which the
* be placed. The string will be up to 6 characters and terminated with a * unit name will be written. The name will be up to `ARDUBOY_UNIT_NAME_LEN`
* null (0x00) character, so the provided array must be at least 7 bytes long. * 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.
* *
* \return The length of the string (0-6). * \return The length of the string (between 0 and
* `ARDUBOY_UNIT_NAME_LEN` *inclusive*).
* *
* \details * \details
* This function reads the unit name that has been set in system EEPROM. The * This function reads the unit name that has been set in system EEPROM.
* name is in ASCII and can contain any values except 0xFF and the * The name represents characters in the library's `font5x7` font. It can
* null (0x00) terminator value. * 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 * 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 * give the unit itself a nickname. A sketch could use it to automatically
@ -1128,35 +1149,39 @@ class Arduboy2Base : public Arduboy2Core
* "player" when the opponent is the computer. * "player" when the opponent is the computer.
* *
* \note * \note
* Sketches can use the defined value `ARDUBOY_UNIT_NAME_LEN` instead of * The defined value `ARDUBOY_UNIT_NAME_BUFFER_SIZE` should be used to
* hard coding a 6 when working with the unit name. For example, to allocate * allocate an array to hold the unit name string, instead of using a
* a buffer and read the unit name into it: * hard coded value for the size.
* For example, to allocate a buffer and read the unit name into it:
* \code{.cpp} * \code{.cpp}
* // Buffer for maximum name length plus the terminator * // Buffer large enough to hold the unit name and a null terminator
* char unitName[ARDUBOY_UNIT_NAME_LEN + 1]; * char unitName[ARDUBOY_UNIT_NAME_BUFFER_SIZE];
* *
* // The actual name length * // After the call, unitNameLength will contain the actual name length,
* byte unitNameLength; * // not including the null terminator.
* * uint8_t unitNameLength = arduboy.readUnitName(unitName);
* unitNameLength = arduboy.readUnitName(unitName);
* \endcode * \endcode
* *
* \see writeUnitName() readUnitID() Arduboy2::bootLogoExtra() * \see writeUnitName() readUnitID() Arduboy2::bootLogoExtra()
* ARDUBOY_UNIT_NAME_BUFFER_SIZE ARDUBOY_UNIT_NAME_LEN Arduboy2::font5x7
*/ */
uint8_t readUnitName(char* name); uint8_t readUnitName(char* name);
/** \brief /** \brief
* Write a unit name to system EEPROM. * Write a unit name to system EEPROM.
* *
* \param name A pointer to a string array variable containing the unit name * \param name A pointer to the first element of a C-style null-terminated
* to be saved. The string can be up to 6 characters and must be terminated * string containing the unit name to be saved. The name can be up to
* with a null (0x00) character. It can contain any values except 0xFF. * `ARDUBOY_UNIT_NAME_LEN` characters long and must be terminated with a
* null (0x00) character.
* *
* \details * \details
* This function writes a unit name to a reserved area in system EEPROM. * This function writes a unit name to a reserved area in system EEPROM.
* The name is in ASCII and can contain any values except 0xFF and the * The name represents characters in the library's `font5x7` font. It can
* null (0x00) terminator value. The newline character (LF, \\n, 0x0A) and * contain any values except 0xFF and the null (0x00) terminator value, plus
* carriage return character (CR, \\r, 0x0D) should also be avoided. * 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 * 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 * give the unit itself a nickname. A sketch could use it to automatically
@ -1164,10 +1189,12 @@ class Arduboy2Base : public Arduboy2Core
* "player" when the opponent is the computer. * "player" when the opponent is the computer.
* *
* \note * \note
* Sketches can use the defined value `ARDUBOY_UNIT_NAME_LEN` instead of * The defined value `ARDUBOY_UNIT_NAME_BUFFER_SIZE` should be used to
* hard coding a 6 when working with the unit name. * allocate an array to hold the unit name string, instead of using a
* hard coded value for the size.
* *
* \see readUnitName() writeUnitID() Arduboy2::bootLogoExtra() * \see readUnitName() writeUnitID() Arduboy2::bootLogoExtra()
* ARDUBOY_UNIT_NAME_BUFFER_SIZE ARDUBOY_UNIT_NAME_LEN Arduboy2::font5x7
*/ */
void writeUnitName(char* name); void writeUnitName(char* name);
@ -1350,11 +1377,26 @@ class Arduboy2Base : public Arduboy2Core
static void drawLogoSpritesBSelfMasked(int16_t y); static void drawLogoSpritesBSelfMasked(int16_t y);
static void drawLogoSpritesBOverwrite(int16_t y); static void drawLogoSpritesBOverwrite(int16_t y);
// draw one or more "corners" of a circle
void drawCircleHelper(int16_t x0, int16_t y0, uint8_t r, uint8_t corners,
uint8_t color = WHITE);
// draw one or both vertical halves of a filled-in circle or
// rounded rectangle edge
void fillCircleHelper(int16_t x0, int16_t y0, uint8_t r,
uint8_t sides, int16_t delta, uint8_t color = WHITE);
// helper for drawCompressed()
struct BitStreamReader;
// swap the values of two int16_t variables passed by reference
void swapInt16(int16_t& a, int16_t& b);
// For button handling // For button handling
uint8_t currentButtonState; uint8_t currentButtonState;
uint8_t previousButtonState; uint8_t previousButtonState;
// For frame funcions // For frame functions
uint8_t eachFrameMillis; uint8_t eachFrameMillis;
uint8_t thisFrameStart; uint8_t thisFrameStart;
bool justRendered; bool justRendered;
@ -1401,7 +1443,15 @@ class Arduboy2 : public Print, public Arduboy2Base
* as the Arduino `Serial.print()`, etc., functions. * as the Arduino `Serial.print()`, etc., functions.
* *
* Print will use the `write()` function to actually draw each character * Print will use the `write()` function to actually draw each character
* in the screen buffer. * in the screen buffer, using the library's `font5x7` font.
* Two character values are handled specially (and thus the font symbols that
* they represent can't be displayed):
*
* - ASCII newline or line feed (`\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.
* - ASCII carriage return (`\r`, 0x0D, musical eighth note).
* This character will be ignored.
* *
* See: * See:
* https://www.arduino.cc/en/Serial/Print * https://www.arduino.cc/en/Serial/Print
@ -1412,12 +1462,13 @@ class Arduboy2 : public Print, public Arduboy2Base
* *
* arduboy.println("Hello World"); // Prints "Hello World" and then moves the * arduboy.println("Hello World"); // Prints "Hello World" and then moves the
* // text cursor to the start of the next line * // text cursor to the start of the next line
* arduboy.print(value); // Prints "42" * arduboy.print(value); // Prints "42"
* arduboy.print('\n'); // Moves the text cursor to the start of the next line * arduboy.print('\n'); // Moves the text cursor to the start of the next line
* arduboy.print(78, HEX) // Prints "4E" (78 in hexadecimal) * arduboy.print(78, HEX); // Prints "4E" (78 in hexadecimal)
* arduboy.print("\x03\xEA"); // Prints a heart symbol and a Greek uppercase omega
* \endcode * \endcode
* *
* \see Arduboy2::write() * \see Arduboy2::write() Arduboy2::font5x7
*/ */
using Print::write; using Print::write;
@ -1475,50 +1526,55 @@ class Arduboy2 : public Print, public Arduboy2Base
virtual void bootLogoExtra(); virtual void bootLogoExtra();
/** \brief /** \brief
* Write a single ASCII character at the current text cursor location. * Write a single character at the current text cursor position.
* *
* \param c The ASCII value of the character to be written. * \param c The value of the character to be written.
* *
* \return The number of characters written (will always be 1). * \return The number of characters written (will always be 1).
* *
* \details * \details
* This is the Arduboy implemetation of the Arduino virtual `write()` * This is the Arduboy implemetation of the Arduino virtual `write()`
* function. The single ASCII character specified is written to the * function. The single character specified is written to the the screen
* the screen buffer at the current text cursor. The text cursor is then * buffer at the current text cursor position. The text cursor is then
* moved to the next character position in the screen buffer. This new cursor * moved to the next character position in the screen buffer. This new cursor
* position will depend on the current text size and possibly the current * position will depend on the current text size and possibly the current
* wrap mode. * wrap mode.
* *
* Two special characters are handled: * Characters are rendered using the library's `font5x7` font.
* Two character values are handled specially (and thus the font symbols that
* they represent can't be displayed):
* *
* - The newline character `\n`. This will move the text cursor to the start * - ASCII newline or line feed (`\n`, 0x0A, inverse white circle).
* of the next line based on the current text size. * This will move the text cursor position to the start of the next line,
* - The carriage return character `\r`. This character will be ignored. * based on the current text size.
* - ASCII carriage return (`\r`, 0x0D, musical eighth note).
* This character will be ignored.
* *
* \note * \note
* This function is rather low level and, although it's available as a public * This function is rather low level and, although it's available as a public
* function, it wouldn't normally be used. In most cases the Arduino Print * function, it wouldn't normally be used. In most cases the Arduino Print
* class should be used for writing text. * class should be used for writing text.
* *
* \see Print setTextSize() setTextWrap() * \see Print setTextSize() setTextWrap() drawChar()
*/ */
virtual size_t write(uint8_t); virtual size_t write(uint8_t);
/** \brief /** \brief
* Draw a single ASCII character at the specified location in the screen * Draw a single character at the specified location in the screen
* buffer. * buffer.
* *
* \param x The X coordinate, in pixels, for where to draw the character. * \param x The X coordinate, in pixels, for where to draw the character.
* \param y The Y coordinate, in pixels, for where to draw the character. * \param y The Y coordinate, in pixels, for where to draw the character.
* \param c The ASCII value of the character to be drawn. * \param c The value of the character to be drawn.
* \param color the forground color of the character. * \param color the forground color of the character.
* \param bg the background color of the character. * \param bg the background color of the character.
* \param size The size of the character to draw. * \param size The size of the character to draw.
* *
* \details * \details
* The specified ASCII character is drawn starting at the provided * The specified character is drawn starting at the provided
* coordinate. The point specified by the X and Y coordinates will be the * coordinate. The point specified by the X and Y coordinates will be the
* top left corner of the character. * top left corner of the character. The character will be rendered using the
* library's `font5x7` font.
* *
* \note * \note
* This is a low level function used by the `write()` function to draw a * This is a low level function used by the `write()` function to draw a
@ -1542,8 +1598,8 @@ class Arduboy2 : public Print, public Arduboy2Base
* The coordinates are in pixels. Since the coordinates can specify any pixel * The coordinates are in pixels. Since the coordinates can specify any pixel
* location, the text does not have to be placed on specific rows. * 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 * As with all drawing functions, location 0, 0 is the top left corner of
* the display. The cursor location will be the top left corner of the next * the display. The cursor location represents the top left corner of the
* character written. * next character written.
* *
* \see getCursorX() getCursorY() * \see getCursorX() getCursorY()
*/ */
@ -1648,7 +1704,7 @@ class Arduboy2 : public Print, public Arduboy2Base
* cursor will be moved to the start of the next line (based on the current * cursor will be moved to the start of the next line (based on the current
* text size) if the following character wouldn't fit entirely at the end of * text size) if the following character wouldn't fit entirely at the end of
* the current line. * the current line.
*
* If wrap mode is disabled, characters will continue to be written to the * If wrap mode is disabled, characters will continue to be written to the
* same line. A character at the right edge of the screen may only be * same line. A character at the right edge of the screen may only be
* partially displayed and additional characters will be off screen. * partially displayed and additional characters will be off screen.
@ -1682,17 +1738,34 @@ class Arduboy2 : public Print, public Arduboy2Base
* size 1 will occupy a 6 x 8 pixel area when drawn. * 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, * The character set represented is code page 437, also known as OEM 437,
* OEM-US, PC-8 or DOS Latin US. * 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 * The data for this font is from file `glcdfont.c` in the
* [Adafruit GFX graphics library](https://github.com/adafruit/Adafruit-GFX-Library). * [Adafruit GFX graphics library](https://github.com/adafruit/Adafruit-GFX-Library).
* *
* \note * \note
* Because of the extra blank pixel added to the right of each character, * \parblock
* the line drawing characters in the font won't touch on the left and right * With the library's text functions, the line drawing characters in the font
* sides, as originally intended. * won't touch on the left and right sides, as originally intended, because
* of the extra blank pixel added to the right of each character.
* \endparblock
* *
* \see drawChar() * \note
* \parblock
* The library's text functions, except `drawChar()`, handle two character
* values specially (and thus the font symbols that they represent can't be
* displayed using these functions):
*
* - ASCII newline or line feed (`\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.
* - ASCII carriage return (`\r`, 0x0D, musical eighth note).
* This character will be ignored.
* \endparblock
*
* \see Print write() readUnitName() writeUnitName()
*/ */
static const PROGMEM uint8_t font5x7[]; static const PROGMEM uint8_t font5x7[];

View File

@ -8,7 +8,7 @@
#include <avr/wdt.h> #include <avr/wdt.h>
const uint8_t PROGMEM lcdBootProgram[] = { const PROGMEM uint8_t lcdBootProgram[] = {
// boot defaults are commented out but left here in case they // boot defaults are commented out but left here in case they
// might prove useful for reference // might prove useful for reference
// //
@ -238,7 +238,7 @@ void Arduboy2Core::SPItransfer(uint8_t data)
SPDR = data; SPDR = data;
/* /*
* The following NOP introduces a small delay that can prevent the wait * The following NOP introduces a small delay that can prevent the wait
* loop form iterating when running at the maximum speed. This gives * loop from iterating when running at the maximum speed. This gives
* about 10% more speed, even if it seems counter-intuitive. At lower * about 10% more speed, even if it seems counter-intuitive. At lower
* speeds it is unnoticed. * speeds it is unnoticed.
*/ */

View File

@ -134,12 +134,6 @@
#define RST_PORT PORTD // Display reset port #define RST_PORT PORTD // Display reset port
#define RST_BIT PORTD6 // Display reset physical bit number #define RST_BIT PORTD6 // Display reset physical bit number
#define SPI_MOSI_PORT PORTB
#define SPI_MOSI_BIT PORTB2
#define SPI_SCK_PORT PORTB
#define SPI_SCK_BIT PORTB1
// map all LEDs to the single TX LED on DEVKIT // map all LEDs to the single TX LED on DEVKIT
#define RED_LED 17 #define RED_LED 17
#define GREEN_LED 17 #define GREEN_LED 17
@ -715,16 +709,16 @@ class Arduboy2Core
* *
* The colors are as follows: * The colors are as follows:
* *
* RED LED GREEN_LED BLUE_LED COLOR * | RED LED | GREEN LED | BLUE LED | COLOR |
* ------- --------- -------- ----- * | ------- | --------- | -------- | :-----: |
* RGB_OFF RGB_OFF RGB_OFF OFF * | RGB_OFF | RGB_OFF | RGB_OFF | OFF |
* RGB_OFF RGB_OFF RGB_ON Blue * | RGB_OFF | RGB_OFF | RGB_ON | Blue |
* RGB_OFF RGB_ON RGB_OFF Green * | RGB_OFF | RGB_ON | RGB_OFF | Green |
* RGB_OFF RGB_ON RGB_ON Cyan * | RGB_OFF | RGB_ON | RGB_ON | Cyan |
* RGB_ON RGB_OFF RGB_OFF Red * | RGB_ON | RGB_OFF | RGB_OFF | Red |
* RGB_ON RGB_OFF RGB_ON Magenta * | RGB_ON | RGB_OFF | RGB_ON | Magenta |
* RGB_ON RGB_ON RGB_OFF Yellow * | RGB_ON | RGB_ON | RGB_OFF | Yellow |
* RGB_ON RGB_ON RGB_ON White * | RGB_ON | RGB_ON | RGB_ON | White |
* *
* \note * \note
* \parblock * \parblock

View File

@ -78,7 +78,7 @@ const PROGMEM uint8_t Arduboy2Base::arduboy_logo_sprite[] = {
0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00
}; };
// Standard ASCII 5x7 font // ASCII based 5x7 font
// IBM PC code page 437 // IBM PC code page 437
const PROGMEM uint8_t Arduboy2::font5x7[] = { const PROGMEM uint8_t Arduboy2::font5x7[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View File

@ -1,7 +1,7 @@
/** /**
* @file SpritesCommon.h * @file SpritesCommon.h
* \brief * \brief
* Common header file for sprite functions * Common header file for sprite functions.
*/ */
#ifndef SpritesCommon_h #ifndef SpritesCommon_h