Kleidos API Search

In development. It changes without notice.

Topic

Display Panel Drivers

The controllers of the panels: ST7789 and ILI9342 for color, SSD1681 and JD79653A for e-paper.

Controller Boards
St7789 LILYGO T-Deck (320×240), M5Cardputer ADV (240×135), M5StickC Plus 1.1, M5StickC Plus2, M5StickC Plus SE and M5StickS3 (135×240)
Ili9342 Core2 v1.3 and CoreS3 SE (320×240). A second command set serves the later controller of the same module.
Gdew0154D67 (SSD1681) CoreInk (200×200)
Gdew0154M09 (JD79653A) The panel of older CoreInk units. No board of this firmware declares it.

A controller here is a description: what to send at the start, how a rotation is set, where the panel starts in the controller's memory. The panel drivers of Display send it.

See also
Display, Touch Controller Drivers

Files

file src/drivers/display/display_controller_factory.cpp
Maps a ControllerType to its stateless singleton controller, and the contract's shared default read rule.
file src/drivers/display/epaper_controller_factory.cpp
Maps an EpaperController to its stateless singleton controller.
file src/drivers/display/gdew0154d67.cpp
GDEW0154D67 (SSD1681) command tables.
file src/drivers/display/gdew0154d67.h
GoodDisplay GDEW0154D67 (SSD1681) e-paper controller description.
file src/drivers/display/gdew0154m09.cpp
GDEW0154M09 (JD79653A) command tables.
file src/drivers/display/gdew0154m09.h
GoodDisplay GDEW0154M09 (JD79653A) e-paper controller description.
file src/drivers/display/gram_window.h
Where a panel's window sits in its controller's memory, and which memory cell a logical pixel lands on.
file src/drivers/display/i_display_controller.h
Data-driven, stateless contract for a TFT panel controller.
file src/drivers/display/i_epaper_controller.h
Data-driven, stateless contract for an e-paper controller.
file src/drivers/display/ili9342.h
Ilitek ILI9342C and ILI9342E display-controller descriptions.
file src/drivers/display/ili9342_probe.h
Tells an ILI9342C from an ILI9342E on the panel's own bus.
file src/drivers/display/ssd1681_grayscale.h
Pure 6-tone grayscale mapping for the SSD1681 two-pass stacked scheme.
file src/drivers/display/ssd1681_lut.h
Pure constexpr builders for SSD1681 waveform LUTs (register 0x32).
file src/drivers/display/st7789.h
Sitronix ST7789 display-controller description.

Classes

