nimphea/ui/display

Source   Edit  

Display Concepts

Nim-friendly display abstraction layer providing concepts and generic programming patterns for working with displays.

This module provides higher-level abstractions over the low-level display drivers (SH1106, SSD1327, SSD1351).

Types

DisplayConcept = concept d
    d.fill(bool)             ## Fill display with color
    d.update()               ## Send buffer to hardware
    d.width() is int         ## Get display width
    d.height() is int        ## Get display height
Generic display concept - any type that implements these methods can be used with generic display functions Source   Edit  

Procs

proc drawCenteredText(display: var auto; y: int; text: string)
Draw text centered horizontally (placeholder - text rendering TBD) This is a template for future text rendering support Source   Edit  
proc drawProgressBar(display: var auto; x, y, width, height: int;
                     progress: float)
Draw a progress bar (0.0 to 1.0) Source   Edit  

Templates

template clearAndDraw(display: var auto; body: untyped)

Clear display and execute drawing operations

Example:

display.clearAndDraw:
  display.drawCircle(64, 32, 20, true)

Source   Edit  
template measureTime(display: var auto; label: static string; body: untyped)
Measure execution time and display on screen (debug helper) Note: Requires text rendering support Source   Edit  
template withDisplay(display: var auto; body: untyped)

Execute drawing operations and automatically update display

Example:

display.withDisplay:
  display.fill(false)
  display.drawRect(10, 10, 50, 20, true)
# display.update() called automatically

Source   Edit