Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bbdb42b
gui for scene selection
KlausMu Mar 25, 2024
49ea6b3
renamed scene__defaultKeys to scene__default
KlausMu Mar 25, 2024
55a6020
increased timer until scene is activated
KlausMu Mar 30, 2024
2c30a22
run sudo apt update in Ubuntu build
KlausMu Mar 30, 2024
ad574d0
Merge branch 'main' into lvgl_9.1
KlausMu Apr 5, 2024
e15fed9
switched to lvgl 9.1
KlausMu Apr 8, 2024
e6e751c
Merge branch 'main' into lvgl_9.1
KlausMu Apr 11, 2024
87f1fde
changes needed for lvgl 9
KlausMu Apr 11, 2024
274dd72
Merge branch 'main' into lvgl_9.1
KlausMu Apr 16, 2024
a2c0b0b
Merge branch 'main' into lvgl_9.1
KlausMu May 9, 2024
21b7154
Merge branch 'main' into lvgl_9.1
KlausMu May 10, 2024
46422b1
Merge branch 'main' into lvgl_9.1
KlausMu May 26, 2024
38e6cc7
Merge branch 'main' into lvgl_9.1
KlausMu Jun 9, 2024
f64d3b6
Merge branch 'main' into lvgl_9.1
KlausMu Jun 22, 2024
d5aafe9
Merge branch 'main' into lvgl_9.1
KlausMu Jul 12, 2024
c62d04f
Merge branch 'main' into lvgl_9.1
KlausMu Jul 12, 2024
3129236
update of main_boardtest.cpp to lvgl 9.1
KlausMu Jul 12, 2024
2c26f13
Merge branch 'main' into lvgl_9.1
KlausMu Sep 28, 2024
e5fee87
changes needed by lvgl 9.2
KlausMu Sep 28, 2024
8ec5fe4
Merge branch 'main' into lvgl_9.1
KlausMu Nov 9, 2024
f3ac819
Merge branch 'main' into lvgl_9.1
KlausMu Dec 7, 2024
1d8a4c2
Merge branch 'main' into lvgl_9.1
KlausMu Dec 7, 2024
f7c9f62
Merge branch 'main' into lvgl_9.1
KlausMu Dec 7, 2024
d416475
keypad for simulator in lvgl 9.2
KlausMu Dec 12, 2024
a1b519d
LG TV add Power ON/OFF and HDMI4
KlausMu Dec 12, 2024
780d270
Merge branch 'main' into lvgl_9.1
KlausMu Dec 12, 2024
7bae7ec
Merge branch 'main' into lvgl_9.1
KlausMu Dec 13, 2024
3d04873
Simulator: use SDL_GetTicks64()
KlausMu Dec 13, 2024
4f45ed4
Merge branch 'main' into lvgl_9.1
KlausMu Dec 14, 2024
a8ed89d
Merge branch 'main' into lvgl_9.1
KlausMu Dec 16, 2024
1f55d42
gui_BLEpairing with lvgl 9.2
KlausMu Dec 16, 2024
f3728e7
Merge branch 'main' into lvgl_9.1
KlausMu Dec 24, 2024
129b682
Merge branch 'main' into lvgl_9.1
KlausMu Dec 24, 2024
9557563
fixed wrong my_touchpad_read
KlausMu Dec 24, 2024
994d20d
Merge branch 'main' into lvgl_9.1
KlausMu Dec 24, 2024
dcca8c3
Merge branch 'main' into lvgl_9.1
KlausMu Dec 25, 2024
d89df14
Merge branch 'main' into lvgl_9.1
KlausMu Dec 27, 2024
e836674
Merge branch 'main' into lvgl_9.1
KlausMu Mar 2, 2025
e58a972
bugfix for touch in boardtest
KlausMu Mar 3, 2025
af63a3b
lvgl 9.x: LV_SPRINTF_USE_FLOAT replaced with LV_USE_FLOAT
KlausMu Mar 3, 2025
4c5b7ad
Merge branch 'main' into lvgl_9.x
KlausMu Mar 29, 2025
e28213c
Merge branch 'main' into lvgl_9.x
KlausMu Mar 29, 2025
77fdd5b
small change for lvgl 9.x
KlausMu Mar 29, 2025
c8e42f6
Merge branch 'main' into lvgl_9.x
KlausMu Mar 31, 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
79 changes: 42 additions & 37 deletions Platformio/hardware/ESP32/boardtest/main_boardtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ enum Wakeup_reasons{WAKEUP_BY_RESET, WAKEUP_BY_IMU, WAKEUP_BY_KEYPAD};

