ISF15ACP4 Driver 1.0.0
API reference
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
isf15acp4::SmartDisplay< SpiType > Class Template Reference

High-level driver for NKK SSD1331-based SmartDisplay modules. More...

#include <isf15acp4.hpp>

Collaboration diagram for isf15acp4::SmartDisplay< SpiType >:
[legend]

Public Member Functions

 SmartDisplay (SpiType *bus, const SmartDisplayConfig &config) noexcept
 Construct with explicit configuration (variant + graphics backend).
 
 SmartDisplay (SpiType *bus, ProductVariant variant=ProductVariant::Isf15acp4) noexcept
 Construct a SmartDisplay driver (defaults to ISF15ACP4 + BuiltinCanvas).
 
bool Initialize (bool enable_vcc=true) noexcept
 Perform power-up, reset, and SSD1331 initialization.
 
bool IsInitialized () const noexcept
 Returns true after successful Initialize().
 
bool Reset (bool enable_vcc=true) noexcept
 Hardware reset pulse and full re-initialization.
 
bool DisplayOn () noexcept
 Turn display on (normal mode, command AFH).
 
bool DisplayOff () noexcept
 Turn display off / sleep (command AEH).
 
bool DisplayDim () noexcept
 Enter dim mode (command ACH).
 
bool SetMasterCurrent (uint8_t level) noexcept
 Set master current while display is off (command 87H).
 
bool SetWindow (const Rect &rect) noexcept
 Configure the active GRAM download window.
 
bool SetFullWindow () noexcept
 Configure full-panel memory window for the active variant.
 
bool WritePixels (const uint8_t *data, std::size_t byte_len) noexcept
 Stream raw pixel bytes to the controller GRAM, unchanged.
 
bool WriteColors (const Color565 *colors, std::size_t count) noexcept
 Stream Color565 pixels to the controller GRAM in the SSD1331 65k-colour byte order.
 
bool DrawCanvas (const Canvas &canvas) noexcept
 Upload an entire canvas framebuffer.
 
bool Present (const GraphicsContext &gfx) noexcept
 Present any graphics backend to the panel.
 
GraphicsContext CreateGraphicsContext () noexcept
 Create a graphics context matching this display configuration.
 
GraphicsContext CreateGraphicsContext () const noexcept
 Create an unbound graphics context matching this display configuration.
 
void ConfigurePresenter (GraphicsContext &gfx) noexcept
 Register presenter hooks for HardwareDirect backend (bind this display to gfx).
 
GraphicsBackend GetGraphicsBackend () const noexcept
 Active graphics backend selected at construction.
 
const SmartDisplayConfig & GetConfig () const noexcept
 Active driver configuration.
 
bool DrawPixel (uint8_t x, uint8_t y, Color565 color) noexcept
 Draw one RGB565 pixel at (x,y).
 
bool FillScreen (Color565 color) noexcept
 Fill the panel with a solid color.
 
bool DrawLine (const Point &start, const Point &end, Color565 color) noexcept
 Draw a hardware-accelerated line (command 21H), in display coordinates.
 
bool DrawRectangle (const Rect &rect, Color565 color, bool filled=false) noexcept
 Draw a hardware rectangle outline (command 22H), in display coordinates.
 
bool ClearWindow (const Rect &rect) noexcept
 Clear a rectangular window via controller command 25H, in display coordinates.
 
bool IsPressed () const noexcept
 Read momentary switch state when wired to SpiInterface::CtrlPin::Switch.
 
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.
 
bool StopScroll () noexcept
 Stop hardware scrolling (2EH).
 
bool StopScroll (const GraphicsContext &gfx) noexcept
 Stop hardware scrolling (2EH), then rewrite the display RAM with Present(gfx).
 
uint16_t GetErrorFlags () const noexcept
 
bool HasError (Error e) const noexcept
 
void ClearErrorFlags (uint16_t mask=0xFFFF) noexcept
 
Error GetLastError () const noexcept
 
const DisplayGeometry & Geometry () const noexcept
 
ProductVariant Variant () const noexcept
 

Static Public Member Functions

static constexpr const char * GetDriverVersion () noexcept
 
static constexpr uint8_t GetDriverVersionMajor () noexcept
 
