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

Common base class for SPI-based display drivers. More...

#include <DisplayDriverSPI.h>

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

Public Member Functions

 DisplayDriverSPI (SPIClass &spi, int8_t cs, int8_t dc, int8_t rst=-1, size_t xOffset=0, size_t yOffset=0, uint32_t frequencyHz=40000000, uint32_t readFrequencyHz=15000000, size_t width=240, size_t height=320)
 
size_t width () const override
 
size_t height () const override
 
bool writeData (ISurface< RGB_T > &surface) override
 
void setSwapOutputBytes (bool swap)
 
bool writeData (ISurface< RGB_T > &surface, size_t x, size_t y) override
 
bool readData (ISurface< RGB_T > &surface, size_t x, size_t y)
 
- 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
 
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

SPIClass & spi_
 
int8_t cs_
 
int8_t dc_
 
int8_t rst_
 
size_t xOffset_
 
size_t yOffset_
 
uint32_t frequencyHz_
 
uint32_t readFrequencyHz_
 
size_t width_
 
size_t height_
 
bool swapOutputBytes_ = false
 
- Protected Attributes inherited from DisplayDriver< RGB_T >
Font5x7< RGB_T > defaultFont
 

Detailed Description

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

Common base class for SPI-based display drivers.

Constructor & Destructor Documentation

◆ DisplayDriverSPI()

DisplayDriverSPI ( SPIClass &  spi,
int8_t  cs,
int8_t  dc,
int8_t  rst = -1,
size_t  xOffset = 0,
size_t  yOffset = 0,
uint32_t  frequencyHz = 40000000,
uint32_t  readFrequencyHz = 15000000,
size_t  width = 240,
size_t  height = 320 
)
inline
Parameters
width/heightthe panel's addressable resolution, as reported by width()/height() - subclasses with a rotation concept (e.g. ILI9341Driver) override width()/height() themselves instead and can ignore these.

Member Function Documentation

◆ height()

size_t height ( ) const
inlineoverridevirtual

◆ readData()

bool readData ( ISurface< RGB_T > &  surface,
size_t  x,
size_t  y 
)
inline

◆ 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

◆ setSwapOutputBytes()

void setSwapOutputBytes ( bool  swap)
inline

Swaps each pixel's two bytes right before they go out over SPI (see writeData()) - off by default, since RGB_T (RGB565) already stores values pre-swapped to the wire order most panels expect (see RGB565.h). Some panels/wiring combinations expect the opposite of that default (symptom: colors come out scrambled/inverted-looking - e.g. a purple app bar rendering green, a light background rendering black - across everything drawn, not just images); this is the one place all pixel data funnels through before hitting the wire, so flipping it here fixes fills/text/images uniformly instead of needing a per-source fix (contrast JPEGParser::setSwapBytes(), which only affects decoded images).

◆ 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 ILI9341Driver< RGB_T >, ILI9341Driver< tinygpu::RGB565 >, and ILI9342Driver< 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.

Member Data Documentation

◆ cs_

int8_t cs_
protected

◆ dc_

int8_t dc_
protected

◆ frequencyHz_

uint32_t frequencyHz_
protected

◆ height_

size_t height_
protected

◆ readFrequencyHz_

uint32_t readFrequencyHz_
protected

◆ rst_

int8_t rst_
protected

◆ spi_

SPIClass& spi_
protected

◆ swapOutputBytes_

bool swapOutputBytes_ = false
protected

◆ width_

size_t width_
protected

◆ xOffset_

size_t xOffset_
protected

◆ yOffset_

size_t yOffset_
protected

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