ISF15ACP4 Driver 1.0.0
API reference
Loading...
Searching...
No Matches
isf15acp4.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <cstddef>
9#include <cstdint>
10
12#include "isf15acp4_canvas.hpp"
15#include "isf15acp4_ssd1331.hpp"
16#include "isf15acp4_types.hpp"
17#include "isf15acp4_version.h"
18
19namespace isf15acp4 {
20
30template <typename SpiType>
32public:
36 SmartDisplay(SpiType* bus, const SmartDisplayConfig& config) noexcept;
37
43 SmartDisplay(SpiType* bus, ProductVariant variant = ProductVariant::Isf15acp4) noexcept;
44
58 bool Initialize(bool enable_vcc = true) noexcept;
59
61 [[nodiscard]] bool IsInitialized() const noexcept { return initialized_; }
62
64 bool Reset(bool enable_vcc = true) noexcept;
65
67 bool DisplayOn() noexcept;
68
70 bool DisplayOff() noexcept;
71
73 bool DisplayDim() noexcept;
74
79 bool SetMasterCurrent(uint8_t level) noexcept;
80
86 bool SetWindow(const Rect& rect) noexcept;
87
89 bool SetFullWindow() noexcept;
90
100 bool WritePixels(const uint8_t* data, std::size_t byte_len) noexcept;
101
112 bool WriteColors(const Color565* colors, std::size_t count) noexcept;
113
115 bool DrawCanvas(const Canvas& canvas) noexcept;
116
118 bool Present(const GraphicsContext& gfx) noexcept;
119
126 [[nodiscard]] GraphicsContext CreateGraphicsContext() noexcept;
127
133 [[nodiscard]] GraphicsContext CreateGraphicsContext() const noexcept;
134
136 void ConfigurePresenter(GraphicsContext& gfx) noexcept;
137
139 [[nodiscard]] GraphicsBackend GetGraphicsBackend() const noexcept { return config_.graphics; }
140
142 [[nodiscard]] const SmartDisplayConfig& GetConfig() const noexcept { return config_; }
143
145 bool DrawPixel(uint8_t x, uint8_t y, Color565 color) noexcept;
146
148 bool FillScreen(Color565 color) noexcept;
149
151 bool DrawLine(const Point& start, const Point& end, Color565 color) noexcept;
152
154 bool DrawRectangle(const Rect& rect, Color565 color, bool filled = false) noexcept;
155
157 bool ClearWindow(const Rect& rect) noexcept;
158
163 [[nodiscard]] bool IsPressed() const noexcept;
164
172 bool ConfigureScroll(uint8_t h_offset, uint8_t start_row, uint8_t scroll_rows,
173 uint8_t v_offset, uint8_t interval_code, bool activate) noexcept;
174
181 bool StopScroll() noexcept;
182
184 bool StopScroll(const GraphicsContext& gfx) noexcept;
185
186 [[nodiscard]] uint16_t GetErrorFlags() const noexcept { return error_flags_; }
187 [[nodiscard]] bool HasError(Error e) const noexcept {
188 return (error_flags_ & static_cast<uint16_t>(e)) != 0;
189 }
190 void ClearErrorFlags(uint16_t mask = 0xFFFF) noexcept { error_flags_ &= static_cast<uint16_t>(~mask); }
191 [[nodiscard]] Error GetLastError() const noexcept { return last_error_; }
192
193 [[nodiscard]] const DisplayGeometry& Geometry() const noexcept { return geometry_; }
194 [[nodiscard]] ProductVariant Variant() const noexcept { return variant_; }
195
196 static constexpr const char* GetDriverVersion() noexcept { return HF_ISF15ACP4_VERSION_STRING; }
197 static constexpr uint8_t GetDriverVersionMajor() noexcept { return HF_ISF15ACP4_VERSION_MAJOR; }
198 static constexpr uint8_t GetDriverVersionMinor() noexcept { return HF_ISF15ACP4_VERSION_MINOR; }
199 static constexpr uint8_t GetDriverVersionPatch() noexcept { return HF_ISF15ACP4_VERSION_PATCH; }
200
201private:
202 SpiType* bus_;
207 bool initialized_{false};
209 uint16_t error_flags_{0};
210
211 void setError(Error e) noexcept;
212 bool sendCommand(uint8_t cmd, const uint8_t* data, uint8_t len) noexcept;
213 bool sendCommandByte(uint8_t cmd, uint8_t data) noexcept;
214 bool sendCommandOnly(uint8_t cmd) noexcept;
215 void pulseReset() noexcept;
216 bool runInitTable() noexcept;
217 static void colorToSsd1331(Color565 color, uint8_t out[3]) noexcept;
218 [[nodiscard]] Rect toRam(const Rect& rect) const noexcept;
219};
220
221inline const char* GetDriverVersion() noexcept { return HF_ISF15ACP4_VERSION_STRING; }
222
223} // namespace isf15acp4
224
225#define ISF15ACP4_HEADER_INCLUDED
226#include "../src/isf15acp4.ipp"
227#undef ISF15ACP4_HEADER_INCLUDED
CPU-side RGB565 framebuffer with basic drawing operations.
Definition isf15acp4_canvas.hpp:22
Owns the active graphics backend selected at construction time.
Definition isf15acp4_graphics_context.hpp:42
High-level driver for NKK SSD1331-based SmartDisplay modules.
Definition isf15acp4.hpp:31
bool ClearWindow(const Rect &rect) noexcept
Clear a rectangular window via controller command 25H, in display coordinates.
Definition isf15acp4.ipp:386
void setError(Error e) noexcept
Definition isf15acp4.ipp:46
ProductVariant variant_
Definition isf15acp4.hpp:204
bool sendCommand(uint8_t cmd, const uint8_t *data, uint8_t len) noexcept
Definition isf15acp4.ipp:62
bool StopScroll() noexcept
Stop hardware scrolling (2EH).
Definition isf15acp4.ipp:418
bool DrawLine(const Point &start, const Point &end, Color565 color) noexcept
Draw a hardware-accelerated line (command 21H), in display coordinates.
Definition isf15acp4.ipp:348
GraphicsBackend GetGraphicsBackend() const noexcept
Active graphics backend selected at construction.
Definition isf15acp4.hpp:139
Error GetLastError() const noexcept
Definition isf15acp4.hpp:191
static constexpr const char * GetDriverVersion() noexcept
Definition isf15acp4.hpp:196
bool IsPressed() const noexcept
Read momentary switch state when wired to SpiInterface::CtrlPin::Switch.
Definition isf15acp4.ipp:393
bool runInitTable() noexcept
Definition isf15acp4.ipp:97
void ConfigurePresenter(GraphicsContext &gfx) noexcept
Register presenter hooks for HardwareDirect backend (bind this display to gfx).
Definition isf15acp4.ipp:305
bool DrawRectangle(const Rect &rect, Color565 color, bool filled=false) noexcept
Draw a hardware rectangle outline (command 22H), in display coordinates.
Definition isf15acp4.ipp:359
Rect toRam(const Rect &rect) const noexcept
Definition isf15acp4.ipp:205
bool DisplayOn() noexcept
Turn display on (normal mode, command AFH).
Definition isf15acp4.ipp:151
bool SetWindow(const Rect &rect) noexcept
Configure the active GRAM download window.
Definition isf15acp4.ipp:175
bool IsInitialized() const noexcept
Returns true after successful Initialize().
Definition isf15acp4.hpp:61
bool DisplayDim() noexcept
Enter dim mode (command ACH).
Definition isf15acp4.ipp:161
DisplayGeometry geometry_
Definition isf15acp4.hpp:205
bool DisplayOff() noexcept
Turn display off / sleep (command AEH).
Definition isf15acp4.ipp:156
const DisplayGeometry & Geometry() const noexcept
Definition isf15acp4.hpp:193
bool initialized_
Definition isf15acp4.hpp:207
bool SetMasterCurrent(uint8_t level) noexcept
Set master current while display is off (command 87H).
Definition isf15acp4.ipp:166
bool HasError(Error e) const noexcept
Definition isf15acp4.hpp:187
static constexpr uint8_t GetDriverVersionMajor() noexcept
Definition isf15acp4.hpp:197
bool DrawCanvas(const Canvas &canvas) noexcept
Upload an entire canvas framebuffer.
Definition isf15acp4.ipp:279
void pulseReset() noexcept
Definition isf15acp4.ipp:52
ProductVariant Variant() const noexcept
Definition isf15acp4.hpp:194
bool DrawPixel(uint8_t x, uint8_t y, Color565 color) noexcept
Draw one RGB565 pixel at (x,y).
Definition isf15acp4.ipp:325
bool ConfigureScroll(uint8_t h_offset, uint8_t start_row, uint8_t scroll_rows, uint8_t v_offset, uint8_t interval_code, bool activate) noexcept
Set up hardware scrolling and optionally start it.
Definition isf15acp4.ipp:398
bool FillScreen(Color565 color) noexcept
Fill the panel with a solid color.
Definition isf15acp4.ipp:333
bool sendCommandByte(uint8_t cmd, uint8_t data) noexcept
Definition isf15acp4.ipp:87
static constexpr uint8_t GetDriverVersionMinor() noexcept
Definition isf15acp4.hpp:198
bool sendCommandOnly(uint8_t cmd) noexcept
Definition isf15acp4.ipp:92
static constexpr uint8_t GetDriverVersionPatch() noexcept
Definition isf15acp4.hpp:199
SmartDisplayConfig config_
Definition isf15acp4.hpp:203
bool WritePixels(const uint8_t *data, std::size_t byte_len) noexcept
Stream raw pixel bytes to the controller GRAM, unchanged.
Definition isf15acp4.ipp:211
uint16_t GetErrorFlags() const noexcept
Definition isf15acp4.hpp:186
bool Initialize(bool enable_vcc=true) noexcept
Perform power-up, reset, and SSD1331 initialization.
Definition isf15acp4.ipp:110
bool Present(const GraphicsContext &gfx) noexcept
Present any graphics backend to the panel.
Definition isf15acp4.ipp:317
Rect window_
Definition isf15acp4.hpp:206
void ClearErrorFlags(uint16_t mask=0xFFFF) noexcept
Definition isf15acp4.hpp:190
SpiType * bus_
Definition isf15acp4.hpp:202
static void colorToSsd1331(Color565 color, uint8_t out[3]) noexcept
Definition isf15acp4.ipp:340
bool SetFullWindow() noexcept
Configure full-panel memory window for the active variant.
Definition isf15acp4.ipp:200
const SmartDisplayConfig & GetConfig() const noexcept
Active driver configuration.
Definition isf15acp4.hpp:142
GraphicsContext CreateGraphicsContext() noexcept
Create a graphics context matching this display configuration.
Definition isf15acp4.ipp:296
uint16_t error_flags_
Definition isf15acp4.hpp:209
Error last_error_
Definition isf15acp4.hpp:208
bool WriteColors(const Color565 *colors, std::size_t count) noexcept
Stream Color565 pixels to the controller GRAM in the SSD1331 65k-colour byte order.
Definition isf15acp4.ipp:237
High-level button + display interaction patterns for SmartDisplay.
Software framebuffer and 2D drawing primitives for SmartDisplay OLEDs.
Runtime-selectable graphics backend for SmartDisplay applications.
CRTP-based SPI and GPIO interface for NKK SmartDisplay OLED drivers.
SSD1331 command constants and initialization tables for NKK SmartDisplay.
Shared types, constants, and color utilities for NKK SmartDisplay OLED drivers.
Definition isf15acp4.hpp:19
Error
Driver error flags (bitmask).
Definition isf15acp4_types.hpp:28
ProductVariant
Supported NKK SmartDisplay OLED product variants.
Definition isf15acp4_types.hpp:19
@ Isf15acp4
Frameless OLED pushbutton, 96x64 (ISF15ACP4)
uint16_t Color565
16-bit RGB565 color value (R5G6B5).
Definition isf15acp4_types.hpp:50
GraphicsBackend
Selectable graphics engine used by SmartDisplay and UI helpers.
Definition isf15acp4_graphics_surface.hpp:22
@ Reset
RES# reset input: Active = held in reset (pin low), Inactive = running (pin high)
Compile-time display geometry for a product variant.
Definition isf15acp4_types.hpp:53
2D point in display coordinates.
Definition isf15acp4_types.hpp:90
Axis-aligned rectangle in display coordinates (inclusive bounds).
Definition isf15acp4_types.hpp:96
Configuration for SmartDisplay construction.
Definition isf15acp4_button_ui.hpp:17
GraphicsBackend graphics
Definition isf15acp4_button_ui.hpp:19