// LVGL declarations ------------------------------------------------------------------------------
// we either show the checksTable with the test results, or an empty screen where all touches are shown as red dots
static lv_disp_draw_buf_t draw_buf;
lv_obj_t* checksTable;
lv_obj_t* touchScreen;

Expand Down Expand Up @@ -287,34 +286,34 @@ static void show_touches_cb(lv_event_t * e) {
if (!show_touches) {
// create new screen, only showing touches
touchScreen = lv_obj_create(NULL);
lv_scr_load(touchScreen);
lv_screen_load(touchScreen);

show_touches = true;
}
}
}

// Display flushing
void my_disp_flush( lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p ){
uint32_t w = ( area->x2 - area->x1 + 1 );
uint32_t h = ( area->y2 - area->y1 + 1 );
static void my_disp_flush( lv_display_t *disp, const lv_area_t *area, uint8_t *px_map ) {
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);

tft.startWrite();
tft.setAddrWindow( area->x1, area->y1, w, h );
tft.setAddrWindow(area->x1, area->y1, w, h);
// single buffer bufA
// tft.pushPixels((uint16_t*)&color_p->full, w * h, true);
// tft.pushColors((uint16_t *)px_map, w * h, true);
// double buffer bufA and bufB
tft.pushPixelsDMA( ( uint16_t * )&color_p->full, w * h);
tft.pushPixelsDMA((uint16_t*)px_map, w * h);
tft.endWrite();

lv_disp_flush_ready( disp );
lv_display_flush_ready(disp);
}

