CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::ui::CanvasView Class Reference

Generic canvas view exposed to WASM plugins for custom UIs. More...

#include <CanvasView.h>

Inheritance diagram for cdc::ui::CanvasView:
cdc::ui::ViewBase cdc::ui::anim::AnimTarget cdc::ui::IView

Public Types

enum class  WidgetType : uint8_t { None = 0 , Slider = 1 , Text = 2 , Button = 3 }
enum class  WidgetEvent : uint8_t { Changed = 1 , Committed = 2 , Cancelled = 3 }
enum  : uint8_t { ANIM_REFRESH_AUTO = 0 , ANIM_REFRESH_LIGHT = 1 }
 Animation refresh policies (mirror HOST_CANVAS_ANIM_REFRESH_*). More...
using KeyCallback = void(*)(char key, uint32_t focused_widget)
using WidgetCallback = void(*)(uint32_t widget_id, WidgetEvent event)
using LongPressCallback = void(*)(char key)
using AnimCallback

Public Member Functions

void init (const char *title)
void setEditMutex (SemaphoreHandle_t mutex)
void setKeyCallback (KeyCallback cb)
void setWidgetCallback (WidgetCallback cb)
void setLongPressCallback (LongPressCallback cb)
void setFooter (const char *hint)
void setKeyRepeat (uint16_t initial_ms, uint16_t repeat_ms)
void getBodySize (uint16_t *w, uint16_t *h) const
void clearBody (bool keep_sprites=false)
void setTextSize (uint8_t size)
void setTextInverted (bool inverted)
void setFontId (uint8_t font_id)
 Select one of the canonical font ids (see cdc_views/Fonts.h).
void setShade (uint8_t shade)
 Fill ink for subsequent filled shapes: 0=none, 255=solid, between=dither.
void setInkWhite (bool white)
 Draw subsequent shapes in white instead of black (eraser/wipes).
void drawText (int16_t x, int16_t y, const char *text)
void drawTextAligned (int16_t x, int16_t y, int16_t w, const char *text, uint8_t align)
void drawRect (int16_t x, int16_t y, int16_t w, int16_t h, bool filled)
void drawPixel (int16_t x, int16_t y)
void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1)
void drawCircle (int16_t x, int16_t y, int16_t r, bool filled)
void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool filled)
void drawRoundRect (int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, bool filled)
void drawBitmap (int16_t x, int16_t y, int16_t w, int16_t h, const uint8_t *data, uint32_t len)
void drawHLine (int16_t x, int16_t y, int16_t w)
void drawVLine (int16_t x, int16_t y, int16_t h)
void commit (bool full_refresh)
bool beginElem (uint32_t id)
void endElem ()
 Stop tagging draw calls with an element id.
bool elemSetOffset (uint32_t id, int16_t ox, int16_t oy)
 Set the element's replay offset relative to its recorded coordinates.
bool elemMove (uint32_t id, int16_t dx, int16_t dy)
 Shift the element's replay offset by a delta.
bool elemShow (uint32_t id, bool visible)
 Show or hide the element (hidden elements are skipped on replay).
bool elemRemove (uint32_t id)
bool elemClear (uint32_t id)
bool elemSetZ (uint32_t id, int8_t z)
bool elemGetOffset (uint32_t id, int16_t *ox, int16_t *oy) const
 Read the element's current replay offset.
bool elemGetBounds (uint32_t id, int16_t *x, int16_t *y, uint16_t *w, uint16_t *h)
int32_t spriteCreate (uint16_t w, uint16_t h, uint16_t frame_count, const uint8_t *data, uint32_t len)
bool spriteSetMask (uint32_t handle, const uint8_t *mask, uint32_t len)
bool spriteSetFlags (uint32_t handle, uint8_t flags)
bool spriteSetScale (uint32_t handle, uint8_t scale)
 Integer upscale 1..4 applied whenever the sprite is drawn.
bool spriteSetFrame (uint32_t handle, uint16_t frame)
int32_t spriteGetFrame (uint32_t handle) const
bool spriteSetFrameDurations (uint32_t handle, const uint16_t *ms, uint16_t count)
bool spritePlay (uint32_t handle, uint8_t mode, uint16_t frame_ms, uint16_t repeat, uint32_t done_action_id)
bool spriteStop (uint32_t handle)
bool spriteDestroy (uint32_t handle)
void drawSprite (int16_t x, int16_t y, uint32_t handle)
 Record a draw-by-reference of the sprite's current frame at (x, y).
