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

Full-screen viewer for a decoded PNG/JPEG, dithered to the e-paper. More...

#include <ImageView.h>

Inheritance diagram for cdc::ui::ImageView:
cdc::ui::ViewBase cdc::ui::IView

Public Member Functions

void init (const char *title, const uint8_t *data, size_t len)
 Decodes and lays out an image.
void render (bool partial) override
InputResult onKey (char key) override
void onExit () override
const char * getName () const override
const char * getFooterHint () const override
hal::RefreshMode preferredEnterRefresh () const override
 Dithered images ghost badly over prior content; demand a clean base.
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
virtual bool prefersLightRefresh () const
virtual InputResult onLongPress (char key)
virtual void onTick (uint32_t nowMs)

Static Public Attributes

static constexpr uint32_t MAX_PIXELS = 1048576
 ~1 megapixel cap.

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

Full-screen viewer for a decoded PNG/JPEG, dithered to the e-paper.

Decodes on init into two 1-bit bitmaps held in PSRAM: one scaled to fit the screen (default view) and one at native resolution for an actual-size pan mode. Decode failures show a readable message instead of crashing.

Keys: 5 = toggle fit/actual, 2/4/6/8 = pan (actual mode), N = back.

Definition at line 21 of file ImageView.h.

Member Function Documentation

◆ getFooterHint()

const char * cdc::ui::ImageView::getFooterHint ( ) const
overridevirtual

Get footer hint text (e.g., "[Y] OK [N] Back") Return nullptr for no footer

Reimplemented from cdc::ui::IView.

Definition at line 126 of file ImageView.cpp.

References cdc::ui::tr().

Referenced by render().

◆ getName()

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

Get view name for debugging

Implements cdc::ui::IView.

Definition at line 36 of file ImageView.h.

◆ init()

void cdc::ui::ImageView::init ( const char * title,
const uint8_t * data,
size_t len )

Decodes and lays out an image.

Parameters
titleHeader/footer title (CP437 file name).
dataEncoded image bytes (PNG or JPEG).
lenByte length.

Definition at line 31 of file ImageView.cpp.

References cdc::ui::ViewBase::dirty_, cdc::ui::display, FOOTER_HEIGHT, cdc::hal::getDisplayInstance(), LOG_D, MAX_PIXELS, cdc::core::psramAlloc(), and cdc::ui::TAG.

◆ onExit()

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

Called when view is being removed from stack

Implements cdc::ui::IView.

Definition at line 105 of file ImageView.cpp.

◆ onKey()

InputResult cdc::ui::ImageView::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 130 of file ImageView.cpp.

References cdc::ui::CONSUMED, cdc::ui::ViewBase::dirty_, cdc::ui::IGNORED, cdc::ui::KEY_DOWN, cdc::ui::KEY_NO, cdc::ui::KEY_SELECT, cdc::ui::KEY_UP, and cdc::ui::REQUEST_POP.

◆ preferredEnterRefresh()

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

Dithered images ghost badly over prior content; demand a clean base.

Reimplemented from cdc::ui::IView.

Definition at line 40 of file ImageView.h.

References cdc::hal::FULL.

◆ render()

void cdc::ui::ImageView::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 158 of file ImageView.cpp.

References cdc::ui::ViewBase::dirty_, cdc::ui::display, cdc::ui::render::drawFooterBar(), FOOTER_HEIGHT, cdc::hal::getDisplayInstance(), getFooterHint(), cdc::ui::render::printText(), and cdc::ui::tr().

Member Data Documentation

◆ MAX_PIXELS

uint32_t cdc::ui::ImageView::MAX_PIXELS = 1048576
staticconstexpr

~1 megapixel cap.

Definition at line 23 of file ImageView.h.

Referenced by init().


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