Kleidos API Search

In development. It changes without notice.

The panel: its surface, its text, its frames and its light.

What draws calls the functions of display::, which draw on a surface (graphics::Surface). Two panel drivers implement it: SpiPanelDriver for the color panels and EpaperPanelDriver for the e-paper one, which gathers a frame and refreshes when the panel is ready. Text goes through a renderer onto the same surface.

A panel driver takes the description of its controller (what to send at the start, how it rotates, how large its memory is) from Display Panel Drivers and does all the traffic on the bus itself. The panel's size, its pins and its bus come from Build Configuration. On the boards whose light hangs off the power chip, that chip drives it.

See also
Hardware Abstraction Layer, Display Panel Drivers, Render Canvas

Files

file src/hal/display/banded_frame.h
A frame buffer held as row bands, in one block or in one block per band.
file src/hal/display/clip_window.h
Allocation-free integer rectangle intersection for the software clip.
file src/hal/display/dirty_region_set.h
Multi-region dirty-rectangle tracker that merges nearby areas.
file src/hal/display/display_catalog.h
Compile-time display panel and bus descriptors for the active variant.
file src/hal/display/display_hal.h
Device-agnostic display drawing API (the display:: namespace).
file src/hal/display/display_hal_epaper.cpp
The CoreInk e-paper back-end of the display:: API (display_hal.h).
file src/hal/display/display_hal_tft.cpp
The SPI TFT back-end (ST7789 / ILI9342) of the display:: API (display_hal.h).
file src/hal/display/display_text.h
Shared display text helpers (UTF-8 to Latin-1 folding).
file src/hal/display/display_types.h
Display primitive types: RGB565 color constants and text datums.
file src/hal/display/epaper_panel_driver.h
Self-contained monochrome e-paper panel driver implementing the graphics Surface.
file src/hal/display/font_ladder.h
The atlas each font role is drawn from, per panel class.
file src/hal/display/fonts/aa_font.h
Self-contained anti-aliased UI font format and runtime decoder.
file src/hal/display/frame_poll.h
When a frame the loop task paints reads an input: the rule behind display::setFramePoll.
file src/hal/display/graphics.h
Backend-independent 2D drawing primitives over an abstract Surface.
file src/hal/display/mono_dither.h
Ink/paper decisions for 1-bit monochrome panels: the text threshold and the ordered (Bayer) dither for brand art.
file src/hal/display/pmic_backlight.h
PMIC-controlled display backlight and panel-rail control.
file src/hal/display/rgb565_blend.h
Shared RGB565 alpha-blend helpers for anti-aliased rendering.
file src/hal/display/spi_panel_driver.h
Self-contained SPI display panel driver implementing the graphics Surface.
file src/hal/display/text_renderer.h
Backend-independent bitmap text renderer over a graphics Surface.

Classes

class kleidos::hal::display::driver::BandedFrame
A frame of fixed-width rows, stored as bands of kBandRows rows. More about kleidos::hal::display::driver::BandedFrame
struct kleidos::hal::display::driver::ClipRect
A logical-pixel rectangle for clip intersection. More about kleidos::hal::display::driver::ClipRect
class kleidos::hal::display::driver::ClipWindow
Optional software clip window in logical screen pixels. More about kleidos::hal::display::driver::ClipWindow
struct kleidos::hal::display::driver::DirtyRect
Axis-aligned rectangle in half-open pixel coordinates. More about kleidos::hal::display::driver::DirtyRect
class kleidos::hal::display::driver::DirtyRegionSet< Capacity >
Fixed-capacity set of dirty rectangles; areas that overlap, touch or lie within a small gap are merged. More about kleidos::hal::display::driver::DirtyRegionSet< Capacity >
struct kleidos::hal::display::catalog::Pins
GPIO assignments for a display bus. More about kleidos::hal::display::catalog::Pins
struct kleidos::hal::display::catalog::PanelSpec
Geometry, rotation and color configuration for a display panel. More about kleidos::hal::display::catalog::PanelSpec
struct kleidos::hal::display::catalog::BusSpec
SPI bus and backlight configuration for a display. More about kleidos::hal::display::catalog::BusSpec
struct kleidos::hal::display::PanelIdentity
How the running firmware identified its panel controller. More about kleidos::hal::display::PanelIdentity
struct kleidos::hal::display::PanelMemoryInfo
The panel controller's frame memory, as the introspection console reads it. More about kleidos::hal::display::PanelMemoryInfo
struct kleidos::hal::display::PanelMemoryCell
One cell of the panel controller's memory, as read back. More about kleidos::hal::display::PanelMemoryCell
struct kleidos::hal::display::TextBox
Destination rectangle plus fill/text colors for a buffered string draw. More about kleidos::hal::display::TextBox
struct kleidos::hal::display::SpiBusStatus
Read-only snapshot of the active panel's SPI peripheral wiring/state. More about kleidos::hal::display::SpiBusStatus
struct kleidos::hal::display::driver::EpaperPanelConfig
Pin/bus description for an SPI-attached e-paper panel. More about kleidos::hal::display::driver::EpaperPanelConfig
class kleidos::hal::display::driver::EpaperPanelDriver
SPI-attached e-paper panel driver exposing a drawable graphics Surface. More about kleidos::hal::display::driver::EpaperPanelDriver
struct kleidos::hal::display::FontRung
One rung of a ladder: the face and its size in pixels. More about kleidos::hal::display::FontRung
struct kleidos::hal::display::fonts::AaGlyph
Per-glyph descriptor over a font's shared alpha bitmap blob. More about kleidos::hal::display::fonts::AaGlyph
struct kleidos::hal::display::fonts::AaCmap
One Unicode-to-glyph mapping block. More about kleidos::hal::display::fonts::AaCmap
struct kleidos::hal::display::fonts::AaFont
A complete generated anti-aliased font at one pixel size. More about kleidos::hal::display::fonts::AaFont
class kleidos::hal::display::FramePoll
Runs a hook from inside a frame, at most once per period. More about kleidos::hal::display::FramePoll
class kleidos::hal::display::graphics::Surface
Abstract drawable target addressed in 16-bit RGB565 pixels. More about kleidos::hal::display::graphics::Surface
class kleidos::hal::display::graphics::SpanWriter
Collects the pixels one scanline writes and sends each run of them to a Surface as one Surface::writePixelSpan. More about kleidos::hal::display::graphics::SpanWriter
class kleidos::hal::display::driver::SpiPanelDriver
SPI-attached panel driver exposing a drawable graphics Surface. More about kleidos::hal::display::driver::SpiPanelDriver
struct kleidos::hal::display::text_renderer::TextStyle
Visual attributes applied when measuring or drawing a string. More about kleidos::hal::display::text_renderer::TextStyle

Typedefs

usingkleidos::hal::display::FramePollHook
A function an open frame runs to read an input (setFramePoll).
usingkleidos::hal::display::WakeHook
A function the panel runs once each time it goes from asleep to awake.

Enumerations

enum class kleidos::hal::display::catalog::PanelController : uint8_t { kleidos::hal::display::catalog::PanelController::None , kleidos::hal::display::catalog::PanelController::St7789 , kleidos::hal::display::catalog::PanelController::Ili9342 }
Supported display panel controllers. More about kleidos::hal::display::catalog::PanelController
enum class kleidos::hal::display::catalog::BusInterface : uint8_t { kleidos::hal::display::catalog::BusInterface::None , kleidos::hal::display::catalog::BusInterface::SpiDataCommand }
Supported display bus interface types. More about kleidos::hal::display::catalog::BusInterface
enum class kleidos::hal::display::Font : uint8_t { kleidos::hal::display::Font::SMALL, kleidos::hal::display::Font::BODY, kleidos::hal::display::Font::HEADING, kleidos::hal::display::Font::LARGE, kleidos::hal::display::Font::MONO }
Logical font roles. Backends map these to the clearest device-specific text renderer available. Use these instead of setTextSize() to keep the UI legible across resolutions. The size of each role depends on the panel: kFontLadderPx. More about kleidos::hal::display::Font
enum class kleidos::hal::display::FontLadder : uint8_t { kleidos::hal::display::FontLadder::StickPortrait , kleidos::hal::display::FontLadder::CardputerLandscape , kleidos::hal::display::FontLadder::Wide , kleidos::hal::display::FontLadder::Epaper }
The panel classes the renderer keeps a role ladder for. More about kleidos::hal::display::FontLadder

Functions