static constexpr uint8_t GetDriverVersionMinor () noexcept
 
static constexpr uint8_t GetDriverVersionPatch () noexcept
 

Private Member Functions

void setError (Error e) noexcept
 
bool sendCommand (uint8_t cmd, const uint8_t *data, uint8_t len) noexcept
 
bool sendCommandByte (uint8_t cmd, uint8_t data) noexcept
 
bool sendCommandOnly (uint8_t cmd) noexcept
 
void pulseReset () noexcept
 
bool runInitTable () noexcept
 
Rect toRam (const Rect &rect) const noexcept
 

Static Private Member Functions

static void colorToSsd1331 (Color565 color, uint8_t out[3]) noexcept
 

Private Attributes

SpiType * bus_
 
SmartDisplayConfig config_
 
ProductVariant variant_
 
DisplayGeometry geometry_
 
Rect window_ {}
 
bool initialized_ {false}
 
Error last_error_ {Error::None}
 
uint16_t error_flags_ {0}
 

Detailed Description

template<typename SpiType>
class isf15acp4::SmartDisplay< SpiType >

High-level driver for NKK SSD1331-based SmartDisplay modules.

Supports ISF15ACP4 (96x64 frameless pushbutton), ISC15ANP4 (64x48), and ISC01P (52x36 display). Communication uses SPI with separate D/C and SS lines.

Template Parameters
SpiTypePlatform adapter implementing SpiInterface CRTP contract.

Constructor & Destructor Documentation

◆ SmartDisplay() [1/2]

template<typename SpiType >
isf15acp4::SmartDisplay< SpiType >::SmartDisplay ( SpiType *  bus,
const SmartDisplayConfig &  config 
)
noexcept

Construct with explicit configuration (variant + graphics backend).

◆ SmartDisplay() [2/2]

template<typename SpiType >
isf15acp4::SmartDisplay< SpiType >::SmartDisplay ( SpiType *  bus,
ProductVariant  variant = ProductVariant::Isf15acp4 
)
noexcept

Construct a SmartDisplay driver (defaults to ISF15ACP4 + BuiltinCanvas).

Parameters
busPointer to platform SPI/GPIO adapter.
variantProduct variant initialization table selector.

Member Function Documentation

◆ ClearErrorFlags()

template<typename SpiType >
void isf15acp4::SmartDisplay< SpiType >::ClearErrorFlags ( uint16_t  mask = 0xFFFF)
inlinenoexcept

◆ ClearWindow()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::ClearWindow ( const Rect &  rect)
noexcept

Clear a rectangular window via controller command 25H, in display coordinates.

◆ colorToSsd1331()

template<typename SpiType >
void isf15acp4::SmartDisplay< SpiType >::colorToSsd1331 ( Color565  color,
uint8_t  out[3] 
)
staticprivatenoexcept

◆ ConfigurePresenter()

template<typename SpiType >
void isf15acp4::SmartDisplay< SpiType >::ConfigurePresenter ( GraphicsContext &  gfx)
noexcept

Register presenter hooks for HardwareDirect backend (bind this display to gfx).

◆ ConfigureScroll()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::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.

Always stops scrolling first (2EH), then sends the setup (27H) and, when activate is true, starts it (2FH): the SSD1331 must not get new scroll parameters while scrolling runs (rev 1.2 Table 10, 27H note 2). With activate false the scroll stays stopped; rewrite the display RAM afterwards (see StopScroll()).

◆ CreateGraphicsContext() [1/2]

template<typename SpiType >
GraphicsContext isf15acp4::SmartDisplay< SpiType >::CreateGraphicsContext ( ) const
noexcept

Create an unbound graphics context matching this display configuration.

A const display cannot bind itself: for HardwareDirect, call ConfigurePresenter() on the result.

◆ CreateGraphicsContext() [2/2]

template<typename SpiType >
GraphicsContext isf15acp4::SmartDisplay< SpiType >::CreateGraphicsContext ( )
noexcept

Create a graphics context matching this display configuration.

With GraphicsBackend::HardwareDirect the returned context is already bound to this display (ConfigurePresenter()), so its shapes go to the panel at once. The display must outlive the context.

◆ DisplayDim()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::DisplayDim ( )
noexcept

