CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
host_api_canvas.cpp File Reference

extern-C adapter for the plugin canvas view. More...

#include "plugin_manager/PluginUiState.h"
#include "plugin_manager/host_api.h"
#include "cdc_views/CanvasView.h"
#include "cdc_views/Fonts.h"
#include "cdc_views/RenderHelpers.h"
#include "cdc_hal/IDisplay.h"
#include "host_str_conv.h"
#include <goodisplay/gdey029T94.h>
#include <cstring>
#include <string>

Go to the source code of this file.

Functions

int host_view_canvas_push (const char *title, uint32_t key_action_id, uint32_t widget_action_id)
 Push a new canvas view.
int host_view_canvas_get_body_size (uint16_t *w, uint16_t *h)
 Read the drawable body region (excluding header/footer).
int host_view_canvas_set_footer (const char *hint)
 Override the footer hint of the canvas.
int host_view_canvas_clear (void)
 Clear all draw state and widgets. Equals host_view_canvas_clear_ex(0).
int host_view_canvas_clear_ex (uint32_t flags)
 Clear with options: like host_view_canvas_clear, but HOST_CANVAS_CLEAR_KEEP_SPRITES keeps the sprite store intact.
int host_view_canvas_set_text_size (uint8_t size)
 Set text size multiplier (Adafruit-GFX semantics).
int host_view_canvas_set_text_color (bool inverted)
 Switch between normal and inverted (white on black) text.
int host_view_canvas_set_shade (uint8_t shade)
 Set the fill ink for subsequent filled shapes (rect, circle, triangle).
int host_view_canvas_set_font (uint8_t font_id)
 Switch the canvas font to one of the canonical HOST_FONT_* ids.
int host_text_pick_font_that_fits (const char *text, int16_t max_width_px, const uint8_t *candidates, uint32_t count, uint8_t *out_font_id)
 Pick the largest HOST_FONT_* whose rendered text fits within max_width_px. Candidates are evaluated in array order; sort them from largest to smallest. Falls back to the last entry when nothing fits.
int host_view_canvas_draw_text (int16_t x, int16_t y, const char *text)
 Draw text at (x, y) using the current text size/colour.
int host_view_canvas_draw_text_aligned (int16_t x, int16_t y, int16_t w, const char *text, uint8_t align)
 Draw text within a horizontal box.
int host_view_canvas_draw_rect (int16_t x, int16_t y, int16_t w, int16_t h, bool filled)
 Draw a rectangle outline or filled rectangle.
int host_view_canvas_draw_pixel (int16_t x, int16_t y)
 Draw a single pixel.
int host_view_canvas_draw_line (int16_t x0, int16_t y0, int16_t x1, int16_t y1)
 Draw a line between two points.
int host_view_canvas_draw_circle (int16_t x, int16_t y, int16_t r, bool filled)
 Draw a circle outline or filled circle of radius r centred at (x, y).
int host_view_canvas_draw_triangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool filled)
 Draw a triangle outline or filled triangle through three points.
int host_view_canvas_draw_round_rect (int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, bool filled)
 Draw a rounded rectangle outline or filled, corner radius r.
int host_view_canvas_draw_bitmap (int16_t x, int16_t y, int16_t w, int16_t h, const uint8_t *data, uint32_t len)
 Draw a 1-bpp bitmap; set bits render black, unset bits are transparent.
int host_view_canvas_hline (int16_t x, int16_t y, int16_t w)
 Draw a horizontal line.
int host_view_canvas_vline (int16_t x, int16_t y, int16_t h)
 Draw a vertical line.
int host_view_canvas_commit (bool full_refresh)
 Flush draw state to the panel.
int host_view_canvas_elem_begin (uint32_t elem_id)
 Start recording draw calls under element elem_id.
int host_view_canvas_elem_end (void)
 Stop recording draw calls into an element.
int host_view_canvas_elem_set_offset (uint32_t elem_id, int16_t ox, int16_t oy)
 Set an element's replay offset relative to its recorded coordinates.
int host_view_canvas_elem_move (uint32_t elem_id, int16_t dx, int16_t dy)
 Shift an element's replay offset by a delta.
int host_view_canvas_elem_show (uint32_t elem_id, bool visible)
 Show or hide an element (hidden elements are skipped on replay).
int host_view_canvas_elem_remove (uint32_t elem_id)
 Remove an element and all draw commands recorded under it.
int host_view_canvas_elem_clear (uint32_t elem_id)
 Drop only an element's recorded draw commands, keeping the element.
int host_view_canvas_elem_set_z (uint32_t elem_id, int8_t z)
 Set an element's replay layer (z-order).
int host_view_canvas_elem_get_offset (uint32_t elem_id, int16_t *ox, int16_t *oy)
 Read an element's current replay offset.
