TinyGPU
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DisplayDriverParallel8RP2040< RGB_T > Class Template Reference

RP2040 PIO/DMA-accelerated 8-bit parallel ("Intel 8080"-style) TFT display driver. D0-D7 and WR are driven by one PIO state machine (see kLcd8080WriteProgram above) instead of bit-banged via digitalWrite() - see DisplayDriverParallel8.h for the portable bit-banged version this mirrors, and DisplayDriverParallel8ESP32.h for the equivalent ESP32 LCD_CAM/PARLIO-peripheral version. DC/CS/RST stay on plain GPIO (Arduino pinMode()/digitalWrite()), same as those two. More...

#include <DisplayDriverParallel8RP2040.h>

Inheritance diagram for DisplayDriverParallel8RP2040< RGB_T >:
Inheritance graph
[legend]
Collaboration diagram for DisplayDriverParallel8RP2040< RGB_T >:
Collaboration graph
[legend]

Public Member Functions

 DisplayDriverParallel8RP2040 (int8_t d0, int8_t wr, int8_t dc, int8_t cs=-1, int8_t rst=-1, size_t width=240, size_t height=320, float clockDiv=8.0f, PIO pio=pio0)
 
void end () override
 
 ~DisplayDriverParallel8RP2040 () override
 
size_t width () const override
 
size_t height () const override
 
bool writeData (ISurface< RGB_T > &surface) override
 
bool writeData (ISurface< RGB_T > &surface, size_t x, size_t y) override
 
- Public Member Functions inherited from DisplayDriver< RGB_T >
virtual ~DisplayDriver ()=default
 
virtual bool begin ()=0
 
virtual void end ()
 
virtual bool writeData (ISurface< RGB_T > &surface)=0
 
virtual bool writeData (ISurface< RGB_T > &surface, size_t x, size_t y)=0
 
virtual void setRotation (DisplayRotation rotation)
 
virtual size_t width () const =0
 
virtual size_t height () const =0
 
void writeColor (size_t width, size_t height, RGB_T color)
 

Protected Member Functions

void setColumnRowAddress (size_t x, size_t y, size_t w, size_t h)
 
bool setAddressWindow (size_t x, size_t y, size_t w, size_t h) override
 
bool beginBus ()
 
void setupPinsAndReset ()
 
void writeCommand (uint8_t cmd)
 
void writeData16 (uint16_t d1, uint16_t d2)
 
void writeData8 (uint8_t data)
 
void writeDataN (std::initializer_list< uint8_t > bytes)
 
virtual bool setAddressWindow (size_t x, size_t y, size_t w, size_t h)=0
 

Protected Attributes

int8_t d0_
 
int8_t wr_
 
int8_t dc_
 
int8_t cs_
 
int8_t rst_
 
size_t width_
 
size_t height_
 
float clockDiv_
 
PIO pio_
 
uint sm_ = 0
 
uint offset_ = 0
 
int dma_ = -1
 
bool busInitialized_ = false
 
- Protected Attributes inherited from DisplayDriver< RGB_T >
Font5x7< RGB_T > defaultFont
 

Detailed Description

template<typename RGB_T = RGB565>
class tinygpu::DisplayDriverParallel8RP2040< RGB_T >

RP2040 PIO/DMA-accelerated 8-bit parallel ("Intel 8080"-style) TFT display driver. D0-D7 and WR are driven by one PIO state machine (see kLcd8080WriteProgram above) instead of bit-banged via digitalWrite() - see DisplayDriverParallel8.h for the portable bit-banged version this mirrors, and DisplayDriverParallel8ESP32.h for the equivalent ESP32 LCD_CAM/PARLIO-peripheral version. DC/CS/RST stay on plain GPIO (Arduino pinMode()/digitalWrite()), same as those two.

Bulk pixel data (writeData()) is fed to the state machine via a DMA channel reading directly out of the surface's buffer - the CPU issues one DMA transfer and waits for it (and the state machine's own FIFO) to drain, rather than looping a pio_sm_put_blocking() call per byte.