class kleidos::drivers::display::Gdew0154D67
GDEW0154D67 1.54" 200x200 black/white e-paper controller (SSD1681). More about kleidos::drivers::display::Gdew0154D67
class kleidos::drivers::display::Gdew0154M09
GDEW0154M09 1.54" 200x200 black/white e-paper controller (JD79653A). More about kleidos::drivers::display::Gdew0154M09
struct kleidos::drivers::display::PanelPlacement
The part of the controller's memory a panel shows, at MADCTL 0. More about kleidos::drivers::display::PanelPlacement
struct kleidos::drivers::display::WindowOrigin
Address-window origin: what the panel driver adds to logical X and Y before it sends CASET and RASET. More about kleidos::drivers::display::WindowOrigin
struct kleidos::drivers::display::MemoryAddress
A cell of the controller's memory, in its own orientation (MADCTL 0). More about kleidos::drivers::display::MemoryAddress
struct kleidos::drivers::display::LogicalPixel
A logical pixel (what the drawing code calls x and y). More about kleidos::drivers::display::LogicalPixel
struct kleidos::drivers::display::ReadPlan
One register's read framing. More about kleidos::drivers::display::ReadPlan
struct kleidos::drivers::display::GramSize
A controller's frame memory (GRAM) size, at MADCTL 0 (no mirror, no row/column exchange): column addresses run 0..columns-1, row addresses 0..rows-1. More about kleidos::drivers::display::GramSize
struct kleidos::drivers::display::MemoryReadPlan
How the controller's memory reads back over the serial interface (RAMRD, 2Eh). More about kleidos::drivers::display::MemoryReadPlan
struct kleidos::drivers::display::InitCommand
One entry in a controller power-on init table. args points to static storage owned by the controller (or nullptr when argCount == 0). More about kleidos::drivers::display::InitCommand
class kleidos::drivers::display::IDisplayController
Stateless, controller-specific TFT panel description (no bus I/O). More about kleidos::drivers::display::IDisplayController
struct kleidos::drivers::display::EpaperCommand
One entry in an e-paper command table. args points to static storage owned by the controller (or nullptr when argCount == 0). More about kleidos::drivers::display::EpaperCommand
class kleidos::drivers::display::IEpaperController
Stateless, controller-specific e-paper panel description (no bus I/O). More about kleidos::drivers::display::IEpaperController
class kleidos::drivers::display::Ili9342Family
The ILI9342 family's shared rotation, memory and read rules. More about kleidos::drivers::display::Ili9342Family
class kleidos::drivers::display::Ili9342
ILI9342C panel controller. More about kleidos::drivers::display::Ili9342
class kleidos::drivers::display::Ili9342e
ILI9342E panel controller. More about kleidos::drivers::display::Ili9342e
struct kleidos::drivers::display::ili9342::ProbeKeys
The bytes the probe read, for a report in the log. More about kleidos::drivers::display::ili9342::ProbeKeys
class kleidos::drivers::display::ili9342::PanelRegisterBus
Register access the probe needs from a panel driver. More about kleidos::drivers::display::ili9342::PanelRegisterBus
struct kleidos::drivers::display::ssd1681::GrayPassPlan
One stacked grayscale pass: per-tone drive index and its waveform. More about kleidos::drivers::display::ssd1681::GrayPassPlan
struct kleidos::drivers::display::ssd1681::PlaneBits
The {RED (MSB), B/W (LSB)} RAM bits that select a drive index's LUT slot. More about kleidos::drivers::display::ssd1681::PlaneBits
struct kleidos::drivers::display::ssd1681::ToneRows
Where a tone frame's rows are, one native row at a time. More about kleidos::drivers::display::ssd1681::ToneRows
struct kleidos::drivers::display::ssd1681::FlatToneFrame
A tone frame held as one block of width-byte rows. More about kleidos::drivers::display::ssd1681::FlatToneFrame
struct kleidos::drivers::display::ssd1681::FastLutSpec
Fast-animation waveform recipe (drive only what changed). More about kleidos::drivers::display::ssd1681::FastLutSpec
struct kleidos::drivers::display::ssd1681::GrayLutSpec
One grayscale render pass: graded black-ward drive per 2-bit index. More about kleidos::drivers::display::ssd1681::GrayLutSpec
class kleidos::drivers::display::St7789
ST7789 panel controller (init table, MADCTL, 240x320 GRAM). More about kleidos::drivers::display::St7789

Enumerations

enum class kleidos::drivers::display::ControllerType : uint8_t { kleidos::drivers::display::ControllerType::St7789 , kleidos::drivers::display::ControllerType::Ili9342 , kleidos::drivers::display::ControllerType::Ili9342E }
Supported panel controllers. Kept local, so this layer depends on nothing in Display. More about kleidos::drivers::display::ControllerType
enum class kleidos::drivers::display::ReadMethod : uint8_t { kleidos::drivers::display::ReadMethod::Direct , kleidos::drivers::display::ReadMethod::Level2Indexed }
How a register's parameters come back over the serial interface. More about kleidos::drivers::display::ReadMethod
enum class kleidos::drivers::display::EpaperController : uint8_t { kleidos::drivers::display::EpaperController::Gdew0154M09 , kleidos::drivers::display::EpaperController::Gdew0154D67 }
Supported e-paper panel controllers. Kept local, so this layer depends on nothing in Display. More about kleidos::drivers::display::EpaperController
enum class kleidos::drivers::display::EpaperRefreshModel : uint8_t { kleidos::drivers::display::EpaperRefreshModel::DualFrameJd79653a , kleidos::drivers::display::EpaperRefreshModel::SingleRamSsd1681 }
E-paper display update model. The two controllers Kleidos supports drive fundamentally different refresh pipelines, so the owning driver selects the matching flush path from this tag. More about kleidos::drivers::display::EpaperRefreshModel
enum class kleidos::drivers::display::ili9342::Variant : uint8_t { kleidos::drivers::display::ili9342::Variant::Unknown , kleidos::drivers::display::ili9342::Variant::C , kleidos::drivers::display::ili9342::Variant::E }
Outcome of a variant probe. More about kleidos::drivers::display::ili9342::Variant
enum class kleidos::drivers::display::ssd1681::PhaseVoltage : uint8_t { kleidos::drivers::display::ssd1681::PhaseVoltage::Vss , kleidos::drivers::display::ssd1681::PhaseVoltage::Vsh1 , kleidos::drivers::display::ssd1681::PhaseVoltage::Vsl , kleidos::drivers::display::ssd1681::PhaseVoltage::Vsh2 }
2-bit source-voltage codes for one waveform phase (datasheet Table 6-6). More about kleidos::drivers::display::ssd1681::PhaseVoltage

