CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
ImageView.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5
6#include "cdc_core/Raii.h"
7#include "cdc_image/MonoBitmap.h"
8#include "cdc_ui/IView.h"
9
10namespace cdc::ui {
11
21class ImageView : public ViewBase {
22public:
23 static constexpr uint32_t MAX_PIXELS = 1048576;
24
31 void init(const char* title, const uint8_t* data, size_t len);
32
33 void render(bool partial) override;
34 InputResult onKey(char key) override;
35 void onExit() override;
36 const char* getName() const override { return "ImageView"; }
37 const char* getFooterHint() const override;
38
41
42private:
43 enum class Mode : uint8_t { Fit, Actual };
44 static constexpr uint16_t MAX_TITLE_LEN = 64;
45 static constexpr int PAN_STEP = 24;
46
47 char titleBuf_[MAX_TITLE_LEN];
48 const char* errorKey_ = nullptr;
51 cdc::image::MonoBitmap fitBmp_;
52 cdc::image::MonoBitmap fullBmp_;
53 Mode mode_ = Mode::Fit;
54 int panX_ = 0;
55 int panY_ = 0;
56
57 void clampPan();
58};
59
67ImageView* showImage(const char* title, const uint8_t* data, size_t len);
68
69} // namespace cdc::ui
Shared RAII wrappers for firmware resources.
Full-screen viewer for a decoded PNG/JPEG, dithered to the e-paper.
Definition ImageView.h:21
static constexpr uint32_t MAX_PIXELS
~1 megapixel cap.
Definition ImageView.h:23
void init(const char *title, const uint8_t *data, size_t len)
Decodes and lays out an image.
Definition ImageView.cpp:31
const char * getFooterHint() const override
void onExit() override
const char * getName() const override
Definition ImageView.h:36
hal::RefreshMode preferredEnterRefresh() const override
Dithered images ghost badly over prior content; demand a clean base.
Definition ImageView.h:40
InputResult onKey(char key) override
std::unique_ptr< T[], CapsFreeDeleter > PsramUniquePtr
Definition Raii.h:44
Centralized key-code constants for cdc_views.
Definition IModule.h:8
InputResult
Definition IView.h:11
ImageView * showImage(const char *title, const uint8_t *data, size_t len)
Decodes and shows an image on the view stack.