Hardware

Hardware namespace

Classes

class  DisplayManager
 
class  EncoderManager
 
struct  LEDEvent
 
class  LEDManager
 
class  SimpleBuzzer
 

Typedefs

typedef void(* AppDisplayCallback) (const CloudMouse::Event &event)
 

Enumerations

enum class  LEDEventType {
  SET_LOADING , FLASH_COLOR , ACTIVATE , SET_COLOR ,
  SET_BRIGHTNESS
}
 

Detailed Description

CloudMouse SDK - Display Management System Implementation

Implementation of comprehensive display controller with event-driven UI management, hardware-accelerated sprite rendering, and integrated QR code generation capabilities.

Implementation Architecture:

  • Event-driven state machine for responsive screen management
  • PSRAM-buffered sprite rendering for flicker-free updates
  • Modular screen rendering system for maintainable UI development
  • Optimized animation timing for smooth visual feedback
  • Memory-efficient resource management with automatic cleanup

Performance Optimizations:

  • Hardware-accelerated SPI transfers (40MHz sustained)
  • PSRAM utilization to preserve main RAM for application logic
  • Selective redraw regions to minimize unnecessary updates
  • Frame rate limiting to balance smoothness with CPU usage
  • Event-driven updates to eliminate polling overhead

Integration Points:

  • EventBus for inter-task communication and state synchronization
  • QRCodeManager for dynamic QR code generation and rendering
  • DeviceConfig for hardware-specific configuration values
  • LGFX library for hardware-accelerated graphics operations

Display Management Controller

High-level display controller providing event-driven UI management with multiple screen states, smooth animations, and integrated QR code generation capabilities.

Architecture:

  • Event-driven screen state machine with automatic transitions
  • Hardware-accelerated sprite rendering with PSRAM buffering
  • Modular screen rendering system for extensible UI development
  • Integrated timing management for smooth animations and responsive updates

Memory Management:

  • Uses PSRAM for large sprite buffer to preserve main RAM
  • Automatic sprite allocation and cleanup in constructor/destructor
  • Efficient color palette with predefined UI theme colors
  • Memory-conscious rendering with selective update regions

Thread Safety:

  • Designed for single UI task usage (typically Core1)
  • Event processing is non-blocking with queue-based communication
  • Sprite operations are inherently thread-safe when called from single task
  • No shared mutable state across multiple tasks

CloudMouse SDK - Rotary Encoder Input Manager Implementation

Implementation of hardware-accelerated rotary encoder input processing with intelligent button press detection and event-driven architecture for reliable user interaction handling.

Implementation Details:

  • PCNT hardware integration for rotation tracking without CPU interrupts
  • State machine approach for button press detection with precise timing
  • Event accumulation strategy for smooth movement reporting across update cycles
  • Multi-threshold press detection for rich interaction vocabulary
  • Consumption-based event model preventing duplicate processing

Performance Characteristics:

  • Rotation tracking: Hardware PCNT with 0.25° resolution
  • Button sampling: 50-100Hz recommended for responsive feel
  • Memory usage: ~100 bytes RAM for state management
  • CPU overhead: Minimal due to hardware acceleration

Timing Analysis:

  • Click detection: < 500ms press duration
  • Long press: 1000-2999ms with optional buzzer feedback
  • Ultra-long press: >= 3000ms with immediate event trigger
  • Debouncing: Handled by hardware pull-ups and state machine logic

Rotary Encoder Manager

Manages rotary encoder input with integrated button press detection. Provides event-driven interface with automatic state reset for reliable interaction handling.

Architecture:

  • Hardware PCNT for precise rotation counting without CPU interrupts
  • State machine for button press detection with timing analysis
  • Event accumulation for smooth movement reporting across update cycles
  • Multi-level press detection for rich interaction vocabulary

Thread Safety:

  • Single-task usage recommended (typically main/core task)
  • State variables are not protected by mutexes
  • Event consumption is atomic at method call level

Update Frequency:

  • Call update() every 10-20ms for responsive feel
  • Higher frequencies improve button responsiveness
  • Lower frequencies may miss rapid encoder movements

CloudMouse SDK - LED Animation Manager Implementation

Implementation of the LED animation system with thread-safe event handling and smooth animation effects for the NeoPixel LED ring.

Typedef Documentation

◆ AppDisplayCallback

typedef void(* CloudMouse::Hardware::AppDisplayCallback) (const CloudMouse::Event &event)

custom DisplayManager callback definition

Enumeration Type Documentation

◆ LEDEventType

LED Event Types for inter-task communication

Enumerator
SET_LOADING 
FLASH_COLOR 
ACTIVATE 
SET_COLOR 
SET_BRIGHTNESS