Functions

constexpr MemoryAddresskleidos::drivers::display::memoryAddress (uint8_t madctl, GramSize gram, WindowOrigin origin, int16_t x, int16_t y)
Memory cell a logical pixel is written to.
constexpr LogicalPixelkleidos::drivers::display::logicalPixel (uint8_t madctl, GramSize gram, WindowOrigin origin, MemoryAddress cell)
Logical pixel a memory cell holds (the inverse of memoryAddress).
constexpr boolkleidos::drivers::display::fitsGram (GramSize gram, PanelPlacement panel)
Whether a panel's placement lies inside the controller's memory.
constexpr WindowOriginkleidos::drivers::display::windowOrigin (uint8_t madctl, GramSize gram, PanelPlacement panel)
Address-window origin that reaches the panel under madctl.
const IDisplayController *kleidos::drivers::display::createController (ControllerType type)
Returns a stateless singleton controller for type. The instance lives in static storage; callers must not delete it.
const IEpaperController *kleidos::drivers::display::createEpaperController (EpaperController type)
Returns a stateless singleton controller for the given type. The instance lives in static storage; callers must not delete it.
boolkleidos::drivers::display::ili9342::readLevel2Parameter (PanelRegisterBus &bus, uint8_t command, uint8_t ordinal, uint8_t &value)
Read one level 2 parameter: select it through XREG, then read it.
boolkleidos::drivers::display::ili9342::clearXreg (PanelRegisterBus &bus)
Return XREG to 00h so the following writes are taken as written.
Variantkleidos::drivers::display::ili9342::probeVariant (PanelRegisterBus &bus, bool tryC, ProbeKeys &keys)
Ask the panel once which controller it is.
Variantkleidos::drivers::display::ili9342::identifyVariant (PanelRegisterBus &bus, uint32_t attempts, bool tryC, ProbeKeys &keys)
Probe, then repeat every millisecond while the answer is unknown.
const char *kleidos::drivers::display::ili9342::variantName (Variant variant)
Short name of a variant for logs.
constexpr PlaneBitskleidos::drivers::display::ssd1681::planeBitsForDriveIndex (uint8_t driveIndex)
Map a drive index to the {RED, B/W} RAM bit pair that selects its LUT.
constexpr uint8_tkleidos::drivers::display::ssd1681::luma565 (uint16_t color)
Rec.601 relative luminance of an RGB565 color (0 = black, 255 = white).
constexpr uint8_tkleidos::drivers::display::ssd1681::toneFromLuma (uint8_t luma)
Quantize a panel luminance to a gray tone.
constexpr boolkleidos::drivers::display::ssd1681::mirrorIsInk (uint8_t tone)
Whether tone is ink in the 1-bit mirror of a gray frame.
constexpr uint8_tkleidos::drivers::display::ssd1681::blendTone (uint8_t background, uint8_t foreground, uint8_t alpha)
Alpha-blend a foreground tone over a background tone.
constexpr uint16_tkleidos::drivers::display::ssd1681::toneToRgb565 (uint8_t tone)
Faithful capture color for a tone (six evenly spaced neutral grays).
const uint8_t *kleidos::drivers::display::ssd1681::flatToneRow (const void *context, int32_t y)
The ToneRows lookup over a FlatToneFrame.
voidkleidos::drivers::display::ssd1681::encodeGrayPass (const ToneRows &tones, int32_t width, int32_t height, size_t rowBytes, const GrayPassPlan &pass, uint8_t *msbPlane, uint8_t *lsbPlane)
Encode one pass's {MSB (RED), LSB (B/W)} planes from a tone frame.
voidkleidos::drivers::display::ssd1681::encodeGrayPass (const uint8_t *toneFrame, int32_t width, int32_t height, size_t rowBytes, const GrayPassPlan &pass, uint8_t *msbPlane, uint8_t *lsbPlane)
Encode one pass's planes from a tone frame held as one block.
constexpr uint8_tkleidos::drivers::display::ssd1681::vsPhase (PhaseVoltage voltage, unsigned phase)
Pack a voltage code into one 2-bit phase field of a VS byte.
constexpr std::array< uint8_t, kLutBytes >kleidos::drivers::display::ssd1681::buildFastLut (const FastLutSpec &spec)
Build a fast-animation differential LUT from spec.
constexpr std::array< uint8_t, kLutBytes >kleidos::drivers::display::ssd1681::buildGrayLut (const GrayLutSpec &spec)
Build one grayscale-pass LUT from spec.
constexpr uint8_tkleidos::drivers::display::ssd1681::vsh1Code (int volts)
Convert a positive VSH1 level in whole volts to its 0x04 code.
constexpr uint8_tkleidos::drivers::display::ssd1681::vslCode (int volts)
Convert a negative VSL level in whole volts to its 0x04 code.

