CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
MonoSurface.h
Go to the documentation of this file.
1
10
11#pragma once
12
13#include <cstddef>
14#include <cstdint>
15
16#include <Adafruit_GFX.h>
17
18namespace cdc::ui {
19
20class MonoSurface : public Adafruit_GFX {
21public:
27 MonoSurface(uint16_t w, uint16_t h);
28 ~MonoSurface() override;
29
30 MonoSurface(const MonoSurface&) = delete;
32
34 [[nodiscard]] bool ok() const { return bits_ != nullptr; }
35
36 void drawPixel(int16_t x, int16_t y, uint16_t color) override;
37
39 void clear();
40
42 [[nodiscard]] const uint8_t* buffer() const { return bits_; }
43
45 [[nodiscard]] uint16_t strideBytes() const { return stride_; }
46
48 [[nodiscard]] size_t byteSize() const { return static_cast<size_t>(stride_) * HEIGHT; }
49
50private:
51 uint8_t* bits_ = nullptr;
52 uint16_t stride_ = 0;
53};
54
55} // namespace cdc::ui
uint16_t strideBytes() const
Bytes per packed row, (width + 7) / 8.
Definition MonoSurface.h:45
void clear()
Clears the surface to white.
MonoSurface & operator=(const MonoSurface &)=delete
MonoSurface(uint16_t w, uint16_t h)
Allocates a w x h 1-bpp surface in PSRAM, cleared to white.
const uint8_t * buffer() const
Packed pixel rows, strideBytes() * height() bytes.
Definition MonoSurface.h:42
size_t byteSize() const
Total packed byte size.
Definition MonoSurface.h:48
bool ok() const
True when the buffer allocation succeeded.
Definition MonoSurface.h:34
MonoSurface(const MonoSurface &)=delete
void drawPixel(int16_t x, int16_t y, uint16_t color) override
Centralized key-code constants for cdc_views.
Definition IModule.h:8