|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Full-screen viewer for a decoded PNG/JPEG, dithered to the e-paper. More...
#include <ImageView.h>
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 |
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.
|
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().
|
inlineoverridevirtual |
| void cdc::ui::ImageView::init | ( | const char * | title, |
| const uint8_t * | data, | ||
| size_t | len ) |
Decodes and lays out an image.
| title | Header/footer title (CP437 file name). |
| data | Encoded image bytes (PNG or JPEG). |
| len | Byte 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.
|
overridevirtual |
Called when view is being removed from stack
Implements cdc::ui::IView.
Definition at line 105 of file ImageView.cpp.
|
overridevirtual |
Handle key press
| key | Key character ('0'-'9', 'Y', 'N', etc.) |
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.
|
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.
|
overridevirtual |
Render view content to display buffer
| partial | True 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().
|
staticconstexpr |