LCDGFX LCD display driver  1.1.4
This library is developed to control SSD1306/SSD1325/SSD1327/SSD1331/SSD1351/IL9163/PCD8554 RGB i2c/spi LED displays
NanoCanvasOps< BPP > Class Template Reference

#include <canvas.h>

Inheritance diagram for NanoCanvasOps< BPP >:
Collaboration diagram for NanoCanvasOps< BPP >:

Public Types

typedef NanoCanvasOps< BPP > T
 

Public Member Functions

 NanoCanvasOps ()
 
 NanoCanvasOps (lcdint_t w, lcdint_t h, uint8_t *bytes)
 
void begin (lcdint_t w, lcdint_t h, uint8_t *bytes)
 
void setOffset (lcdint_t ox, lcdint_t oy)
 
const NanoPoint offsetEnd () const
 
const NanoRect rect () const
 
void putPixel (lcdint_t x, lcdint_t y)
 
void putPixel (const NanoPoint &p)
 
void drawVLine (lcdint_t x1, lcdint_t y1, lcdint_t y2)
 
void drawHLine (lcdint_t x1, lcdint_t y1, lcdint_t x2)
 
void drawLine (lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2)
 
void drawLine (const NanoRect &rect)
 
void drawRect (lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) __attribute__((noinline))
 
void drawRect (const NanoRect &rect)
 
void fillRect (lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) __attribute__((noinline))
 
void fillRect (const NanoRect &rect)
 
void drawCircle (lcdint_t x, lcdint_t y, lcdint_t r) __attribute__((noinline))
 
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. 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. Draws 16-bit color bitmap in color buffer. More...
 
void clear () __attribute__((noinline))
 
size_t write (uint8_t c)
 
uint8_t printChar (uint8_t c)
 
void printFixed (lcdint_t xpos, lcdint_t y, const char *ch, EFontStyle style=STYLE_NORMAL) __attribute__((noinline))
 
void printFixedPgm (lcdint_t xpos, lcdint_t y, const char *ch, EFontStyle style=STYLE_NORMAL)
 
void setMode (uint8_t modeFlags)
 Sets canvas drawing mode Sets canvas drawing mode. The set flags define transparency of output images. More...
 
void setColor (uint16_t color)
 
uint16_t getColor ()
 
void invertColors ()
 
void setBackground (uint16_t color)
 
void setFont (NanoFont &font)
 
NanoFontgetFont ()
 
void setFontSpacing (uint8_t spacing)
 
void setFixedFont (const uint8_t *progmemFont)
 
void setFreeFont (const uint8_t *progmemFont, const uint8_t *secondaryFont=nullptr)
 
uint8_t * getData ()
 
lcduint_t width ()
 
lcduint_t height ()
 
void rotateCW (T &out)
 

Public Attributes

NanoPoint offset
 

Static Public Attributes

static const uint8_t BITS_PER_PIXEL = BPP
 

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
 
NanoFontm_font = nullptr
 current set font to use with NanoCanvas
 

Detailed Description

template<uint8_t BPP>
class NanoCanvasOps< BPP >

NanoCanvasOps provides operations for drawing in memory buffer. Depending on BPP argument, this class can work with 1,8,16-bit canvas areas.

Definition at line 45 of file canvas.h.

Member Typedef Documentation

◆ T

template<uint8_t BPP>
typedef NanoCanvasOps<BPP> NanoCanvasOps< BPP >::T

Base type for canvas class specific operations

Definition at line 49 of file canvas.h.

Constructor & Destructor Documentation

◆ NanoCanvasOps() [1/2]

template<uint8_t BPP>
NanoCanvasOps< BPP >::NanoCanvasOps ( )
inline

Creates new empty canvas object. If you this constructor is used, you must call begin() method before working with canvas.

Definition at line 62 of file canvas.h.

◆ NanoCanvasOps() [2/2]

template<uint8_t BPP>
NanoCanvasOps< BPP >::NanoCanvasOps ( lcdint_t  w,
lcdint_t  h,
uint8_t *  bytes 
)
inline

Creates new canvas object. Width can be of any value. Height should be divided by 8. Memory buffer must be not less than w * h.

Parameters
w- width
h- height
bytes- pointer to memory buffer to use

Definition at line 76 of file canvas.h.

Member Function Documentation

◆ begin()

template<uint8_t BPP>
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.

Parameters
w- width
h- height
bytes- pointer to memory buffer to use

◆ clear()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::clear ( )

Clears canvas

◆ drawBitmap1()

template<uint8_t BPP>
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.

Parameters
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
Note
There are 2 modes: transparent and non-transparent mode, - and 2 colors available: black and white. In non-transparent mode, when black color is selected, the monochrome image just inverted. In transparent mode, those pixels of source monochrome image, which are black, do not overwrite pixels in the screen buffer.

