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/ |
| Maps a ControllerType to its stateless singleton controller, and the contract's shared default read rule. | |
| file | src/ |
| Maps an EpaperController to its stateless singleton controller. | |
| file | src/ |
| GDEW0154D67 (SSD1681) command tables. | |
| file | src/ |
| GoodDisplay GDEW0154D67 (SSD1681) e-paper controller description. | |
| file | src/ |
| GDEW0154M09 (JD79653A) command tables. | |
| file | src/ |
| GoodDisplay GDEW0154M09 (JD79653A) e-paper controller description. | |
| file | src/ |
| Where a panel's window sits in its controller's memory, and which memory cell a logical pixel lands on. | |
| file | src/ |
| Data-driven, stateless contract for a TFT panel controller. | |
| file | src/ |
| Data-driven, stateless contract for an e-paper controller. | |
| file | src/ |
| Ilitek ILI9342C and ILI9342E display-controller descriptions. | |
| file | src/ |
| Tells an ILI9342C from an ILI9342E on the panel's own bus. | |
| file | src/ |
| Pure 6-tone grayscale mapping for the SSD1681 two-pass stacked scheme. | |
| file | src/ |
| Pure constexpr builders for SSD1681 waveform LUTs (register 0x32). | |
| file | src/ |
| Sitronix ST7789 display-controller description. | |
Functions | |
| constexpr MemoryAddress | kleidos:: |
| Memory cell a logical pixel is written to. | |
| constexpr LogicalPixel | kleidos:: |
| Logical pixel a memory cell holds (the inverse of memoryAddress). | |
| constexpr bool | kleidos:: |
| Whether a panel's placement lies inside the controller's memory. | |
| constexpr WindowOrigin | kleidos:: |
Address-window origin that reaches the panel under madctl. | |
| const IDisplayController * | kleidos:: |
| Returns a stateless singleton controller for type. The instance lives in static storage; callers must not delete it. | |
| const IEpaperController * | kleidos:: |
| Returns a stateless singleton controller for the given type. The instance lives in static storage; callers must not delete it. | |
| bool | kleidos:: |
| Read one level 2 parameter: select it through XREG, then read it. | |
| bool | kleidos:: |
| Return XREG to 00h so the following writes are taken as written. | |
| Variant | kleidos:: |
| Ask the panel once which controller it is. | |
| Variant | kleidos:: |
| Probe, then repeat every millisecond while the answer is unknown. | |
| const char * | kleidos:: |
| Short name of a variant for logs. | |
| constexpr PlaneBits | kleidos:: |
| Map a drive index to the {RED, B/W} RAM bit pair that selects its LUT. | |
| constexpr uint8_t | kleidos:: |
| Rec.601 relative luminance of an RGB565 color (0 = black, 255 = white). | |
| constexpr uint8_t | kleidos:: |
| Quantize a panel luminance to a gray tone. | |
| constexpr bool | kleidos:: |
Whether tone is ink in the 1-bit mirror of a gray frame. | |
| constexpr uint8_t | kleidos:: |
| Alpha-blend a foreground tone over a background tone. | |
| constexpr uint16_t | kleidos:: |
| Faithful capture color for a tone (six evenly spaced neutral grays). | |
| const uint8_t * | kleidos:: |
The ToneRows lookup over a FlatToneFrame. | |
| void | kleidos:: |
| Encode one pass's {MSB (RED), LSB (B/W)} planes from a tone frame. | |
| void | kleidos:: |
| Encode one pass's planes from a tone frame held as one block. | |
| constexpr uint8_t | kleidos:: |
| Pack a voltage code into one 2-bit phase field of a VS byte. | |
| constexpr std::array< uint8_t, kLutBytes > | kleidos:: |
Build a fast-animation differential LUT from spec. | |
| constexpr std::array< uint8_t, kLutBytes > | kleidos:: |
Build one grayscale-pass LUT from spec. | |
| constexpr uint8_t | kleidos:: |
| Convert a positive VSH1 level in whole volts to its 0x04 code. | |
| constexpr uint8_t | kleidos:: |
| Convert a negative VSL level in whole volts to its 0x04 code. | |
Variables | |
| constexpr uint8_t | kleidos:: |
| Distinct gray tones the two-pass stacked scheme resolves (white + 4 + black). | |
| constexpr size_t | kleidos:: |
| Number of stacked passes the 6-tone recipe uses. | |
| constexpr std::array< GrayPassPlan, kGrayPassCount > | kleidos:: |
| The six-tone recipe as two stacked passes, tuned on a CoreInk panel. | |
| constexpr uint8_t | kleidos:: |
| Lightest tone that counts as ink in the 1-bit mirror of a gray frame. | |
| constexpr size_t | kleidos:: |
| Byte count of one SSD1681 waveform LUT (the 0x32 register payload). | |
| constexpr size_t | kleidos:: |
| Byte layout anchors of the 153-byte waveform setting. | |
| constexpr size_t | kleidos:: |
| First timing byte (group 0 TP_A). | |
| constexpr size_t | kleidos:: |
| TP_A TP_B SR_AB TP_C TP_D SR_CD RP. | |
| constexpr size_t | kleidos:: |
| Six packed FR nibble bytes. | |
| constexpr size_t | kleidos:: |
| Two 3-bit FR codes per byte. | |
| constexpr uint8_t | kleidos:: |
| Source-voltage register codes (0x04 parameters, datasheet p.21 tables). | |
| constexpr uint8_t | kleidos:: |
| VSL -9 V anchor; -0.5 V per 2 codes. | |
| constexpr uint8_t | kleidos:: |
| VSH2 5.8 V (stock operating point). | |
Probe constants | |
| constexpr uint8_t | kleidos:: |
| Value written to DDh. | |
| constexpr uint8_t | kleidos:: |
| Value written to CBh. | |
| constexpr uint8_t | kleidos:: |
| RDID4 parameter 2 of an ILI9342C. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint32_t | kleidos:: |
Enumeration Type Documentation
ControllerType #
Supported panel controllers. Kept local, so this layer depends on nothing in Display.
EpaperController #
Supported e-paper panel controllers. Kept local, so this layer depends on nothing in Display.
EpaperRefreshModel #
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.
PhaseVoltage #
ReadMethod #
How a register's parameters come back over the serial interface.
| Enumerator | |
|---|---|
| Direct | The command is followed straight by its parameters, after |
| 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 |
Variant #
Function Documentation
blendTone() #
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
-
Name Direction Meaning background in Existing tone at the pixel (0 = white .. 5 = black). foreground in Glyph/ink tone to blend in. alpha in Coverage 0 (transparent) .. 255 (opaque).
- Returns
- Blended tone, clamped to 0..
kGrayToneCount-1.
buildFastLut() #
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
-
Name Direction Meaning spec in Frame counts and options.
- Returns
- The 153-byte 0x32 payload.
buildGrayLut() #
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
-
Name Direction Meaning spec in Per-tone drive frames.
- Returns
- The 153-byte 0x32 payload.
clearXreg() #
Return XREG to 00h so the following writes are taken as written.
- Parameters
-
Name Direction Meaning bus in Panel register access.
- Return values
-
Value Meaning true The write completed. false Bus failure.
createController() #
Returns a stateless singleton controller for type. The instance lives in static storage; callers must not delete it.
- Parameters
-
Name Direction Meaning type in The controller variant to retrieve.
- Returns
- Pointer to the singleton controller instance.
- See also
- ControllerType
createEpaperController() #
Returns a stateless singleton controller for the given type. The instance lives in static storage; callers must not delete it.
- Parameters
-
Name Meaning type The e-paper controller type to instantiate.
- Returns
- Stateless singleton controller pointer.
encodeGrayPass() [1/2] #
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
-
Name Direction Meaning tones in Row lookup of the native tone frame ( widthbytes per row).width in Native panel width in pixels. height in Native panel height in pixels. rowBytes in Bytes per plane row (>= (width + 7) / 8). pass in Pass plan (per-tone drive index). msbPlane out RED plane (rowBytes * height bytes). lsbPlane out B/W plane (rowBytes * height bytes).
encodeGrayPass() [2/2] #
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
-
Name Direction Meaning toneFrame in Native row-major tone frame ( width*heightbytes).width in Native panel width in pixels. height in Native panel height in pixels. rowBytes in Bytes per plane row (>= (width + 7) / 8). pass in Pass plan (per-tone drive index). msbPlane out RED plane (rowBytes * height bytes). lsbPlane out B/W plane (rowBytes * height bytes).
fitsGram() #
Whether a panel's placement lies inside the controller's memory.
- Parameters
-
Name Direction Meaning gram in The controller's memory size. panel in The panel's placement at MADCTL 0.
- Returns
- True when every shown column and row has a memory address.
flatToneRow() #
The ToneRows lookup over a FlatToneFrame.
- Parameters
-
Name Direction Meaning context in The FlatToneFrame.y in Row.
- Returns
- The row's first byte.
identifyVariant() #
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
-
Name Direction Meaning bus in Panel register access. attempts in Probes to run at most, 1 ms apart (at least one runs). tryC in As for probeVariant.keys out The bytes the last probe read.
- Returns
- The first known variant, or
Variant::.Unknown
logicalPixel() #
Logical pixel a memory cell holds (the inverse of memoryAddress).
- Parameters
-
Name Direction Meaning madctl in MADCTL byte in force (only MX, MY and MV matter). gram in The controller's memory size. origin in The window origin the driver adds. cell in The memory cell, in MADCTL 0 coordinates.
- Returns
- The logical pixel; outside the viewport when no draw reaches the cell.
luma565() #
Rec.601 relative luminance of an RGB565 color (0 = black, 255 = white).
- Parameters
-
Name Direction Meaning color in RGB565 color value.
- Returns
- Luminance in 0..255.
memoryAddress() #
Memory cell a logical pixel is written to.
- Parameters
-
Name Direction Meaning madctl in MADCTL byte in force (only MX, MY and MV matter). gram in The controller's memory size. origin in The window origin the driver adds. x in Logical X. y in Logical Y.
- Returns
- The memory cell, in MADCTL 0 coordinates.
mirrorIsInk() #
Whether tone is ink in the 1-bit mirror of a gray frame.
- Parameters
-
Name Direction Meaning tone in Tone index (0 = paper .. 5 = ink).
- Returns
- Whether the mirrored pixel is ink.
planeBitsForDriveIndex() #
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
-
Name Direction Meaning driveIndex in Drive index 0..3 (values >3 are treated as 3/black).
- Returns
- The RED/B/W bits to set for that index.
probeVariant() #
Ask the panel once which controller it is.
- Parameters
-
Name Direction Meaning bus in Panel register access. tryC in Run 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. keys out The bytes read.
- Returns
- The variant, or
Variant::.Unknown
readLevel2Parameter() #
Read one level 2 parameter: select it through XREG, then read it.
Leaves XREG holding the ordinal; the caller clears it (clearXreg).
- Parameters
-
Name Direction Meaning bus in Panel register access. command in Level 2 register. ordinal in 1-based parameter number. value out The parameter.
- Return values
-
Value Meaning true Both transfers completed. false Bus failure.
toneFromLuma() #
Quantize a panel luminance to a gray tone.
- Parameters
-
Name Direction Meaning luma in Luminance 0..255 (255 = white/paper, 0 = black/ink).
- Returns
- Tone index 0 (white) ..
kGrayToneCount- 1 (black).
toneToRgb565() #
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
-
Name Direction Meaning tone in Tone index (clamped to the valid range).
- Returns
- RGB565 neutral gray for the tone.
variantName() #
Short name of a variant for logs.
- Parameters
-
Name Direction Meaning variant in Variant to name.
- Returns
- "ILI9342C", "ILI9342E" or "unknown".
vsh1Code() #
Convert a positive VSH1 level in whole volts to its 0x04 code.
- Parameters
-
Name Direction Meaning volts in VSH1 level, 9..17 V.
- Returns
- The 0x04 register code (0.2 V per step from the 9 V anchor).
vslCode() #
Convert a negative VSL level in whole volts to its 0x04 code.
- Parameters
-
Name Direction Meaning volts in VSL level, -9..-17 V.
- Returns
- The 0x04 register code (0.5 V per two codes from the -9 V anchor).
vsPhase() #
Pack a voltage code into one 2-bit phase field of a VS byte.
- Parameters
-
Name Direction Meaning voltage in Source voltage for the phase. phase in Phase slot 0 (A) .. 3 (D); phase A occupies the top bits.
- Returns
- The voltage code shifted into the requested field.
windowOrigin() #
Address-window origin that reaches the panel under madctl.
- Parameters
-
Name Direction Meaning madctl in MADCTL byte in force (only MX, MY and MV matter). gram in The controller's memory size. panel in The panel's placement at MADCTL 0.
- Returns
- The offsets to add to logical X and Y.
Variable Documentation
kId4ModelLow #
RDID4 parameter 3 of an ILI9342C.
kMaxXregOrdinal #
Highest parameter XREG can select: its ordinal field is 4 bits (SPI_
kMirrorInkTone #
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::
kReloadWindowMs #
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 #
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 #
Byte layout anchors of the 153-byte waveform setting.
One VS row: 12 group bytes.
kVsh1CodeFor9V #
Source-voltage register codes (0x04 parameters, datasheet p.21 tables).
VSH1 9 V anchor; +0.2 V per code.