Enter dim mode (command ACH).

◆ DisplayOff()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::DisplayOff ( )
noexcept

Turn display off / sleep (command AEH).

◆ DisplayOn()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::DisplayOn ( )
noexcept

Turn display on (normal mode, command AFH).

◆ DrawCanvas()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::DrawCanvas ( const Canvas &  canvas)
noexcept

Upload an entire canvas framebuffer.

◆ DrawLine()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::DrawLine ( const Point &  start,
const Point &  end,
Color565  color 
)
noexcept

Draw a hardware-accelerated line (command 21H), in display coordinates.

◆ DrawPixel()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::DrawPixel ( uint8_t  x,
uint8_t  y,
Color565  color 
)
noexcept

Draw one RGB565 pixel at (x,y).

◆ DrawRectangle()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::DrawRectangle ( const Rect &  rect,
Color565  color,
bool  filled = false 
)
noexcept

Draw a hardware rectangle outline (command 22H), in display coordinates.

◆ FillScreen()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::FillScreen ( Color565  color)
noexcept

Fill the panel with a solid color.

◆ Geometry()

template<typename SpiType >
const DisplayGeometry & isf15acp4::SmartDisplay< SpiType >::Geometry ( ) const
inlinenoexcept

◆ GetConfig()

template<typename SpiType >
const SmartDisplayConfig & isf15acp4::SmartDisplay< SpiType >::GetConfig ( ) const
inlinenoexcept

Active driver configuration.

◆ GetDriverVersion()

template<typename SpiType >
static constexpr const char * isf15acp4::SmartDisplay< SpiType >::GetDriverVersion ( )
inlinestaticconstexprnoexcept

◆ GetDriverVersionMajor()

template<typename SpiType >
static constexpr uint8_t isf15acp4::SmartDisplay< SpiType >::GetDriverVersionMajor ( )
inlinestaticconstexprnoexcept

◆ GetDriverVersionMinor()

template<typename SpiType >
static constexpr uint8_t isf15acp4::SmartDisplay< SpiType >::GetDriverVersionMinor ( )
inlinestaticconstexprnoexcept

◆ GetDriverVersionPatch()

template<typename SpiType >
static constexpr uint8_t isf15acp4::SmartDisplay< SpiType >::GetDriverVersionPatch ( )
inlinestaticconstexprnoexcept

◆ GetErrorFlags()

template<typename SpiType >
uint16_t isf15acp4::SmartDisplay< SpiType >::GetErrorFlags ( ) const
inlinenoexcept

◆ GetGraphicsBackend()

template<typename SpiType >
GraphicsBackend isf15acp4::SmartDisplay< SpiType >::GetGraphicsBackend ( ) const
inlinenoexcept

Active graphics backend selected at construction.

◆ GetLastError()

template<typename SpiType >
Error isf15acp4::SmartDisplay< SpiType >::GetLastError ( ) const
inlinenoexcept

◆ HasError()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::HasError ( Error  e) const
inlinenoexcept

◆ Initialize()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::Initialize ( bool  enable_vcc = true)
noexcept

Perform power-up, reset, and SSD1331 initialization.