// Read the touchpad
void my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) {
static void my_touchpad_read(lv_indev_t *indev_driver, lv_indev_data_t *data) {
uint16_t x, y;
if (tft.getTouch(&x, &y)) {
data->state = LV_INDEV_STATE_PR;
data->state = LV_INDEV_STATE_PRESSED;
data->point.x = x;
data->point.y = y;

Expand All @@ -331,7 +330,7 @@ void my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) {
lv_table_set_cell_value_fmt(checksTable, 8, 1, "%" LV_PRIu32, count_touches);

} else {
data->state = LV_INDEV_STATE_REL;
data->state = LV_INDEV_STATE_RELEASED;
}
}

Expand Down Expand Up @@ -522,6 +521,10 @@ void WiFiEvent(WiFiEvent_t event){
}
#endif

static uint32_t my_tick_get_cb(void) {
return millis();
}

// Setup ----------------------------------------------------------------------------------------------------------------------------------

int fuelGaugeInitSuccessful = false;
Expand Down Expand Up @@ -656,38 +659,40 @@ void setup() {
tft.setSwapBytes(true);

// setup LVGL -----------------------------------------------------------------------------------
// Double buffer
lv_color_t * bufA = (lv_color_t *) malloc(sizeof(lv_color_t) * SCR_WIDTH * SCR_HEIGHT / 10);
lv_color_t * bufB = (lv_color_t *) malloc(sizeof(lv_color_t) * SCR_WIDTH * SCR_HEIGHT / 10);
lv_disp_draw_buf_init( &draw_buf, bufA, bufB, SCR_WIDTH * SCR_HEIGHT / 10 );

// Initialize the display driver
static lv_disp_drv_t disp_drv;
lv_disp_drv_init( &disp_drv );
disp_drv.hor_res = SCR_WIDTH;
disp_drv.ver_res = SCR_HEIGHT;
disp_drv.flush_cb = my_disp_flush;
disp_drv.draw_buf = &draw_buf;
lv_disp_drv_register( &disp_drv );
// new in lvgl 9
lv_tick_set_cb(my_tick_get_cb);

/*LVGL draw into this buffer, 1/10 screen size usually works well. The size is in bytes*/
#define DRAW_BUF_SIZE (SCR_WIDTH * SCR_HEIGHT / 10 * (LV_COLOR_DEPTH / 8))

// https://github.com/lvgl/lvgl/blob/release/v9.0/docs/CHANGELOG.rst#display-api
// https://docs.lvgl.io/master/get-started/quick-overview.html#add-lvgl-into-your-project
lv_display_t *disp = lv_display_create(SCR_WIDTH, SCR_HEIGHT);
lv_display_set_flush_cb(disp, my_disp_flush);

// https://github.com/lvgl/lvgl/blob/release/v9.0/docs/CHANGELOG.rst#migration-guide
// lv_display_set_buffers(display, buf1, buf2, buf_size_byte, mode) is more or less the equivalent of lv_disp_draw_buf_init(&draw_buf_dsc, buf1, buf2, buf_size_px) from v8, however in v9 the buffer size is set in bytes.
uint8_t *bufA = (uint8_t *) malloc(DRAW_BUF_SIZE);
uint8_t *bufB = (uint8_t *) malloc(DRAW_BUF_SIZE);
lv_display_set_buffers(disp, bufA, bufB, DRAW_BUF_SIZE, LV_DISPLAY_RENDER_MODE_PARTIAL);

// Initialize the touchscreen driver
static lv_indev_drv_t indev_drv;
lv_indev_drv_init( &indev_drv );
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = my_touchpad_read;
lv_indev_drv_register( &indev_drv );
// https://github.com/lvgl/lvgl/blob/release/v9.0/docs/CHANGELOG.rst#indev-api
static lv_indev_t * indev = lv_indev_create();
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(indev, my_touchpad_read);

// create GUI content ---------------------------------------------------------------------------
// Set the background color
lv_obj_set_style_bg_color(lv_scr_act(), lv_color_black(), LV_PART_MAIN);
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_black(), LV_PART_MAIN);

// we either show the checksTable with the test results, or an empty screen where all touches are shown as red dots

// Table showing the check results
checksTable = lv_table_create(lv_scr_act());
lv_table_set_col_width(checksTable, 0, 157);
lv_table_set_col_width(checksTable, 1, 80);
lv_table_set_col_cnt(checksTable, 2);
checksTable = lv_table_create(lv_screen_active());
lv_table_set_column_width(checksTable, 0, 157);
lv_table_set_column_width(checksTable, 1, 80);
lv_table_set_column_count(checksTable, 2);
lv_obj_remove_style(checksTable, NULL, LV_PART_ITEMS | LV_STATE_PRESSED);
lv_obj_set_style_pad_top(checksTable, 5, LV_PART_ITEMS);
lv_obj_set_style_pad_bottom(checksTable, 5, LV_PART_ITEMS);
Expand Down Expand Up @@ -715,15 +720,15 @@ void setup() {
lv_table_set_cell_value_fmt(checksTable, 9, 1, "%.1f", 0.001f * (float)standbyTimer);

// restart button
lv_obj_t * btnRestart = lv_btn_create(lv_scr_act());
lv_obj_t * btnRestart = lv_button_create(lv_screen_active());
lv_obj_add_event_cb(btnRestart, esp32_restart_cb, LV_EVENT_ALL, NULL);
lv_obj_align(btnRestart, LV_ALIGN_BOTTOM_MID, -74, -15);
lv_obj_t * labelRestart = lv_label_create(btnRestart);
lv_label_set_text(labelRestart, "restart");
lv_obj_center(labelRestart);

// show touch hits
lv_obj_t * btnShowTouches = lv_btn_create(lv_scr_act());
lv_obj_t * btnShowTouches = lv_button_create(lv_screen_active());
lv_obj_add_event_cb(btnShowTouches, show_touches_cb, LV_EVENT_ALL, NULL);
lv_obj_align(btnShowTouches, LV_ALIGN_BOTTOM_MID, 43, -15);
lv_obj_t * labelShowTouches = lv_label_create(btnShowTouches);
Expand Down
65 changes: 35 additions & 30 deletions Platformio/hardware/ESP32/lvgl_hal_esp32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@
#include "sleep_hal_esp32.h"

// -----------------------
// https://docs.lvgl.io/8.3/porting/display.html?highlight=lv_disp_draw_buf_init#buffering-modes
// https://docs.lvgl.io/master/porting/display.html#two-buffers
// With two buffers, the rendering and refreshing of the display become parallel operations
// Second buffer needs 15.360 bytes more memory in heap.
#define useTwoBuffersForlvgl

// Display flushing
void my_disp_flush( lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p ){
uint32_t w = ( area->x2 - area->x1 + 1 );
uint32_t h = ( area->y2 - area->y1 + 1 );
static void my_disp_flush( lv_display_t *disp, const lv_area_t *area, uint8_t *px_map ) {
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);

tft.startWrite();
tft.setAddrWindow(area->x1, area->y1, w, h);
#ifdef useTwoBuffersForlvgl
tft.pushPixelsDMA((uint16_t*)&color_p->full, w * h);
tft.pushPixelsDMA((uint16_t*)px_map, w * h);
#else
tft.pushColors((uint16_t*)&color_p->full, w * h, true);
tft.pushColors((uint16_t *)px_map, w * h, true);
#endif
tft.endWrite();

lv_disp_flush_ready( disp );
lv_display_flush_ready(disp);
}

// Read the touchpad
void my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) {
static void my_touchpad_read(lv_indev_t *indev_driver, lv_indev_data_t *data) {
uint16_t x, y;
if (tft.getTouch(&x, &y)) {
data->state = LV_INDEV_STATE_PR;
data->state = LV_INDEV_STATE_PRESSED;
data->point.x = x;
data->point.y = y;
setLastActivityTimestamp_HAL();
Expand All @@ -38,39 +38,44 @@ void my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) {
//tft.drawFastHLine(0, y, SCR_WIDTH, TFT_RED);
//tft.drawFastVLine(x, 0, SCR_HEIGHT, TFT_RED);
} else {
data->state = LV_INDEV_STATE_REL;
data->state = LV_INDEV_STATE_RELEASED;
}
}

static lv_disp_draw_buf_t draw_buf;
/*LVGL draw into this buffer, 1/10 screen size usually works well. The size is in bytes*/
#define DRAW_BUF_SIZE (SCR_WIDTH * SCR_HEIGHT / 10 * (LV_COLOR_DEPTH / 8))

static uint32_t my_tick_get_cb(void) {
return millis();
}

void init_lvgl_HAL() {
// first init TFT
init_tft();

// new in lvgl 9
lv_tick_set_cb(my_tick_get_cb);

// https://github.com/lvgl/lvgl/blob/release/v9.0/docs/CHANGELOG.rst#display-api
// https://docs.lvgl.io/master/get-started/quick-overview.html#add-lvgl-into-your-project
lv_display_t *disp = lv_display_create(SCR_WIDTH, SCR_HEIGHT);
lv_display_set_flush_cb(disp, my_disp_flush);

// https://github.com/lvgl/lvgl/blob/release/v9.0/docs/CHANGELOG.rst#migration-guide
// lv_display_set_buffers(display, buf1, buf2, buf_size_byte, mode) is more or less the equivalent of lv_disp_draw_buf_init(&draw_buf_dsc, buf1, buf2, buf_size_px) from v8, however in v9 the buffer size is set in bytes.
#ifdef useTwoBuffersForlvgl
lv_color_t * bufA = (lv_color_t *) malloc(sizeof(lv_color_t) * SCR_WIDTH * SCR_HEIGHT / 10);
lv_color_t * bufB = (lv_color_t *) malloc(sizeof(lv_color_t) * SCR_WIDTH * SCR_HEIGHT / 10);
lv_disp_draw_buf_init(&draw_buf, bufA, bufB, SCR_WIDTH * SCR_HEIGHT / 10);
uint8_t *bufA = (uint8_t *) malloc(DRAW_BUF_SIZE);
uint8_t *bufB = (uint8_t *) malloc(DRAW_BUF_SIZE);
lv_display_set_buffers(disp, bufA, bufB, DRAW_BUF_SIZE, LV_DISPLAY_RENDER_MODE_PARTIAL);
#else
lv_color_t * bufA = (lv_color_t *) malloc(sizeof(lv_color_t) * SCR_WIDTH * SCR_HEIGHT / 10);
lv_disp_draw_buf_init(&draw_buf, bufA, NULL, SCR_WIDTH * SCR_HEIGHT / 10);
uint8_t *bufA = (uint8_t *) malloc(DRAW_BUF_SIZE);
lv_display_set_buffers(disp, bufA, NULL, DRAW_BUF_SIZE, LV_DISPLAY_RENDER_MODE_PARTIAL);
#endif

// Initialize the display driver --------------------------------------------------------------------------
static lv_disp_drv_t disp_drv;
lv_disp_drv_init( &disp_drv );
disp_drv.hor_res = SCR_WIDTH;
disp_drv.ver_res = SCR_HEIGHT;
disp_drv.flush_cb = my_disp_flush;
disp_drv.draw_buf = &draw_buf;
lv_disp_drv_register( &disp_drv );

// Initialize the touchscreen driver
static lv_indev_drv_t indev_drv;
lv_indev_drv_init( &indev_drv );
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = my_touchpad_read;
lv_indev_drv_register( &indev_drv );
// https://github.com/lvgl/lvgl/blob/release/v9.0/docs/CHANGELOG.rst#indev-api
static lv_indev_t * indev = lv_indev_create();
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(indev, my_touchpad_read);

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ long HeapUsed()
#elif defined(__linux__) || defined(__APPLE__)
long HeapUsed() {
// don't know how to get used heap size in linux
return 800000;
return 80000;
}
#endif

Expand Down
Loading