Hardware constraint (PIO's out pins/side-set addressing): D0-D7 must be 8 consecutive GPIOs, D0 being the lowest-numbered - this isn't a software choice, it's how the PIO block maps its 32 general-purpose output-mapped pins. WR must be a separate GPIO outside that D0-D7 range.

Constructor & Destructor Documentation

◆ DisplayDriverParallel8RP2040()

DisplayDriverParallel8RP2040 ( int8_t  d0,
int8_t  wr,
int8_t  dc,
int8_t  cs = -1,
int8_t  rst = -1,
size_t  width = 240,
size_t  height = 320,
float  clockDiv = 8.0f,
PIO  pio = pio0 
)
inline
Parameters
d0the first (lowest-numbered) of 8 consecutive data-line GPIOs - see the class comment's hardware constraint.
wrwrite-strobe pin - the PIO program's side-set pin.
dcdata/command ("RS") select pin.
cschip-select pin, or -1 if the panel has CS permanently tied low.
rstreset pin, or -1 if not wired up.
width/heightthe panel's addressable resolution - subclasses with a rotation concept (e.g. ILI9341Driver8080RP2040) override width()/height() themselves instead and can ignore these.
clockDivPIO state machine clock divider - the program runs at 2 PIO-clock cycles/byte, so the WR toggle rate is (clock_sys_hz / clockDiv) / 2. Default (8.0) gives roughly 7.8MHz at a stock 125MHz system clock - comfortably inside most 8080 panels' timing spec; lower it for a faster panel/wiring, raise it if data looks corrupted (a symptom of the panel not keeping up).
piowhich PIO block to use (pio0/pio1) - pick one not already fully claimed by another peripheral (e.g. an RP2040 audio driver using PIO for I2S).

◆ ~DisplayDriverParallel8RP2040()

~DisplayDriverParallel8RP2040 ( )
inlineoverride

Member Function Documentation

◆ beginBus()

bool beginBus ( )
inlineprotected

Claims a state machine + DMA channel and starts the PIO program. Subclasses call this first thing in their begin() (after setupPinsAndReset()), then send their chip's own init register sequence via writeCommand()/writeDataN() before returning.

◆ end()

void end ( )
inlineoverridevirtual

Reimplemented from DisplayDriver< RGB_T >.

◆ height()

size_t height ( ) const
inlineoverridevirtual

◆ setAddressWindow()

bool setAddressWindow ( size_t  x,
size_t  y,
size_t  w,
size_t  h 
)
inlineoverrideprotectedvirtual

◆ setColumnRowAddress()

void setColumnRowAddress ( size_t  x,
size_t  y,
size_t  w,
size_t  h 
)
inlineprotected

◆ setupPinsAndReset()

void setupPinsAndReset ( )
inlineprotected

◆ width()

size_t width ( ) const
inlineoverridevirtual

Current addressable panel width/height in pixels - for a driver that supports setRotation(), these reflect the current rotation (landscape vs portrait swaps them; see isLandscapeFamily()), not necessarily the panel's native/physical orientation. Callers that need to lay out content (e.g. OutputTinyGPU's scale_to_fit target, or clearScreen()'s band loop) should read these fresh rather than caching their own copy, so a setRotation() call is picked up automatically without needing separate bookkeeping.

Implements DisplayDriver< RGB_T >.

Reimplemented in ILI9341Driver8080RP2040< RGB_T >.

◆ writeCommand()

void writeCommand ( uint8_t  cmd)
inlineprotected

◆ writeData() [1/2]

bool writeData ( ISurface< RGB_T > &  surface)
inlineoverridevirtual

◆ writeData() [2/2]

bool writeData ( ISurface< RGB_T > &  surface,
size_t  x,
size_t  y 
)
inlineoverridevirtual

◆ writeData16()

void writeData16 ( uint16_t  d1,
uint16_t  d2 
)
inlineprotected

◆ writeData8()

void writeData8 ( uint8_t  data)
inlineprotected

◆ writeDataN()

void writeDataN ( std::initializer_list< uint8_t >  bytes)
inlineprotected

Writes each byte as a separate writeData8() call - a convenience for sending a command's multi-byte parameter list during init sequences, matching DisplayDriverSPI::writeDataN()/DisplayDriverParallel8's writeDataN().

Member Data Documentation

◆ busInitialized_

bool busInitialized_ = false
protected

◆ clockDiv_

float clockDiv_
protected

◆ cs_

int8_t cs_
protected

◆ d0_

int8_t d0_
protected

◆ dc_

int8_t dc_
protected

◆ dma_

int dma_ = -1
protected

◆ height_

size_t height_
protected

◆ offset_

uint offset_ = 0
protected

◆ pio_

PIO pio_
protected

◆ rst_

int8_t rst_
protected

◆ sm_

uint sm_ = 0
protected

◆ width_

size_t width_
protected

◆ wr_

int8_t wr_
protected

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