Sequence:

  1. Ensure SPI/GPIO ready
  2. Assert Reset (RES# low) >= 3 us, release it (high), wait for reset completion
  3. Optionally enable VCC rail via VccEnable pin
  4. Transmit variant-specific initialization table
  5. Configure default memory window
Parameters
enable_vccWhen true, asserts VccEnable after reset.
Returns
true on success.

◆ IsInitialized()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::IsInitialized ( ) const
inlinenoexcept

Returns true after successful Initialize().

◆ IsPressed()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::IsPressed ( ) const
noexcept

Read momentary switch state when wired to SpiInterface::CtrlPin::Switch.

Returns
true when the switch is pressed (active).

◆ Present()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::Present ( const GraphicsContext &  gfx)
noexcept

Present any graphics backend to the panel.

◆ pulseReset()

template<typename SpiType >
void isf15acp4::SmartDisplay< SpiType >::pulseReset ( )
privatenoexcept

◆ Reset()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::Reset ( bool  enable_vcc = true)
noexcept

Hardware reset pulse and full re-initialization.

◆ runInitTable()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::runInitTable ( )
privatenoexcept

◆ sendCommand()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::sendCommand ( uint8_t  cmd,
const uint8_t *  data,
uint8_t  len 
)
privatenoexcept

◆ sendCommandByte()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::sendCommandByte ( uint8_t  cmd,
uint8_t  data 
)
privatenoexcept

◆ sendCommandOnly()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::sendCommandOnly ( uint8_t  cmd)
privatenoexcept

◆ setError()

template<typename SpiType >
void isf15acp4::SmartDisplay< SpiType >::setError ( Error  e)
privatenoexcept

◆ SetFullWindow()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::SetFullWindow ( )
noexcept

Configure full-panel memory window for the active variant.

◆ SetMasterCurrent()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::SetMasterCurrent ( uint8_t  level)
noexcept

Set master current while display is off (command 87H).

Parameters
level0x00 (min) to 0x0F (max brightness).

◆ SetWindow()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::SetWindow ( const Rect &  rect)
noexcept

Configure the active GRAM download window.

Parameters
rectInclusive pixel rectangle in display coordinates (0..width-1, 0..height-1). The driver adds the variant's RAM column/row offset (DisplayGeometry::column_start / row_start).

◆ StopScroll() [1/2]

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::StopScroll ( )
noexcept

Stop hardware scrolling (2EH).

The display RAM stays shifted: the SSD1331 needs it rewritten after 2EH (rev 1.2 Table 10). Prefer StopScroll(const GraphicsContext&), or redraw yourself.

◆ StopScroll() [2/2]

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::StopScroll ( const GraphicsContext &  gfx)
noexcept

Stop hardware scrolling (2EH), then rewrite the display RAM with Present(gfx).

◆ toRam()

template<typename SpiType >
Rect isf15acp4::SmartDisplay< SpiType >::toRam ( const Rect &  rect) const
privatenoexcept

◆ Variant()

template<typename SpiType >
ProductVariant isf15acp4::SmartDisplay< SpiType >::Variant ( ) const
inlinenoexcept

◆ WriteColors()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::WriteColors ( const Color565 *  colors,
std::size_t  count 
)
noexcept

Stream Color565 pixels to the controller GRAM in the SSD1331 65k-colour byte order.

Each pixel is converted to the panel's colour order (ssd1331::ToPanelPixel(): blue in the high bits) and goes out high byte first (SSD1331 rev 1.2 section 7.5.2, Table 9), whatever the CPU's byte order, in one data transaction. Use this instead of WritePixels() for Color565 buffers.

Parameters
colorsPixel buffer.
countNumber of pixels (not bytes).

◆ WritePixels()

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::WritePixels ( const uint8_t *  data,
std::size_t  byte_len 
)
noexcept

Stream raw pixel bytes to the controller GRAM, unchanged.

The bytes must already be in the panel's 65k-colour format: two bytes per pixel, high byte first, blue in bits 15..11 and red in bits 4..0 (see ssd1331::ToPanelPixel()). For Color565 buffers use WriteColors().

Parameters
dataPixel buffer (two bytes per pixel).
byte_lenNumber of bytes (must be even).

Member Data Documentation

◆ bus_

template<typename SpiType >
SpiType* isf15acp4::SmartDisplay< SpiType >::bus_
private

◆ config_

template<typename SpiType >
SmartDisplayConfig isf15acp4::SmartDisplay< SpiType >::config_
private

◆ error_flags_

template<typename SpiType >
uint16_t isf15acp4::SmartDisplay< SpiType >::error_flags_ {0}
private

◆ geometry_

template<typename SpiType >
DisplayGeometry isf15acp4::SmartDisplay< SpiType >::geometry_
private

◆ initialized_

template<typename SpiType >
bool isf15acp4::SmartDisplay< SpiType >::initialized_ {false}
private

◆ last_error_

template<typename SpiType >
Error isf15acp4::SmartDisplay< SpiType >::last_error_ {Error::None}
private

◆ variant_

template<typename SpiType >
ProductVariant isf15acp4::SmartDisplay< SpiType >::variant_
private

◆ window_

template<typename SpiType >
Rect isf15acp4::SmartDisplay< SpiType >::window_ {}
private

The documentation for this class was generated from the following files: