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
NanoEngineTiler< C, D > Class Template Reference

This class template is responsible for holding and updating data about areas to be refreshed on LCD display. More...

#include <tiler.h>

Inheritance diagram for NanoEngineTiler< C, D >:

Public Types

typedef NanoEngineTiler< C, D > TilerT
 This type is template argument for all Nano Objects.
 

Public Member Functions

void refresh ()
 Marks all tiles for update. More...
 
void refresh (const NanoRect &rect)
 Mark specified area in pixels for redrawing by NanoEngine. More...
 
void refresh (const NanoPoint &point) __attribute__((noinline))
 Mark specified area in pixels for redrawing by NanoEngine. More...
 
void refresh (lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) __attribute__((noinline))
 Mark specified area in pixels for redrawing by NanoEngine. More...
 
void refreshWorld (const NanoRect &rect)
 Marks for refresh lcd area, which corresponds to specified rectangle in global (World) coordinates. More...
 
void refreshWorld (lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) __attribute__((noinline))
 Marks for refresh lcd area, which corresponds to specified rectangle in global (World) coordinates. More...
 
void refreshWorld (const NanoPoint &point)
 Marks specified pixel area for redrawing by NanoEngine. More...
 
void localCoordinates ()
 Switches engine canvas to local coordinates system. More...
 
void worldCoordinates ()
 Switches engine canvas to global (World) coordinates system. More...
 
void moveTo (const NanoPoint &position)
 Moves engine coordinate to new position (this sets World coordinates offset).
 
void moveToAndRefresh (const NanoPoint &position)
 Moves engine coordinate to new position and mark whole display for refresh (this sets World coordinates offset).
 
const NanoPointgetPosition () const
 Returns current World offset.
 
void drawCallback (TNanoEngineOnDraw callback)
 Sets user-defined draw callback. More...
 
bool collision (const NanoPoint &p, const NanoRect &rect)
 Returns true if point is inside the rectangle area. More...
 
void insert (NanoEngineObject< TilerT > &object) __attribute__((noinline))
 Inserts new NanoEngineObject. More...
 
void remove (NanoEngineObject< TilerT > &object) __attribute__((noinline))
 Removes NanoEngineObject from the list, but doesn't destroy the object. More...
 
void update () __attribute__((noinline))
 Updates all objects. More...
 
C & getCanvas ()
 Returns canvas, used by the NanoEngine.
 
D & getDisplay ()
 Returns reference to display object.
 

Protected Member Functions

 NanoEngineTiler (D &display)
 Only child classes can initialize the engine.
 
void displayBuffer () __attribute__((noinline))
 refreshes content on oled display. More...
 
void displayPopup (const char *msg)
 prints popup message over display content prints popup message over display content More...
 

Protected Attributes

D & m_display
 Reference to display object, used by NanoEngine.
 
TNanoEngineOnDraw m_onDraw
 Callback to call if specific tile needs to be updated.
 
uint16_t m_refreshFlags [NE_MAX_TILE_ROWS]
 Contains information on tiles to be updated. More...
 

Detailed Description

template<class C, class D>
class NanoEngineTiler< C, D >

This class template is responsible for holding and updating data about areas to be refreshed on LCD display.

It accepts canvas class, tile width in pixels, tile height in pixels and number of bits in tile width as arguments for the template. For example, for 8x8 8-bit RGB tiles the reference should be NanoEngineTiler<NanoCanvas8,8,8,3>, and 3 bits means 3^2 = 8. If you need to have single big buffer, holding the whole content for monochrome display, you can specify something like this NanoEngineTiler<NanoCanvas1,128,64,7>.

Definition at line 79 of file tiler.h.

Member Function Documentation

◆ collision()

template<class C , class D >
bool NanoEngineTiler< C, D >::collision ( const NanoPoint p,
const NanoRect rect 
)
inline

Returns true if point is inside the rectangle area.

Returns true if point is inside the rectangle area.

Parameters
p- point to check
rect- rectangle, describing the region to check with the point
Returns
true if point is inside the rectangle area.

Definition at line 353 of file tiler.h.

◆ displayBuffer()

template<class C , class D >
void NanoEngineTiler< C, D >::displayBuffer ( )
protected

refreshes content on oled display.

Refreshes content on oled display. Call it, if you want to update the screen. Engine will update only those areas, which are marked by refresh() methods.

Definition at line 487 of file tiler.h.

◆ displayPopup()

template<class C , class D >
void NanoEngineTiler< C, D >::displayPopup ( const char *  msg)
protected

prints popup message over display content prints popup message over display content

Parameters
msg- message to display

Definition at line 518 of file tiler.h.

◆ drawCallback()

template<class C , class D >
void NanoEngineTiler< C, D >::drawCallback ( TNanoEngineOnDraw  callback)
inline

Sets user-defined draw callback.

This callback will be called everytime, engine needs to update display content. If user callback returns false, engine will not update that area. You always have a way to find out, which area is being updated by engine via NanoEngine<>::canvas::getOffset() and NanoEngine<>::NE_TILE_SIZE.

Warning
By default canvas in the engine is initialized with world coordinates. So graphics object with [0,0] coordinates will be placed at topleft position fo the window pointed by offset property of NanoEngine. But engine supports also local coordinates, if you need to draw some dialog, for example. In this case actual object position depends on current engine offset. Refer to worldCoordinates() and localCoordinates().
Parameters
callback- user-defined draw callback.
Note
you can change draw callback anytime you need.
See also
worldCoordinates()
localCoordinates()

Definition at line 341 of file tiler.h.

◆ insert()

template<class C , class D >
void NanoEngineTiler< C, D >::insert ( NanoEngineObject< TilerT > &  object)
inline

Inserts new NanoEngineObject.

This object will be displayed during next call to update()/draw() methods.

Parameters
objectreference to object to place to NanoEngine

Definition at line 364 of file tiler.h.

◆ localCoordinates()

template<class C , class D >
void NanoEngineTiler< C, D >::localCoordinates ( )
inline

Switches engine canvas to local coordinates system.

This method can be useful to ease up drawing of some static elements on lcd display.

Warning
do not call twice subsequentally.

Definition at line 284 of file tiler.h.

◆ refresh() [1/4]

template<class C , class D >
void NanoEngineTiler< C, D >::refresh ( )
inline

Marks all tiles for update.

Actual update will take place in display() method.

Definition at line 201 of file tiler.h.

◆ refresh() [2/4]

template<class C , class D >
void NanoEngineTiler< C, D >::refresh ( const NanoRect rect)
inline

Mark specified area in pixels for redrawing by NanoEngine.

Actual update will take place in display() method.

Note
assumes that rect is in local screen coordinates

Definition at line 211 of file tiler.h.

◆ refresh() [3/4]

template<class C , class D >
void NanoEngineTiler< C, D >::refresh ( const NanoPoint point)
inline

Mark specified area in pixels for redrawing by NanoEngine.

Actual update will take place in display() method.

Definition at line 220 of file tiler.h.

◆ refresh() [4/4]

template<class C , class D >
void NanoEngineTiler< C, D >::refresh ( lcdint_t  x1,
lcdint_t  y1,
lcdint_t  x2,
lcdint_t  y2 
)
inline

Mark specified area in pixels for redrawing by NanoEngine.

Actual update will take place in display() method.

Definition at line 231 of file tiler.h.

◆ refreshWorld() [1/3]

template<class C , class D >
void NanoEngineTiler< C, D >::refreshWorld ( const NanoRect rect)
inline

Marks for refresh lcd area, which corresponds to specified rectangle in global (World) coordinates.

If engine offset is (0,0), then this function refreshes the same area as refresh().

Definition at line 255 of file tiler.h.

◆ refreshWorld() [2/3]

template<class C , class D >
void NanoEngineTiler< C, D >::refreshWorld ( lcdint_t  x1,
lcdint_t  y1,
lcdint_t  x2,
lcdint_t  y2 
)
inline

Marks for refresh lcd area, which corresponds to specified rectangle in global (World) coordinates.

If engine offset is (0,0), then this function refreshes the same area as refresh().

Definition at line 265 of file tiler.h.

◆ refreshWorld() [3/3]

template<class C , class D >
void NanoEngineTiler< C, D >::refreshWorld ( const NanoPoint point)
inline

Marks specified pixel area for redrawing by NanoEngine.

Parameters
pointpoint in global (World) coordinates

Definition at line 274 of file tiler.h.

◆ remove()

template<class C , class D >
void NanoEngineTiler< C, D >::remove ( NanoEngineObject< TilerT > &  object)
inline

Removes NanoEngineObject from the list, but doesn't destroy the object.

The place occupied by this object will be refreshed during next call to update()/draw() methods.

Parameters
objectobject to remove from NanoEngine

Definition at line 379 of file tiler.h.

◆ update()

template<class C , class D >
void NanoEngineTiler< C, D >::update ( )
inline

Updates all objects.

This method doesn't refresh screen content

Definition at line 412 of file tiler.h.

◆ worldCoordinates()

template<class C , class D >
void NanoEngineTiler< C, D >::worldCoordinates ( )
inline

Switches engine canvas to global (World) coordinates system.

This method can be useful to create screen moving animation.

Warning
do not call twice subsequentally.

Definition at line 294 of file tiler.h.

Member Data Documentation

◆ m_refreshFlags

template<class C , class D >
uint16_t NanoEngineTiler< C, D >::m_refreshFlags[NE_MAX_TILE_ROWS]
protected

Contains information on tiles to be updated.

Elements of array are rows and bits are columns.

Definition at line 451 of file tiler.h.


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