|
LCDGFX LCD display driver
1.2.0
Lightweight graphics library for SSD1306, SSD1325, SSD1327, SSD1331, SSD1351, SH1106, SH1107, IL9163, ST7735, ST7789, ILI9341, PCD8544 displays over I2C/SPI
|
NanoCanvasOps provides operations for drawing in memory buffer. More...
#include <canvas.h>


Public Types | |
| typedef NanoCanvasOps< BPP > | T |
| Base type for canvas class specific operations. | |
Public Member Functions | |
| NanoCanvasOps () | |
| Creates new empty canvas object. More... | |
| NanoCanvasOps (lcdint_t w, lcdint_t h, uint8_t *bytes) | |
| Creates new canvas object. More... | |
| void | begin (lcdint_t w, lcdint_t h, uint8_t *bytes) |
| Initializes canvas object. More... | |
| void | setOffset (lcdint_t ox, lcdint_t oy) |
| Sets offset. More... | |
| const NanoPoint | offsetEnd () const |
| Returns right-bottom point of the canvas in offset terms. More... | |
| const NanoRect | rect () const |
| Returns rectangle area, covered by canvas in offset terms. More... | |
| void | putPixel (lcdint_t x, lcdint_t y) |
| Draws pixel on specified position. More... | |
| void | putPixel (const NanoPoint &p) |
| Draws pixel on specified position. More... | |
| void | drawVLine (lcdint_t x1, lcdint_t y1, lcdint_t y2) |
| Draws vertical line from (x1,y1) to (x1,y2). More... | |
| void | drawHLine (lcdint_t x1, lcdint_t y1, lcdint_t x2) |
| Draws horizontal line from (x1,y1) to (x2,y1). More... | |
| void | drawLine (lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) |
| Draws a line between two points using Bresenham's algorithm. More... | |
| void | drawLine (const NanoRect &rect) |
| Draws line. More... | |
| void | drawRect (lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) __attribute__((noinline)) |
| Draws rectangle outline. More... | |
| void | drawRect (const NanoRect &rect) |
| Draws rectangle outline using NanoRect structure. More... | |
| void | fillRect (lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) __attribute__((noinline)) |
| Fills a rectangular area with the current color. More... | |
| void | fillRect (const NanoRect &rect) |
| Fills a rectangular area with the current color. More... | |
| void | drawCircle (lcdint_t x, lcdint_t y, lcdint_t r, uint8_t options=0x0F) __attribute__((noinline)) |
| Draws circle outline. More... | |
| void | drawBitmap1 (lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *bitmap) __attribute__((noinline)) |
| Draws monochrome bitmap in color buffer using color, specified via setColor() method Draws monochrome bitmap in color buffer using color, specified via setColor() method. More... | |
| void | drawBitmap8 (lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *bitmap) __attribute__((noinline)) |
| Draws 8-bit color bitmap in color buffer. More... | |
| void | drawBitmap16 (lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *bitmap) __attribute__((noinline)) |
| Draws 16-bit color bitmap in color buffer. More... | |
| void | clear () __attribute__((noinline)) |
| Clears canvas. | |
| size_t | write (uint8_t c) |
| Writes single character to canvas. More... | |
| uint8_t | printChar (uint8_t c) |
| Draws single character to canvas. More... | |
| void | printFixed (lcdint_t xpos, lcdint_t y, const char *ch, EFontStyle style=STYLE_NORMAL) __attribute__((noinline)) |
| Print text at specified position to canvas. More... | |
| void | printFixedPgm (lcdint_t xpos, lcdint_t y, const char *ch, EFontStyle style=STYLE_NORMAL) |
| Print text at specified position to canvas. More... | |
| void | setMode (uint8_t modeFlags) |
| Sets canvas drawing mode Sets canvas drawing mode. More... | |
| void | setColor (uint16_t color) |
| Sets color for monochrome operations. More... | |
| uint16_t | getColor () |
| Returns currently set foreground color. More... | |
| void | invertColors () |
| Swaps foreground and background colors. More... | |
| void | setBackground (uint16_t color) |
| Sets background color. More... | |
| void | setFont (NanoFont &font) |
| Sets new font to use with print functions. More... | |
| NanoFont & | getFont () |
| Returns reference to NanoFont object currently in use. More... | |
| void | setFontSpacing (uint8_t spacing) |
| Sets font spacing for currently active font. More... | |
| void | setFixedFont (const uint8_t *progmemFont) |
| Sets new font to use with print functions. More... | |
| void | setFreeFont (const uint8_t *progmemFont, const uint8_t *secondaryFont=nullptr) |
| Sets new font to use with print functions. More... | |
| uint8_t * | getData () |
| Return pointer to canvas pixels data. | |
| lcduint_t | width () |
| Returns canvas width in pixels. | |
| lcduint_t | height () |
| Returns canvas height in pixels. | |
| void | rotateCW (T &out) |
| Rotates the canvas clock-wise. | |
Public Attributes | |
| NanoPoint | offset |
| Fixed offset for all operation of NanoCanvasOps in pixels. | |
Static Public Attributes | |
| static const uint8_t | BITS_PER_PIXEL = BPP |
| number of bits per single pixel in buffer | |
Protected Attributes | |
| lcduint_t | m_w |
| width of NanoCanvas area in pixels | |
| lcduint_t | m_h |
| height of NanoCanvas area in pixels | |
| lcdint_t | m_cursorX |
| current X cursor position for text output | |
| lcdint_t | m_cursorY |
| current Y cursor position for text output | |
| uint8_t | m_textMode |
| Flags for current NanoCanvas mode. | |
| EFontStyle | m_fontStyle |
| currently active font style | |
| uint8_t * | m_buf |
| Canvas data. | |
| uint16_t | m_color |
| current color | |
| uint16_t | m_bgColor |
| current background color | |
| NanoFont * | m_font = nullptr |
| current set font to use with NanoCanvas | |
NanoCanvasOps provides operations for drawing in memory buffer.
Depending on the BPP template argument, this class can work with 1-bit (monochrome), 8-bit, or 16-bit canvas areas. All drawing operations write to an off-screen buffer that can later be flushed to a display.
| BPP | bits per pixel (1, 8, or 16) |
|
inline |
|
inline |
| void NanoCanvasOps< BPP >::begin | ( | lcdint_t | w, |
| lcdint_t | h, | ||
| uint8_t * | bytes | ||
| ) |
Initializes canvas object.
Width can be of any value. Height should be divided by 8. Memory buffer must be not less than w * h.
| w | - width |
| h | - height |
| bytes | - pointer to memory buffer to use |
| void NanoCanvasOps< BPP >::drawBitmap1 | ( | lcdint_t | x, |
| lcdint_t | y, | ||
| lcduint_t | w, | ||
| lcduint_t | h, | ||
| const uint8_t * | bitmap | ||
| ) |
Draws monochrome bitmap in color buffer using color, specified via setColor() method Draws monochrome bitmap in color buffer using color, specified via setColor() method.
| x | - position X in pixels |
| y | - position Y in pixels |
| w | - width in pixels |
| h | - height in pixels |
| bitmap | - monochrome bitmap data, located in flash |
| void NanoCanvasOps< BPP >::drawBitmap16 | ( | lcdint_t | x, |
| lcdint_t | y, | ||
| lcduint_t | w, | ||
| lcduint_t | h, | ||
| const uint8_t * | bitmap | ||
| ) |
Draws 16-bit color bitmap in color buffer.
Draws 16-bit color bitmap in color buffer.
| x | - position X in pixels |
| y | - position Y in pixels |
| w | - width in pixels |
| h | - height in pixels |
| bitmap | - 16-bit color bitmap data, located in flash |
| void NanoCanvasOps< BPP >::drawBitmap8 | ( | lcdint_t | x, |
| lcdint_t | y, | ||
| lcduint_t | w, | ||
| lcduint_t | h, | ||
| const uint8_t * | bitmap | ||
| ) |
Draws 8-bit color bitmap in color buffer.
Draws 8-bit color bitmap in color buffer.
| x | - position X in pixels |
| y | - position Y in pixels |
| w | - width in pixels |
| h | - height in pixels |
| bitmap | - 8-bit color bitmap data, located in flash |
| void NanoCanvasOps< BPP >::drawCircle | ( | lcdint_t | x, |
| lcdint_t | y, | ||
| lcdint_t | r, | ||
| uint8_t | options = 0x0F |
||
| ) |
Draws circle outline.
| x | horizontal position of circle center in pixels |
| y | vertical position of circle center in pixels |
| r | circle radius in pixels |
| options | bitmask for quadrants to draw (bits 0–3 for 4 quadrants, 0x0F = full circle) |
| void NanoCanvasOps< BPP >::drawHLine | ( | lcdint_t | x1, |
| lcdint_t | y1, | ||
| lcdint_t | x2 | ||
| ) |
Draws horizontal line from (x1,y1) to (x2,y1).
| x1 | - start X position |
| y1 | - Y position |
| x2 | - end X position |
| void NanoCanvasOps< BPP >::drawLine | ( | lcdint_t | x1, |
| lcdint_t | y1, | ||
| lcdint_t | x2, | ||
| lcdint_t | y2 | ||
| ) |
Draws a line between two points using Bresenham's algorithm.
| x1 | - start X position |
| y1 | - start Y position |
| x2 | - end X position |
| y2 | - end Y position |
| void NanoCanvasOps< BPP >::drawLine | ( | const NanoRect & | rect | ) |
Draws line.
| rect | - structure, describing rectangle area |
| void NanoCanvasOps< BPP >::drawRect | ( | lcdint_t | x1, |
| lcdint_t | y1, | ||
| lcdint_t | x2, | ||
| lcdint_t | y2 | ||
| ) |
Draws rectangle outline.
| x1 | - left X |
| y1 | - top Y |
| x2 | - right X |
| y2 | - bottom Y |
| void NanoCanvasOps< BPP >::drawRect | ( | const NanoRect & | rect | ) |
Draws rectangle outline using NanoRect structure.
| rect | - rectangle area to draw |
| void NanoCanvasOps< BPP >::drawVLine | ( | lcdint_t | x1, |
| lcdint_t | y1, | ||
| lcdint_t | y2 | ||
| ) |
Draws vertical line from (x1,y1) to (x1,y2).
| x1 | - X position |
| y1 | - start Y position |
| y2 | - end Y position |
| void NanoCanvasOps< BPP >::fillRect | ( | lcdint_t | x1, |
| lcdint_t | y1, | ||
| lcdint_t | x2, | ||
| lcdint_t | y2 | ||
| ) |
Fills a rectangular area with the current color.
| x1 | - left X |
| y1 | - top Y |
| x2 | - right X |
| y2 | - bottom Y |
| void NanoCanvasOps< BPP >::fillRect | ( | const NanoRect & | rect | ) |
Fills a rectangular area with the current color.
| rect | - rectangle area to fill |
|
inline |
|
inline |
Returns reference to NanoFont object currently in use.
|
inline |
Swaps foreground and background colors.
|
inline |
Returns right-bottom point of the canvas in offset terms.
If offset is (0,0), then offsetEnd() will return (width-1,height-1).
| uint8_t NanoCanvasOps< BPP >::printChar | ( | uint8_t | c | ) |
Draws single character to canvas.
| c | - character code to print |
| void NanoCanvasOps< BPP >::printFixed | ( | lcdint_t | xpos, |
| lcdint_t | y, | ||
| const char * | ch, | ||
| EFontStyle | style = STYLE_NORMAL |
||
| ) |
Print text at specified position to canvas.
| xpos | position in pixels |
| y | position in pixels |
| ch | pointer to NULL-terminated string. |
| style | specific font style to use |
| void NanoCanvasOps< BPP >::printFixedPgm | ( | lcdint_t | xpos, |
| lcdint_t | y, | ||
| const char * | ch, | ||
| EFontStyle | style = STYLE_NORMAL |
||
| ) |
Print text at specified position to canvas.
| xpos | position in pixels |
| y | position in pixels |
| ch | pointer to NULL-terminated string, located in flash |
| style | specific font style to use |
| void NanoCanvasOps< BPP >::putPixel | ( | lcdint_t | x, |
| lcdint_t | y | ||
| ) |
Draws pixel on specified position.
| x | - position X |
| y | - position Y |
| void NanoCanvasOps< BPP >::putPixel | ( | const NanoPoint & | p | ) |
|
inline |
|
inline |
|
inline |
|
inline |
Sets new font to use with print functions.
If multiple canvases are used in single application, this method can cause conflicts.
| progmemFont | pointer to font data in flash (refer to NanoFont::loadFixedFont) |
|
inline |
|
inline |
|
inline |
Sets new font to use with print functions.
If multiple canvases are used in single application, this method can cause conflicts.
| progmemFont | pointer to font data in flash (refer to NanoFont::loadFreeFont) |
| secondaryFont | pointer to font data in flash (refer to NanoFont::loadSecondaryFont) |
|
inline |
|
inline |
| size_t NanoCanvasOps< BPP >::write | ( | uint8_t | c | ) |
Writes single character to canvas.
| c | - character code to print |