CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
QRCodeView.h
Go to the documentation of this file.
1#pragma once
2
3#include "cdc_ui/IView.h"
4#include <cstdint>
5
6namespace cdc::ui {
7
21class QRCodeView : public ViewBase {
22public:
29 void init(const char* data, const char* title = nullptr, const char* subtitle = nullptr);
30
34 void setHint(const char* hint) { customHint_ = hint; }
35
36 // IView implementation
37 void render(bool partial) override;
38 InputResult onKey(char key) override;
39 const char* getName() const override { return "QRCodeView"; }
40 const char* getFooterHint() const override;
41
42private:
43 const char* data_ = nullptr;
44 const char* title_ = nullptr;
45 const char* subtitle_ = nullptr;
46 const char* customHint_ = nullptr;
47
48 // QR code sizing
49 int qrModuleCount_ = 0;
50 int qrScale_ = 1;
51 int qrOffsetX_ = 0;
52 int qrOffsetY_ = 0;
53
54 void calculateLayout();
55 void renderQrCode();
56 void renderText();
57};
58
59// ============================================================================
60// Convenience Functions
61// ============================================================================
62
75QRCodeView* showQRCode(const char* data, const char* title = nullptr,
76 const char* subtitle = nullptr, const char* hint = nullptr);
77
78} // namespace cdc::ui
const char * getFooterHint() const override
Returns footer hint text.
void setHint(const char *hint)
Definition QRCodeView.h:34
const char * getName() const override
Definition QRCodeView.h:39
InputResult onKey(char key) override
Handles key input by closing the QR view.
void init(const char *data, const char *title=nullptr, const char *subtitle=nullptr)
Initializes QR code content and layout state.
const char * title_
Definition IView.h:202
Centralized key-code constants for cdc_views.
Definition IModule.h:8
InputResult
Definition IView.h:10
QRCodeView * showQRCode(const char *data, const char *title=nullptr, const char *subtitle=nullptr, const char *hint=nullptr)
Shows a shared QR code view instance.