Performance improvements (#203)

- Use DMA buffers for drawing
- Fix for draw buffer sizes
- Reduced rendering refresh interval
- Removed custom icons from wifi app to fix scroll performance issue
This commit is contained in:
Ken Van Hoeylandt 2025-02-02 23:02:50 +01:00 committed by GitHub
parent c0f4738abe
commit 5ec96f60f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 47 additions and 56 deletions

View File

@ -15,7 +15,7 @@
#define TWODOTFOUR_LCD_VERTICAL_RESOLUTION 320
#define TWODOTFOUR_LCD_BITS_PER_PIXEL 16
#define TWODOTFOUR_LCD_DRAW_BUFFER_HEIGHT (TWODOTFOUR_LCD_VERTICAL_RESOLUTION / 10)
#define TWODOTFOUR_LCD_DRAW_BUFFER_SIZE (TWODOTFOUR_LCD_HORIZONTAL_RESOLUTION * TWODOTFOUR_LCD_DRAW_BUFFER_HEIGHT * (TWODOTFOUR_LCD_BITS_PER_PIXEL / 8))
#define TWODOTFOUR_LCD_DRAW_BUFFER_SIZE (TWODOTFOUR_LCD_HORIZONTAL_RESOLUTION * TWODOTFOUR_LCD_DRAW_BUFFER_HEIGHT)
#define TWODOTFOUR_LCD_PIN_CS GPIO_NUM_15
#define TWODOTFOUR_LCD_PIN_DC GPIO_NUM_2

View File

@ -138,8 +138,8 @@ bool TdeckDisplay::start() {
.io_handle = ioHandle,
.panel_handle = panelHandle,
.control_handle = nullptr,
.buffer_size = TDECK_LCD_HORIZONTAL_RESOLUTION * TDECK_LCD_DRAW_BUFFER_HEIGHT * (TDECK_LCD_BITS_PER_PIXEL / 8),
.double_buffer = true, // Disable to free up SPIRAM
.buffer_size = TDECK_LCD_HORIZONTAL_RESOLUTION * TDECK_LCD_DRAW_BUFFER_HEIGHT,
.double_buffer = false, // Disable to free up memory
.trans_size = 0,
.hres = TDECK_LCD_HORIZONTAL_RESOLUTION,
.vres = TDECK_LCD_VERTICAL_RESOLUTION,
@ -151,8 +151,8 @@ bool TdeckDisplay::start() {
},
.color_format = LV_COLOR_FORMAT_RGB565,
.flags = {
.buff_dma = false,
.buff_spiram = true,
.buff_dma = true,
.buff_spiram = false,
.sw_rotate = false,
.swap_bytes = false,
.full_refresh = false,

View File

@ -73,7 +73,7 @@ bool Core2Display::start() {
.panel_handle = panelHandle,
.control_handle = nullptr,
.buffer_size = CORE2_LCD_DRAW_BUFFER_SIZE,
.double_buffer = true,
.double_buffer = false,
.trans_size = 0,
.hres = CORE2_LCD_HORIZONTAL_RESOLUTION,
.vres = CORE2_LCD_VERTICAL_RESOLUTION,
@ -85,8 +85,8 @@ bool Core2Display::start() {
},
.color_format = LV_COLOR_FORMAT_RGB565,
.flags = {
.buff_dma = false,
.buff_spiram = true,
.buff_dma = true,
.buff_spiram = false,
.sw_rotate = false,
.swap_bytes = true,
.full_refresh = false,

View File

@ -8,4 +8,4 @@
#define CORE2_LCD_VERTICAL_RESOLUTION 240
#define CORE2_LCD_BITS_PER_PIXEL 16
#define CORE2_LCD_DRAW_BUFFER_HEIGHT (CORE2_LCD_VERTICAL_RESOLUTION / 10)
#define CORE2_LCD_DRAW_BUFFER_SIZE (CORE2_LCD_HORIZONTAL_RESOLUTION * CORE2_LCD_DRAW_BUFFER_HEIGHT * (CORE2_LCD_BITS_PER_PIXEL / 8))
#define CORE2_LCD_DRAW_BUFFER_SIZE (CORE2_LCD_HORIZONTAL_RESOLUTION * CORE2_LCD_DRAW_BUFFER_HEIGHT)

View File

@ -93,7 +93,7 @@ bool CoreS3Display::start() {
.panel_handle = panelHandle,
.control_handle = nullptr,
.buffer_size = CORES3_LCD_DRAW_BUFFER_SIZE,
.double_buffer = true,
.double_buffer = false,
.trans_size = 0,
.hres = CORES3_LCD_HORIZONTAL_RESOLUTION,
.vres = CORES3_LCD_VERTICAL_RESOLUTION,
@ -105,8 +105,8 @@ bool CoreS3Display::start() {
},
.color_format = LV_COLOR_FORMAT_RGB565,
.flags = {
.buff_dma = false,
.buff_spiram = true,
.buff_dma = true,
.buff_spiram = false,
.sw_rotate = false,
.swap_bytes = true,
.full_refresh = false,

View File

@ -8,4 +8,4 @@
#define CORES3_LCD_VERTICAL_RESOLUTION 240
#define CORES3_LCD_BITS_PER_PIXEL 16
#define CORES3_LCD_DRAW_BUFFER_HEIGHT (CORES3_LCD_VERTICAL_RESOLUTION / 10)
#define CORES3_LCD_DRAW_BUFFER_SIZE (CORES3_LCD_HORIZONTAL_RESOLUTION * CORES3_LCD_DRAW_BUFFER_HEIGHT * (CORES3_LCD_BITS_PER_PIXEL / 8))
#define CORES3_LCD_DRAW_BUFFER_SIZE (CORES3_LCD_HORIZONTAL_RESOLUTION * CORES3_LCD_DRAW_BUFFER_HEIGHT)

View File

@ -3,8 +3,6 @@
#include "UnPhoneTouch.h"
#include <Tactility/Log.h>
#include <Tactility/TactilityCore.h>
#include "UnPhoneFeatures.h"
#include "esp_err.h"
#include "hx8357/disp_spi.h"
@ -30,15 +28,13 @@ bool UnPhoneDisplay::start() {
lv_display_set_color_format(displayHandle, LV_COLOR_FORMAT_NATIVE);
// TODO malloc to use SPIRAM
buffer1 = (uint8_t*)heap_caps_malloc(BUFFER_SIZE, MALLOC_CAP_SPIRAM);
buffer2 = (uint8_t*)heap_caps_malloc(BUFFER_SIZE, MALLOC_CAP_SPIRAM);
assert(buffer1 != nullptr);
assert(buffer2 != nullptr);
buffer = (uint8_t*)heap_caps_malloc(BUFFER_SIZE, MALLOC_CAP_DMA);
assert(buffer != nullptr);
lv_display_set_buffers(
displayHandle,
buffer1,
buffer2,
buffer,
nullptr,
BUFFER_SIZE,
LV_DISPLAY_RENDER_MODE_PARTIAL
);
@ -61,10 +57,8 @@ bool UnPhoneDisplay::stop() {
lv_display_delete(displayHandle);
displayHandle = nullptr;
heap_caps_free(buffer1);
heap_caps_free(buffer2);
buffer1 = nullptr;
buffer2 = nullptr;
heap_caps_free(buffer);
buffer = nullptr;
return true;
}

View File

@ -11,8 +11,7 @@ class UnPhoneDisplay : public tt::hal::Display {
private:
lv_display_t* displayHandle = nullptr;
uint8_t* buffer1 = nullptr;
uint8_t* buffer2 = nullptr;
uint8_t* buffer = nullptr;
public:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 505 B

View File

@ -8,6 +8,7 @@
#include <Tactility/Log.h>
#include <Tactility/service/wifi/Wifi.h>
#include <format>
#include <string>
#include <set>
@ -17,14 +18,16 @@ namespace tt::app::wifimanage {
std::shared_ptr<WifiManage> _Nullable optWifiManage();
const char* getWifiStatusIconForRssi(int rssi) {
if (rssi >= -60) {
return "signal_strong.png";
} else if (rssi >= -70) {
return "signal_medium.png";
} else {
return "signal_weak.png";
uint8_t mapRssiToPercentage(int rssi) {
auto abs_rssi = std::abs(rssi);
if (abs_rssi < 30U) {
abs_rssi = 30U;
} else if (abs_rssi > 90U) {
abs_rssi = 90U;
}
auto percentage = (float)(90U - abs_rssi) / 60.f * 100.f;
return (uint8_t)percentage;
}
static void on_enable_switch_changed(lv_event_t* event) {
@ -115,18 +118,19 @@ void View::createSsidListItem(const service::wifi::ApRecord& record, bool isConn
lv_obj_t* connecting_spinner = tt::lvgl::spinner_create(wrapper);
lv_obj_align_to(connecting_spinner, info_wrapper, LV_ALIGN_OUT_LEFT_MID, -8, 0);
} else {
const char* icon = getWifiStatusIconForRssi(record.rssi);
auto icon_path = paths->getSystemPathLvgl(icon);
lv_obj_t* rssi_image = lv_image_create(wrapper);
lv_image_set_src(rssi_image, icon_path.c_str());
lv_obj_align(rssi_image, LV_ALIGN_RIGHT_MID, -42, 0);
auto percentage = mapRssiToPercentage(record.rssi);
if (record.auth_mode != WIFI_AUTH_OPEN) {
lv_obj_t* lock_image = lv_image_create(wrapper);
auto lock = paths->getSystemPathLvgl("lock.png");
lv_image_set_src(lock_image, lock.c_str());
lv_obj_align(lock_image, LV_ALIGN_RIGHT_MID, -62, 0);
std::string auth_info;
if (record.auth_mode == WIFI_AUTH_OPEN) {
auth_info = "(open) ";
} else {
auth_info = "";
}
std::string info = std::format("{}{}%", auth_info, percentage);
lv_obj_t* open_label = lv_label_create(wrapper);
lv_label_set_text(open_label, info.c_str());
lv_obj_align(open_label, LV_ALIGN_RIGHT_MID, -42, 0);
}
}

View File

@ -38,8 +38,7 @@ CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_FLASHMODE_QIO=y
# LVGL
CONFIG_LV_DISP_DEF_REFR_PERIOD=17
CONFIG_LV_INDEV_DEF_READ_PERIOD=17
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
CONFIG_LV_DPI_DEF=160
# Fix for IRAM
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y

View File

@ -47,9 +47,8 @@ CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
# SPI Flash (can set back to 80MHz after ESP-IDF bug is resolved)
CONFIG_ESPTOOLPY_FLASHFREQ_120M=y
# LVGL
CONFIG_LV_DISP_DEF_REFR_PERIOD=17
CONFIG_LV_INDEV_DEF_READ_PERIOD=17
CONFIG_LV_DPI_DEF=139
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
# USB
CONFIG_TINYUSB_MSC_ENABLED=y
CONFIG_TINYUSB_MSC_MOUNT_PATH="/sdcard"

View File

@ -46,8 +46,7 @@ CONFIG_SPIRAM_MODE_QUAD=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
# LVGL
CONFIG_LV_DISP_DEF_REFR_PERIOD=17
CONFIG_LV_INDEV_DEF_READ_PERIOD=17
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
CONFIG_LV_DPI_DEF=139
# Fix for IRAM
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y

View File

@ -52,8 +52,7 @@ CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
# SPI Flash (can set back to 80MHz after ESP-IDF bug is resolved)
CONFIG_ESPTOOLPY_FLASHFREQ_120M=y
# LVGL
CONFIG_LV_DISP_DEF_REFR_PERIOD=17
CONFIG_LV_INDEV_DEF_READ_PERIOD=17
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
CONFIG_LV_DPI_DEF=139
# USB
CONFIG_TINYUSB_MSC_ENABLED=y

View File

@ -44,9 +44,8 @@ CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM_USE_MALLOC=y
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
# LVGL
CONFIG_LV_DISP_DEF_REFR_PERIOD=17
CONFIG_LV_INDEV_DEF_READ_PERIOD=17
CONFIG_LV_DPI_DEF=139
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
CONFIG_LV_COLOR_DEPTH_24=y
CONFIG_LV_COLOR_DEPTH=24
# TinyUSB: Currently not working (no error in log, mounting takes minutes or more)

View File

@ -31,5 +31,4 @@ CONFIG_FATFS_VOLUME_COUNT=3
# Hardware defaults
CONFIG_TT_BOARD_CUSTOM=y
# LVGL
CONFIG_LV_DISP_DEF_REFR_PERIOD=17
CONFIG_LV_INDEV_DEF_READ_PERIOD=17
CONFIG_LV_DISP_DEF_REFR_PERIOD=10