SSD1306 OLED display driver  1.4.4
This library is developed to control SSD1306/SSD1331 RGB i2c/spi OLED displays and spi PCD8544 LED display
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
SpritePool Class Reference

#include <sprite_pool.h>

Public Member Functions

 SpritePool ()
 
void drawSprites ()
 
void refreshScreen ()
 
uint8_t add (SPRITE &sprite)
 
void clear ()
 
void remove (SPRITE &sprite)
 
void setRect (SSD1306_RECT rect)
 

Static Public Attributes

static const uint8_t SP_ERR_NO_SPACE = 0xFF
 No free space for new sprite error.
 
static const uint8_t MAX_SPRITES = 10
 Defines max sprites number supported by SpritePool.
 

Protected Member Functions

virtual void drawBlock (uint8_t blockColumn, uint8_t blockRow)
 

Protected Attributes

NanoCanvas m_canvas
 Canvas used to draw sprites to avoid flickering.
 
SSD1306_RECT m_rect
 Rectangle, which specifies part of the display, used by the sprites.
 

Detailed Description

Sprites pool class automates processing of several sprites. It remembers pointers to SPRITE objects, and carefully updates only the areas, touched by the sprites. So, it reduces number of i2c calls to SSD1306 display.

Definition at line 40 of file sprite_pool.h.

Constructor & Destructor Documentation

◆ SpritePool()

SpritePool::SpritePool ( )

Creates empty SpritePool object. It is able to hold up to 10 sprites on AVR platforms and up to 32 sprites on ESP platforms.

Definition at line 29 of file sprite_pool.cpp.

Member Function Documentation

◆ add()

uint8_t SpritePool::add ( SPRITE sprite)

Adds SPRITE object to the internal list of SpritePool

Parameters
sprite- reference to SPRITE object
Returns
index of added object or SP_ERR_NO_SPACE in case of error.

Definition at line 73 of file sprite_pool.cpp.

◆ clear()

void SpritePool::clear ( )

Removes all SPRITE objects from internal list of SpritePool.

Definition at line 85 of file sprite_pool.cpp.

◆ drawBlock()

void SpritePool::drawBlock ( uint8_t  blockColumn,
uint8_t  blockRow 
)
protectedvirtual

This method is call every time 8x8 pixels block is needed to be drawn. Use m_canvas field variable, which represents block to update. For example, you can draw any 8x8 image, starting at 0,0 position in m_canvas.

Parameters
blockColumn- column of the block to redraw
blockRow- row of the block to redraw
Note
128x64 display has 16 columns and 8 rows.

Definition at line 41 of file sprite_pool.cpp.

◆ drawSprites()

void SpritePool::drawSprites ( )

Draw all areas, touched by the sprites. To remove flickering, the method uses NanoCanvas capabilities.

Definition at line 46 of file sprite_pool.cpp.

◆ refreshScreen()

void SpritePool::refreshScreen ( )

Redraws whole area, used by the sprites.

Definition at line 65 of file sprite_pool.cpp.

◆ remove()

void SpritePool::remove ( SPRITE sprite)

Removes specific SPRITE object from the SpritePool.

Definition at line 90 of file sprite_pool.cpp.

◆ setRect()

void SpritePool::setRect ( SSD1306_RECT  rect)
inline

Sets active paint area region in blocks (pixels / 8)

Parameters
rect- region in blocks (pixels / 8)

Definition at line 94 of file sprite_pool.h.


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