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

LVGLDriver is a helper class to initialize LVGL v9 with a TinyGPU Output driver. It sets up the display buffer and flush callback for LVGL. More...

#include <LVGLDriver.h>

Collaboration diagram for LVGLDriver< RGB_T >:
Collaboration graph
[legend]

Public Member Functions

 LVGLDriver (DisplayDriver< RGB_T > &driver, size_t x, size_t y, size_t bufferSize=0)
 
bool begin ()
 
void end ()
 
void delay (uint32_t ms)
 
void setTouchDriver (TouchDriver &touch)
 
bool hasTouchDriver () const
 Checks if a touch driver has been set for this LVGLDriver.
 
TouchDriver & touchDriver ()
 
DisplayDriver< RGB_T > & getDriver ()
 

Static Public Member Functions

static void display (lv_display_t *disp, const lv_area_t *area, uint8_t *px_map)
 
static void setGamma (float gammaR, float gammaG, float gammaB)
 

Protected Member Functions

lv_indev_t * setupTouch ()
 Registers a touch driver with this LVGL display instance.
 
void dumpBuffer (const uint8_t *data, size_t len)
 

Static Protected Member Functions

static uint32_t my_tick (void)
 
static GammaTable & gammaR_ ()
 
static GammaTable & gammaG_ ()
 
static GammaTable & gammaB_ ()
 
static void convertBuffer (uint8_t *px_map, size_t pixelCount)
 

Protected Attributes

Vector< uint8_t > buf_1
 
DisplayDriver< RGB_T > * driver = nullptr
 
TouchDriver * touch_driver = nullptr
 
lv_display_t * disp = nullptr
 
size_t disp_x = 0
 
size_t disp_y = 0
 
size_t dispBufferSize = 0
 

Detailed Description

template<typename RGB_T = RGB565>
class LVGLDriver< RGB_T >

LVGLDriver is a helper class to initialize LVGL v9 with a TinyGPU Output driver. It sets up the display buffer and flush callback for LVGL.

Template Parameters
RGB_TThe pixel format LVGL's rendered output is converted to before transmission. Defaults to RGB565, matching LVGL's own internal RGB565 color format (convertBuffer() below still has to undo RGB565's own byte-swapped storage - see RGB565.h - even in that default case).

Constructor & Destructor Documentation

◆ LVGLDriver()

LVGLDriver ( DisplayDriver< RGB_T > &  driver,
size_t  x,
size_t  y,
size_t  bufferSize = 0 
)
inline

Member Function Documentation

◆ begin()

bool begin ( )
inline

◆ convertBuffer()

static void convertBuffer ( uint8_t *  px_map,
size_t  pixelCount 
)
inlinestaticprotected

Converts a buffer LVGL packed as (native-order) RGB565 into RGB_T's own byte layout, applying per-channel gamma correction (see setGamma()), in place. Each pixel is decoded with RGB565's semantics (what LVGL actually wrote), gamma corrected, and re-encoded via RGB_T::fromRGB(), so RGB_T's own compensation (if any) is genuinely applied regardless of how RGB_T's constructor happens to order its arguments.

◆ delay()

void delay ( uint32_t  ms)
inline

◆ display()

static void display ( lv_display_t *  disp,
const lv_area_t *  area,
uint8_t *  px_map 
)
inlinestatic

◆ dumpBuffer()

void dumpBuffer ( const uint8_t *  data,
size_t  len 
)
inlineprotected

◆ end()

void end ( )
inline

◆ gammaB_()

static GammaTable & gammaB_ ( )
inlinestaticprotected

◆ gammaG_()

static GammaTable & gammaG_ ( )
inlinestaticprotected

◆ gammaR_()

static GammaTable & gammaR_ ( )
inlinestaticprotected

◆ getDriver()

DisplayDriver< RGB_T > & getDriver ( )
inline

Provides a reference to the underlying DisplayDriver instance used by this LVGLDriver (an SPI panel driver on ESP32, DisplayDriverSDL on desktop, or any other DisplayDriver<RGB_T> implementation).

◆ hasTouchDriver()

bool hasTouchDriver ( ) const
inline

Checks if a touch driver has been set for this LVGLDriver.

◆ my_tick()

static uint32_t my_tick ( void  )
inlinestaticprotected

◆ setGamma()

static void setGamma ( float  gammaR,
float  gammaG,
float  gammaB 
)
inlinestatic

Applies independent per-channel gamma correction to every color LVGL renders, before RGB_T's own field layout/compensation is applied. gammaR=gammaG=gammaB=1.0 (the default) applies no correction.

This is deliberately per-channel rather than one shared curve: some panels show a visible color tint in near-black/grey tones even with correct field compensation, because the panel's red/green/blue subpixels have different non-linear responses at low brightness. A single gamma applied equally to R, G and B can only ever change overall brightness - if R=G=B going in, the same curve on all three still gives R=G=B going out, so it mathematically cannot fix a hue tint in grey tones. Independent per-channel curves can, by deliberately un-balancing a grey input to counteract the panel's own imbalance. There's no single correct set of values for an unknown/ undocumented panel - try values on both sides of 1.0 per channel and compare on real hardware. See GammaTable.h.

◆ setTouchDriver()

void setTouchDriver ( TouchDriver &  touch)
inline

Defines the touch driver to be used with LVGL. This is optional and can be set if a touch driver is available.

◆ setupTouch()

lv_indev_t * setupTouch ( )
inlineprotected

Registers a touch driver with this LVGL display instance.

◆ touchDriver()

TouchDriver & touchDriver ( )
inline

Provides a pointer to the touch driver, if one has been set. Returns nullptr if no touch driver is available.

Member Data Documentation

◆ buf_1

Vector<uint8_t> buf_1
protected

◆ disp

lv_display_t* disp = nullptr
protected

◆ disp_x

size_t disp_x = 0
protected

◆ disp_y

size_t disp_y = 0
protected

◆ dispBufferSize

size_t dispBufferSize = 0
protected

◆ driver

DisplayDriver<RGB_T>* driver = nullptr
protected

◆ touch_driver

TouchDriver* touch_driver = nullptr
protected

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