int host_view_canvas_elem_get_bounds (uint32_t elem_id, int16_t *x, int16_t *y, uint16_t *w, uint16_t *h)
 Bounding box of an element's recorded commands, offset applied.
int host_view_canvas_set_anim_policy (uint8_t refresh_policy, uint8_t max_fps)
 Configure host-driven animation pacing for the current canvas.
int host_view_canvas_draw_sprite (int16_t x, int16_t y, uint32_t sprite)
 Record a draw of a sprite's current frame at (x, y).
int host_view_canvas_set_ink (bool white)
 Draw subsequent shapes in white instead of black.
int host_view_canvas_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 (ticker).
int host_sprite_create (uint16_t frame_w, uint16_t frame_h, uint16_t frame_count, const uint8_t *frames, uint32_t len)
 Create a sprite from a packed 1-bpp frame sheet in plugin memory.
int host_sprite_set_mask (uint32_t sprite, const uint8_t *mask, uint32_t len)
 Attach a transparency mask plane (same sheet layout and size as the frame data). Mask bit set = pixel painted; overrides HOST_SPRITE_FLAG_OPAQUE.
int host_sprite_set_flags (uint32_t sprite, uint8_t flags)
 Replace the sprite's flag set (HOST_SPRITE_FLAG_*).
int host_sprite_set_scale (uint32_t sprite, uint8_t scale)
 Integer upscale factor applied whenever the sprite is drawn.
int host_sprite_create_from_image (const uint8_t *data, uint32_t len, uint16_t target_w, uint16_t frame_h)
 Create a sprite straight from an encoded PNG/JPEG.
int host_sprite_set_frame (uint32_t sprite, uint16_t frame)
 Jump to a frame. A running playback continues from it.
int host_sprite_get_frame (uint32_t sprite, uint16_t *out)
 Read the currently displayed frame index.
int host_sprite_set_frame_durations (uint32_t sprite, const uint16_t *ms, uint16_t count)
 Optional per-frame durations in milliseconds.
int host_sprite_play (uint32_t sprite, uint8_t mode, uint16_t frame_ms, uint16_t repeat, uint32_t done_action_id)
 Start host-driven playback from frame 0.
int host_sprite_stop (uint32_t sprite)
 Stop playback, keeping the current frame on screen.
int host_sprite_destroy (uint32_t sprite)
 Destroy a sprite and reclaim its arena bytes. Recorded draw-sprite commands referencing it are skipped from then on.
int host_anim_start (const host_anim_t *cfg)
 Start (or queue, when start_after != 0) a tween on an element.
int host_anim_cancel (uint32_t handle)
 Cancel a tween and its chained successors; handle 0 cancels all of the canvas's tweens. Elements keep their current offset; no completion actions fire.
int host_anim_pause (uint32_t handle, bool paused)
 Pause (paused != 0) or resume a tween; delay time freezes too.
int host_anim_state (uint32_t handle)
 Query a tween's state.
int host_anim_active_count (void)
 Number of live tweens plus playing sprites (>= 0).
int host_anim_blink (uint32_t elem_id, uint16_t period_ms, uint16_t count, uint32_t done_action_id)
 Convenience: blink an element.
int host_view_canvas_add_slider (uint32_t widget_id, int32_t min, int32_t max, int32_t initial, int32_t step)
 Add an integer slider widget bound to widget_id.
int host_view_canvas_add_text (uint32_t widget_id, uint16_t max_len, const char *initial)
 Add a T9 text input widget bound to widget_id.
int host_view_canvas_add_button (uint32_t widget_id)
 Add a focusable button widget bound to widget_id.
int host_view_canvas_remove_widget (uint32_t widget_id)
 Remove a widget previously added to the canvas.
int host_view_canvas_set_value (uint32_t widget_id, int32_t value)
 Set the integer value of a slider widget.
int host_view_canvas_get_value (uint32_t widget_id, int32_t *out)
 Read the integer value of a slider widget.
int host_view_canvas_set_text (uint32_t widget_id, const char *text)
 Set the text of a text-input widget.
int host_view_canvas_get_text (uint32_t widget_id, char *out, size_t cap)
 Read the text of a text-input widget.
int host_view_canvas_set_focus (uint32_t widget_id)
 Move keyboard focus to the given widget.
int host_view_canvas_get_focus (uint32_t *out)
 Read the currently focused widget id, 0 if none.
int host_view_canvas_set_key_repeat (uint16_t initial_ms, uint16_t repeat_ms)
 Configure key auto-repeat timing for the canvas.
int host_view_canvas_set_long_press_action (uint32_t action_id)
 Set the action id fired on a canvas long-press.

Detailed Description

extern-C adapter for the plugin canvas view.

Push a CanvasView, then forward draw/widget/focus calls to it. All state lives in PluginUiState / CanvasView; this TU only marshals C arguments.

Definition in file host_api_canvas.cpp.