DisplayManager

TFT display control and UI rendering

#include <DisplayManager.h>

Public Member Functions

 DisplayManager ()
 
 ~DisplayManager ()
 
void init ()
 
void update ()
 
void processEvent (const CloudMouse::Event &event)
 
void registerAppCallback (AppDisplayCallback callback)
 
bool isReady () const
 
int getWidth () const
 
int getHeight () const
 
bool isAnimating () const
 

Constructor & Destructor Documentation

◆ DisplayManager()

CloudMouse::Hardware::DisplayManager::DisplayManager ( )

Constructor - initializes display manager instance Prepares internal state but does not configure hardware Call init() separately for actual display initialization

◆ ~DisplayManager()

CloudMouse::Hardware::DisplayManager::~DisplayManager ( )

Destructor - ensures proper cleanup of sprite resources Automatically frees PSRAM sprite buffer and resets display state

Member Function Documentation

◆ getHeight()

int CloudMouse::Hardware::DisplayManager::getHeight ( ) const
inline

Get display height in pixels Returns configured display height for layout calculations

Returns
Display height (320 pixels in landscape mode)

◆ getWidth()

int CloudMouse::Hardware::DisplayManager::getWidth ( ) const
inline

Get display width in pixels Returns configured display width for layout calculations

Returns
Display width (480 pixels in landscape mode)

◆ init()

void CloudMouse::Hardware::DisplayManager::init ( )

Initialize display hardware and create sprite buffer Configures ILI9488 controller, allocates PSRAM buffer, and sets up QR code manager

Initialization Steps:

  1. Configure ILI9488 hardware (SPI, pins, power management)
  2. Set display brightness and orientation (landscape mode)
  3. Allocate full-screen sprite buffer in PSRAM (307KB)
  4. Initialize QR code generation system
  5. Set default text properties and color scheme

Hardware Requirements:

  • Sufficient PSRAM available (>400KB recommended)
  • Properly configured SPI pins and power management
  • ILI9488 controller properly connected and powered
Note
Must be called after PSRAM initialization
Not thread-safe - call only from single initialization thread

◆ isAnimating()

bool CloudMouse::Hardware::DisplayManager::isAnimating ( ) const
inline

Check if animations are currently active Useful for performance monitoring and power management

Returns
true if screen requires continuous animation updates

◆ isReady()

bool CloudMouse::Hardware::DisplayManager::isReady ( ) const
inline

Check if display manager is properly initialized Validates hardware initialization and sprite buffer allocation

Returns
true if display is ready for rendering operations

◆ processEvent()

void CloudMouse::Hardware::DisplayManager::processEvent ( const CloudMouse::Event event)

Process individual display event and update screen state Handles event-driven screen transitions and UI state updates Called internally by update() but available for manual event injection

Parameters
eventEvent structure containing type and payload data

Supported Event Types:

  • DISPLAY_WAKE_UP: Activate display and show default screen
  • DISPLAY_WIFI_CONNECTING: Show animated connection progress
  • DISPLAY_WIFI_AP_MODE: Display QR code for WiFi network access
  • DISPLAY_WIFI_SETUP_URL: Show QR code for web configuration
  • ENCODER_ROTATION: Update encoder interaction feedback
  • ENCODER_CLICK: Process button click feedback
  • ENCODER_LONG_PRESS: Handle long press interaction
  • DISPLAY_CLEAR: Clear screen to background color

State Management:

  • Automatic screen state transitions based on event type
  • Animation control (start/stop) based on screen requirements
  • Persistent state tracking for interactive elements

◆ registerAppCallback()

void CloudMouse::Hardware::DisplayManager::registerAppCallback ( AppDisplayCallback  callback)
inline

Register callback function for custom DislpayManager

Parameters
callbackCustom DisplayManager event process function

◆ update()

void CloudMouse::Hardware::DisplayManager::update ( )

Process pending display events and update animations Handles incoming events from EventBus and manages animation timing Should be called regularly from UI task loop for responsive display updates

Processing Operations:

  1. Receive and process all pending events from EventBus
  2. Update animation frames for active animated screens
  3. Trigger redraws based on timing and state changes
  4. Manage frame rate limiting for smooth animations

Recommended Call Frequency:

  • 20-50Hz for responsive UI updates
  • Higher frequencies improve animation smoothness
  • Lower frequencies reduce CPU usage but may impact responsiveness
Note
Non-blocking operation with configurable timeout