Variables

constexpr uint8_tkleidos::drivers::display::ssd1681::kGrayToneCount
Distinct gray tones the two-pass stacked scheme resolves (white + 4 + black).
constexpr size_tkleidos::drivers::display::ssd1681::kGrayPassCount
Number of stacked passes the 6-tone recipe uses.
constexpr std::array< GrayPassPlan, kGrayPassCount >kleidos::drivers::display::ssd1681::kSixTonePasses
The six-tone recipe as two stacked passes, tuned on a CoreInk panel.
constexpr uint8_tkleidos::drivers::display::ssd1681::kMirrorInkTone
Lightest tone that counts as ink in the 1-bit mirror of a gray frame.
constexpr size_tkleidos::drivers::display::ssd1681::kLutBytes
Byte count of one SSD1681 waveform LUT (the 0x32 register payload).
constexpr size_tkleidos::drivers::display::ssd1681::kVsBytesPerLut
Byte layout anchors of the 153-byte waveform setting.
constexpr size_tkleidos::drivers::display::ssd1681::kTimingOffset
First timing byte (group 0 TP_A).
constexpr size_tkleidos::drivers::display::ssd1681::kTimingBytesPerGrp
TP_A TP_B SR_AB TP_C TP_D SR_CD RP.
constexpr size_tkleidos::drivers::display::ssd1681::kFrameRateOffset
Six packed FR nibble bytes.
constexpr size_tkleidos::drivers::display::ssd1681::kFrameRateBytes
Two 3-bit FR codes per byte.
constexpr uint8_tkleidos::drivers::display::ssd1681::kVsh1CodeFor9V
Source-voltage register codes (0x04 parameters, datasheet p.21 tables).
constexpr uint8_tkleidos::drivers::display::ssd1681::kVslCodeForNeg9V
VSL -9 V anchor; -0.5 V per 2 codes.
constexpr uint8_tkleidos::drivers::display::ssd1681::kVsh2Code5V8
VSH2 5.8 V (stock operating point).

MADCTL (Memory Access Control, command 0x36) bit definitions

Shared by all MIPI-style controllers.

constexpr uint8_tkleidos::drivers::display::kMadctlMy
Row address order.
constexpr uint8_tkleidos::drivers::display::kMadctlMx
Column address order.
constexpr uint8_tkleidos::drivers::display::kMadctlMv
Row/column exchange.
constexpr uint8_tkleidos::drivers::display::kMadctlMl
Vertical refresh order.
constexpr uint8_tkleidos::drivers::display::kMadctlBgr
BGR color order.
constexpr uint8_tkleidos::drivers::display::kMadctlMh
Horizontal refresh order.

Probe constants

constexpr uint8_tkleidos::drivers::display::ili9342::kProbeSetExtcE
Value written to DDh.
constexpr uint8_tkleidos::drivers::display::ili9342::kProbePowerControl6
Value written to CBh.
constexpr uint8_tkleidos::drivers::display::ili9342::kId4ModelHigh
RDID4 parameter 2 of an ILI9342C.
constexpr uint8_tkleidos::drivers::display::ili9342::kId4ModelLow
constexpr uint8_tkleidos::drivers::display::ili9342::kMaxXregOrdinal
constexpr uint32_tkleidos::drivers::display::ili9342::kReloadWindowMs

Back to the top

