Skip to content

feat: LVGL driver #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 169 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
4e21cf2
lvgl driver initial draft
mverch67 Jan 25, 2025
8581f01
Merge branch 'master' into lvgl-driver
mverch67 Jan 25, 2025
c2a165b
lvgl driver class structures completed
mverch67 Jan 26, 2025
85a4ca9
fix compiler error if USE_ST7789 not defined
mverch67 Jan 26, 2025
b1003d5
Merge branch 'master' into lvgl-driver
mverch67 Jan 27, 2025
5c52c48
set GPIO capabilities
mverch67 Jan 27, 2025
70abf5c
Merge branch 'master' into lvgl-driver
mverch67 Feb 7, 2025
f2c9722
Merge branch 'master' into lvgl-driver
mverch67 Feb 7, 2025
a932d61
style: Improved Greek translation (#35)
iliaschat Feb 8, 2025
e12bfad
fix BBCapTouch for Indicator
mverch67 Feb 8, 2025
f1e54dc
sd card icon
mverch67 Feb 9, 2025
7cb8176
fix nodes online calculation
mverch67 Feb 10, 2025
b1fe211
fix SD card calculations
mverch67 Feb 10, 2025
5af5436
fix macro definition
mverch67 Feb 11, 2025
06c55a1
remove touch driver sleep/wakeup which may cause trouble on devices w…
mverch67 Feb 11, 2025
f5a87bb
add BT programming mode (#37)
mverch67 Feb 13, 2025
2f7e019
remove debug log
mverch67 Feb 13, 2025
0c28713
fixes view states related to programming mode, add timer
mverch67 Feb 14, 2025
7a472c8
style: Enhance Greek Translation and Maintain File Consistency (#36)
iliaschat Feb 15, 2025
b40f883
update default translations
mverch67 Feb 15, 2025
0a7aab2
backup/restore keys (#38)
mverch67 Feb 15, 2025
cc691a9
style: Update en.yml and Greek translation, fix SD card status displa…
iliaschat Feb 15, 2025
208009f
Update README
mverch67 Feb 17, 2025
ab37998
added lightSleep observers for more graceful wakeup after sleep (#40)
mverch67 Feb 17, 2025
464fb4a
allow variable task sleep time
mverch67 Feb 17, 2025
7b9023f
unPhone: remove invalid include
mverch67 Feb 17, 2025
2a94b2b
fix manual resynch
mverch67 Feb 18, 2025
a9a8c9e
fix manual resynch again
mverch67 Feb 18, 2025
6a55c74
add support for MMC
mverch67 Feb 18, 2025
162aa26
add alert message #6085
mverch67 Feb 19, 2025
c9e3b8b
fix: Update french (#41)
joyel24 Feb 21, 2025
afce943
get rid of the h (#42)
mverch67 Feb 21, 2025
01c8233
regenerate and trunk fmt i18n
mverch67 Feb 21, 2025
39660b6
update Spanish translation, gracias Roberto
mverch67 Feb 23, 2025
6f06ff4
upgrade trunk
mverch67 Feb 23, 2025
f594d82
fix duplicate " which trunk did not find
mverch67 Feb 23, 2025
061bad8
update Netherlands translation
mverch67 Feb 25, 2025
3d1fd5f
map implementation
mverch67 Feb 24, 2025
ff7adf1
count objects
mverch67 Feb 24, 2025
c9b4ea7
default not using LVGL built-in SD
mverch67 Feb 24, 2025
b8dd119
add healine translation for all languages
mverch67 Feb 24, 2025
6b162e1
update README
mverch67 Feb 24, 2025
a58a64c
update map objects counter asynchronously; draw node names >= zoom 7 …
mverch67 Feb 24, 2025
b20f0ca
persistent home location on map
mverch67 Feb 25, 2025
a267f24
minor update of comments in code
mverch67 Feb 25, 2025
2898093
replace short name if it contains non-printable glyphs only
mverch67 Feb 25, 2025
2268b31
check if scrolling exceeds the edges of the tile map; improve code co…
mverch67 Feb 25, 2025
81c9e02
disable scrolling and clicking map background panel
mverch67 Feb 25, 2025
6d5aa4b
implemented gpsLock persistency
mverch67 Feb 25, 2025
436f8f3
added map style selection
mverch67 Feb 26, 2025
21850ab
added standard map tile set
mverch67 Feb 26, 2025
78714de
fix channel OK/cancel button
mverch67 Feb 26, 2025
d756500
fix movement of underlying settings panel
mverch67 Feb 26, 2025
960355f
map: don't draw labels based on objectsOnMap for now
mverch67 Feb 26, 2025
d75697b
map: hide gps button when no gps present
mverch67 Feb 26, 2025
0b09bc7
added two more map style sets
mverch67 Feb 26, 2025
d96a13a
fix priv/pub key reversal
mverch67 Feb 26, 2025
ca18394
fix username dialog
mverch67 Feb 26, 2025
e5dff4d
BT programming mode at reboot page
mverch67 Feb 26, 2025
7968aaf
Update issue templates
mverch67 Feb 27, 2025
6b5e3ff
Update feature template
mverch67 Feb 27, 2025
b16de25
fix T-HMI linker error SD_MMC
mverch67 Feb 27, 2025
fc1f6e5
add dark style tiles to the map startup-kit
mverch67 Feb 27, 2025
d6b11f5
style: Update Greek (el) translations and align with English entries …
iliaschat Feb 27, 2025
bd0bf26
Update LGFX_ELECROW70.h
mverch67 Feb 28, 2025
db15b4c
Added map tile instructions and attribution
mverch67 Feb 28, 2025
1e45be0
fix links
mverch67 Feb 28, 2025
697942a
fix links again
mverch67 Feb 28, 2025
f871f1a
mention tile calculator
mverch67 Feb 28, 2025
ff558be
typos
mverch67 Feb 28, 2025
16e7b9e
Update maps credits README.md (#55)
joyel24 Feb 28, 2025
8af4d85
ignore project files
mverch67 Feb 28, 2025
2a5a66b
studio project
mverch67 Feb 28, 2025
a169f42
imperial units support (#56)
mverch67 Feb 28, 2025
f4f5774
fix locked UI when screenTimeout is 0
mverch67 Feb 28, 2025
2b7963a
Update maps README.md - thanks to teddy1602 (#59)
joyel24 Mar 1, 2025
ee74dd3
disable wifi before entering BT programming mode (#60)
mverch67 Mar 1, 2025
9df1841
fix ack for channel (#63)
mverch67 Mar 1, 2025
1ebe2c6
feat: set fixed_position using MUI map home position (#65)
mverch67 Mar 2, 2025
4d83882
fix: Update Swedish translation file (#44)
ThatKalle Mar 2, 2025
f2d00dc
updated translations; shortened string for map not found
mverch67 Mar 2, 2025
9b77218
fix node resize animation (#66)
mverch67 Mar 2, 2025
8a60d16
PIO: Changes so srcfilter doesn't have to be used in `firmware`
vidplace7 Mar 1, 2025
39496bd
Use extraScript to select views / portduino
vidplace7 Mar 4, 2025
a60048d
Update TFTView_320x240.cpp
mverch67 Mar 5, 2025
9f0a346
Replace srcFilter, set srcDir, includeDir. Add Thread dependency
vidplace7 Mar 5, 2025
af75da4
fix frequency display (#75)
mverch67 Mar 6, 2025
c39d746
fix locked reboot screen (#76)
mverch67 Mar 6, 2025
2f5118b
chore: Setup Dependabot, Trunk Upgrades, and trunk fmt Actions (#74)
vidplace7 Mar 7, 2025
2c835bb
Update ArduinoThread (#78)
vidplace7 Mar 8, 2025
56b429e
feat: exFat (#79)
mverch67 Mar 10, 2025
a9a9950
Update README.md
mverch67 Mar 10, 2025
0ec2a7b
Update README.md
mverch67 Mar 10, 2025
6828875
SdFat: fix compiler error
mverch67 Mar 10, 2025
cec6769
fix for targets without SDCard
mverch67 Mar 10, 2025
392d738
Upgrade trunk (#80)
github-actions[bot] Mar 11, 2025
2a6da44
increase max queue size (due to SdFat blocking)
mverch67 Mar 11, 2025
0e51dcf
Upgrade trunk to 1.22.11 (#83)
github-actions[bot] Mar 14, 2025
569d5a2
fix: no.yml (#77)
idarlund Mar 14, 2025
a9a3dd3
fix: wifi button behavior (#89)
mverch67 Mar 15, 2025
ee7dd48
fix bell & sound if ringtone is custom/default
mverch67 Mar 15, 2025
da2ef7f
ukrainian laguage support
mverch67 Mar 15, 2025
43b8568
feat: add Ukrainian translation (#88)
krant Mar 15, 2025
e01a1bf
fix SD_MMC
mverch67 Mar 17, 2025
beae910
fix compile error
mverch67 Mar 17, 2025
b1e8d1b
fix: map style dropdown (#91)
mverch67 Mar 17, 2025
01ad507
Upgrade trunk (#90)
github-actions[bot] Mar 18, 2025
2b3910a
Upgrade trunk (#95)
github-actions[bot] Mar 19, 2025
bb8835d
added cmake + doctest (#97)
mverch67 Mar 19, 2025
3ff5352
fix: Compiler warnings (#98)
mverch67 Mar 19, 2025
9873052
update-lvgl (#99)
mverch67 Mar 19, 2025
a7f401c
vscode: disable ctest integration, enable TestMate integration
mverch67 Mar 19, 2025
bc9affd
update extension recommendations
mverch67 Mar 19, 2025
8204a30
Upgrade trunk (#100)
github-actions[bot] Mar 22, 2025
3d2801e
fix: map scrolling (#101)
mverch67 Mar 23, 2025
4ddd65d
fix negative index
mverch67 Mar 24, 2025
703d3c7
Upgrade trunk (#103)
github-actions[bot] Mar 24, 2025
c17ff45
increase cache size and screen buffer (#104)
mverch67 Mar 24, 2025
7c9cf7d
feat: Add short ringtones (#94)
j6k4m8 Mar 25, 2025
3bcca5b
chore: Add Netherlands tiles torrent link (#69)
joyel24 Mar 25, 2025
e16b106
let UNKNOWN_PUBKEY error mark sent message as failed
mverch67 Mar 28, 2025
9c73b3e
add stack protector to cope with array index issues of touch driver (…
mverch67 Mar 28, 2025
96f60c8
fix BT programming mode
mverch67 Mar 28, 2025
c85ce6c
revert stack protection
mverch67 Mar 28, 2025
a0bc3ec
customizable boot logo (#108)
mverch67 Mar 29, 2025
d546069
feat: node list <-> map navigation (#109)
mverch67 Mar 29, 2025
c9c0659
git archive zip references
mverch67 Mar 30, 2025
8f286d8
filter location pins according node filtering (#111)
mverch67 Mar 30, 2025
cb646ec
Upgrade trunk (#105)
github-actions[bot] Mar 30, 2025
fa1109c
fix BT icon on boot screen
mverch67 Apr 1, 2025
1516c28
Update README
mverch67 Apr 6, 2025
fd79122
message panel keyboard placement and animation (#116)
mverch67 Apr 9, 2025
4740535
sd card errors
mverch67 Apr 10, 2025
5f0273a
fix linker error native-tft
mverch67 Apr 11, 2025
ae223e9
fix T-HMI compile error
mverch67 Apr 11, 2025
5081fe1
Upgrade trunk to 1.22.12 (#112)
github-actions[bot] Apr 11, 2025
e03cbc1
show node on chat clicked (#117)
mverch67 Apr 12, 2025
7a8c84e
WT32-SC01 support
mverch67 Apr 14, 2025
704eb85
fix warning
mverch67 Apr 15, 2025
a757dd3
SD soft SPI support
mverch67 Apr 15, 2025
f32424e
imperial environment metrics
mverch67 Apr 18, 2025
e8c03f3
fix locations counter
mverch67 Apr 18, 2025
0d0f6a5
Upgrade trunk (#118)
github-actions[bot] Apr 18, 2025
42d31d1
fix object location counter
mverch67 Apr 23, 2025
654a414
fix button in LGFX_WT_SC01PLUS.h
mverch67 Apr 27, 2025
5d15808
feat: Linux frame buffer support (#124)
mverch67 Apr 30, 2025
a79e592
elecrow lgfx support
mverch67 Apr 30, 2025
31b783d
Upgrade trunk (#120)
github-actions[bot] Apr 30, 2025
5e58f84
try-fix blank map tiles
mverch67 May 3, 2025
cf170c1
revert deletion of FB in commit 5eae5d3
mverch67 May 6, 2025
c33b435
Upgrade trunk to 1.22.15 (#125)
github-actions[bot] May 6, 2025
cad6097
calc default channel; keep channel_num if UNSET (#127)
mverch67 May 10, 2025
e4625dc
Upgrade trunk (#126)
github-actions[bot] May 10, 2025
abe3ae2
trunk fmt
mverch67 May 10, 2025
575c27f
alternative backlight control (elecrow)
mverch67 May 10, 2025
9338e40
handle routing error NO_INTERFACE
mverch67 May 10, 2025
e450f33
Upgrade trunk (#128)
github-actions[bot] May 17, 2025
ecff021
router-late (#131)
mverch67 May 18, 2025
be65984
fix roles
mverch67 May 19, 2025
e882dfb
feat: ethernet client support for MUI (#129)
mverch67 May 22, 2025
8023ccc
fix bluetooth fixedPin during restart (#135)
mverch67 May 24, 2025
ea451d4
allow revert to formet UI
mverch67 May 24, 2025
cf4c551
fix display mode setting
mverch67 May 25, 2025
acad977
enabled backup/restore if card is detected; fix warnings
mverch67 May 25, 2025
fe655eb
enable BT before reverting to oled style UI
mverch67 May 25, 2025
81a26e7
lvgl driver initial draft
mverch67 Jan 25, 2025
f442307
lvgl driver class structures completed
mverch67 Jan 26, 2025
469cd5a
SPI bus implementation
mverch67 May 26, 2025
92c26fb
Merge branch 'master' into lvgl-driver
mverch67 May 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#ifdef LGFX_DRIVER
#include "LovyanGFX.h"
#include "graphics/driver/DisplayDriverConfig.h"
#include "graphics/driver/TFTDriver.h"
Expand Down Expand Up @@ -465,3 +466,5 @@ template <class LGFX> void LGFXDriver<LGFX>::printConfig(void)
ILOG_DEBUG("BL pin assigned");
}
}

#endif
17 changes: 17 additions & 0 deletions include/graphics/LGFX/LGFX_GENERIC.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* build_flags =
* -D LGFX_DRIVER_TEMPLATE
* -D LGFX_DRIVER=LGFX_GENERIC
* -D GFX_DRIVER_INC=\"graphics/LGFX/LGFX_GENERIC.h\"
* -D LGFX_PANEL=ST7789
* -D LGFX_TOUCH=XPT2046
* -D LGFX_INVERT_COLOR=true
Expand All @@ -30,6 +31,8 @@
*/

#define LGFX_USE_V1
#include "hal/gpio_types.h"
#include "util/ILog.h"
#include <LovyanGFX.hpp>

#ifndef SPI_FREQUENCY
Expand Down Expand Up @@ -206,6 +209,20 @@ class LGFX_GENERIC : public lgfx::LGFX_Device

bool hasButton(void) { return false; }

bool init_impl(bool use_reset, bool use_clear) override
{
// increase output power to SPI GPIOs to be able to run with higher frequency
if (LGFX_PIN_SCK >= 0) {
gpio_set_direction((gpio_num_t)LGFX_PIN_SCK, GPIO_MODE_OUTPUT);
gpio_set_drive_capability((gpio_num_t)LGFX_PIN_SCK, GPIO_DRIVE_CAP_3);
}
if (LGFX_PIN_MOSI >= 0) {
gpio_set_direction((gpio_num_t)LGFX_PIN_SCK, GPIO_MODE_OUTPUT);
gpio_set_drive_capability((gpio_num_t)LGFX_PIN_MOSI, GPIO_DRIVE_CAP_3);
}
return lgfx::LGFX_Device::init_impl(use_reset, use_clear);
}

LGFX_GENERIC(void)
{
{
Expand Down
41 changes: 41 additions & 0 deletions include/graphics/LVGL/LVGLConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once

#include "graphics/LVGL/LVGLDriver.h"
#include "graphics/LVGL/LVGLSpiBusDriver.h"
#include "graphics/driver/DisplayDriverConfig.h"
#include "lvgl.h"
#include "strings.h"
#include "util/ILog.h"

class DisplayDeviceDriver;

/**
* @brief Runtime configuration class for lvgl driver
*
*/
class LVGLConfig
{
public:
uint16_t screenWidth = 0;
uint16_t screenHeight = 0;

LVGLConfig(void);
LVGLConfig(const DisplayDriverConfig &cfg);
void init(void);
lv_display_t *create(uint32_t hor_res, uint32_t ver_res);
void touchpad_read(lv_indev_t *indev_driver, lv_indev_data_t *data);

bool hasButton(void);
bool hasTouch(void);
bool light(void);

uint8_t getBrightness(void);
void setBrightness(uint8_t setBrightness);

~LVGLConfig();

protected:
private:
const DisplayDriverConfig *config;
DisplayDeviceDriver *lvglDeviceDriver;
};
130 changes: 130 additions & 0 deletions include/graphics/LVGL/LVGLDriver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#pragma once

#ifdef LVGL_DRIVER
#include "drivers/display/lcd/lv_lcd_generic_mipi.h"
#include "graphics/driver/DisplayDriverConfig.h"
#include "graphics/driver/TFTDriver.h"
#include "input/InputDriver.h"
#include "util/ILog.h"

/**
* Base class for all specific LVGL drivers classes
*/
template <class LVGL> class LVGLDriver : public TFTDriver<LVGL>
{
public:
const uint32_t defaultScreenTimeout = 60 * 1000;
const uint32_t defaultScreenLockTimeout = 5 * 1000;
const uint32_t defaultBrightness = 153;

LVGLDriver(uint16_t width, uint16_t height);
LVGLDriver(const DisplayDriverConfig &cfg);
void init(DeviceGUI *gui) override;
bool hasTouch(void) override;
bool hasButton(void) override { return lvgldriver->hasButton(); }
bool hasLight(void) override { return lvgldriver->light(); }
bool isPowersaving(void) override { return powerSaving; }
void task_handler(void) override;

uint8_t getBrightness(void) override { return lvgldriver->getBrightness(); }
void setBrightness(uint8_t brightness) override {} // TODO

uint16_t getScreenTimeout() override { return screenTimeout / 1000; }
void setScreenTimeout(uint16_t timeout) override { screenTimeout = timeout * 1000; };

~LVGLDriver() { delete lvgldriver; }

protected:
void init_lvgl(void);
static void touchpad_read(lv_indev_t *indev_driver, lv_indev_data_t *data)
{
return lvgldriver->touchpad_read(indev_driver, data);
}

uint32_t screenTimeout;
uint32_t lastBrightness;
bool powerSaving;

private:
static LVGL *lvgldriver;
lv_display_t *display;
size_t bufsize;
std::pair<lv_color_t *, lv_color_t *> drawBuffer = {nullptr, nullptr};
};

template <class LVGL> LVGL *LVGLDriver<LVGL>::lvgldriver = nullptr;

template <class LVGL>
LVGLDriver<LVGL>::LVGLDriver(uint16_t width, uint16_t height)
: TFTDriver<LVGL>(lvgldriver ? lvgldriver : new LVGL, width, height), screenTimeout(defaultScreenTimeout),
lastBrightness(defaultBrightness), powerSaving(false), display(nullptr), bufsize(0)
{
lvgldriver = this->tft;
}

template <class LVGL>
LVGLDriver<LVGL>::LVGLDriver(const DisplayDriverConfig &cfg)
: TFTDriver<LVGL>(lvgldriver ? lvgldriver : new LVGL(cfg), cfg.width(), cfg.height()), screenTimeout(defaultScreenTimeout),
lastBrightness(defaultBrightness), powerSaving(false), display(nullptr), bufsize(0)
{
lvgldriver = this->tft;
}

template <class LVGL> void LVGLDriver<LVGL>::init(DeviceGUI *gui)
{
ILOG_DEBUG("LVGLDriver<LVGL>::init...");
init_lvgl();
TFTDriver<LVGL>::init(gui);

// LVGL: setup display device driver
ILOG_DEBUG("LVGL display driver create...");
display = lvgldriver->create(DisplayDriver::screenWidth, DisplayDriver::screenHeight);

std::pair<lv_color_t *, lv_color_t *> draw_buffers = {nullptr, nullptr};
const auto buffer_size =
DisplayDriver::screenWidth * DisplayDriver::screenHeight * lv_color_format_get_size(lv_display_get_color_format(display));

ILOG_INFO("allocating %d bytes for LVGL draw buffers", buffer_size);
// ESP_ERROR_CHECK(esp_dma_malloc(EXAMPLE_LCD_H_RES * 100 * sizeof(lv_color_t), ESP_DMA_MALLOC_FLAG_PSRAM, draw_buffers.first,
// nullptr)); ESP_ERROR_CHECK(esp_dma_malloc(EXAMPLE_LCD_H_RES * 100 * sizeof(lv_color_t), ESP_DMA_MALLOC_FLAG_PSRAM,
// draw_buffers.second, nullptr));

draw_buffers.first = (lv_color_t *)lv_malloc(buffer_size);
if (draw_buffers.first == nullptr) {
LV_LOG_ERROR("display draw buffer malloc failed");
return;
}

draw_buffers.second = (lv_color_t *)lv_malloc(buffer_size);
if (draw_buffers.second == nullptr) {
LV_LOG_ERROR("display buffer malloc failed");
lv_free(draw_buffers.first);
return;
}
lv_display_set_buffers(display, draw_buffers.first, draw_buffers.second, buffer_size, LV_DISPLAY_RENDER_MODE_PARTIAL);

if (hasTouch()) {
lv_indev_t *indev = lv_indev_create();
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(indev, touchpad_read);
lv_indev_set_display(indev, this->display);
}
}

template <class LGFX> void LVGLDriver<LGFX>::init_lvgl(void)
{
lvgldriver->init();
lvgldriver->setBrightness(defaultBrightness);
// lvgldriver->fillScreen(LGFX::color565(0x3D, 0xDA, 0x83));
}

template <class LGFX> bool LVGLDriver<LGFX>::hasTouch(void)
{
return lvgldriver->hasTouch();
}

template <class LGFX> void LVGLDriver<LGFX>::task_handler(void)
{
DisplayDriver::task_handler();
}
#endif
50 changes: 50 additions & 0 deletions include/graphics/LVGL/LVGLSpiBusDriver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#pragma once

#ifdef LVGL_DRIVER

#include "SPI.h"
#include "drivers/display/lcd/lv_lcd_generic_mipi.h"
#include "graphics/driver/DisplayDeviceDriver.h"
#include "graphics/driver/DisplayDriverConfig.h"
#include <functional>

class LVGLSpiBusDriver
{
public:
using CreateCB =
std::function<lv_display_t *(uint32_t, uint32_t, lv_lcd_flag_t, lv_lcd_send_cmd_cb_t, lv_lcd_send_color_cb_t)>;

LVGLSpiBusDriver(uint16_t width, uint16_t height, CreateCB createDisplayFunc);
void init(int16_t spiBus, int16_t sclk, int16_t mosi, int16_t miso, int16_t dc, int16_t rst, int16_t cs);
lv_display_t *create(uint32_t hor_res, uint32_t ver_res);
virtual ~LVGLSpiBusDriver()
{
if (spi)
delete spi;
}

protected:
LVGLSpiBusDriver() = default;
virtual void connect(void);

private:
LVGLSpiBusDriver(const LVGLSpiBusDriver &) = delete;
LVGLSpiBusDriver &operator=(const LVGLSpiBusDriver &) = delete;

static void lcd_send_cmd_cb(lv_display_t *disp, const uint8_t *cmd, size_t cmd_size, const uint8_t *param, size_t param_size);
static void lcd_send_color_cb(lv_display_t *disp, const uint8_t *cmd, size_t cmd_size, uint8_t *param, size_t param_size);

int8_t rst;
int8_t dc;
int8_t cs;
int8_t sclk;
int8_t mosi;
int8_t miso;
int8_t spiBus;
SPISettings spiSettings;
static SPIClass *spi;
static LVGLSpiBusDriver *instance;
CreateCB createDisplay;
};

#endif
35 changes: 35 additions & 0 deletions include/graphics/LVGL/LVGL_T_DECK.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#ifdef LVGL_DRIVER

#include "graphics/driver/LVGL_ST7789.h"
#include "lvgl.h"
#include "stdint.h"

class LVGLSpiBusDriver;

class LVGL_TDECK : public LVGL_ST7789
{
public:
static constexpr uint16_t c_screenWidth = 320;
static constexpr uint16_t c_screenHeight = 240;

LVGL_TDECK(void);
LVGL_TDECK(const DisplayDriverConfig &cfg);

void init(void) override;
bool hasButton(void) const override { return true; }
bool hasTouch(void) const override { return true; }
bool light(void) override { return true; }
uint8_t getBrightness(void) const override { return 150; }
void setBrightness(uint8_t setBrightness) override {}

void touchpad_read(lv_indev_t *indev_driver, lv_indev_data_t *data);

~LVGL_TDECK() {}

protected:
private:
};

#endif
36 changes: 36 additions & 0 deletions include/graphics/driver/DisplayDeviceDriver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

#include "lvgl.h"
#include "stdint.h"

/**
* Base class for all implemented display device drivers
*/
class DisplayDeviceDriver
{
public:
DisplayDeviceDriver(uint16_t width, uint16_t height) : screenWidth(width), screenHeight(height){};

virtual void init(void) {}
virtual lv_display_t *create(uint32_t hor_res, uint32_t ver_res) = 0;

virtual uint8_t getBrightness(void) const { return 128; }
virtual void setBrightness(uint8_t brightness) {}

virtual uint16_t getScreenTimeout() const { return 0; }
virtual void setScreenTimeout(uint16_t timeout) {}

virtual bool hasButton(void) const { return false; }
virtual bool hasTouch(void) const { return false; }
virtual bool light(void) { return false; }

virtual ~DisplayDeviceDriver(){};

protected:
const uint16_t screenWidth;
const uint16_t screenHeight;

private:
DisplayDeviceDriver(const DisplayDeviceDriver &) = delete;
DisplayDeviceDriver &operator=(const DisplayDeviceDriver &) = delete;
};
4 changes: 4 additions & 0 deletions include/graphics/driver/DisplayDriverConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class DisplayDriver;
class DisplayDriverConfig
{
public:
enum struct driver_t { LGFX, LVGL, ADAFRUIT, OTHER };

enum struct device_t {
NONE,
CUSTOM_TFT,
Expand All @@ -40,6 +42,7 @@ class DisplayDriverConfig

struct panel_config_t {
char *type = nullptr;
driver_t driver = driver_t::LGFX;
uint16_t panel_width = 0;
uint16_t panel_height = 0;
bool rotation = false;
Expand Down Expand Up @@ -166,6 +169,7 @@ class DisplayDriverConfig
private:
friend class DisplayDriverFactory;
friend class LGFXConfig;
friend class LVGLConfig;

enum device_t _device;
panel_config_t _panel;
Expand Down
Loading
Loading