FabGL
ESP32 Display Controller and Graphics Library
fabgl::BitmappedDisplayController Class Referenceabstract

Represents the base abstract class for bitmapped display controllers. More...

#include <displaycontroller.h>

Inheritance diagram for fabgl::BitmappedDisplayController:
Collaboration diagram for fabgl::BitmappedDisplayController:

Public Member Functions

DisplayControllerType controllerType ()
 Determines the display controller type. More...
 
void enableBackgroundPrimitiveExecution (bool value)
 Enables or disables drawings inside vertical retracing time. More...
 
void enableBackgroundPrimitiveTimeout (bool value)
 Enables or disables execution time limitation inside vertical retracing interrupt. More...
 
virtual int getScreenHeight ()=0
 Determines the screen height in pixels. More...
 
virtual int getScreenWidth ()=0
 Determines the screen width in pixels. More...
 
virtual int getViewPortHeight ()=0
 Determines vertical size of the viewport. More...
 
virtual int getViewPortWidth ()=0
 Determines horizontal size of the viewport. More...
 
bool isDoubleBuffered ()
 Determines whether BitmappedDisplayController is on double buffered mode. More...
 
virtual NativePixelFormat nativePixelFormat ()=0
 Represents the native pixel format used by this display. More...
 
void processPrimitives ()
 Draws immediately all primitives in the queue. More...
 
void refreshSprites ()
 Forces the sprites to be updated. More...
 
void removeSprites ()
 Empties the list of active sprites. More...
 
virtual void resumeBackgroundPrimitiveExecution ()=0
 Resumes drawings after suspendBackgroundPrimitiveExecution(). More...
 
void setMouseCursor (Cursor *cursor)
 Sets mouse cursor and make it visible. More...
 
void setMouseCursor (CursorName cursorName)
 Sets mouse cursor from a set of predefined cursors. More...
 
void setMouseCursorPos (int X, int Y)
 Sets mouse cursor position. More...
 
template<typename T >
void setSprites (T *sprites, int count)
 Sets the list of active sprites. More...
 
virtual void suspendBackgroundPrimitiveExecution ()=0
 Suspends drawings. More...
 

Static Public Attributes

static int queueSize = FABGLIB_DEFAULT_DISPLAYCONTROLLER_QUEUE_SIZE
 Size of display controller primitives queue. More...
 

Detailed Description

Represents the base abstract class for bitmapped display controllers.

Member Function Documentation

◆ controllerType()

DisplayControllerType fabgl::BitmappedDisplayController::controllerType ( )
inlinevirtual

Determines the display controller type.

Returns
Display controller type.

Implements fabgl::BaseDisplayController.

◆ enableBackgroundPrimitiveExecution()

void fabgl::BitmappedDisplayController::enableBackgroundPrimitiveExecution ( bool  value)

Enables or disables drawings inside vertical retracing time.

Primitives are processed in background (for example in vertical retracing for VGA or in a separated task for SPI/I2C displays). This method can disable (or reenable) this behavior, making drawing instantaneous. Flickering may occur when drawings are executed out of retracing time.
When background executing is disabled the queue is emptied executing all pending primitives. Some displays (SPI/I2C) may be not updated at all when enableBackgroundPrimitiveExecution is False.

Parameters
valueWhen true drawings are done on background, when false drawings are executed instantly.

◆ enableBackgroundPrimitiveTimeout()

void fabgl::BitmappedDisplayController::enableBackgroundPrimitiveTimeout ( bool  value)
inline

Enables or disables execution time limitation inside vertical retracing interrupt.

Disabling interrupt execution timeout may generate flickering but speedup drawing operations.

Parameters
valueTrue enables timeout (default), False disables timeout

◆ getScreenHeight()

virtual int fabgl::BaseDisplayController::getScreenHeight ( )
pure virtualinherited

Determines the screen height in pixels.

Returns
Screen height in pixels.

Implemented in fabgl::VGAController, fabgl::VGA16Controller, fabgl::TFTController, fabgl::VGATextController, and fabgl::SSD1306Controller.

◆ getScreenWidth()

virtual int fabgl::BaseDisplayController::getScreenWidth ( )
pure virtualinherited

Determines the screen width in pixels.

Returns
Screen width in pixels.

Implemented in fabgl::VGAController, fabgl::VGA16Controller, fabgl::TFTController, fabgl::VGATextController, and fabgl::SSD1306Controller.

◆ getViewPortHeight()

virtual int fabgl::BitmappedDisplayController::getViewPortHeight ( )
pure virtual

Determines vertical size of the viewport.

Returns
Vertical size of the viewport.

Implemented in fabgl::VGAController, fabgl::VGA16Controller, fabgl::TFTController, and fabgl::SSD1306Controller.

◆ getViewPortWidth()

virtual int fabgl::BitmappedDisplayController::getViewPortWidth ( )
pure virtual

Determines horizontal size of the viewport.

Returns
Horizontal size of the viewport.

Implemented in fabgl::VGAController, fabgl::VGA16Controller, fabgl::TFTController, and fabgl::SSD1306Controller.

◆ isDoubleBuffered()

bool fabgl::BitmappedDisplayController::isDoubleBuffered ( )
inline

Determines whether BitmappedDisplayController is on double buffered mode.

Returns
True if BitmappedDisplayController is on double buffered mode.

◆ nativePixelFormat()

virtual NativePixelFormat fabgl::BitmappedDisplayController::nativePixelFormat ( )
pure virtual

Represents the native pixel format used by this display.

Returns
Display native pixel format

Implemented in fabgl::VGAController, fabgl::TFTController, fabgl::VGA16Controller, and fabgl::SSD1306Controller.

◆ processPrimitives()

void IRAM_ATTR fabgl::BitmappedDisplayController::processPrimitives ( )

Draws immediately all primitives in the queue.

Draws all primitives before they are processed in the vertical sync interrupt.
May generate flickering because don't care of vertical sync.

◆ refreshSprites()

void fabgl::BitmappedDisplayController::refreshSprites ( )

Forces the sprites to be updated.

Screen is automatically updated whenever a primitive is painted (look at Canvas).
When a sprite updates its image or its position (or any other property) it is required to force a refresh using this method.
BitmappedDisplayController.refreshSprites() is required also when using the double buffered mode, to paint sprites.

Examples:
SSD1306_OLED/128x32/CollisionDetection/CollisionDetection.ino, SSD1306_OLED/128x64/CollisionDetection/CollisionDetection.ino, VGA/CollisionDetection/CollisionDetection.ino, VGA/SpaceInvaders/SpaceInvaders.ino, and VGA/Sprites/Sprites.ino.

◆ removeSprites()

void fabgl::BitmappedDisplayController::removeSprites ( )
inline

Empties the list of active sprites.

Call this method when you don't need active sprites anymore.

Examples:
VGA/SpaceInvaders/SpaceInvaders.ino.

◆ resumeBackgroundPrimitiveExecution()

virtual void fabgl::BitmappedDisplayController::resumeBackgroundPrimitiveExecution ( )
pure virtual

Resumes drawings after suspendBackgroundPrimitiveExecution().

Resumes drawings enabling vertical sync interrupt.

Implemented in fabgl::VGAController, fabgl::TFTController, fabgl::VGA16Controller, and fabgl::SSD1306Controller.

◆ setMouseCursor() [1/2]

void fabgl::BitmappedDisplayController::setMouseCursor ( Cursor cursor)

Sets mouse cursor and make it visible.

Parameters
cursorCursor to use when mouse pointer need to be painted. nullptr = disable mouse pointer.
Examples:
VGA/MouseOnScreen/MouseOnScreen.ino.

◆ setMouseCursor() [2/2]

void fabgl::BitmappedDisplayController::setMouseCursor ( CursorName  cursorName)

Sets mouse cursor from a set of predefined cursors.

Parameters
cursorNameName (enum) of predefined cursor.

Example:

VGAController.setMouseCursor(CursorName::CursorPointerShadowed);

◆ setMouseCursorPos()

void fabgl::BitmappedDisplayController::setMouseCursorPos ( int  X,
int  Y 
)

Sets mouse cursor position.

Parameters
XMouse cursor horizontal position.
YMouse cursor vertical position.

◆ setSprites()

template<typename T >
void fabgl::BitmappedDisplayController::setSprites ( T *  sprites,
int  count 
)
inline

Sets the list of active sprites.

A sprite is an image that keeps background unchanged.
There is no limit to the number of active sprites, but flickering and slow refresh happens when a lot of sprites (or large sprites) are visible.
To empty the list of active sprites call BitmappedDisplayController.removeSprites().

Parameters
spritesThe list of sprites to make currently active.
countNumber of sprites in the list.

Example:

// define a sprite with user data (velX and velY)
struct MySprite : Sprite {
  int  velX;
  int  velY;
};

static MySprite sprites[10];

VGAController.setSprites(sprites, 10);
Examples:
SSD1306_OLED/128x32/CollisionDetection/CollisionDetection.ino, SSD1306_OLED/128x64/CollisionDetection/CollisionDetection.ino, VGA/CollisionDetection/CollisionDetection.ino, VGA/SpaceInvaders/SpaceInvaders.ino, and VGA/Sprites/Sprites.ino.

◆ suspendBackgroundPrimitiveExecution()

virtual void fabgl::BitmappedDisplayController::suspendBackgroundPrimitiveExecution ( )
pure virtual

Suspends drawings.

Suspends drawings disabling vertical sync interrupt.
After call to suspendBackgroundPrimitiveExecution() adding new primitives may cause a deadlock.
To avoid it a call to "processPrimitives()" should be performed very often.
This method maintains a counter so can be nested.

Implemented in fabgl::VGAController, fabgl::TFTController, fabgl::VGA16Controller, and fabgl::SSD1306Controller.

Member Data Documentation

◆ queueSize

int fabgl::BitmappedDisplayController::queueSize = FABGLIB_DEFAULT_DISPLAYCONTROLLER_QUEUE_SIZE
static

Size of display controller primitives queue.

Application should change before begin() method.

Default value is FABGLIB_DEFAULT_DISPLAYCONTROLLER_QUEUE_SIZE (defined in fabglconf.h)

Examples:
VGA/MultitaskingCPM/MultitaskingCPM.ino.

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