Enumeration Type Documentation

ControllerType #

enum class kleidos::drivers::display::ControllerType : uint8_t

Supported panel controllers. Kept local, so this layer depends on nothing in Display.

Enumerator
St7789 

ST7789 (135x240 / 240x240 / 240x280 IPS panels).

Ili9342 

ILI9342C (320x240 panels: Core2 v1.3, CoreS3 SE).

Ili9342E 

ILI9342E (the same module's later controller, other command set).

EpaperController #

enum class kleidos::drivers::display::EpaperController : uint8_t

Supported e-paper panel controllers. Kept local, so this layer depends on nothing in Display.

Enumerator
Gdew0154M09 

GoodDisplay GDEW0154M09 (JD79653A), 200x200 black/white.

Gdew0154D67 

GoodDisplay GDEW0154D67 (SSD1681), 200x200 black/white.

EpaperRefreshModel #

enum class kleidos::drivers::display::EpaperRefreshModel : uint8_t

E-paper display update model. The two controllers Kleidos supports drive fundamentally different refresh pipelines, so the owning driver selects the matching flush path from this tag.

Enumerator
DualFrameJd79653a 

JD79653A style: load a "previous" (0x10) and "current" (0x13) RAM frame, arm a partial window, then trigger one refresh command (0x12).

GDEW0154M09 pipeline: dual RAM frames + single refresh.

SingleRamSsd1681 

SSD1681 style: set RAM X/Y window counters (0x44/0x4E/0x45/0x4F), write a single B/W RAM frame (0x24), then run an update sequence (0x22 Display Update Control 2 + 0x20 Master Activation).

GDEW0154D67 pipeline: single RAM frame + Display Update Control 2.

PhaseVoltage #

enum class kleidos::drivers::display::ssd1681::PhaseVoltage : uint8_t

2-bit source-voltage codes for one waveform phase (datasheet Table 6-6).

Enumerator
Vss 

No drive (source at VSS).

Vsh1 

Drive toward black.

Vsl 

Drive toward white.

Vsh2 

Secondary positive source level.

ReadMethod #

enum class kleidos::drivers::display::ReadMethod : uint8_t

How a register's parameters come back over the serial interface.

Enumerator
Direct 

The command is followed straight by its parameters, after ReadPlan::dummyBits clocks (the MIPI DCS read commands).

Level2Indexed 

An Ilitek level 2 register: SPI reads one parameter at a time, each selected beforehand by writing its ordinal to XREG (D9h); the controller's level2Unlock sequence goes first.

Variant #

enum class kleidos::drivers::display::ili9342::Variant : uint8_t

Outcome of a variant probe.

Enumerator
Unknown 

Neither key answered (panel in reset, reloading, or absent).

C 

ILI9342C: Read ID4 answered 93h 42h.

E 

ILI9342E: DDh and CBh read back 01h and 1Ch.

Back to the top

Function Documentation

blendTone() #

uint8_t kleidos::drivers::display::ssd1681::blendTone(uint8_t background, uint8_t foreground, uint8_t alpha)
constexpr

Alpha-blend a foreground tone over a background tone.

Blends in tone space (0..kGrayToneCount-1) with rounding, so an anti-aliased glyph edge ramps smoothly across the six panel tones as its coverage alpha rises from 0 (keep background) to 255 (full foreground). Both inputs are clamped to the valid tone range.

Parameters
NameDirectionMeaning
backgroundinExisting tone at the pixel (0 = white .. 5 = black).
foregroundinGlyph/ink tone to blend in.
alphainCoverage 0 (transparent) .. 255 (opaque).
Returns
Blended tone, clamped to 0..kGrayToneCount-1.

buildFastLut() #

std::array< uint8_t, kLutBytes > kleidos::drivers::display::ssd1681::buildFastLut(const FastLutSpec & spec)
constexpr

Build a fast-animation differential LUT from spec.

LUT0/LUT3 (unchanged pixels) stay undriven unless spec.poke is set; LUT1 (black to white) gets the kick + drive; LUT2 (white to black) gets the drive in the same slots without a kick (driving ink into white film needs less help than clearing it).

Parameters
NameDirectionMeaning
specinFrame counts and options.
Returns
The 153-byte 0x32 payload.

buildGrayLut() #

std::array< uint8_t, kLutBytes > kleidos::drivers::display::ssd1681::buildGrayLut(const GrayLutSpec & spec)
constexpr

Build one grayscale-pass LUT from spec.

All driven indexes share phase A of groups 0-2 at VSH1 (black-ward); the graded TP counts stop the light tone first, then the dark tone, leaving only black driving to the end. Requires lightFrames < darkFrames < blackFrames (the timing bytes store the differences).

Parameters
NameDirectionMeaning
specinPer-tone drive frames.
Returns
The 153-byte 0x32 payload.

clearXreg() #

bool kleidos::drivers::display::ili9342::clearXreg(PanelRegisterBus & bus)

Return XREG to 00h so the following writes are taken as written.

Parameters
NameDirectionMeaning
businPanel register access.
Return values
ValueMeaning
trueThe write completed.
falseBus failure.

createController() #

const IDisplayController * kleidos::drivers::display::createController(ControllerType type)

Returns a stateless singleton controller for type. The instance lives in static storage; callers must not delete it.

Parameters
NameDirectionMeaning
typeinThe controller variant to retrieve.
Returns
Pointer to the singleton controller instance.
See also
ControllerType

createEpaperController() #

const IEpaperController * kleidos::drivers::display::createEpaperController(EpaperController type)

Returns a stateless singleton controller for the given type. The instance lives in static storage; callers must not delete it.

Parameters
NameMeaning
typeThe e-paper controller type to instantiate.
Returns
Stateless singleton controller pointer.

encodeGrayPass() [1/2] #

void kleidos::drivers::display::ssd1681::encodeGrayPass(const ToneRows & tones, int32_t width, int32_t height, size_t rowBytes, const GrayPassPlan & pass, uint8_t * msbPlane, uint8_t * lsbPlane)
inline

Encode one pass's {MSB (RED), LSB (B/W)} planes from a tone frame.

The tone frame is read row by row through tones (values 0..5, clamped). The two output planes are 1 bpp row-major with rowBytes bytes per row and height rows, matching the panel RAM layout. Both planes are fully written (cleared bits included), so the caller need not pre-zero them.

Parameters
NameDirectionMeaning
tonesinRow lookup of the native tone frame (width bytes per row).
widthinNative panel width in pixels.
heightinNative panel height in pixels.
rowBytesinBytes per plane row (>= (width + 7) / 8).
passinPass plan (per-tone drive index).
msbPlaneoutRED plane (rowBytes * height bytes).
lsbPlaneoutB/W plane (rowBytes * height bytes).

encodeGrayPass() [2/2] #

void kleidos::drivers::display::ssd1681::encodeGrayPass(const uint8_t * toneFrame, int32_t width, int32_t height, size_t rowBytes, const GrayPassPlan & pass, uint8_t * msbPlane, uint8_t * lsbPlane)
inline

Encode one pass's planes from a tone frame held as one block.

The row-callback overload, reading toneFrame as rows of width bytes.

Parameters
NameDirectionMeaning
toneFrameinNative row-major tone frame (width * height bytes).
widthinNative panel width in pixels.
heightinNative panel height in pixels.
rowBytesinBytes per plane row (>= (width + 7) / 8).
passinPass plan (per-tone drive index).
msbPlaneoutRED plane (rowBytes * height bytes).
lsbPlaneoutB/W plane (rowBytes * height bytes).

fitsGram() #

bool kleidos::drivers::display::fitsGram(GramSize gram, PanelPlacement panel)
constexpr

Whether a panel's placement lies inside the controller's memory.

Parameters
NameDirectionMeaning
graminThe controller's memory size.
panelinThe panel's placement at MADCTL 0.
Returns
True when every shown column and row has a memory address.

flatToneRow() #

const uint8_t * kleidos::drivers::display::ssd1681::flatToneRow(const void * context, int32_t y)
inline

The ToneRows lookup over a FlatToneFrame.

Parameters
NameDirectionMeaning
contextinThe FlatToneFrame.
yinRow.
Returns
The row's first byte.

identifyVariant() #

Variant kleidos::drivers::display::ili9342::identifyVariant(PanelRegisterBus & bus, uint32_t attempts, bool tryC, ProbeKeys & keys)

Probe, then repeat every millisecond while the answer is unknown.

A panel just released from reset reloads its registers from NV memory before it answers again; the repeat covers that window.

Parameters
NameDirectionMeaning
businPanel register access.
attemptsinProbes to run at most, 1 ms apart (at least one runs).
tryCinAs for probeVariant.
keysoutThe bytes the last probe read.
Returns
The first known variant, or Variant::Unknown.

logicalPixel() #

LogicalPixel kleidos::drivers::display::logicalPixel(uint8_t madctl, GramSize gram, WindowOrigin origin, MemoryAddress cell)
constexpr

Logical pixel a memory cell holds (the inverse of memoryAddress).

Parameters
NameDirectionMeaning
madctlinMADCTL byte in force (only MX, MY and MV matter).
graminThe controller's memory size.
origininThe window origin the driver adds.
cellinThe memory cell, in MADCTL 0 coordinates.
Returns
The logical pixel; outside the viewport when no draw reaches the cell.

luma565() #

uint8_t kleidos::drivers::display::ssd1681::luma565(uint16_t color)
constexpr

Rec.601 relative luminance of an RGB565 color (0 = black, 255 = white).

Parameters
NameDirectionMeaning
colorinRGB565 color value.
Returns
Luminance in 0..255.

memoryAddress() #

MemoryAddress kleidos::drivers::display::memoryAddress(uint8_t madctl, GramSize gram, WindowOrigin origin, int16_t x, int16_t y)
constexpr

Memory cell a logical pixel is written to.

Parameters
NameDirectionMeaning
madctlinMADCTL byte in force (only MX, MY and MV matter).
graminThe controller's memory size.
origininThe window origin the driver adds.
xinLogical X.
yinLogical Y.
Returns
The memory cell, in MADCTL 0 coordinates.

mirrorIsInk() #

bool kleidos::drivers::display::ssd1681::mirrorIsInk(uint8_t tone)
constexpr

Whether tone is ink in the 1-bit mirror of a gray frame.

Parameters
NameDirectionMeaning
toneinTone index (0 = paper .. 5 = ink).
Returns
Whether the mirrored pixel is ink.

planeBitsForDriveIndex() #

PlaneBits kleidos::drivers::display::ssd1681::planeBitsForDriveIndex(uint8_t driveIndex)
constexpr

Map a drive index to the {RED, B/W} RAM bit pair that selects its LUT.

SSD1681 LUT slot = old(RED)*2 + new(B/W): none(0) -> {0,1} LUT1 (no drive), light(1) -> {1,1} LUT3, dark(2) -> {1,0} LUT2, black(3) -> {0,0} LUT0.

Parameters
NameDirectionMeaning
driveIndexinDrive index 0..3 (values >3 are treated as 3/black).
Returns
The RED/B/W bits to set for that index.

probeVariant() #

Variant kleidos::drivers::display::ili9342::probeVariant(PanelRegisterBus & bus, bool tryC, ProbeKeys & keys)

Ask the panel once which controller it is.

Parameters
NameDirectionMeaning
businPanel register access.
tryCinRun the C step when the E step does not answer. False once the panel is known to be an E, so it never receives the C's key.
keysoutThe bytes read.
Returns
The variant, or Variant::Unknown.

readLevel2Parameter() #

bool kleidos::drivers::display::ili9342::readLevel2Parameter(PanelRegisterBus & bus, uint8_t command, uint8_t ordinal, uint8_t & value)

Read one level 2 parameter: select it through XREG, then read it.

Leaves XREG holding the ordinal; the caller clears it (clearXreg).

Parameters
NameDirectionMeaning
businPanel register access.
commandinLevel 2 register.
ordinalin1-based parameter number.
valueoutThe parameter.
Return values
ValueMeaning
trueBoth transfers completed.
falseBus failure.

toneFromLuma() #

uint8_t kleidos::drivers::display::ssd1681::toneFromLuma(uint8_t luma)
constexpr

Quantize a panel luminance to a gray tone.

Parameters
NameDirectionMeaning
lumainLuminance 0..255 (255 = white/paper, 0 = black/ink).
Returns
Tone index 0 (white) .. kGrayToneCount - 1 (black).

toneToRgb565() #

uint16_t kleidos::drivers::display::ssd1681::toneToRgb565(uint8_t tone)
constexpr

Faithful capture color for a tone (six evenly spaced neutral grays).

The screenshot path maps each retained tone back to a representative gray so a decoded PNG shows the true tone ladder (tone 0 = white .. tone 5 = black) rather than 1-bit black/white. These are nominal even-spaced levels, not photometric panel reflectance measurements.

Parameters
NameDirectionMeaning
toneinTone index (clamped to the valid range).
Returns
RGB565 neutral gray for the tone.

variantName() #

const char * kleidos::drivers::display::ili9342::variantName(Variant variant)

Short name of a variant for logs.

Parameters
NameDirectionMeaning
variantinVariant to name.
Returns
"ILI9342C", "ILI9342E" or "unknown".

vsh1Code() #

uint8_t kleidos::drivers::display::ssd1681::vsh1Code(int volts)
constexpr

Convert a positive VSH1 level in whole volts to its 0x04 code.

Parameters
NameDirectionMeaning
voltsinVSH1 level, 9..17 V.
Returns
The 0x04 register code (0.2 V per step from the 9 V anchor).

vslCode() #

uint8_t kleidos::drivers::display::ssd1681::vslCode(int volts)
constexpr

Convert a negative VSL level in whole volts to its 0x04 code.

Parameters
NameDirectionMeaning
voltsinVSL level, -9..-17 V.
Returns
The 0x04 register code (0.5 V per two codes from the -9 V anchor).

vsPhase() #

uint8_t kleidos::drivers::display::ssd1681::vsPhase(PhaseVoltage voltage, unsigned phase)
constexpr

Pack a voltage code into one 2-bit phase field of a VS byte.

Parameters
NameDirectionMeaning
voltageinSource voltage for the phase.
phaseinPhase slot 0 (A) .. 3 (D); phase A occupies the top bits.
Returns
The voltage code shifted into the requested field.

windowOrigin() #

WindowOrigin kleidos::drivers::display::windowOrigin(uint8_t madctl, GramSize gram, PanelPlacement panel)
constexpr

Address-window origin that reaches the panel under madctl.

Parameters
NameDirectionMeaning
madctlinMADCTL byte in force (only MX, MY and MV matter).
graminThe controller's memory size.
panelinThe panel's placement at MADCTL 0.
Returns
The offsets to add to logical X and Y.

Back to the top

Variable Documentation

kId4ModelLow #

uint8_t kleidos::drivers::display::ili9342::kId4ModelLow
inlineconstexpr

RDID4 parameter 3 of an ILI9342C.

kMaxXregOrdinal #

uint8_t kleidos::drivers::display::ili9342::kMaxXregOrdinal
inlineconstexpr

Highest parameter XREG can select: its ordinal field is 4 bits (SPI_EXT_ORD[3:0], ILI9342C datasheet 8.3.29), so a level 2 read returns at most 15 parameters.

kMirrorInkTone #

uint8_t kleidos::drivers::display::ssd1681::kMirrorInkTone
inlineconstexpr

Lightest tone that counts as ink in the 1-bit mirror of a gray frame.

A 6-tone frame has to be mirrored into the 1-bit framebuffer, or the next partial repaint drives a blank panel (see kleidos::hal::display::driver::EpaperPanelDriver::commitToneCompose). Tone 3 is the threshold because it is the lightest tone text is ever drawn in — tone 2 is below the contrast a glyph needs on paper — so everything the reader is meant to read survives the mirror, and the tone-1 rules and fills that only separate content do not.

kReloadWindowMs #

uint32_t kleidos::drivers::display::ili9342::kReloadWindowMs
inlineconstexpr

Longest wait for a panel that reloads its registers after a reset: up to 120 ms in sleep-out mode, the figure given for the ILI9342E.

kSixTonePasses #

std::array<GrayPassPlan, kGrayPassCount> kleidos::drivers::display::ssd1681::kSixTonePasses
inlineconstexpr

The six-tone recipe as two stacked passes, tuned on a CoreInk panel.

Accumulated drive frames per tone (pass 0 + pass 1) are 0, 1, 2, 4, 6 and 10: white, four graded grays, black.

kVsBytesPerLut #

size_t kleidos::drivers::display::ssd1681::kVsBytesPerLut
inlineconstexpr

Byte layout anchors of the 153-byte waveform setting.

One VS row: 12 group bytes.

kVsh1CodeFor9V #

uint8_t kleidos::drivers::display::ssd1681::kVsh1CodeFor9V
inlineconstexpr

Source-voltage register codes (0x04 parameters, datasheet p.21 tables).

VSH1 9 V anchor; +0.2 V per code.

Back to the top