mirror of
https://github.com/adafruit/Adafruit-GFX-Library.git
synced 2024-10-03 18:18:46 -04:00
more doxy
This commit is contained in:
parent
836a499055
commit
ed59d3ea4a
205
Adafruit_GFX.cpp
205
Adafruit_GFX.cpp
@ -338,7 +338,17 @@ void Adafruit_GFX::drawRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
|||||||
endWrite();
|
endWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a rounded rectangle
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Draw a rounded rectangle with no fill color
|
||||||
|
@param x Top left corner x coordinate
|
||||||
|
@param y Top left corner y coordinate
|
||||||
|
@param w Width in pixels
|
||||||
|
@param h Height in pixels
|
||||||
|
@param r Radius of corner rounding
|
||||||
|
@param color 16-bit 5-6-5 Color to draw with
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w,
|
void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w,
|
||||||
int16_t h, int16_t r, uint16_t color) {
|
int16_t h, int16_t r, uint16_t color) {
|
||||||
// smarter version
|
// smarter version
|
||||||
@ -355,7 +365,17 @@ void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w,
|
|||||||
endWrite();
|
endWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill a rounded rectangle
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Draw a rounded rectangle with fill color
|
||||||
|
@param x Top left corner x coordinate
|
||||||
|
@param y Top left corner y coordinate
|
||||||
|
@param w Width in pixels
|
||||||
|
@param h Height in pixels
|
||||||
|
@param r Radius of corner rounding
|
||||||
|
@param color 16-bit 5-6-5 Color to draw/fill with
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::fillRoundRect(int16_t x, int16_t y, int16_t w,
|
void Adafruit_GFX::fillRoundRect(int16_t x, int16_t y, int16_t w,
|
||||||
int16_t h, int16_t r, uint16_t color) {
|
int16_t h, int16_t r, uint16_t color) {
|
||||||
// smarter version
|
// smarter version
|
||||||
@ -368,7 +388,18 @@ void Adafruit_GFX::fillRoundRect(int16_t x, int16_t y, int16_t w,
|
|||||||
endWrite();
|
endWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a triangle
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Draw a triangle with no fill color
|
||||||
|
@param x0 Vertex #0 x coordinate
|
||||||
|
@param y0 Vertex #0 y coordinate
|
||||||
|
@param x1 Vertex #1 x coordinate
|
||||||
|
@param y1 Vertex #1 y coordinate
|
||||||
|
@param x2 Vertex #2 x coordinate
|
||||||
|
@param y2 Vertex #2 y coordinate
|
||||||
|
@param color 16-bit 5-6-5 Color to draw with
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::drawTriangle(int16_t x0, int16_t y0,
|
void Adafruit_GFX::drawTriangle(int16_t x0, int16_t y0,
|
||||||
int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) {
|
int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) {
|
||||||
drawLine(x0, y0, x1, y1, color);
|
drawLine(x0, y0, x1, y1, color);
|
||||||
@ -376,7 +407,18 @@ void Adafruit_GFX::drawTriangle(int16_t x0, int16_t y0,
|
|||||||
drawLine(x2, y2, x0, y0, color);
|
drawLine(x2, y2, x0, y0, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill a triangle
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Draw a triangle with color-fill
|
||||||
|
@param x0 Vertex #0 x coordinate
|
||||||
|
@param y0 Vertex #0 y coordinate
|
||||||
|
@param x1 Vertex #1 x coordinate
|
||||||
|
@param y1 Vertex #1 y coordinate
|
||||||
|
@param x2 Vertex #2 x coordinate
|
||||||
|
@param y2 Vertex #2 y coordinate
|
||||||
|
@param color 16-bit 5-6-5 Color to fill/draw with
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0,
|
void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0,
|
||||||
int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) {
|
int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) {
|
||||||
|
|
||||||
@ -805,12 +847,13 @@ void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
|
|||||||
|
|
||||||
} // End classic vs custom font
|
} // End classic vs custom font
|
||||||
}
|
}
|
||||||
|
/**************************************************************************/
|
||||||
#if ARDUINO >= 100
|
/*!
|
||||||
|
@brief Print one byte/character of data, used to support print()
|
||||||
|
@param c The 8-bit ascii character to write
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
size_t Adafruit_GFX::write(uint8_t c) {
|
size_t Adafruit_GFX::write(uint8_t c) {
|
||||||
#else
|
|
||||||
void Adafruit_GFX::write(uint8_t c) {
|
|
||||||
#endif
|
|
||||||
if(!gfxFont) { // 'Classic' built-in font
|
if(!gfxFont) { // 'Classic' built-in font
|
||||||
|
|
||||||
if(c == '\n') { // Newline?
|
if(c == '\n') { // Newline?
|
||||||
@ -852,47 +895,101 @@ void Adafruit_GFX::write(uint8_t c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#if ARDUINO >= 100
|
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Set text cursor location
|
||||||
|
@param x X coordinate in pixels
|
||||||
|
@param y Y coordinate in pixels
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::setCursor(int16_t x, int16_t y) {
|
void Adafruit_GFX::setCursor(int16_t x, int16_t y) {
|
||||||
cursor_x = x;
|
cursor_x = x;
|
||||||
cursor_y = y;
|
cursor_y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Get text cursor X location
|
||||||
|
@returns X coordinate in pixels
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
int16_t Adafruit_GFX::getCursorX(void) const {
|
int16_t Adafruit_GFX::getCursorX(void) const {
|
||||||
return cursor_x;
|
return cursor_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Get text cursor Y location
|
||||||
|
@returns Y coordinate in pixels
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
int16_t Adafruit_GFX::getCursorY(void) const {
|
int16_t Adafruit_GFX::getCursorY(void) const {
|
||||||
return cursor_y;
|
return cursor_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Set text 'magnification' size. Each increase in s makes 1 pixel that much bigger.
|
||||||
|
@param s Desired text size. 1 is default 6x8, 2 is 12x16, 3 is 18x24, etc
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::setTextSize(uint8_t s) {
|
void Adafruit_GFX::setTextSize(uint8_t s) {
|
||||||
textsize = (s > 0) ? s : 1;
|
textsize = (s > 0) ? s : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Set text font color with transparant background
|
||||||
|
@param c 16-bit 5-6-5 Color to draw text with
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::setTextColor(uint16_t c) {
|
void Adafruit_GFX::setTextColor(uint16_t c) {
|
||||||
// For 'transparent' background, we'll set the bg
|
// For 'transparent' background, we'll set the bg
|
||||||
// to the same as fg instead of using a flag
|
// to the same as fg instead of using a flag
|
||||||
textcolor = textbgcolor = c;
|
textcolor = textbgcolor = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Set text font color with custom background color
|
||||||
|
@param c 16-bit 5-6-5 Color to draw text with
|
||||||
|
@param b 16-bit 5-6-5 Color to draw background/fill with
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::setTextColor(uint16_t c, uint16_t b) {
|
void Adafruit_GFX::setTextColor(uint16_t c, uint16_t b) {
|
||||||
textcolor = c;
|
textcolor = c;
|
||||||
textbgcolor = b;
|
textbgcolor = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Whether text that is too long should 'wrap' around to the next line.
|
||||||
|
@param w Set true for wrapping, false for clipping
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::setTextWrap(boolean w) {
|
void Adafruit_GFX::setTextWrap(boolean w) {
|
||||||
wrap = w;
|
wrap = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Get rotation setting for display
|
||||||
|
@returns 0 thru 3 corresponding to 4 cardinal rotations
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
uint8_t Adafruit_GFX::getRotation(void) const {
|
uint8_t Adafruit_GFX::getRotation(void) const {
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Set rotation setting for display
|
||||||
|
@param x 0 thru 3 corresponding to 4 cardinal rotations
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::setRotation(uint8_t x) {
|
void Adafruit_GFX::setRotation(uint8_t x) {
|
||||||
rotation = (x & 3);
|
rotation = (x & 3);
|
||||||
switch(rotation) {
|
switch(rotation) {
|
||||||
@ -909,17 +1006,28 @@ void Adafruit_GFX::setRotation(uint8_t x) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable (or disable) Code Page 437-compatible charset.
|
/**************************************************************************/
|
||||||
// There was an error in glcdfont.c for the longest time -- one character
|
/*!
|
||||||
// (#176, the 'light shade' block) was missing -- this threw off the index
|
@brief Enable (or disable) Code Page 437-compatible charset.
|
||||||
// of every character that followed it. But a TON of code has been written
|
There was an error in glcdfont.c for the longest time -- one character
|
||||||
// with the erroneous character indices. By default, the library uses the
|
(#176, the 'light shade' block) was missing -- this threw off the index
|
||||||
// original 'wrong' behavior and old sketches will still work. Pass 'true'
|
of every character that followed it. But a TON of code has been written
|
||||||
// to this function to use correct CP437 character values in your code.
|
with the erroneous character indices. By default, the library uses the
|
||||||
|
original 'wrong' behavior and old sketches will still work. Pass 'true'
|
||||||
|
to this function to use correct CP437 character values in your code.
|
||||||
|
@param x Whether to enable (True) or not (False)
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::cp437(boolean x) {
|
void Adafruit_GFX::cp437(boolean x) {
|
||||||
_cp437 = x;
|
_cp437 = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Set the font to display when print()ing, either custom or default
|
||||||
|
@param f The GFXfont object, if NULL use built in 6x8 font
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::setFont(const GFXfont *f) {
|
void Adafruit_GFX::setFont(const GFXfont *f) {
|
||||||
if(f) { // Font struct pointer passed in?
|
if(f) { // Font struct pointer passed in?
|
||||||
if(!gfxFont) { // And no current font struct?
|
if(!gfxFont) { // And no current font struct?
|
||||||
@ -935,8 +1043,20 @@ void Adafruit_GFX::setFont(const GFXfont *f) {
|
|||||||
gfxFont = (GFXfont *)f;
|
gfxFont = (GFXfont *)f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Broke this out as it's used by both the PROGMEM- and RAM-resident
|
|
||||||
// getTextBounds() functions.
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Helper to determine size of a character with current font/size.
|
||||||
|
Broke this out as it's used by both the PROGMEM- and RAM-resident getTextBounds() functions.
|
||||||
|
@param c The ascii character in question
|
||||||
|
@param x Pointer to x location of character
|
||||||
|
@param y Pointer to y location of character
|
||||||
|
@param minx Minimum clipping value for X
|
||||||
|
@param miny Minimum clipping value for Y
|
||||||
|
@param maxx Maximum clipping value for X
|
||||||
|
@param maxy Maximum clipping value for Y
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::charBounds(char c, int16_t *x, int16_t *y,
|
void Adafruit_GFX::charBounds(char c, int16_t *x, int16_t *y,
|
||||||
int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy) {
|
int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy) {
|
||||||
|
|
||||||
@ -995,7 +1115,18 @@ void Adafruit_GFX::charBounds(char c, int16_t *x, int16_t *y,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass string and a cursor position, returns UL corner and W,H.
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Helper to determine size of a string with current font/size. Pass string and a cursor position, returns UL corner and W,H.
|
||||||
|
@param str The ascii string to measure
|
||||||
|
@param x The current cursor X
|
||||||
|
@param y The current cursor Y
|
||||||
|
@param x1 The boundary X coordinate, set by function
|
||||||
|
@param y1 The boundary Y coordinate, set by function
|
||||||
|
@param w The boundary width, set by function
|
||||||
|
@param h The boundary height, set by function
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::getTextBounds(char *str, int16_t x, int16_t y,
|
void Adafruit_GFX::getTextBounds(char *str, int16_t x, int16_t y,
|
||||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) {
|
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) {
|
||||||
uint8_t c; // Current character
|
uint8_t c; // Current character
|
||||||
@ -1019,7 +1150,18 @@ void Adafruit_GFX::getTextBounds(char *str, int16_t x, int16_t y,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same as above, but for PROGMEM strings
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Helper to determine size of a PROGMEM string with current font/size. Pass string and a cursor position, returns UL corner and W,H.
|
||||||
|
@param str The flash-memory ascii string to measure
|
||||||
|
@param x The current cursor X
|
||||||
|
@param y The current cursor Y
|
||||||
|
@param x1 The boundary X coordinate, set by function
|
||||||
|
@param y1 The boundary Y coordinate, set by function
|
||||||
|
@param w The boundary width, set by function
|
||||||
|
@param h The boundary height, set by function
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::getTextBounds(const __FlashStringHelper *str,
|
void Adafruit_GFX::getTextBounds(const __FlashStringHelper *str,
|
||||||
int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) {
|
int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) {
|
||||||
uint8_t *s = (uint8_t *)str, c;
|
uint8_t *s = (uint8_t *)str, c;
|
||||||
@ -1043,15 +1185,32 @@ void Adafruit_GFX::getTextBounds(const __FlashStringHelper *str,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the size of the display (per current rotation)
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Get width of the display, accounting for the current rotation
|
||||||
|
@returns Width in pixels
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
int16_t Adafruit_GFX::width(void) const {
|
int16_t Adafruit_GFX::width(void) const {
|
||||||
return _width;
|
return _width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Get height of the display, accounting for the current rotation
|
||||||
|
@returns Height in pixels
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
int16_t Adafruit_GFX::height(void) const {
|
int16_t Adafruit_GFX::height(void) const {
|
||||||
return _height;
|
return _height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Invert the display (ideally using built-in hardware command)
|
||||||
|
@param i True if you want to invert, false to make 'normal'
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
void Adafruit_GFX::invertDisplay(boolean i) {
|
void Adafruit_GFX::invertDisplay(boolean i) {
|
||||||
// Do nothing, must be subclassed if supported by hardware
|
// Do nothing, must be subclassed if supported by hardware
|
||||||
}
|
}
|
||||||
|
@ -126,20 +126,24 @@ class Adafruit_GFX : public Print {
|
|||||||
charBounds(char c, int16_t *x, int16_t *y,
|
charBounds(char c, int16_t *x, int16_t *y,
|
||||||
int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy);
|
int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy);
|
||||||
const int16_t
|
const int16_t
|
||||||
WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes
|
WIDTH, ///< This is the 'raw' display width - never changes
|
||||||
|
HEIGHT; ///< This is the 'raw' display height - never changes
|
||||||
int16_t
|
int16_t
|
||||||
_width, _height, // Display w/h as modified by current rotation
|
_width, ///< Display width as modified by current rotation
|
||||||
cursor_x, cursor_y;
|
_height, ///< Display height as modified by current rotation
|
||||||
|
cursor_x, ///< x location to start print()ing text
|
||||||
|
cursor_y; ///< y location to start print()ing text
|
||||||
uint16_t
|
uint16_t
|
||||||
textcolor, textbgcolor;
|
textcolor, ///< 16-bit background color for print()
|
||||||
|
textbgcolor; ///< 16-bit text color for print()
|
||||||
uint8_t
|
uint8_t
|
||||||
textsize,
|
textsize, ///< Desired magnification of text to print()
|
||||||
rotation;
|
rotation; ///< Display rotation (0 thru 3)
|
||||||
boolean
|
boolean
|
||||||
wrap, // If set, 'wrap' text at right edge of display
|
wrap, ///< If set, 'wrap' text at right edge of display
|
||||||
_cp437; // If set, use correct CP437 charset (default is off)
|
_cp437; ///< If set, use correct CP437 charset (default is off)
|
||||||
GFXfont
|
GFXfont
|
||||||
*gfxFont;
|
*gfxFont; ///< Pointer to special font
|
||||||
};
|
};
|
||||||
|
|
||||||
class Adafruit_GFX_Button {
|
class Adafruit_GFX_Button {
|
||||||
|
Loading…
Reference in New Issue
Block a user