bool spriteFrameView (uint32_t handle, anim::SpriteStore::FrameView *out) const
int32_t marquee (int16_t x, int16_t y, int16_t window_w, const char *text, uint16_t step_px, uint16_t frame_ms)
uint32_t animStart (const anim::TweenConfig &cfg)
uint32_t animBlink (uint32_t elem_id, uint16_t period_ms, uint16_t count, uint32_t done_action_id)
bool animCancel (uint32_t handle)
 Handle 0 cancels all (no events).
bool animPause (uint32_t handle, bool paused)
int8_t animState (uint32_t handle) const
uint8_t animActiveCount () const
 Live tweens plus playing sprites.
void setAnimCallback (AnimCallback cb)
bool setAnimPolicy (uint8_t policy, uint8_t max_fps)
 Configure refresh policy and step-rate cap (0 = default 4 fps).
bool addSlider (uint32_t id, int32_t min, int32_t max, int32_t initial, int32_t step)
bool addText (uint32_t id, uint16_t max_len, const char *initial)
bool addButton (uint32_t id)
bool removeWidget (uint32_t id)
bool setValue (uint32_t id, int32_t value)
bool getValue (uint32_t id, int32_t *out) const
bool setText (uint32_t id, const char *text)
int getText (uint32_t id, char *out, size_t cap) const
bool setFocus (uint32_t id)
uint32_t getFocus () const
void render (bool partial) override
InputResult onKey (char key) override
InputResult onLongPress (char key) override
void onEnter (void *context) override
void onResume () override
void onPause () override
void onExit () override
void onTick (uint32_t nowMs) override
const char * getName () const override
hal::RefreshMode preferredEnterRefresh () const override
bool prefersLightRefresh () const override
Public Member Functions inherited from cdc::ui::ViewBase
virtual ~ViewBase ()=default
void onEnter (void *context) override
void onExit () override
void onResume () override
void onPause () override
void setLifecycleHooks (void(*onHide)(void *), void(*onShow)(void *), void *userData) override
bool needsRender () const override
void markDirty () override
void clearDirty () override
void setFooterHint (const char *hint) override
const char * getFooterHint () const override
Public Member Functions inherited from cdc::ui::IView
virtual ~IView ()=default

Static Public Attributes

static constexpr uint8_t MAX_WIDGETS = 8
static constexpr uint8_t MAX_ELEMS = 16
static constexpr uint16_t MAX_TEXT_LEN = 256
static constexpr uint16_t T9_SETTLE_MS = 800
static constexpr uint16_t MAX_CMDS = 128
static constexpr uint16_t TEXT_ARENA = 2048
static constexpr uint16_t BLOB_ARENA = 8192
 Pixel-data arena for recorded bitmaps. 8 KB holds one full-body mono bitmap.
static constexpr uint32_t SPRITE_ARENA = 65536
 Pixel arena for sprite frame sheets (lazy PSRAM allocation).
static constexpr uint8_t ANIM_FPS_DEFAULT = 4
static constexpr uint8_t ANIM_FPS_MAX = 5
static constexpr uint16_t ANIM_CLEANUP_IDLE_MS = 1000
 Idle time after the last animation before the AUTO ghost-cleanup FAST.
static constexpr uint8_t ANIM_HYGIENE_COMMITS = 128
 Endless animations get one hygiene FAST every this many anim commits.

Additional Inherited Members

Protected Member Functions inherited from cdc::ui::ViewBase
void setTitle (const char *title)
const char * getTitle () const
Protected Attributes inherited from cdc::ui::ViewBase
bool dirty_ = true
const char * title_ = nullptr
const char * customFooter_ = nullptr
void(* onHide_ )(void *) = nullptr
void(* onShow_ )(void *) = nullptr
void * lifecycleUserData_ = nullptr

Detailed Description

Generic canvas view exposed to WASM plugins for custom UIs.

The plugin draws into the body area via host_view_canvas_* draw primitives. Inline widgets (slider, text-input, button) have host-owned input state while their visual representation is rendered by the plugin reading the widget value/text on each frame.

Coordinates are body-local: (0,0) is the top-left of the body area (display rows after the header up to the footer bar).

Definition at line 26 of file CanvasView.h.

Member Typedef Documentation