◆ drawBitmap16()

template<uint8_t BPP>
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.

Parameters
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

◆ drawBitmap8()

template<uint8_t BPP>
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.

Parameters
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

◆ drawCircle()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::drawCircle ( lcdint_t  x,
lcdint_t  y,
lcdint_t  r 
)

Draws circle

Parameters
xhorizontal position of circle center in pixels
yvertical position of circle center in pixels
rcircle radius in pixels

◆ drawHLine()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::drawHLine ( lcdint_t  x1,
lcdint_t  y1,
lcdint_t  x2 
)

Draws horizontal or vertical line

Parameters
x1- position X
y1- position Y
x2- position X
Note
color can be set via setColor()

◆ drawLine() [1/2]

template<uint8_t BPP>
void NanoCanvasOps< BPP >::drawLine ( lcdint_t  x1,
lcdint_t  y1,
lcdint_t  x2,
lcdint_t  y2 
)

Draws line

Parameters
x1- position X
y1- position Y
x2- position X
y2- position Y
Note
color can be set via setColor()

◆ drawLine() [2/2]

template<uint8_t BPP>
void NanoCanvasOps< BPP >::drawLine ( const NanoRect rect)

Draws line

Parameters
rect- structure, describing rectangle area
Note
color can be set via setColor()

◆ drawRect() [1/2]

template<uint8_t BPP>
void NanoCanvasOps< BPP >::drawRect ( lcdint_t  x1,
lcdint_t  y1,
lcdint_t  x2,
lcdint_t  y2 
)

Draws rectangle

Parameters
x1- position X
y1- position Y
x2- position X
y2- position Y
Note
color can be set via setColor()

◆ drawRect() [2/2]

template<uint8_t BPP>
void NanoCanvasOps< BPP >::drawRect ( const NanoRect rect)

Draws rectangle

Parameters
rect- structure, describing rectangle area
Note
color can be set via setColor()

◆ drawVLine()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::drawVLine ( lcdint_t  x1,
lcdint_t  y1,
lcdint_t  y2 
)

Draws horizontal or vertical line

Parameters
x1- position X
y1- position Y
y2- position Y
Note
color can be set via setColor()

◆ fillRect() [1/2]

template<uint8_t BPP>
void NanoCanvasOps< BPP >::fillRect ( lcdint_t  x1,
lcdint_t  y1,
lcdint_t  x2,
lcdint_t  y2 
)

Fills rectangle area

Parameters
x1- position X
y1- position Y
x2- position X
y2- position Y
Note
color can be set via setColor()

◆ fillRect() [2/2]

template<uint8_t BPP>
void NanoCanvasOps< BPP >::fillRect ( const NanoRect rect)

Fills rectangle area

Parameters
rect- structure, describing rectangle area
Note
color can be set via setColor()

◆ getColor()

template<uint8_t BPP>
uint16_t NanoCanvasOps< BPP >::getColor ( )
inline

Returns currently set color.

Definition at line 318 of file canvas.h.

◆ getData()

template<uint8_t BPP>
uint8_t* NanoCanvasOps< BPP >::getData ( )
inline

Return pointer to canvas pixels data

Definition at line 407 of file canvas.h.

◆ getFont()

template<uint8_t BPP>
NanoFont& NanoCanvasOps< BPP >::getFont ( )
inline

Returns reference to NanoFont object, currently used by Display

Definition at line 359 of file canvas.h.

◆ height()

template<uint8_t BPP>
lcduint_t NanoCanvasOps< BPP >::height ( )
inline

Returns canvas height in pixels

Definition at line 419 of file canvas.h.

◆ invertColors()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::invertColors ( )
inline

Changes foreground and background colors

Definition at line 326 of file canvas.h.

◆ offsetEnd()

template<uint8_t BPP>
const NanoPoint NanoCanvasOps< BPP >::offsetEnd ( ) const
inline

Returns right-bottom point of the canvas in offset terms. If offset is (0,0), then offsetEnd() will return (width-1,height-1).

Definition at line 108 of file canvas.h.

◆ printChar()

template<uint8_t BPP>
uint8_t NanoCanvasOps< BPP >::printChar ( uint8_t  c)

Draws single character to canvas

Parameters
c- character code to print
Returns
0 if char is not printed

◆ printFixed()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::printFixed ( lcdint_t  xpos,
lcdint_t  y,
const char *  ch,
EFontStyle  style = STYLE_NORMAL 
)

Print text at specified position to canvas