constexpr boolkleidos::hal::display::driver::intersectRect (ClipRect &rect, int32_t x, int32_t y, int32_t w, int32_t h)
Intersect rect in place with the rectangle [x, y, w, h].
constexpr PanelControllerkleidos::hal::display::catalog::devicePanelController ()
Get the panel controller selected by the active variant.
constexpr BusInterfacekleidos::hal::display::catalog::deviceBusInterface ()
Get the bus interface selected by the active variant's display pin assignments.
constexpr PanelSpeckleidos::hal::display::catalog::devicePanelSpec ()
Assemble the full panel descriptor from the active variant's config.
constexpr kleidos::drivers::display::GramSizekleidos::hal::display::catalog::gramSize (PanelController controller)
Frame-memory size of a panel controller.
constexpr kleidos::drivers::display::PanelPlacementkleidos::hal::display::catalog::placement (const PanelSpec &panel)
The part of the controller's memory a panel shows.
constexpr boolkleidos::hal::display::catalog::fitsControllerGram (const PanelSpec &panel)
Whether a panel's declared placement lies inside its controller's memory.
kleidos::platform::spi::Hostkleidos::hal::display::catalog::deviceSpiHost ()
Get the SPI host for the active variant.
BusSpeckleidos::hal::display::catalog::deviceBusSpec ()
Assemble the full bus descriptor for the active variant.
const char *kleidos::hal::display::catalog::panelControllerName (PanelController controller)
Get the human-readable name for a panel controller.
const char *kleidos::hal::display::catalog::busInterfaceName (BusInterface interface)
Get the human-readable name for a bus interface.
boolkleidos::hal::display::catalog::isSupported (const PanelSpec &panel, const BusSpec &bus)
Check whether the given panel/bus combination is supported.
voidkleidos::hal::display::init ()
Initialize the active display backend (SPI panel or e-paper).
voidkleidos::hal::display::setInvert (bool invert)
Swap the ink/paper polarity for the light/dark theme on 1-bit panels.
boolkleidos::hal::display::setFastPartial (bool enable)
Switch e-paper partial refreshes between the quality and fast waveforms.
boolkleidos::hal::display::setEpaperAlwaysFull (bool enable)
Select the e-paper user refresh mode ("Full" vs the hybrid default).
boolkleidos::hal::display::initEpaperRetained ()
Bring the e-paper panel up without clearing it.
boolkleidos::hal::display::adoptEpaperRetainedFrame ()
Take the frame drawn since initEpaperRetained as what the glass shows.
voidkleidos::hal::display::setEpaperBusyPoll (void(*hook)())
Run hook on every poll while the e-paper panel is busy.
voidkleidos::hal::display::setFramePoll (FramePollHook hook, uint32_t periodMs)
Read an input from inside the frames the loop task paints.
boolkleidos::hal::display::epaperAlwaysFull ()
boolkleidos::hal::display::readEpaperRam (uint8_t plane, uint8_t *out, size_t outSize)
Read back an e-paper RAM plane or CPU frame buffer (QA/debug).
boolkleidos::hal::display::setEpaperFastTuning (const uint8_t *lut, const uint8_t *sourceVoltage, int updateMode)
Override the e-paper fast-animation waveform at runtime (QA tuning).
boolkleidos::hal::display::renderEpaperGray (const uint8_t *msbPlane, const uint8_t *lsbPlane, const uint8_t *lut)
Render a 2-bit grayscale image on the e-paper (QA/exploration).
boolkleidos::hal::display::renderEpaperGrayFrame (const uint8_t *toneFrame, size_t pixelCount)
Render a retained full-frame 6-tone grayscale image (QA/static UI).
boolkleidos::hal::display::beginEpaperToneCompose ()
Begin composing the current frame as 6-tone grayscale (static UI).
boolkleidos::hal::display::commitEpaperToneCompose ()
Finish a tone-compose pass by driving the retained 6-tone frame.
voidkleidos::hal::display::abortEpaperToneCompose ()
Discard an armed tone-compose pass without a gray render.
boolkleidos::hal::display::epaperToneComposeActive ()
Whether a 6-tone tone-compose pass is currently armed.
boolkleidos::hal::display::epaperGrayRetained ()
Whether a 6-tone gray frame is currently retained on the panel.
boolkleidos::hal::display::epaperFastPartial ()
Whether the e-paper controller currently holds the fast-animation LUT.
boolkleidos::hal::display::epaperPowerDownWhenIdle (uint32_t nowMs, uint32_t idleMs)
Power the e-paper panel's analog rails down once the glass has been still for idleMs.
boolkleidos::hal::display::grayUpdateProbe (const uint8_t *msbPlane, const uint8_t *lsbPlane, const uint8_t *lut, uint16_t y0, uint16_t y1, uint16_t gateLines, uint32_t &outUpdateMs)
Run one windowed grayscale update pass for wall-clock profiling (QA probe).
voidkleidos::hal::display::sleep ()
Put the active display into its low-power sleep state.
voidkleidos::hal::display::holdBacklightOff ()
Before a deep sleep: drive the backlight pin to its off level and hold it there through the sleep.
boolkleidos::hal::display::reinit ()
Re-initialize a controller that lost its supply.
boolkleidos::hal::display::reacquireBacklight ()
Take the backlight pad back for the display driver.
voidkleidos::hal::display::setBrightness (uint8_t b)
Set backlight brightness as a chip-agnostic percent (0..100).
uint8_tkleidos::hal::display::getBrightness ()
Get the last brightness setting.
voidkleidos::hal::display::fillScreen (uint16_t color)
Fill the entire screen with a single color.
voidkleidos::hal::display::fillRect (int32_t x, int32_t y, int32_t w, int32_t h, uint16_t c)
Fill a rectangular region with a single color.
uint32_tkleidos::hal::display::screenClears ()
How many times the whole glass has been cleared since boot.
voidkleidos::hal::display::drawRect (int32_t x, int32_t y, int32_t w, int32_t h, uint16_t c)
Draw a 1-pixel-wide rectangle outline.
voidkleidos::hal::display::fillRoundRect (int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, uint16_t c)
Fill a rounded rectangle.
voidkleidos::hal::display::drawRoundRect (int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, uint16_t c)
Draw a rounded rectangle outline.
voidkleidos::hal::display::drawLine (int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint16_t c)
Draw a Bresenham line.
voidkleidos::hal::display::drawFastHLine (int32_t x, int32_t y, int32_t w, uint16_t c)
Draw a 1-pixel-tall horizontal line.
voidkleidos::hal::display::fillCircle (int32_t x, int32_t y, int32_t r, uint16_t c)
Fill a disc of radius r around (x, y).
voidkleidos::hal::display::drawCircle (int32_t x, int32_t y, int32_t r, uint16_t c)
Draw a 1-pixel circle of radius r around (x, y).
voidkleidos::hal::display::drawPixel (int32_t x, int32_t y, uint16_t c)
Draw a single pixel.
voidkleidos::hal::display::setTextColor (uint16_t fg, uint16_t bg)
Set text color with an opaque background.
voidkleidos::hal::display::setTextColor (uint16_t fg)
Set text color with a transparent background.
voidkleidos::hal::display::setTextSize (float s)
Set text scale factor.
voidkleidos::hal::display::setTextDatum (uint8_t d)
Set text alignment datum.
voidkleidos::hal::display::setFont (Font role)
Select a logical font role. Call before drawString/print. Resets text size to 1x.
intkleidos::hal::display::fontHeight ()
Approximate font height for the current font (used for layout).
intkleidos::hal::display::textWidth (const char *s)
Pixel width of a string in the current font (advance, not bounding box).
intkleidos::hal::display::textWidthBold (const char *s)
Pixel width of a string in the bold face of the current font.
voidkleidos::hal::display::drawString (const char *s, int32_t x, int32_t y)
Draw a string with the current text settings.
voidkleidos::hal::display::drawStringBold (const char *s, int32_t x, int32_t y)
Fake-bold: draws the string twice with a 1px horizontal offset so AA glyphs look heavier without needing a separate bold typeface. Use sparingly (selected rows, section headers, headlines).
voidkleidos::hal::display::setCursor (int32_t x, int32_t y)
Place the top-left corner of the next print or printf text.
voidkleidos::hal::display::print (const char *s)
Print a NUL-terminated string at the cursor.
voidkleidos::hal::display::print (int value)
Print an integer at the cursor.
voidkleidos::hal::display::printf (const char *fmt,...)
printf-style output at the cursor.
voidkleidos::hal::display::setRotation (uint8_t r)
Turn the drawing by quarter turns (0 to 3) clockwise.
boolkleidos::hal::display::canReadRect ()
Check whether the active backend supports read-back of pixel data.
boolkleidos::hal::display::framebufferHasContent ()
Check whether the read-back surface holds a frame the UI actually drew.
voidkleidos::hal::display::readRect (int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *buf)
Read a rectangular region into an RGB565 buffer.
boolkleidos::hal::display::readPanelRegister (uint8_t cmd, uint8_t *out, size_t len)
Read a panel controller register over the display bus.
boolkleidos::hal::display::panelIdentity (PanelIdentity &out)
Fill out with how the panel controller was identified.
boolkleidos::hal::display::panelMemoryInfo (PanelMemoryInfo &out)
Describe the panel controller's memory and how the driver reaches it.
boolkleidos::hal::display::readPanelMemory (uint16_t column, uint16_t row, uint16_t columns, uint16_t rows, PanelMemoryCell *out, size_t capacity, int16_t dummyBits=-1)
Read a rectangle of the panel controller's memory.
boolkleidos::hal::display::panelMemoryCellOf (int16_t x, int16_t y, uint16_t &column, uint16_t &row)
Memory cell the driver draws logical pixel (x, y) into.
uint32_tkleidos::hal::display::frameSequence ()
Seqlock counter for tear-free read-back of a composed frame.
uint32_tkleidos::hal::display::drawCount ()
Count of the draws the panel has taken since boot, composed into a frame or streamed to the glass.
voidkleidos::hal::display::streamDamageEnable (bool on)
Enable/disable stream-damage accumulation (off costs nothing).
boolkleidos::hal::display::streamDamagePeek (int16_t &x, int16_t &y, int16_t &w, int16_t &h)
Read the accumulated damage union.
voidkleidos::hal::display::streamDamageClear ()
Drop the accumulated damage (call after a successful capture).
voidkleidos::hal::display::writePixels (int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *pixels)
Write a block of RGB565 pixels to a rectangular region.
voidkleidos::hal::display::waitDisplay ()
Block until the panel has caught up with all queued writes. No-op on panels without a deferred refresh. On e-paper a frame that changes the glass wakes a sleeping panel first; one that does not leaves it asleep.
voidkleidos::hal::display::setClip (int32_t x, int32_t y, int32_t w, int32_t h)
Constrain subsequent draws to a rectangle (software clip).
voidkleidos::hal::display::clearClip ()
Release the software clip armed by setClip (restore full-screen drawing).
voidkleidos::hal::display::startWrite ()
Open a frame: a batched write transaction.
voidkleidos::hal::display::endWrite ()
Close a frame opened by startWrite().
voidkleidos::hal::display::markHeavyFrame ()
Mark the open frame as a heavy one: a full-frame compose or a popup card.
voidkleidos::hal::display::releaseLiveFramebuffer ()
Temporarily release the live-render shadow framebuffer to free SRAM.
voidkleidos::hal::display::restoreLiveFramebuffer ()
Try to reallocate the shadow framebuffer released by releaseLiveFramebuffer().
boolkleidos::hal::display::liveFramebufferReleased ()
voidkleidos::hal::display::drawStringBuffered (const char *s, const TextBox &box, float textSize, uint8_t datum)
Draw text into an off-screen sprite, then push to display in one transfer. Zero flicker: the old content is replaced atomically.
voidkleidos::hal::display::drawStringBufferedFont (const char *s, const TextBox &box, Font font, uint8_t datum)
Same as drawStringBuffered, but selects a logical font role at its native size (no nearest-neighbor scaling). Use this for crisp glyphs instead of textSize=N which scales Font0 blockily.
constexpr int16_tkleidos::hal::display::width ()
Get the logical screen width in pixels (constexpr).
constexpr int16_tkleidos::hal::display::height ()
Get the logical screen height in pixels (constexpr).
constexpr int16_tkleidos::hal::display::centerX ()
Get the screen center X coordinate in pixels (constexpr).
constexpr int16_tkleidos::hal::display::centerY ()
Get the screen center Y coordinate in pixels (constexpr).
voidkleidos::hal::display::wakeup ()
Wake the active display from its sleep state.
voidkleidos::hal::display::setWakeHook (WakeHook hook)
Run hook each time wakeup() brings a sleeping panel back, inside that call, before anything draws on the panel.
boolkleidos::hal::display::panelParked ()
Whether setPanelPark() is holding the panel asleep.
boolkleidos::hal::display::isAsleep ()
Whether the panel is in the sleep state sleep() put it in.
boolkleidos::hal::display::spiBusStatus (SpiBusStatus &out)
Fill out with the active SPI panel's bus status for diagnostics.
size_tkleidos::hal::display::text::foldUtf8Latin1 (const char *input, char *output, size_t outputCapacity)
Fold a UTF-8 string to Latin-1 (best-effort), writing up to outputCapacity bytes including the NUL terminator.
boolkleidos::hal::display::text::needsFold (const char *value, bool activeFontCoversLatin1)
Check whether a string needs folding for the active font.
size_tkleidos::hal::display::text::upperUtf8Latin1 (const char *input, char *output, size_t outputCapacity)
Copy a UTF-8 string upper-cased, for the Latin-1 letters the atlas draws.
constexpr FontLadderkleidos::hal::display::fontLadderFor (int width, int height, bool monochrome)
The ladder a panel of width x height draws with.
constexpr FontRungkleidos::hal::display::fontRungFor (FontLadder ladder, Font role)
The rung ladder draws role at.
uint16_tkleidos::hal::display::fonts::glyphIdFor (const AaFont &font, uint32_t codepoint)
Resolve a codepoint to its glyph id within font.
boolkleidos::hal::display::fonts::glyphDsc (const AaFont &font, uint16_t glyphId, AaGlyph &glyph)
Get the descriptor for a glyph id.
uint8_tkleidos::hal::display::fonts::glyphAlpha (const AaFont &font, const AaGlyph &glyph, uint32_t col, uint32_t row)
Read one glyph's A4 alpha value at a box-local pixel.
constexpr boolkleidos::hal::display::monoGlyphInk (uint8_t coverage)
Text rule on a 1-bit panel: does a glyph pixel of coverage draw ink?
boolkleidos::hal::display::monoBayerInk (uint8_t coverage, int32_t x, int32_t y)
Ordered-dither decision: does coverage render as ink at (x, y)?
boolkleidos::hal::m5backlight::prepareDisplay ()
Power the display logic rails and leave a PMIC- or expander-driven LCD reset line released.
boolkleidos::hal::m5backlight::resetPanel ()
Pulse the LCD reset line the PMIC (Core2 v1.3, AXP192 GPIO4) or the I/O expander (CoreS3 SE, AW9523B P1.1) drives.
boolkleidos::hal::m5backlight::hasPanelResetLine ()
Whether the board's LCD reset line is the PMIC's or the expander's.
boolkleidos::hal::m5backlight::setBrightness (uint8_t percent)
Set the PMIC-controlled backlight to a chip-agnostic brightness percent.
uint8_tkleidos::hal::display::expandAlpha4 (uint8_t nibble)
Expand a 4-bit (A4) coverage nibble to the full 0..255 alpha range.
uint16_tkleidos::hal::display::blendRgb565 (uint16_t foreground, uint16_t background, uint8_t alpha)
Alpha-blend foreground over background in RGB565 space.
intkleidos::hal::display::text_renderer::fontHeight (Font font, float size=1.0f, bool bold=false)
Get the glyph height for a font role.
intkleidos::hal::display::text_renderer::textWidth (const char *value, Font font, float size=1.0f, bool bold=false)
Get the rendered width of a string.
voidkleidos::hal::display::text_renderer::drawString (const graphics::Surface &surface, const char *value, int32_t posX, int32_t posY, const TextStyle &style)
Draw a string onto a Surface.
voidkleidos::hal::display::text_renderer::aaAtlasStats (uint16_t &atlasCount, uint32_t &totalGlyphs)
Count the anti-aliased glyph atlases wired for this board's UI roles.

Variables

constexpr size_tkleidos::hal::display::text::kFoldBufferSize
Suggested scratch buffer size for folding.
constexpr charkleidos::hal::display::text::kMaskGlyphByte
Single-byte sentinel the fold emits for U+2022 BULLET (•).
constexpr unsigned intkleidos::hal::display::text::kMaskGlyphCodepoint
Code point the AA renderer looks up for kMaskGlyphByte (U+2022 BULLET).
constexpr charkleidos::hal::display::text::kEllipsisGlyphByte
Single-byte stand-in for U+2026 HORIZONTAL ELLIPSIS in folded text.
constexpr unsigned intkleidos::hal::display::text::kEllipsisCodepoint
Code point the AA renderer looks up for kEllipsisGlyphByte.
constexpr uint16_tkleidos::kTftBlack
Pure black (R=0, G=0, B=0).
constexpr uint16_tkleidos::kTftNavy
Deep navy blue (R=0, G=0, B=31).
constexpr uint16_tkleidos::kTftDarkgreen
Dark green (R=0, G=63, B=0).
constexpr uint16_tkleidos::kTftDarkgrey
Dark grey (50% luminance).
constexpr uint16_tkleidos::kTftBlue
Pure blue (R=0, G=0, B=31).
constexpr uint16_tkleidos::kTftGreen
Pure green (R=0, G=63, B=0).
constexpr uint16_tkleidos::kTftCyan
Cyan (G=63, B=31).
constexpr uint16_tkleidos::kTftRed
Pure red (R=31, G=0, B=0).
constexpr uint16_tkleidos::kTftMagenta
Magenta (R=31, B=31).
constexpr uint16_tkleidos::kTftYellow
Yellow (R=31, G=63).
constexpr uint16_tkleidos::kTftWhite
Pure white (R=31, G=63, B=31).
constexpr uint16_tkleidos::kTftOrange
Warm orange.
constexpr uint8_tkleidos::kTopLeft
Anchor: top-left of the text bounding box.
constexpr uint8_tkleidos::kTopCenter
Anchor: top-center of the text bounding box.
constexpr uint8_tkleidos::kTopRight
Anchor: top-right of the text bounding box.
constexpr uint8_tkleidos::kMiddleLeft
Anchor: middle-left of the text bounding box.
constexpr uint8_tkleidos::kMiddleCenter
Anchor: middle-center of the text bounding box.
constexpr uint8_tkleidos::kMiddleRight
Anchor: middle-right of the text bounding box.
constexpr uint8_tkleidos::kBottomLeft
Anchor: bottom-left of the text bounding box.
constexpr uint8_tkleidos::kBottomCenter
Anchor: bottom-center of the text bounding box.
constexpr uint8_tkleidos::kBottomRight
Anchor: bottom-right of the text bounding box.
constexpr std::array< std::array< uint8_t, 5 >, 4 >kleidos::hal::display::kFontLadderPx
Atlas size per ladder (rows, in FontLadder order) and role (columns, in Font order: SMALL, BODY, HEADING, LARGE, MONO).
constexpr int32_tkleidos::hal::display::kMonoGlyphInkBias
constexpr int32_tkleidos::hal::display::kMonoGlyphInkThreshold
Biased glyph coverage at or above which the pixel is ink: half coverage.
constexpr std::array< uint8_t, 64 >kleidos::hal::display::kMonoBayer8x8
constexpr uint32_tkleidos::hal::display::kMonoBayerEdge
Number of columns/rows in the ordered-dither matrix (its period in pixels).
constexpr uint8_tkleidos::hal::display::kRgb565NibbleMask
Mask selecting the low 4 bits of an A4 coverage nibble.
constexpr uint8_tkleidos::hal::display::kRgb565NibbleBits
Bit width of an A4 coverage nibble.
constexpr uint32_tkleidos::hal::display::kRgb565BlendRoundBias
Rounding bias for the 8-bit alpha blend divide-by-255.
constexpr uint8_tkleidos::hal::display::kRgb565AlphaOpaque
Full opacity for the 8-bit alpha blend.

Measurement parks

Two independent parks, because the panel and its light are two measurements. The FSM wakes the display on a state change and on every input, so a park is what keeps a measured state alive past the next keypress; and one shared flag would let a release of either name silently light the other's panel.

Neither park lights anything when it is released: the caller applies the state it wants (a wakeup(), or the brightness it saved) afterwards.

voidkleidos::hal::display::setPanelPark (bool parked)
Ignore every request to wake the panel.
voidkleidos::hal::display::setBacklightPark (bool parked)
Ignore every request to change the backlight level.
boolkleidos::hal::display::backlightParked ()
Whether setBacklightPark is holding the backlight level.

Back to the top

Enumeration Type Documentation

BusInterface #

enum class kleidos::hal::display::catalog::BusInterface : uint8_t

Supported display bus interface types.

Enumerator
None 

No bus selected.

SpiDataCommand 

SPI bus with dedicated D/C line.

Font #

enum class kleidos::hal::display::Font : uint8_t

Logical font roles. Backends map these to the clearest device-specific text renderer available. Use these instead of setTextSize() to keep the UI legible across resolutions. The size of each role depends on the panel: kFontLadderPx.

Enumerator
SMALL 

Captions, hints and the action bar.

BODY 

Labels and list rows.

HEADING 

Titles.

LARGE 

Hero numbers and entry digits.

MONO 

Monospace data (status chips, %, item counts).

FontLadder #

enum class kleidos::hal::display::FontLadder : uint8_t

The panel classes the renderer keeps a role ladder for.

Enumerator
StickPortrait 

135 x 240 color (the Sticks).

CardputerLandscape 

240 x 135 color (the Cardputer).

Wide 

320 x 240 color (Core2, CoreS3 SE, T-Deck).

Epaper 

200 x 200 1-bit e-paper (CoreInk), the ink family.

PanelController #

enum class kleidos::hal::display::catalog::PanelController : uint8_t

Supported display panel controllers.

Enumerator
None 

No panel selected.

St7789 

ST7789 (or compatible) controller.

Ili9342 

ILI9342 controller.

Back to the top

Function Documentation

aaAtlasStats() #

void kleidos::hal::display::text_renderer::aaAtlasStats(uint16_t & atlasCount, uint32_t & totalGlyphs)

Count the anti-aliased glyph atlases wired for this board's UI roles.

Walks the five UI font roles (SMALL / BODY / HEADING / LARGE / MONO), resolves each to its baked AaFont atlas for the panel size, and reports how many are present plus the total glyph count across the distinct atlases. A board that loses an atlas from its per-size font ladder shows a lower count, so this is a cheap flash-inclusion regression probe.

Parameters
NameDirectionMeaning
atlasCountoutReceives the number of distinct non-null role atlases.
totalGlyphsoutReceives the summed glyph count of those atlases.

abortEpaperToneCompose() #

void kleidos::hal::display::abortEpaperToneCompose()

Discard an armed tone-compose pass without a gray render.

Frees the compose buffer and leaves the 1-bit frame untouched so a later waitDisplay renders it normally.

adoptEpaperRetainedFrame() #

bool kleidos::hal::display::adoptEpaperRetainedFrame()

Take the frame drawn since initEpaperRetained as what the glass shows.

Mirrors display::driver::EpaperPanelDriver::adoptRetainedFrame(): the next flush drives only the pixels that differ from it. Defined by the e-paper backend only: gate call sites on device::kDisplayIsEpaper.

Return values
ValueMeaning
trueFrame adopted.
falsePanel not ready or not an SSD1681 panel.

backlightParked() #

bool kleidos::hal::display::backlightParked()

Whether setBacklightPark is holding the backlight level.

Return values
ValueMeaning
truesetBrightness() is being ignored.
falseThe level follows setBrightness() normally.

beginEpaperToneCompose() #

bool kleidos::hal::display::beginEpaperToneCompose()

Begin composing the current frame as 6-tone grayscale (static UI).

Mirrors display::driver::EpaperPanelDriver::beginToneCompose(): arms tone capture so the next full screen redraw (normal drawString / fillRect calls) records true panel tones — smooth gray anti-aliased text and gray fills — instead of collapsing to 1-bit. Pair with commitEpaperToneCompose at the frame boundary. While armed, waitDisplay / endWrite defer the 1-bit flush. Defined by the e-paper backend only: gate call sites on device::kDisplayIsEpaper.

Return values
ValueMeaning
trueTone capture armed; redraw the whole screen, then commit.
falseNot an SSD1681 panel or allocation failed (fall back to 1-bit).

blendRgb565() #

uint16_t kleidos::hal::display::blendRgb565(uint16_t foreground, uint16_t background, uint8_t alpha)
inline

Alpha-blend foreground over background in RGB565 space.

Parameters
NameDirectionMeaning
foregroundinSource color (RGB565).
backgroundinDestination color (RGB565).
alphainSource coverage (0 = background, 255 = foreground).
Returns
Blended RGB565 color.

busInterfaceName() #

const char * kleidos::hal::display::catalog::busInterfaceName(BusInterface interface)

Get the human-readable name for a bus interface.

Parameters
NameDirectionMeaning
interfaceinBus interface enum value.
Returns
NUL-terminated name string.

canReadRect() #

bool kleidos::hal::display::canReadRect()

Check whether the active backend supports read-back of pixel data.

Return values
ValueMeaning
trueif a readRect() call would return meaningful data (SPI panel with shadow buffer, or e-paper with frame buffer).
falseon panels without either (returns zeros from readRect).

centerX() #

int16_t kleidos::hal::display::centerX()
constexpr

Get the screen center X coordinate in pixels (constexpr).

Returns
Center X in pixels.

centerY() #

int16_t kleidos::hal::display::centerY()
constexpr

Get the screen center Y coordinate in pixels (constexpr).

Returns
Center Y in pixels.

commitEpaperToneCompose() #

bool kleidos::hal::display::commitEpaperToneCompose()

Finish a tone-compose pass by driving the retained 6-tone frame.

If the screen drew nothing since beginEpaperToneCompose, the costly gray refresh is skipped and the pass is aborted. Otherwise the composed tones are rendered via the two-pass 6-tone waveform (retained for capture).

Return values
ValueMeaning
true6-tone frame rendered.
falseNothing was drawn, compose was not armed, or the render failed.

deviceBusInterface() #

BusInterface kleidos::hal::display::catalog::deviceBusInterface()
constexpr

Get the bus interface selected by the active variant's display pin assignments.

Returns
Bus interface enum value.

deviceBusSpec() #

BusSpec kleidos::hal::display::catalog::deviceBusSpec()

Assemble the full bus descriptor for the active variant.

Returns
BusSpec describing the active variant's SPI bus and backlight wiring.

devicePanelController() #

PanelController kleidos::hal::display::catalog::devicePanelController()
constexpr

Get the panel controller selected by the active variant.

Returns
Panel controller enum value.

devicePanelSpec() #

PanelSpec kleidos::hal::display::catalog::devicePanelSpec()
constexpr

Assemble the full panel descriptor from the active variant's config.

Returns
PanelSpec describing the active variant's display geometry and options.

deviceSpiHost() #

kleidos::platform::spi::Host kleidos::hal::display::catalog::deviceSpiHost()

Get the SPI host for the active variant.

Returns
SPI host identifier.

drawCircle() #

void kleidos::hal::display::drawCircle(int32_t x, int32_t y, int32_t r, uint16_t c)

Draw a 1-pixel circle of radius r around (x, y).

Parameters
NameDirectionMeaning
xinCenter X.
yinCenter Y.
rinRadius in pixels.
cinRGB565 color value.

drawCount() #

uint32_t kleidos::hal::display::drawCount()

Count of the draws the panel has taken since boot, composed into a frame or streamed to the glass.

Only its movement means anything: a caller reads it before and after a stretch of code to learn whether that code drew, which a frame's own bookkeeping cannot tell while the frame is still open. The main loop reads it around the entering state's enter(), to learn whether the glass now holds the new state's first screen.

Returns
The count; it wraps.

drawFastHLine() #

void kleidos::hal::display::drawFastHLine(int32_t x, int32_t y, int32_t w, uint16_t c)

Draw a 1-pixel-tall horizontal line.

Parameters
NameDirectionMeaning
xinLeft edge in pixels.
yinY coordinate in pixels.
winWidth in pixels.
cinRGB565 color value.

drawLine() #

void kleidos::hal::display::drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint16_t c)

Draw a Bresenham line.

Parameters
NameDirectionMeaning
x0inStart X.
y0inStart Y.
x1inEnd X.
y1inEnd Y.
cinRGB565 color value.

drawPixel() #

void kleidos::hal::display::drawPixel(int32_t x, int32_t y, uint16_t c)

Draw a single pixel.

Parameters
NameDirectionMeaning
xinX coordinate in pixels.
yinY coordinate in pixels.
cinRGB565 color value.

drawRect() #

void kleidos::hal::display::drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t c)

Draw a 1-pixel-wide rectangle outline.

Parameters
NameDirectionMeaning
xinLeft edge in pixels.
yinTop edge in pixels.
winWidth in pixels.
hinHeight in pixels.
cinRGB565 color value.

drawRoundRect() #

void kleidos::hal::display::drawRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, uint16_t c)

Draw a rounded rectangle outline.

Parameters
NameDirectionMeaning
xinLeft edge in pixels.
yinTop edge in pixels.
winWidth in pixels.
hinHeight in pixels.
rinCorner radius in pixels.
cinRGB565 color value.

drawString() [1/2] #

void kleidos::hal::display::drawString(const char * s, int32_t x, int32_t y)

Draw a string with the current text settings.

Parameters
NameDirectionMeaning
sinNUL-terminated string to draw.
xinTop-left X coordinate in pixels (modified by datum).
yinTop-left Y coordinate in pixels (modified by datum).

drawString() [2/2] #

void kleidos::hal::display::text_renderer::drawString(const graphics::Surface & surface, const char * value, int32_t posX, int32_t posY, const TextStyle & style)

Draw a string onto a Surface.

Parameters
NameDirectionMeaning
surfacein, outTarget surface to draw onto.
valueinNUL-terminated string to render.
posXinX coordinate in pixels (anchor, modified by style.datum).
posYinY coordinate in pixels (anchor, modified by style.datum).
styleinVisual attributes (font, color, scale, datum).

drawStringBold() #

void kleidos::hal::display::drawStringBold(const char * s, int32_t x, int32_t y)

Fake-bold: draws the string twice with a 1px horizontal offset so AA glyphs look heavier without needing a separate bold typeface. Use sparingly (selected rows, section headers, headlines).

Parameters
NameDirectionMeaning
sinNUL-terminated string to draw.
xinTop-left X coordinate in pixels (modified by datum).
yinTop-left Y coordinate in pixels (modified by datum).

drawStringBuffered() #

void kleidos::hal::display::drawStringBuffered(const char * s, const TextBox & box, float textSize, uint8_t datum)

Draw text into an off-screen sprite, then push to display in one transfer. Zero flicker: the old content is replaced atomically.

Parameters
NameDirectionMeaning
sinNUL-terminated string to draw.
boxinDestination rectangle plus fill/text colors.
textSizeinScale factor for the rendered glyphs.
datuminAlignment datum (see display_types.h).

drawStringBufferedFont() #

void kleidos::hal::display::drawStringBufferedFont(const char * s, const TextBox & box, Font font, uint8_t datum)

Same as drawStringBuffered, but selects a logical font role at its native size (no nearest-neighbor scaling). Use this for crisp glyphs instead of textSize=N which scales Font0 blockily.

Parameters
NameDirectionMeaning
sinNUL-terminated string to draw.
boxinDestination rectangle plus fill/text colors.
fontinFont role to render with.
datuminAlignment datum (see display_types.h).

endWrite() #

void kleidos::hal::display::endWrite()

Close a frame opened by startWrite().

The outermost close triggers the e-paper refresh or the SPI blit when anything was drawn, and on SPI panels ends the frame's boost to the frame clock (markHeavyFrame) once the blit is done.

epaperAlwaysFull() #

bool kleidos::hal::display::epaperAlwaysFull()
Returns
True while the e-paper panel forces a full refresh on every flush.

epaperFastPartial() #

bool kleidos::hal::display::epaperFastPartial()

Whether the e-paper controller currently holds the fast-animation LUT.

The render orchestrator drives the fast/quality waveform off the panel's real state (not a shadow flag) so a gray render — which drops the fast LUT — cannot leave a navigable 1-bit screen stuck on the slow quality waveform: the next 1-bit tick re-reads false here and re-arms fast partials. Defined by the e-paper backend only: gate call sites on device::kDisplayIsEpaper.

Return values
ValueMeaning
trueFast-animation LUT is loaded (partials use the short waveform).
falseQuality waveform (or not an SSD1681 fast-capable controller).

epaperGrayRetained() #

bool kleidos::hal::display::epaperGrayRetained()

Whether a 6-tone gray frame is currently retained on the panel.

Retained gray sits on the glass until the next 1-bit flush releases it. The render orchestrator watches the retained → released edge to re-arm a settle so a GrayOnSettle screen returns to gray after a stray 1-bit repaint.

Return values
ValueMeaning
trueA retained tone frame is present (gray is on the glass).
falseNo retained tone frame (1-bit, or the gray was collapsed).

epaperPowerDownWhenIdle() #

bool kleidos::hal::display::epaperPowerDownWhenIdle(uint32_t nowMs, uint32_t idleMs)

Power the e-paper panel's analog rails down once the glass has been still for idleMs.

Fast-mode and gray updates leave the panel's booster and source rails up so the next update starts sooner; a screen at rest would keep them up for as long as it stays. Called every loop tick; the next update powers the rails back up itself. Defined by the e-paper backend only: gate call sites on device::kDisplayIsEpaper.

Parameters
NameDirectionMeaning
nowMsinMonotonic time in milliseconds.
idleMsinQuiet time before the rails go down.
Return values
ValueMeaning
trueThe rails were powered down by this call.

epaperToneComposeActive() #

bool kleidos::hal::display::epaperToneComposeActive()

Whether a 6-tone tone-compose pass is currently armed.

Return values
ValueMeaning
trueCompose is armed (draws are captured as tones).
falseNot composing.

expandAlpha4() #

uint8_t kleidos::hal::display::expandAlpha4(uint8_t nibble)
inline

Expand a 4-bit (A4) coverage nibble to the full 0..255 alpha range.

Nibble n maps to (n<<4)|n so 0xF becomes 0xFF (fully opaque). This is the inverse of the offline A4 quantization used by the font and brand atlases.

Parameters
NameDirectionMeaning
nibblein4-bit coverage value (0..15).
Returns
8-bit alpha (0..255).

fillCircle() #

void kleidos::hal::display::fillCircle(int32_t x, int32_t y, int32_t r, uint16_t c)

Fill a disc of radius r around (x, y).

Parameters
NameDirectionMeaning
xinCenter X.
yinCenter Y.
rinRadius in pixels.
cinRGB565 color value.

fillRect() #

void kleidos::hal::display::fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t c)

Fill a rectangular region with a single color.

Parameters
NameDirectionMeaning
xinLeft edge in pixels.
yinTop edge in pixels.
winWidth in pixels.
hinHeight in pixels.
cinRGB565 color value.

fillRoundRect() #

void kleidos::hal::display::fillRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, uint16_t c)

Fill a rounded rectangle.

Parameters
NameDirectionMeaning
xinLeft edge in pixels.
yinTop edge in pixels.
winWidth in pixels.
hinHeight in pixels.
rinCorner radius in pixels.
cinRGB565 color value.

fillScreen() #

void kleidos::hal::display::fillScreen(uint16_t color)

Fill the entire screen with a single color.

Parameters
NameDirectionMeaning
colorinRGB565 color value.

fitsControllerGram() #

bool kleidos::hal::display::catalog::fitsControllerGram(const PanelSpec & panel)
constexpr

Whether a panel's declared placement lies inside its controller's memory.

Parameters
NameDirectionMeaning
panelinPanel descriptor.
Returns
True when every shown pixel has a memory address.

foldUtf8Latin1() #

size_t kleidos::hal::display::text::foldUtf8Latin1(const char * input, char * output, size_t outputCapacity)

Fold a UTF-8 string to Latin-1 (best-effort), writing up to outputCapacity bytes including the NUL terminator.

Multi-byte UTF-8 sequences that have a single-byte Latin-1 equivalent are folded; everything else is replaced with '?'. The result is always NUL-terminated as long as outputCapacity is at least 1.

Parameters
NameDirectionMeaning
inputinNUL-terminated UTF-8 source.
outputoutDestination buffer.
outputCapacityinCapacity of output in bytes.
Returns
Number of bytes written (excluding the terminator).

fontHeight() [1/2] #

int kleidos::hal::display::fontHeight()

Approximate font height for the current font (used for layout).

Returns
Pixel height of the current font at the current text size.

fontHeight() [2/2] #

int kleidos::hal::display::text_renderer::fontHeight(Font font, float size = 1.0f, bool bold = false)

Get the glyph height for a font role.

Parameters
NameDirectionMeaning
fontinFont role to measure.
sizeinScale factor (default 1.0).
boldinTrue to measure the bold face (matches a bold draw; default false).
Returns
Pixel height of the tallest glyph in the font at the given scale.

fontLadderFor() #

FontLadder kleidos::hal::display::fontLadderFor(int width, int height, bool monochrome)
constexpr

The ladder a panel of width x height draws with.

Parameters
NameDirectionMeaning
widthinPanel width in pixels.
heightinPanel height in pixels.
monochromeinTrue for a 1-bit e-paper panel.
Returns
The panel's ladder.

fontRungFor() #

FontRung kleidos::hal::display::fontRungFor(FontLadder ladder, Font role)
constexpr

The rung ladder draws role at.

Parameters
NameDirectionMeaning
ladderinThe panel's ladder.
roleinUI font role.
Returns
The face (mono for Font::MONO, sans otherwise) and its size.

framebufferHasContent() #

bool kleidos::hal::display::framebufferHasContent()

Check whether the read-back surface holds a frame the UI actually drew.

canReadRect only reports that a read-back surface exists. On the color backends that surface is allocated and zero-filled at display bring-up, so between bring-up and the first composed frame readRect() returns a fully black image that is indistinguishable from a genuine render. A capture taken in that window (for example by a QA tool that reset the board and sampled ~1 s into boot) therefore reads as a render defect when nothing is wrong. Callers that serve a captured frame to a host should refuse rather than hand out that placeholder.

Return values
ValueMeaning
truethe surface holds drawn content (any shadow mutation has happened), or the backend retains a settled frame at all times.
falsethe color shadow buffer is still the zero-filled bring-up state.

frameSequence() #

uint32_t kleidos::hal::display::frameSequence()

Seqlock counter for tear-free read-back of a composed frame.

Even while the backend holds a complete, settled frame; odd while one is being composed. A reader on another core should load this, copy via readRect only when even, then re-load and keep the copy only if the value is unchanged — this keeps mid-compose states (which never reach the panel) out of captures.

It is also how a capture decides there is anything new to read, so it must advance once per settled frame on every backend that holds one. The e-paper backend turns it odd at the first draw of a frame and even again when the refresh that puts it on the glass has finished. A backend with no framebuffer at all returns 0.

Returns
The sequence: even while a settled frame is held, odd mid-compose, 0 when the backend has no framebuffer.

getBrightness() #

uint8_t kleidos::hal::display::getBrightness()

Get the last brightness setting.

Returns
Brightness percent in 0..100 (0 if setBrightness was never called or the backend failed to apply the last value).

glyphAlpha() #

uint8_t kleidos::hal::display::fonts::glyphAlpha(const AaFont & font, const AaGlyph & glyph, uint32_t col, uint32_t row)

Read one glyph's A4 alpha value at a box-local pixel.

Parameters
NameDirectionMeaning
fontinFont owning the bitmap blob.
glyphinGlyph descriptor previously obtained from glyphDsc.
colinColumn inside the glyph box (0 .. glyph.boxW - 1).
rowinRow inside the glyph box (0 .. glyph.boxH - 1).
Returns
8-bit alpha (0..255) for the pixel; 0 when out of range.

glyphDsc() #

bool kleidos::hal::display::fonts::glyphDsc(const AaFont & font, uint16_t glyphId, AaGlyph & glyph)

Get the descriptor for a glyph id.

Parameters
NameDirectionMeaning
fontinFont to query.
glyphIdinGlyph id (1-based; 0 is the reserved blank).
glyphoutReceives the descriptor on success.
Returns
True when glyphId is valid and glyph was filled.

glyphIdFor() #

uint16_t kleidos::hal::display::fonts::glyphIdFor(const AaFont & font, uint32_t codepoint)

Resolve a codepoint to its glyph id within font.

Parameters
NameDirectionMeaning
fontinFont to query.
codepointinUnicode code point.
Returns
Glyph id (>= 1) on success, or 0 when the codepoint is absent.

gramSize() #

kleidos::drivers::display::GramSize kleidos::hal::display::catalog::gramSize(PanelController controller)
constexpr

Frame-memory size of a panel controller.

Parameters
NameDirectionMeaning
controllerinPanel controller enum value.
Returns
The controller's GRAM at MADCTL 0; zero for PanelController::None.

grayUpdateProbe() #

bool kleidos::hal::display::grayUpdateProbe(const uint8_t * msbPlane, const uint8_t * lsbPlane, const uint8_t * lut, uint16_t y0, uint16_t y1, uint16_t gateLines, uint32_t & outUpdateMs)

Run one windowed grayscale update pass for wall-clock profiling (QA probe).

Mirrors display::driver::EpaperPanelDriver::grayUpdateProbe(): drives a single gray pass over native rows [y0, y1], optionally scanning only gateLines gate lines, and reports the activation-to-idle time in outUpdateMs. A measurement seam for the grayscale-partial-refresh investigation, not a rendering path. Defined by the e-paper backend only: gate call sites on device::kDisplayIsEpaper (the setInvert pattern).

Parameters
NameDirectionMeaning
msbPlaneinFull-frame RED-plane bits (rowBytes*height bytes).
lsbPlaneinFull-frame B/W-plane bits (rowBytes*height bytes).
lutin153-byte gray-pass waveform LUT.
y0inFirst native row of the update window (inclusive).
y1inLast native row of the update window (inclusive).
gateLinesinGate lines to scan (0 = full panel height).
outUpdateMsoutActivation-to-idle time of the update in ms.
Return values
ValueMeaning
truePass driven and geometry restored.
falsePanel not ready, bad arguments, or unsupported model.

hasPanelResetLine() #

bool kleidos::hal::m5backlight::hasPanelResetLine()

Whether the board's LCD reset line is the PMIC's or the expander's.

Returns
True on the Core2 v1.3 and the CoreS3 SE.

height() #

int16_t kleidos::hal::display::height()
constexpr

Get the logical screen height in pixels (constexpr).

Returns
Screen height in pixels.

holdBacklightOff() #

void kleidos::hal::display::holdBacklightOff()

Before a deep sleep: drive the backlight pin to its off level and hold it there through the sleep.

A deep sleep isolates every ESP pad it does not hold, so a backlight enable left to the PWM peripheral floats for the whole sleep and the backlight driver may light. For a board whose sleep leaves that driver powered (the Cardputer ADV) or whose pin would float (the T-Deck). From here the pin no longer follows setBrightness(); the next init() releases the hold. No-op without a backlight GPIO (a PMIC-driven backlight, e-paper).

init() #

void kleidos::hal::display::init()

Initialize the active display backend (SPI panel or e-paper).

Idempotent: callers may invoke it more than once without side effects. The active backend is selected at link time by the variant's display_hal_*.cpp translation unit.

initEpaperRetained() #

bool kleidos::hal::display::initEpaperRetained()

Bring the e-paper panel up without clearing it.

For a board that powered on only to update the image the glass kept through a power cut: unlike init, the glass is left as it is. Draw the retained image, call adoptEpaperRetainedFrame, then draw the new image and flush. Defined by the e-paper backend only: gate call sites on device::kDisplayIsEpaper.

Return values
ValueMeaning
truePanel ready.
falseThe panel did not come up.

intersectRect() #

bool kleidos::hal::display::driver::intersectRect(ClipRect & rect, int32_t x, int32_t y, int32_t w, int32_t h)
constexpr

Intersect rect in place with the rectangle [x, y, w, h].

Pure integer clamp; safe against overflow for on-screen coordinates. After the call rect holds the overlap (possibly empty).

Parameters
NameDirectionMeaning
rectin, outRectangle to clip; replaced by the overlap.
xinClip rectangle left edge.
yinClip rectangle top edge.
winClip rectangle width.
hinClip rectangle height.
Return values
ValueMeaning
trueThe overlap is non-empty (rect now describes it).
falseThe rectangles do not overlap (rect is empty).

isAsleep() #

bool kleidos::hal::display::isAsleep()

Whether the panel is in the sleep state sleep() put it in.

getBrightness() keeps reporting the last brightness while the panel sleeps, so this is the call that tells a lit panel from a sleeping one. Declared for host builds too: a surface that paints nothing on a sleeping panel is host-tested against a fake.

Return values
ValueMeaning
truesleep() put the panel to sleep and nothing has woken it.
falseThe panel is awake, or never came up.

isSupported() #

bool kleidos::hal::display::catalog::isSupported(const PanelSpec & panel, const BusSpec & bus)

Check whether the given panel/bus combination is supported.

Parameters
NameDirectionMeaning
panelinPanel descriptor.
businBus descriptor.
Return values
ValueMeaning
trueif the combination is supported by the SPI panel driver (valid controller + SPI D/C bus + in-range pins + a panel placement inside the controller's memory).
falseotherwise — the driver will refuse to begin() with this descriptor.

liveFramebufferReleased() #

bool kleidos::hal::display::liveFramebufferReleased()
Return values
ValueMeaning
trueif releaseLiveFramebuffer() freed the buffer and it has not yet been restored. Always false on PSRAM / e-paper / no-shadow backends.

markHeavyFrame() #

void kleidos::hal::display::markHeavyFrame()

Mark the open frame as a heavy one: a full-frame compose or a popup card.

On SPI panels the rest of the frame — its compose and its blit — runs at the frame clock (kleidos::platform::kCpuFrameMhz) inside a kleidos::platform::FrameBoostGuard that the open frame owns until its outermost endWrite(); the guard only raises the clock, so a crypto boost in force keeps its own. Idempotent within a frame, and a no-op outside an open frame. A full-screen fill (fillScreen) marks its frame by itself; the UI marks the others (ui::Canvas::markHeavyFrame). A partial repaint is never marked and stays at the base clock. A no-op on e-paper, where the refresh is bound by the panel, not by the core.

monoBayerInk() #

bool kleidos::hal::display::monoBayerInk(uint8_t coverage, int32_t x, int32_t y)
inline

Ordered-dither decision: does coverage render as ink at (x, y)?

A pure function of coverage and absolute panel position: a mid coverage turns into a deterministic ink/paper stipple whose density tracks the coverage, so a gray tone reads as gray on a 1-bit panel. Zero coverage is always paper; a fully covered pixel (255) is always ink (it exceeds the 254 threshold cap).

Parameters
NameDirectionMeaning
coverageinInk coverage (0 = paper .. 255 = solid ink).
xinAbsolute panel X of the pixel.
yinAbsolute panel Y of the pixel.
Return values
ValueMeaning
trueThe pixel should be drawn as ink.
falseThe pixel should be left as paper (background).

monoGlyphInk() #

bool kleidos::hal::display::monoGlyphInk(uint8_t coverage)
constexpr

Text rule on a 1-bit panel: does a glyph pixel of coverage draw ink?

A threshold on the weight-biased coverage, independent of the pixel's position: an anti-aliased fringe resolves to a clean edge instead of a position-dependent stipple, and a 1 px stem stays continuous. Zero coverage is always paper.

Parameters
NameDirectionMeaning
coverageinGlyph coverage (0 = paper .. 255 = solid ink).
Return values
ValueMeaning
trueThe pixel should be drawn as ink.
falseThe pixel should be left as paper (background).

needsFold() #

bool kleidos::hal::display::text::needsFold(const char * value, bool activeFontCoversLatin1)

Check whether a string needs folding for the active font.

Used by the renderer to skip the fold buffer when the source is already pure Latin-1 and the active font covers it.

Parameters
NameDirectionMeaning
valueinNUL-terminated candidate string.
activeFontCoversLatin1inWhether the active font renders Latin-1.
Return values
ValueMeaning
trueif value contains characters that need folding (or any non-ASCII byte).
falseif value is pure ASCII, or the active font already covers its bytes.

panelControllerName() #

const char * kleidos::hal::display::catalog::panelControllerName(PanelController controller)

Get the human-readable name for a panel controller.

Parameters
NameDirectionMeaning
controllerinPanel controller enum value.
Returns
NUL-terminated name string (e.g. "ST7789", "ILI9342", "None").

panelIdentity() #

bool kleidos::hal::display::panelIdentity(PanelIdentity & out)

Fill out with how the panel controller was identified.

Parameters
NameDirectionMeaning
outoutRecord to populate.
Return values
ValueMeaning
trueA panel is up and out is populated.
falseThe panel never came up; out untouched.

panelMemoryCellOf() #

bool kleidos::hal::display::panelMemoryCellOf(int16_t x, int16_t y, uint16_t & column, uint16_t & row)

Memory cell the driver draws logical pixel (x, y) into.

Parameters
NameDirectionMeaning
xinLogical X.
yinLogical Y.
columnoutMemory column.
rowoutMemory row.
Return values
ValueMeaning
trueThe cell lies inside the controller's memory.
falseIt does not (or no panel is up).

panelMemoryInfo() #

bool kleidos::hal::display::panelMemoryInfo(PanelMemoryInfo & out)

Describe the panel controller's memory and how the driver reaches it.

Parameters
NameDirectionMeaning
outoutRecord to populate.
Return values
ValueMeaning
trueA panel is up and out is populated.
falseThe panel never came up; out untouched.

panelParked() #

bool kleidos::hal::display::panelParked()

Whether setPanelPark() is holding the panel asleep.

Declared for host builds too, beside isAsleep.

Return values
ValueMeaning
truewakeup() is being ignored.
falseThe panel follows wakeup() normally.

placement() #

kleidos::drivers::display::PanelPlacement kleidos::hal::display::catalog::placement(const PanelSpec & panel)
constexpr

The part of the controller's memory a panel shows.

Parameters
NameDirectionMeaning
panelinPanel descriptor.
Returns
Its native size and offsets, at MADCTL 0.

prepareDisplay() #

bool kleidos::hal::m5backlight::prepareDisplay()

Power the display logic rails and leave a PMIC- or expander-driven LCD reset line released.

Must be called once before the SPI panel driver addresses the panel. The reset itself is resetPanel, which the panel driver runs once it has identified the controller. Backlight brightness is handled separately via setBrightness().

Return values
ValueMeaning
trueif the rails came up (and the reset line is released).
falseif the active variant has no PMIC backlight, or the I2C write to the PMIC or the expander failed.

print() [1/2] #

void kleidos::hal::display::print(const char * s)

Print a NUL-terminated string at the cursor.

Parameters
NameDirectionMeaning
sinNUL-terminated string to print.

print() [2/2] #

void kleidos::hal::display::print(int value)

Print an integer at the cursor.

Parameters
NameDirectionMeaning
valueinValue to print.

printf() #

void kleidos::hal::display::printf(const char * fmt, ...)

printf-style output at the cursor.

Parameters
NameDirectionMeaning
fmtinprintf-style format string.

reacquireBacklight() #

bool kleidos::hal::display::reacquireBacklight()

Take the backlight pad back for the display driver.

A debug command that drives the pad as a plain GPIO leaves the PWM channel no longer routed to it, and the driver's own level writes then reach nothing while reporting success. This re-routes the pad and re-applies the level the driver holds.

Return values
ValueMeaning
trueThe pad was re-routed (or needs no routing: a PMIC backlight).
falseThere is no backlight on this board.

readEpaperRam() #

bool kleidos::hal::display::readEpaperRam(uint8_t plane, uint8_t * out, size_t outSize)

Read back an e-paper RAM plane or CPU frame buffer (QA/debug).

Plane selectors match display::driver::EpaperPanelDriver::readPanelRam(): 0 = controller B/W RAM, 1 = controller old-image RAM (both read over SPI — the ground truth of what the panel controller holds), 2/3 = the driver's CPU-side current/previous frames. Defined by the e-paper backend only: gate call sites on device::kDisplayIsEpaper (the setInvert pattern).

Parameters
NameDirectionMeaning
planeinPlane selector (0-3).
outoutBuffer receiving the 1 bpp row-major plane.
outSizeinCapacity of out in bytes.
Return values
ValueMeaning
truePlane read/copied.
falseUnsupported plane/controller, not ready, or SPI error.

readPanelMemory() #

bool kleidos::hal::display::readPanelMemory(uint16_t column, uint16_t row, uint16_t columns, uint16_t rows, PanelMemoryCell * out, size_t capacity, int16_t dummyBits = -1)

Read a rectangle of the panel controller's memory.

A genuine bus read of the controller's frame memory (RAMRD on a TFT, the SSD1681's B/W RAM on e-paper), unlike readRect which serves the CPU frame. Each cell also says which logical pixel the driver draws into it and what the CPU frame holds there, so a caller can tell an unwritten cell from a written one.

Parameters
NameDirectionMeaning
columninFirst memory column.
rowinFirst memory row.
columnsinColumns to read.
rowsinRows to read.
outoutReceives columns x rows cells, row by row.
capacityinCells out holds.
dummyBitsinTFT dummy clocks to use, or -1 for the controller's.
Return values
ValueMeaning
trueout holds the cells.
falseNot readable on this board (panelMemoryInfo says why), a rectangle outside the memory, or a bus failure.
Note
Loop task only, like readPanelRegister.

readPanelRegister() #

bool kleidos::hal::display::readPanelRegister(uint8_t cmd, uint8_t * out, size_t len)

Read a panel controller register over the display bus.

Issues cmd as a read command and clocks len parameter bytes back from the panel controller (e.g. RDDID 0x04 → 3 bytes, RDDST 0x09 → 4 bytes), framed the way the controller reads that register: the dummy clock RDDID and RDDST take, or an ILI9342 level 2 register's one-parameter-per-XREG-ordinal reads. This is a genuine bus transaction against the controller, distinct from readRect() which serves pixels from the RAM shadow buffer.

Parameters
NameDirectionMeaning
cmdinController read command opcode.
outoutBuffer receiving len bytes; must hold at least len bytes.
leninNumber of parameter bytes to read.
Return values
ValueMeaning
trueThe read completed and out holds the parameters.
falseNo panel read-back on this board (e-paper backend, or an SPI panel with no MISO and not wired 3-wire), or bad arguments.
Note
Must be called only from the sole display-SPI owner task (the Core-1 loop task). On the SPI panel backend this briefly retires the shared write device to run the read on its own CS-owning device; calling it concurrently with a display blit would wedge the panel via CS re-routing.

readRect() #

void kleidos::hal::display::readRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t * buf)

Read a rectangular region into an RGB565 buffer.

Parameters
NameDirectionMeaning
xinLeft edge in pixels.
yinTop edge in pixels.
winWidth in pixels.
hinHeight in pixels.
bufoutBuffer receiving width*height RGB565 values. Must be at least w*h*sizeof(uint16_t) bytes.

reinit() #

bool kleidos::hal::display::reinit()

Re-initialize a controller that lost its supply.

init() cannot do this: it is idempotent and returns immediately once the driver is up, so after a rail cycle it would send the cold-booted controller nothing at all and the glass would stay dead while the caller reported a restore. wakeup() cannot either: it only sends SLPOUT, and a controller that lost VDD needs its whole initialization sequence.

Re-runs the panel's bring-up on the bus and the pins already configured: the panel logic rails where the PMIC owns them, the backlight routing, the reset pulse where there is a reset line, the controller's init sequence, and the brightness last set. The SPI bus and its device are left as they are.

Return values
ValueMeaning
trueThe controller was re-initialized.
falseThe driver never came up, so there was nothing to re-run.

releaseLiveFramebuffer() #

void kleidos::hal::display::releaseLiveFramebuffer()

Temporarily release the live-render shadow framebuffer to free SRAM.

On a board without PSRAM the SPI-panel backend keeps its RGB565 shadow buffer (64,800 B on a 135x240 or 240x135 panel) in internal RAM; that leaves too little heap for the NimBLE stack or the Wi-Fi access point to start. Call this on the UI/render core immediately before bringing a radio up to hand that memory back; the renderer falls back to direct draw (unbuffered but correct) until restoreLiveFramebuffer() reclaims it. No-op when the shadow buffer lives in PSRAM (it is not stealing internal RAM there), on backends without a shadow buffer, and on e-paper. Called again while the buffer is already released, it restarts the reclaim schedule, so the reclaim after the next radio starts with its per-tick window. Pair with restoreLiveFramebuffer(); query state with liveFramebufferReleased().

renderEpaperGray() #

bool kleidos::hal::display::renderEpaperGray(const uint8_t * msbPlane, const uint8_t * lsbPlane, const uint8_t * lut)

Render a 2-bit grayscale image on the e-paper (QA/exploration).

Mirrors display::driver::EpaperPanelDriver::renderGrayImage(): the two RAM planes select one of four LUTs per pixel, so a graded-drive LUT yields black / dark gray / light gray / white in a single update. Defined by the e-paper backend only: gate call sites on device::kDisplayIsEpaper (the setInvert pattern).

Parameters
NameDirectionMeaning
msbPlaneinGray-index MSB plane (1 bpp row-major, RED RAM).
lsbPlaneinGray-index LSB plane (1 bpp row-major, B/W RAM).
lutin153-byte waveform LUT with per-index drive lengths.
Return values
ValueMeaning
trueImage rendered; the next flush resynchronizes with a full.
falsePanel not ready or bad arguments.

renderEpaperGrayFrame() #

bool kleidos::hal::display::renderEpaperGrayFrame(const uint8_t * toneFrame, size_t pixelCount)

Render a retained full-frame 6-tone grayscale image (QA/static UI).

Mirrors display::driver::EpaperPanelDriver::renderGrayFrame(): drives the two stacked SSD1681 grayscale passes so the tone frame resolves as six tones (white + four grays + black), and retains it so a subsequent readRect / screenshot captures the true grays instead of 1-bit. The retained frame is dropped on the next 1-bit redraw. Defined by the e-paper backend only: gate call sites on device::kDisplayIsEpaper (the setInvert pattern).

Parameters
NameDirectionMeaning
toneFrameinNative row-major tone frame, one byte per pixel (0..5).
pixelCountinLength of toneFrame in pixels (native panel area).
Return values
ValueMeaning
trueFrame rendered and retained.
falsePanel not ready or bad arguments.

resetPanel() #

bool kleidos::hal::m5backlight::resetPanel()

Pulse the LCD reset line the PMIC (Core2 v1.3, AXP192 GPIO4) or the I/O expander (CoreS3 SE, AW9523B P1.1) drives.

The SPI panel driver's reset hook: it runs inside the driver's bring-up, after the ILI9342 variant probe.

Return values
ValueMeaning
trueThe pulse was sent.
falseThe board has no such reset line, or an I2C write failed.

restoreLiveFramebuffer() #

void kleidos::hal::display::restoreLiveFramebuffer()

Try to reallocate the shadow framebuffer released by releaseLiveFramebuffer().

Call on the UI/render core, outside any frame, once every radio that borrowed the memory is down; the main loop calls it on every tick while liveFramebufferReleased() holds. The buffer comes back as 16-row bands, each its own allocation, so a heap the access point left split into blocks narrower than the frame still takes it. Attempts run on every tick for 750 ms (the heap settles a few ticks after Bluetooth stops), then every 5 s until one succeeds; a frame that would leave less than 16 kB of internal heap free is given back and retried. One log line per outcome, not per attempt. Once it succeeds, buffered/dirty-region rendering resumes and the active screen must be fully redrawn so the cleared buffer matches the panel. No-op when nothing was released, or while a frame is open.

screenClears() #

uint32_t kleidos::hal::display::screenClears()

How many times the whole glass has been cleared since boot.

Moved by fillScreen() and by a fillRect() that covers the whole panel: a screen's first paint clears the glass, so a count that moved since a header was drawn says that header is no longer on it (the battery gauge's watch, ui/components/header_gauge_watch.h).

Returns
The count; it wraps, and only its equality with an earlier read means anything.

setBacklightPark() #

void kleidos::hal::display::setBacklightPark(bool parked)

Ignore every request to change the backlight level.

While set, setBrightness() does nothing, so the level a measurement set stays until the park is released.

Parameters
NameDirectionMeaning
parkedinTrue to ignore setBrightness(), false to honor it again.

setBrightness() [1/2] #

void kleidos::hal::display::setBrightness(uint8_t b)

Set backlight brightness as a chip-agnostic percent (0..100).

0 powers the backlight off. Each HAL backend maps the percent onto its panel's usable range (PMIC voltage window or PWM duty); see M5PmicBacklight and SpiPanelDriver for the per-chip mapping. Values above 100 are clamped to 100 by the backend. While the panel sleeps the level is only kept: the backlight stays off until wakeup() lights it.

Parameters
NameDirectionMeaning
binBrightness percent in 0..100.

setBrightness() [2/2] #

bool kleidos::hal::m5backlight::setBrightness(uint8_t percent)

Set the PMIC-controlled backlight to a chip-agnostic brightness percent.

percent in 0..100; 0 powers the backlight rail off. The percent is mapped onto the variant's usable voltage window [DISPLAY_BL_MIN_MV, DISPLAY_BL_MAX_MV] and converted to the chip-specific register code (AXP192 LDO2/DC3, AXP2101 DLDO1).

Parameters
NameDirectionMeaning
percentinBrightness level, 0..100.
Return values
ValueMeaning
trueif the PMIC register write succeeded.
falseif the active variant has no PMIC backlight.

setClip() #

void kleidos::hal::display::setClip(int32_t x, int32_t y, int32_t w, int32_t h)

Constrain subsequent draws to a rectangle (software clip).

Arms an exact, uniform software clip on the active backend: every primitive drawn afterwards — fills, outlines, lines, circles, anti-aliased shapes and text — is clamped to the intersection of the screen and this rectangle. Content outside is dropped exactly, with no partial coverage. Coordinates are logical (rotation-aware) screen pixels; a non-positive w or h clips everything out. Pair with clearClip(). Every backend has a software clip.

Parameters
NameDirectionMeaning
xinClip left edge in pixels.
yinClip top edge in pixels.
winClip width in pixels.
hinClip height in pixels.

setCursor() #

void kleidos::hal::display::setCursor(int32_t x, int32_t y)

Place the top-left corner of the next print or printf text.

Each print advances the cursor's X by the width it drew.

Parameters
NameDirectionMeaning
xinCursor X in pixels.
yinCursor Y in pixels.

setEpaperAlwaysFull() #

bool kleidos::hal::display::setEpaperAlwaysFull(bool enable)

Select the e-paper user refresh mode ("Full" vs the hybrid default).

Mirrors display::driver::EpaperPanelDriver::setAlwaysFull(): when enabled, every flush runs a clean full-panel refresh (ghost-free, with a flash); when disabled, the default hybrid (fast partial-damage-diff + periodic full) is restored. Backs Settings -> Display -> Refresh mode. Defined by the e-paper backend only: gate call sites on device::kDisplayIsEpaper (the setInvert pattern).

Parameters
NameDirectionMeaning
enableinTrue for always-full ("Full"), false for the hybrid.
Return values
ValueMeaning
trueMode applied (or already in it).
falsePanel not ready.

setEpaperBusyPoll() #

void kleidos::hal::display::setEpaperBusyPoll(void(* hook )())

Run hook on every poll while the e-paper panel is busy.

Mirrors display::driver::EpaperPanelDriver::setBusyPollHook. Defined by the e-paper backend only: gate call sites on device::kDisplayIsEpaper.

Parameters
NameDirectionMeaning
hookinThe function to run, or null for none.

setEpaperFastTuning() #

bool kleidos::hal::display::setEpaperFastTuning(const uint8_t * lut, const uint8_t * sourceVoltage, int updateMode)

Override the e-paper fast-animation waveform at runtime (QA tuning).

Mirrors display::driver::EpaperPanelDriver::setFastTuning(): replaces the fast LUT (153 bytes), optionally the source-voltage parameters and the Display Update Control 2 byte used by fast partials, until cleared with all-null arguments. The live tuning seam for a waveform sweep over the serial console. Defined by the e-paper backend only: gate call sites on device::kDisplayIsEpaper (the setInvert pattern).

Parameters
NameDirectionMeaning
lutin153-byte LUT, or nullptr to restore the built-in.
sourceVoltageinThree 0x04 bytes (VSH1, VSH2, VSL), or nullptr for the panel's OTP calibration.
updateModein0x22 byte for fast partials, or -1 for built-in.
Return values
ValueMeaning
trueOverrides stored (and pushed live if fast mode is active).
falsePanel not ready.

setFastPartial() #

bool kleidos::hal::display::setFastPartial(bool enable)

Switch e-paper partial refreshes between the quality and fast waveforms.

Only meaningful on e-paper: fast mode loads a custom short animation LUT and keeps the analog rails on between updates, so region updates complete faster than with the OTP waveform's ghost-compensated one, trading contrast headroom for speed. Callers must keep fast-mode streaks bounded (an animation, a live counter) and disable it afterwards — leaving fast mode consolidates with a full refresh on the next flush. Entering on a sleeping panel wakes it first; leaving on a sleeping panel sends nothing (its deep sleep dropped the fast LUT already). Defined by the e-paper backend only: gate call sites on device::kDisplayIsEpaper (the setInvert pattern).

Parameters
NameDirectionMeaning
enableinTrue to enter fast-animation mode, false to leave it.
Return values
ValueMeaning
trueMode switched (controller has a tuned fast LUT).
falsePanel not ready or controller lacks a fast LUT.

setFont() #

void kleidos::hal::display::setFont(Font role)

Select a logical font role. Call before drawString/print. Resets text size to 1x.

Parameters
NameDirectionMeaning
roleinFont role to use for subsequent text draws.

setFramePoll() #

void kleidos::hal::display::setFramePoll(FramePollHook hook, uint32_t periodMs)

Read an input from inside the frames the loop task paints.

A frame is composed and blitted synchronously on the task that draws it, and an input read only by polling is not read meanwhile: a tap that lands and lifts during it was never seen. While hook is set, every draw made inside an open frame (between startWrite and the outermost endWrite) runs it once periodMs has passed since it last ran, the outermost endWrite runs it before its blit whatever the period, and the blit runs it between its chunks under the same period. A frame that draws nothing runs it at most at that commit. It is not run from inside itself (the rule: frame_poll.h).

The hook runs on the drawing task, with the panel's bus held during a blit: it must not draw or use that bus. Defined by the color-TFT backend only: gate call sites on !device::kDisplayIsEpaper.

Parameters
NameDirectionMeaning
hookinThe function to run, or null for none.
periodMsinThe least time between two runs inside a frame, ms.

setInvert() #

void kleidos::hal::display::setInvert(bool invert)

Swap the ink/paper polarity for the light/dark theme on 1-bit panels.

Only meaningful on e-paper, where it flips every pixel's paper/ink decision so the shared dark palette reads as dark content on paper white (light theme). The next full screen redraw renders the new polarity. Color panels implement this as a no-op. Driven by the persisted ui::ThemeMode.

Parameters
NameDirectionMeaning
invertinTrue for the light (paper-background) look.

setPanelPark() #

void kleidos::hal::display::setPanelPark(bool parked)

Ignore every request to wake the panel.

While set, wakeup() does nothing, so a panel put to sleep for a measurement stays asleep.

Parameters
NameDirectionMeaning
parkedinTrue to ignore wakeup(), false to honor it again.

setRotation() #

void kleidos::hal::display::setRotation(uint8_t r)

Turn the drawing by quarter turns (0 to 3) clockwise.

Parameters
NameDirectionMeaning
rinRotation in 0..3 (0, 90, 180, 270 degrees clockwise). Backends apply the variant's DISPLAY_OFFSET_ROTATION skew and re-aim the panel's MADCTL so the active area stays centered on the physical glass.

setTextColor() [1/2] #

void kleidos::hal::display::setTextColor(uint16_t fg)

Set text color with a transparent background.

Parameters
NameDirectionMeaning
fginForeground (text) RGB565 color.

setTextColor() [2/2] #

void kleidos::hal::display::setTextColor(uint16_t fg, uint16_t bg)

Set text color with an opaque background.

Parameters
NameDirectionMeaning
fginForeground (text) RGB565 color.
bginBackground RGB565 color.

setTextDatum() #

void kleidos::hal::display::setTextDatum(uint8_t d)

Set text alignment datum.

Parameters
NameDirectionMeaning
dinDatum code (see display_types.h).

setTextSize() #

void kleidos::hal::display::setTextSize(float s)

Set text scale factor.

Parameters
NameDirectionMeaning
sinScale factor (1.0 = native).

setWakeHook() #

void kleidos::hal::display::setWakeHook(WakeHook hook)

Run hook each time wakeup() brings a sleeping panel back, inside that call, before anything draws on the panel.

The main loop's battery sample (hal/power/battery_sampler.h): a wake takes a fresh one at once, so the first frame after it already shows the battery now. Called on the UI task only, like wakeup(); nullptr removes it.

Parameters
NameDirectionMeaning
hookinThe function to run, or nullptr.

sleep() #

void kleidos::hal::display::sleep()

Put the active display into its low-power sleep state.

On SPI panels this powers the backlight off and sends DISPOFF + SLPIN. On e-paper it flushes a pending frame, powers the analog rails down if they are up and puts the controller into deep sleep; the glass keeps the frame. Idempotent: a sleeping panel takes no command, so a call while asleep sends nothing and costs nothing, and the idle path may call it on every tick.

spiBusStatus() #

bool kleidos::hal::display::spiBusStatus(SpiBusStatus & out)

Fill out with the active SPI panel's bus status for diagnostics.

Parameters
NameDirectionMeaning
outoutSnapshot to populate (untouched on failure).
Return values
ValueMeaning
trueActive backend is an SPI panel; out is populated.
falseActive backend has no SPI panel (e.g. e-paper); out untouched.

startWrite() #

void kleidos::hal::display::startWrite()

Open a frame: a batched write transaction.

Bracket a sequence of draws with startWrite() / endWrite(). On e-paper the bracket coalesces the slow full-screen refresh into one transfer; on SPI panels the draws compose into the RAM shadow framebuffer and the outermost endWrite() blits them in one transfer, or stream directly while no shadow buffer is available. Brackets nest; the outermost pair is the frame.

streamDamageEnable() #

void kleidos::hal::display::streamDamageEnable(bool on)

Enable/disable stream-damage accumulation (off costs nothing).

Damage bookkeeping for a live-stream reader on the services core. The seqlock makes pixel reads tear-free but says nothing about WHERE damage landed; a reader that wants to fetch only the changed band enables this, peeks the union bounding box of every mutation since its last clear, and clears it after a successful capture. It bounds what readGlassRect (a debug build's capture read) would read differently: on a color panel every draw into the shadow buffer, on electronic paper the box each refresh changed on the glass, noted only in a debug build, where a capture runs. A backend that reports none leaves its readers to fall back to full frames.

Parameters
NameDirectionMeaning
oninTrue to accumulate, false to stop and drop any damage.

streamDamagePeek() #

bool kleidos::hal::display::streamDamagePeek(int16_t & x, int16_t & y, int16_t & w, int16_t & h)

Read the accumulated damage union.

Parameters
NameDirectionMeaning
xoutLeft edge.
youtTop edge.
woutWidth (0 when nothing changed).
houtHeight.
Return values
ValueMeaning
trueDamage exists;
falsenothing changed / unsupported.

textWidth() [1/2] #

int kleidos::hal::display::text_renderer::textWidth(const char * value, Font font, float size = 1.0f, bool bold = false)

Get the rendered width of a string.

Parameters
NameDirectionMeaning
valueinNUL-terminated string to measure.
fontinFont role to use.
sizeinScale factor (default 1.0).
boldinTrue to measure the bold face (matches a bold draw; default false).
Returns
Pixel width of the rendered string (advance, not bounding box).

textWidth() [2/2] #

int kleidos::hal::display::textWidth(const char * s)

Pixel width of a string in the current font (advance, not bounding box).

Parameters
NameDirectionMeaning
sinNUL-terminated string to measure.
Returns
Pixel width.

textWidthBold() #

int kleidos::hal::display::textWidthBold(const char * s)

Pixel width of a string in the bold face of the current font.

Parameters
NameDirectionMeaning
sinNUL-terminated string to measure.
Returns
Pixel width (advance, not bounding box).

upperUtf8Latin1() #

size_t kleidos::hal::display::text::upperUtf8Latin1(const char * input, char * output, size_t outputCapacity)

Copy a UTF-8 string upper-cased, for the Latin-1 letters the atlas draws.

ASCII a-z and the Latin-1 lowercase letters U+00E0..U+00FE (except U+00F7 DIVISION SIGN) map to their capitals; every other byte or sequence, ß and ÿ among them, is copied unchanged, so the output stays valid UTF-8. The result is NUL-terminated whenever outputCapacity is at least 1, and a sequence that would not fit whole is left out rather than cut.

Parameters
NameDirectionMeaning
inputinNUL-terminated UTF-8 source.
outputoutDestination buffer.
outputCapacityinCapacity of output in bytes.
Returns
Number of bytes written (excluding the terminator).

wakeup() #

void kleidos::hal::display::wakeup()

Wake the active display from its sleep state.

Counterpart of sleep(); brings the panel back to the brightness set by the last setBrightness() call. Idempotent: an awake panel sends nothing. On e-paper a wake is a hardware reset and the init sequence, and the next flush is a full refresh. An e-paper flush, or an entry into the fast waveform (setFastPartial), wakes a sleeping panel by itself. Declared for host builds too: the wake-press gate (hal/input/wake_press_gate.h) is host-tested against a fake.

width() #

int16_t kleidos::hal::display::width()
constexpr

Get the logical screen width in pixels (constexpr).

Returns
Screen width in pixels.

writePixels() #

void kleidos::hal::display::writePixels(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t * pixels)

Write a block of RGB565 pixels to a rectangular region.

Parameters
NameDirectionMeaning
xinLeft edge in pixels.
yinTop edge in pixels.
winWidth in pixels.
hinHeight in pixels.
pixelsinSource buffer of width*height RGB565 values.

Back to the top

Variable Documentation

kEllipsisGlyphByte #

char kleidos::hal::display::text::kEllipsisGlyphByte
constexpr

Single-byte stand-in for U+2026 HORIZONTAL ELLIPSIS in folded text.

The ellipsis is in every atlas, but it is outside Latin-1, so folding a cut string to Latin-1 cannot spell it, and ".." would be confusable beside an abbreviation that ends in one and two advances wide instead of one. It folds to this sentinel: the AA renderer looks the real glyph up again, and the bitmap backend draws three baseline dots.

kFontLadderPx #

std::array<std::array<uint8_t, 5>, 4> kleidos::hal::display::kFontLadderPx
inlineconstexpr

Atlas size per ladder (rows, in FontLadder order) and role (columns, in Font order: SMALL, BODY, HEADING, LARGE, MONO).

  • Stick: the action bar sans 10, rows and labels sans 13 (sans 13 shares the sans-12 line box), dialog titles sans 16, heroes sans 24, data mono 14.
  • Cardputer: hints and tab labels sans 12, body sans 14, titles sans 15 (drawn bold), heroes from sans 24, data mono 14 (tokens::kCardputerSheetFont holds the same sizes).
  • 320 x 240: sans 12 / 16 / 20 / 32, mono 16.
  • CoreInk: tab labels sans 11, row and body labels sans 14, header titles sans 17 (bold), the sans 32 hero base, mono 16 for data, drawn from the e-paper family.

kMaskGlyphByte #

char kleidos::hal::display::text::kMaskGlyphByte
constexpr

Single-byte sentinel the fold emits for U+2022 BULLET (•).

The text renderer iterates folded text byte-wise, so the 3-byte UTF-8 bullet cannot survive to the glyph lookup as its real code point (8226). Instead the fold collapses U+2022 to this one byte (0x95, the CP1252/Latin-1 bullet slot, a C1 control that never appears in legitimate ASCII text). The renderer then resolves it per backend: the AA path maps it back to the real U+2022 atlas glyph (a round bullet), and the bitmap-fallback path draws the mid-dot fallback. This implements the documented mask fallback order • -> · -> * (see ui::kMaskGlyph) without ever rendering the plaintext.

kMonoBayer8x8 #

std::array<uint8_t, 64> kleidos::hal::display::kMonoBayer8x8
inlineconstexpr

8x8 recursive (Knuth) Bayer ordered-dither thresholds, scaled to 0..254. Indexed by absolute panel (y & 7) * 8 + (x & 7): deterministic from position, so a redraw reproduces the same stipple. The 254 cap keeps a fully-covered pixel (coverage 255) always above threshold, so solid interiors never drop a pixel.

kMonoGlyphInkBias #

int32_t kleidos::hal::display::kMonoGlyphInkBias
inlineconstexpr

"+weight" bias added to a glyph's coverage before the ink decision: e-ink hairlines vanish, so glyphs render slightly bolder (e-ink text is 1-bit, solid and a little heavier). Kept small because the atlas coverage is already stem-darkened when the atlases are generated.

Back to the top