◆ AnimCallback

Initial value:
void(*)(uint32_t done_action_id, uint32_t handle,
uint32_t ref_id)

Fired outside the edit mutex for every finished tween/sprite playback that carries a done-action id.

Definition at line 74 of file CanvasView.h.

◆ KeyCallback

using cdc::ui::CanvasView::KeyCallback = void(*)(char key, uint32_t focused_widget)

Definition at line 69 of file CanvasView.h.

◆ LongPressCallback

using cdc::ui::CanvasView::LongPressCallback = void(*)(char key)

Definition at line 71 of file CanvasView.h.

◆ WidgetCallback

using cdc::ui::CanvasView::WidgetCallback = void(*)(uint32_t widget_id, WidgetEvent event)

Definition at line 70 of file CanvasView.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : uint8_t

Animation refresh policies (mirror HOST_CANVAS_ANIM_REFRESH_*).

Enumerator
ANIM_REFRESH_AUTO 

PARTIAL_LIGHT while running + FAST cleanup.

ANIM_REFRESH_LIGHT 

PARTIAL_LIGHT always, no automatic cleanup.

Definition at line 56 of file CanvasView.h.

◆ WidgetEvent

enum class cdc::ui::CanvasView::WidgetEvent : uint8_t
strong
Enumerator
Changed 
Committed 
Cancelled 

Definition at line 35 of file CanvasView.h.

◆ WidgetType

enum class cdc::ui::CanvasView::WidgetType : uint8_t
strong
Enumerator
None 
Slider 
Text 
Button 

Definition at line 28 of file CanvasView.h.

Member Function Documentation

◆ addButton()

bool cdc::ui::CanvasView::addButton ( uint32_t id)

Definition at line 1136 of file CanvasView.cpp.

References Button, and MAX_WIDGETS.

◆ addSlider()

bool cdc::ui::CanvasView::addSlider ( uint32_t id,
int32_t min,
int32_t max,
int32_t initial,
int32_t step )

Definition at line 1102 of file CanvasView.cpp.

References MAX_WIDGETS, and Slider.

◆ addText()

bool cdc::ui::CanvasView::addText ( uint32_t id,
uint16_t max_len,
const char * initial )

Definition at line 1118 of file CanvasView.cpp.

References MAX_TEXT_LEN, MAX_WIDGETS, and Text.

◆ animActiveCount()

uint8_t cdc::ui::CanvasView::animActiveCount ( ) const

Live tweens plus playing sprites.

Definition at line 1041 of file CanvasView.cpp.

◆ animBlink()

uint32_t cdc::ui::CanvasView::animBlink ( uint32_t elem_id,
uint16_t period_ms,
uint16_t count,
uint32_t done_action_id )

Blink an element: count on/off cycles of period_ms per phase, ending visible. Occupies one tween slot.

Definition at line 1013 of file CanvasView.cpp.

◆ animCancel()

bool cdc::ui::CanvasView::animCancel ( uint32_t handle)

Handle 0 cancels all (no events).

Definition at line 1026 of file CanvasView.cpp.

◆ animPause()

bool cdc::ui::CanvasView::animPause ( uint32_t handle,
bool paused )

Definition at line 1031 of file CanvasView.cpp.

◆ animStart()

uint32_t cdc::ui::CanvasView::animStart ( const anim::TweenConfig & cfg)
Returns
Tween handle >= 1, or 0 on invalid config / full slots / unknown element / unknown startAfter predecessor.

Definition at line 1001 of file CanvasView.cpp.

References cdc::ui::anim::TweenConfig::elemId, and cdc::ui::ViewBase::markDirty().

◆ animState()

int8_t cdc::ui::CanvasView::animState ( uint32_t handle) const

anim::STATE_* or -1.

Definition at line 1036 of file CanvasView.cpp.

◆ beginElem()

bool cdc::ui::CanvasView::beginElem ( uint32_t id)

Start recording subsequent draw calls under element id (creates the element on first use). Elements are named groups of draw commands that can later be moved, hidden or removed without rebuilding the whole display list — the building block for animations.

Definition at line 438 of file CanvasView.cpp.

References LOG_W, and MAX_ELEMS.

◆ clearBody()

void cdc::ui::CanvasView::clearBody ( bool keep_sprites = false)

Drop the display list, elements and their tweens. With keep_sprites the sprite assets (frames, masks, flags, current frame) survive; their playback is stopped so orphans cannot keep the animation clock busy.

Definition at line 134 of file CanvasView.cpp.

References SPRITE_ARENA.

◆ commit()

void cdc::ui::CanvasView::commit ( bool full_refresh)

Definition at line 852 of file CanvasView.cpp.

References cdc::ui::ViewBase::markDirty().

◆ drawBitmap()

void cdc::ui::CanvasView::drawBitmap ( int16_t x,
int16_t y,
int16_t w,
int16_t h,
const uint8_t * data,
uint32_t len )

Draw a 1-bpp bitmap (rows byte-padded, MSB first). Set bits draw black, unset bits are transparent. Pixel data is copied into the canvas arena.

Definition at line 351 of file CanvasView.cpp.

References BLOB_ARENA, LOG_W, and MAX_CMDS.

◆ drawCircle()

void cdc::ui::CanvasView::drawCircle ( int16_t x,
int16_t y,
int16_t r,
bool filled )

Definition at line 303 of file CanvasView.cpp.

References MAX_CMDS.

◆ drawHLine()

void cdc::ui::CanvasView::drawHLine ( int16_t x,
int16_t y,
int16_t w )

Definition at line 376 of file CanvasView.cpp.

References MAX_CMDS.

◆ drawLine()

void cdc::ui::CanvasView::drawLine ( int16_t x0,
int16_t y0,
int16_t x1,
int16_t y1 )

Definition at line 290 of file CanvasView.cpp.

References MAX_CMDS.

◆ drawPixel()

void cdc::ui::CanvasView::drawPixel ( int16_t x,
int16_t y )

Definition at line 279 of file CanvasView.cpp.

References MAX_CMDS.

◆ drawRect()

void cdc::ui::CanvasView::drawRect ( int16_t x,
int16_t y,
int16_t w,
int16_t h,
bool filled )

Definition at line 264 of file CanvasView.cpp.

References MAX_CMDS.

◆ drawRoundRect()

void cdc::ui::CanvasView::drawRoundRect ( int16_t x,
int16_t y,
int16_t w,
int16_t h,
int16_t r,
bool filled )

Definition at line 335 of file CanvasView.cpp.

References MAX_CMDS.

◆ drawSprite()

void cdc::ui::CanvasView::drawSprite ( int16_t x,
int16_t y,
uint32_t handle )

Record a draw-by-reference of the sprite's current frame at (x, y).

Definition at line 986 of file CanvasView.cpp.

References MAX_CMDS.

◆ drawText()

void cdc::ui::CanvasView::drawText ( int16_t x,
int16_t y,
const char * text )

Definition at line 221 of file CanvasView.cpp.

References LOG_W, and MAX_CMDS.

◆ drawTextAligned()

void cdc::ui::CanvasView::drawTextAligned ( int16_t x,
int16_t y,
int16_t w,
const char * text,
uint8_t align )

Definition at line 241 of file CanvasView.cpp.

References LOG_W, and MAX_CMDS.

◆ drawTriangle()

void cdc::ui::CanvasView::drawTriangle ( int16_t x0,
int16_t y0,
int16_t x1,
int16_t y1,
int16_t x2,
int16_t y2,
bool filled )

Definition at line 317 of file CanvasView.cpp.

References MAX_CMDS.

◆ drawVLine()

void cdc::ui::CanvasView::drawVLine ( int16_t x,
int16_t y,
int16_t h )

Definition at line 388 of file CanvasView.cpp.

References MAX_CMDS.

◆ elemClear()

bool cdc::ui::CanvasView::elemClear ( uint32_t id)

Drop only the element's draw commands, keeping the element (offset, visibility, z, running tweens) for re-recording in place.

Definition at line 521 of file CanvasView.cpp.

◆ elemGetBounds()

bool cdc::ui::CanvasView::elemGetBounds ( uint32_t id,
int16_t * x,
int16_t * y,
uint16_t * w,
uint16_t * h )

Bounding box of the element's recorded commands with its offset applied, in body-local pixels. False when unknown or empty.

Definition at line 545 of file CanvasView.cpp.

◆ elemGetOffset()

bool cdc::ui::CanvasView::elemGetOffset ( uint32_t id,
int16_t * ox,
int16_t * oy ) const

Read the element's current replay offset.

Definition at line 536 of file CanvasView.cpp.

◆ elemMove()

bool cdc::ui::CanvasView::elemMove ( uint32_t id,
int16_t dx,
int16_t dy )

Shift the element's replay offset by a delta.

Definition at line 471 of file CanvasView.cpp.

◆ elemRemove()

bool cdc::ui::CanvasView::elemRemove ( uint32_t id)

Drop the element and all its draw commands; arena space is reclaimed. Tweens bound to the element are cancelled silently.

Definition at line 503 of file CanvasView.cpp.

◆ elemSetOffset()

bool cdc::ui::CanvasView::elemSetOffset ( uint32_t id,
int16_t ox,
int16_t oy )

Set the element's replay offset relative to its recorded coordinates.

Definition at line 462 of file CanvasView.cpp.

◆ elemSetZ()

bool cdc::ui::CanvasView::elemSetZ ( uint32_t id,
int8_t z )

Set the element's replay layer (-128..127, default 0). Lower layers draw first; untagged commands draw in layer 0. Ties keep recording order.

Definition at line 528 of file CanvasView.cpp.

◆ elemShow()

bool cdc::ui::CanvasView::elemShow ( uint32_t id,
bool visible )

Show or hide the element (hidden elements are skipped on replay).

Definition at line 480 of file CanvasView.cpp.

◆ endElem()

void cdc::ui::CanvasView::endElem ( )

Stop tagging draw calls with an element id.

Definition at line 457 of file CanvasView.cpp.

◆ getBodySize()

void cdc::ui::CanvasView::getBodySize ( uint16_t * w,
uint16_t * h ) const

Definition at line 123 of file CanvasView.cpp.

References cdc::ui::display, and cdc::hal::getDisplayInstance().

◆ getFocus()

uint32_t cdc::ui::CanvasView::getFocus ( ) const
inline

Definition at line 223 of file CanvasView.h.

◆ getName()

const char * cdc::ui::CanvasView::getName ( ) const
inlineoverridevirtual

Get view name for debugging

Implements cdc::ui::IView.

Definition at line 233 of file CanvasView.h.

◆ getText()

int cdc::ui::CanvasView::getText ( uint32_t id,
char * out,
size_t cap ) const

Definition at line 1189 of file CanvasView.cpp.

◆ getValue()

bool cdc::ui::CanvasView::getValue ( uint32_t id,
int32_t * out ) const

Definition at line 1169 of file CanvasView.cpp.

◆ init()

void cdc::ui::CanvasView::init ( const char * title)

◆ marquee()

int32_t cdc::ui::CanvasView::marquee ( int16_t x,
int16_t y,
int16_t window_w,
const char * text,
uint16_t step_px,
uint16_t frame_ms )

Record a host-driven text marquee: the text is rendered once into an internal sprite and a window_w-wide window scrolls through it seamlessly (content + a window-sized blank gap). Uses the current font/size. Returns the backing sprite handle (stop/destroy like any sprite) or 0/-1 like spriteCreate.

Definition at line 897 of file CanvasView.cpp.

References cdc::ui::MonoSurface::buffer(), cdc::ui::MonoSurface::byteSize(), cdc::ui::render::drawText(), cdc::ui::getGfxFont(), cdc::ui::ViewBase::markDirty(), MAX_CMDS, cdc::ui::render::measureText(), and cdc::ui::MonoSurface::ok().

◆ onEnter()

void cdc::ui::CanvasView::onEnter ( void * context)
overridevirtual

Called when view becomes active (pushed or becomes top)

Parameters
contextOptional context data from parent

Implements cdc::ui::IView.

Definition at line 1374 of file CanvasView.cpp.

References cdc::ui::ViewBase::onEnter().

◆ onExit()

void cdc::ui::CanvasView::onExit ( )
overridevirtual

Called when view is being removed from stack

Implements cdc::ui::IView.

Definition at line 1399 of file CanvasView.cpp.

References cdc::hal::IKeypad::DEFER_SRC_VIEW, cdc::hal::getKeypadInstance(), cdc::ui::ViewBase::onExit(), and SPRITE_ARENA.

◆ onKey()

InputResult cdc::ui::CanvasView::onKey ( char key)
overridevirtual

Handle key press

Parameters
keyKey character ('0'-'9', 'Y', 'N', etc.)
Returns
Input result

Implements cdc::ui::IView.

Definition at line 1331 of file CanvasView.cpp.

References cdc::ui::CONSUMED, cdc::ui::IGNORED, cdc::ui::KEY_NO, and cdc::ui::REQUEST_POP.

◆ onLongPress()

InputResult cdc::ui::CanvasView::onLongPress ( char key)
overridevirtual

Handle long key press (optional)

Parameters
keyKey character
Returns
Input result

Reimplemented from cdc::ui::IView.

Definition at line 1366 of file CanvasView.cpp.

References cdc::ui::CONSUMED, and cdc::ui::IGNORED.

◆ onPause()

void cdc::ui::CanvasView::onPause ( )
overridevirtual

Called when the view is covered by another view or modal (still on the stack but no longer active). Counterpart to onResume(). Default no-op.

Reimplemented from cdc::ui::IView.

Definition at line 1394 of file CanvasView.cpp.

References cdc::ui::ViewBase::onPause().

◆ onResume()

void cdc::ui::CanvasView::onResume ( )
overridevirtual

Called when view becomes visible again (child popped)

Implements cdc::ui::IView.

Definition at line 1379 of file CanvasView.cpp.

References cdc::ui::ViewBase::onResume().

◆ onTick()

void cdc::ui::CanvasView::onTick ( uint32_t nowMs)
overridevirtual

Called periodically for animations/timers

Parameters
nowMsCurrent time in milliseconds

Reimplemented from cdc::ui::IView.

Definition at line 1420 of file CanvasView.cpp.

References ANIM_CLEANUP_IDLE_MS, ANIM_HYGIENE_COMMITS, ANIM_REFRESH_AUTO, cdc::hal::FAST, cdc::ui::ViewStack::forceRefresh(), cdc::ui::ViewStack::instance(), and cdc::ui::ViewBase::markDirty().

◆ preferredEnterRefresh()

hal::RefreshMode cdc::ui::CanvasView::preferredEnterRefresh ( ) const
inlineoverridevirtual

Plugin free-draw surfaces accumulate churn; a single-flash FAST refresh gives them a mostly clean base without the full multi-flash waveform.

Reimplemented from cdc::ui::IView.

Definition at line 237 of file CanvasView.h.

References cdc::hal::FAST.

◆ prefersLightRefresh()

bool cdc::ui::CanvasView::prefersLightRefresh ( ) const
inlineoverridevirtual

While animations run, partial refreshes must not escalate to a FAST mid-motion flash; ghost hygiene is handled by the anim policy instead.

Reimplemented from cdc::ui::IView.

Definition at line 241 of file CanvasView.h.

◆ removeWidget()

bool cdc::ui::CanvasView::removeWidget ( uint32_t id)

Definition at line 1147 of file CanvasView.cpp.

◆ render()

void cdc::ui::CanvasView::render ( bool partial)
overridevirtual

Render view content to display buffer

Parameters
partialTrue for partial update, false for full refresh

Implements cdc::ui::IView.

Definition at line 1477 of file CanvasView.cpp.

References cdc::ui::ViewBase::customFooter_, cdc::ui::ViewBase::dirty_, cdc::ui::display, cdc::ui::render::drawFooterBar(), cdc::ui::render::drawHeaderLeft(), cdc::hal::getDisplayInstance(), cdc::ui::ViewBase::title_, and cdc::ui::TITLE_Y.

◆ setAnimCallback()

void cdc::ui::CanvasView::setAnimCallback ( AnimCallback cb)
inline

Definition at line 208 of file CanvasView.h.

◆ setAnimPolicy()

bool cdc::ui::CanvasView::setAnimPolicy ( uint8_t policy,
uint8_t max_fps )

Configure refresh policy and step-rate cap (0 = default 4 fps).

Definition at line 1048 of file CanvasView.cpp.

References ANIM_FPS_DEFAULT, ANIM_FPS_MAX, and ANIM_REFRESH_LIGHT.

◆ setEditMutex()

void cdc::ui::CanvasView::setEditMutex ( SemaphoreHandle_t mutex)
inline

Set an optional recursive mutex serialising display-list access.

When set (non-null), the draw/element mutators and the render-time replay acquire it. A cross-task writer (plugin host calls on the plg_tick task) mutates the command list and arenas while the UI task replays them, so both sides must hold the same mutex. Null (default) disables locking entirely for single-task use.

Definition at line 88 of file CanvasView.h.

References mutex.

◆ setFocus()

bool cdc::ui::CanvasView::setFocus ( uint32_t id)

Definition at line 1198 of file CanvasView.cpp.

◆ setFontId()

void cdc::ui::CanvasView::setFontId ( uint8_t font_id)
inline

Select one of the canonical font ids (see cdc_views/Fonts.h).

Definition at line 106 of file CanvasView.h.

◆ setFooter()

void cdc::ui::CanvasView::setFooter ( const char * hint)

Definition at line 112 of file CanvasView.cpp.

References cdc::ui::ViewBase::customFooter_.

◆ setInkWhite()

void cdc::ui::CanvasView::setInkWhite ( bool white)
inline

Draw subsequent shapes in white instead of black (eraser/wipes).

Definition at line 110 of file CanvasView.h.

◆ setKeyCallback()

void cdc::ui::CanvasView::setKeyCallback ( KeyCallback cb)
inline

Definition at line 90 of file CanvasView.h.

◆ setKeyRepeat()

void cdc::ui::CanvasView::setKeyRepeat ( uint16_t initial_ms,
uint16_t repeat_ms )

Definition at line 117 of file CanvasView.cpp.

◆ setLongPressCallback()

void cdc::ui::CanvasView::setLongPressCallback ( LongPressCallback cb)

Register a plugin long-press handler. Setting a non-null callback opts this canvas into deferred short-press keypad mode while it is active.

Definition at line 1361 of file CanvasView.cpp.

◆ setShade()

void cdc::ui::CanvasView::setShade ( uint8_t shade)
inline

Fill ink for subsequent filled shapes: 0=none, 255=solid, between=dither.

Definition at line 108 of file CanvasView.h.

◆ setText()

bool cdc::ui::CanvasView::setText ( uint32_t id,
const char * text )

Definition at line 1176 of file CanvasView.cpp.

References Text.

◆ setTextInverted()

void cdc::ui::CanvasView::setTextInverted ( bool inverted)
inline

Definition at line 104 of file CanvasView.h.

◆ setTextSize()

void cdc::ui::CanvasView::setTextSize ( uint8_t size)
inline

Definition at line 103 of file CanvasView.h.

◆ setValue()

bool cdc::ui::CanvasView::setValue ( uint32_t id,
int32_t value )

Definition at line 1162 of file CanvasView.cpp.

References Slider.

◆ setWidgetCallback()

void cdc::ui::CanvasView::setWidgetCallback ( WidgetCallback cb)
inline

Definition at line 91 of file CanvasView.h.

◆ spriteCreate()

int32_t cdc::ui::CanvasView::spriteCreate ( uint16_t w,
uint16_t h,
uint16_t frame_count,
const uint8_t * data,
uint32_t len )

Copy a vertically stacked frame sheet into the sprite arena.

Returns
Handle >= 1, 0 = invalid arguments, -1 = out of slots/arena.

Definition at line 872 of file CanvasView.cpp.

◆ spriteDestroy()

bool cdc::ui::CanvasView::spriteDestroy ( uint32_t handle)

Destroy the sprite; recorded draw-sprite commands referencing it are skipped on replay from then on.

Definition at line 975 of file CanvasView.cpp.

◆ spriteFrameView()

bool cdc::ui::CanvasView::spriteFrameView ( uint32_t handle,
anim::SpriteStore::FrameView * out ) const

Snapshot the sprite's current frame pixels (for stamping onto surfaces). Pointers stay valid until the next sprite mutation.

Definition at line 980 of file CanvasView.cpp.

◆ spriteGetFrame()

int32_t cdc::ui::CanvasView::spriteGetFrame ( uint32_t handle) const

Definition at line 947 of file CanvasView.cpp.

◆ spritePlay()

bool cdc::ui::CanvasView::spritePlay ( uint32_t handle,
uint8_t mode,
uint16_t frame_ms,
uint16_t repeat,
uint32_t done_action_id )

Definition at line 958 of file CanvasView.cpp.

References cdc::ui::ViewBase::markDirty().

◆ spriteSetFlags()

bool cdc::ui::CanvasView::spriteSetFlags ( uint32_t handle,
uint8_t flags )

Definition at line 884 of file CanvasView.cpp.

References flags.

◆ spriteSetFrame()

bool cdc::ui::CanvasView::spriteSetFrame ( uint32_t handle,
uint16_t frame )

Definition at line 942 of file CanvasView.cpp.

◆ spriteSetFrameDurations()

bool cdc::ui::CanvasView::spriteSetFrameDurations ( uint32_t handle,
const uint16_t * ms,
uint16_t count )

Definition at line 952 of file CanvasView.cpp.

◆ spriteSetMask()

bool cdc::ui::CanvasView::spriteSetMask ( uint32_t handle,
const uint8_t * mask,
uint32_t len )

Definition at line 879 of file CanvasView.cpp.

◆ spriteSetScale()

bool cdc::ui::CanvasView::spriteSetScale ( uint32_t handle,
uint8_t scale )

Integer upscale 1..4 applied whenever the sprite is drawn.

Definition at line 889 of file CanvasView.cpp.

References cdc::ui::scale.

◆ spriteStop()

bool cdc::ui::CanvasView::spriteStop ( uint32_t handle)

Definition at line 970 of file CanvasView.cpp.

Member Data Documentation

◆ ANIM_CLEANUP_IDLE_MS

uint16_t cdc::ui::CanvasView::ANIM_CLEANUP_IDLE_MS = 1000
staticconstexpr

Idle time after the last animation before the AUTO ghost-cleanup FAST.

Definition at line 65 of file CanvasView.h.

Referenced by onTick().

◆ ANIM_FPS_DEFAULT

uint8_t cdc::ui::CanvasView::ANIM_FPS_DEFAULT = 4
staticconstexpr

Animation step-rate cap. The partial waveform (~200-300 ms) bounds the panel to ~5 Hz; anything above just burns replay CPU.

Definition at line 62 of file CanvasView.h.

Referenced by init(), and setAnimPolicy().

◆ ANIM_FPS_MAX

uint8_t cdc::ui::CanvasView::ANIM_FPS_MAX = 5
staticconstexpr

Definition at line 63 of file CanvasView.h.

Referenced by setAnimPolicy().

◆ ANIM_HYGIENE_COMMITS

uint8_t cdc::ui::CanvasView::ANIM_HYGIENE_COMMITS = 128
staticconstexpr

Endless animations get one hygiene FAST every this many anim commits.

Definition at line 67 of file CanvasView.h.

Referenced by onTick().

◆ BLOB_ARENA

uint16_t cdc::ui::CanvasView::BLOB_ARENA = 8192
staticconstexpr

Pixel-data arena for recorded bitmaps. 8 KB holds one full-body mono bitmap.

Definition at line 51 of file CanvasView.h.

Referenced by drawBitmap().

◆ MAX_CMDS

uint16_t cdc::ui::CanvasView::MAX_CMDS = 128
staticconstexpr

Retained display list: draw primitives are recorded here and replayed in render() after the framework clears the screen. Arenas are PSRAM-backed.

Definition at line 48 of file CanvasView.h.

Referenced by drawBitmap(), drawCircle(), drawHLine(), drawLine(), drawPixel(), drawRect(), drawRoundRect(), drawSprite(), drawText(), drawTextAligned(), drawTriangle(), drawVLine(), and marquee().

◆ MAX_ELEMS

uint8_t cdc::ui::CanvasView::MAX_ELEMS = 16
staticconstexpr

Definition at line 42 of file CanvasView.h.

Referenced by beginElem().

◆ MAX_TEXT_LEN

uint16_t cdc::ui::CanvasView::MAX_TEXT_LEN = 256
staticconstexpr

Definition at line 43 of file CanvasView.h.

Referenced by addText().

◆ MAX_WIDGETS

uint8_t cdc::ui::CanvasView::MAX_WIDGETS = 8
staticconstexpr

Definition at line 41 of file CanvasView.h.

Referenced by addButton(), addSlider(), and addText().

◆ SPRITE_ARENA

uint32_t cdc::ui::CanvasView::SPRITE_ARENA = 65536
staticconstexpr

Pixel arena for sprite frame sheets (lazy PSRAM allocation).

Definition at line 53 of file CanvasView.h.

Referenced by clearBody(), init(), and onExit().

◆ T9_SETTLE_MS

uint16_t cdc::ui::CanvasView::T9_SETTLE_MS = 800
staticconstexpr

Definition at line 44 of file CanvasView.h.

◆ TEXT_ARENA

uint16_t cdc::ui::CanvasView::TEXT_ARENA = 2048
staticconstexpr

Definition at line 49 of file CanvasView.h.


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