Parameters
xposposition in pixels
yposition in pixels
chpointer to NULL-terminated string.
stylespecific font style to use
Note
Supports only STYLE_NORMAL and STYLE_BOLD

◆ printFixedPgm()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::printFixedPgm ( lcdint_t  xpos,
lcdint_t  y,
const char *  ch,
EFontStyle  style = STYLE_NORMAL 
)

Print text at specified position to canvas

Parameters
xposposition in pixels
yposition in pixels
chpointer to NULL-terminated string, located in flash
stylespecific font style to use
Note
Supports only STYLE_NORMAL and STYLE_BOLD

◆ putPixel() [1/2]

template<uint8_t BPP>
void NanoCanvasOps< BPP >::putPixel ( lcdint_t  x,
lcdint_t  y 
)

Draws pixel on specified position

Parameters
x- position X
y- position Y
Note
color can be set via setColor()

◆ putPixel() [2/2]

template<uint8_t BPP>
void NanoCanvasOps< BPP >::putPixel ( const NanoPoint p)

Draws pixel on specified position

Parameters
p- NanoPoint
Note
color can be set via setColor()

◆ rect()

template<uint8_t BPP>
const NanoRect NanoCanvasOps< BPP >::rect ( ) const
inline

Returns rectangle area, covered by canvas in offset terms. If offset is (0,0), then rect() will return ((0,0),(width-1,height-1))

Definition at line 117 of file canvas.h.

◆ rotateCW()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::rotateCW ( T out)

Rotates the canvas clock-wise

◆ setBackground()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::setBackground ( uint16_t  color)
inline

Sets background color

Parameters
colorBackground color

Definition at line 338 of file canvas.h.

◆ setColor()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::setColor ( uint16_t  color)
inline

Sets color for monochrome operations

Parameters
color- color to set (refer to RGB_COLOR8 definition)

Definition at line 310 of file canvas.h.

◆ setFixedFont()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::setFixedFont ( const uint8_t *  progmemFont)
inline

Sets new font to use with print functions. If multiple canvases are used in single application, this method can cause conflicts.

Warning
use this method only if single canvas is used in project
Parameters
progmemFontpointer to font data in flash (refer to NanoFont::loadFixedFont)

Definition at line 383 of file canvas.h.

◆ setFont()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::setFont ( NanoFont font)
inline

Sets new font to use with print functions. If multiple canvases are used in single application, this method allows to use different fonts for different canvases.

Parameters
fontreference to font object (NanoFont)

Definition at line 351 of file canvas.h.

◆ setFontSpacing()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::setFontSpacing ( uint8_t  spacing)
inline

Sets font spacing for currently active font

Parameters
spacingspacing in pixels

Definition at line 368 of file canvas.h.

◆ setFreeFont()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::setFreeFont ( const uint8_t *  progmemFont,
const uint8_t *  secondaryFont = nullptr 
)
inline

Sets new font to use with print functions. If multiple canvases are used in single application, this method can cause conflicts.

Warning
use this method only if single canvas is used in project
Parameters
progmemFontpointer to font data in flash (refer to NanoFont::loadFreeFont)
secondaryFontpointer to font data in flash (refer to NanoFont::loadSecondaryFont)

Definition at line 399 of file canvas.h.

◆ setMode()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::setMode ( uint8_t  modeFlags)
inline

Sets canvas drawing mode Sets canvas drawing mode. The set flags define transparency of output images.

Parameters
modeFlags- combination of flags: CANVAS_TEXT_WRAP, CANVAS_MODE_TRANSPARENT

Definition at line 301 of file canvas.h.

◆ setOffset()

template<uint8_t BPP>
void NanoCanvasOps< BPP >::setOffset ( lcdint_t  ox,
lcdint_t  oy 
)
inline

Sets offset

Parameters
ox- X offset in pixels
oy- Y offset in pixels

Definition at line 98 of file canvas.h.

◆ width()

template<uint8_t BPP>
lcduint_t NanoCanvasOps< BPP >::width ( )
inline

Returns canvas width in pixels

Definition at line 413 of file canvas.h.

◆ write()

template<uint8_t BPP>
size_t NanoCanvasOps< BPP >::write ( uint8_t  c)

Writes single character to canvas

Parameters
c- character code to print

Member Data Documentation

◆ BITS_PER_PIXEL

template<uint8_t BPP>
const uint8_t NanoCanvasOps< BPP >::BITS_PER_PIXEL = BPP
static

number of bits per single pixel in buffer

Definition at line 52 of file canvas.h.

◆ offset

template<uint8_t BPP>
NanoPoint NanoCanvasOps< BPP >::offset

Fixed offset for all operation of NanoCanvasOps in pixels

Definition at line 55 of file canvas.h.


The documentation for this class was generated from the following file: