Fixes
This commit is contained in:
parent
1e6f65807e
commit
ae8bb5a01f
Binary file not shown.
@ -37,7 +37,7 @@ bool SdCard::init() {
|
|||||||
|
|
||||||
// Configure SDMMC host
|
// Configure SDMMC host
|
||||||
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
|
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
|
||||||
host.max_freq_khz = SDMMC_FREQ_DEFAULT; // 20 MHz
|
host.max_freq_khz = SDMMC_FREQ_HIGHSPEED; // 40 MHz (faster image loading)
|
||||||
|
|
||||||
// Initialize SD card power control via internal LDO
|
// Initialize SD card power control via internal LDO
|
||||||
sd_pwr_ctrl_ldo_config_t ldo_config = {
|
sd_pwr_ctrl_ldo_config_t ldo_config = {
|
||||||
|
|||||||
@ -792,24 +792,43 @@ void WidgetManager::createAllWidgets(const ScreenConfig& screen, lv_obj_t* paren
|
|||||||
lv_obj_t* bgImg = lv_image_create(parent);
|
lv_obj_t* bgImg = lv_image_create(parent);
|
||||||
lv_image_set_src(bgImg, fullPath);
|
lv_image_set_src(bgImg, fullPath);
|
||||||
|
|
||||||
// Position at top-left
|
// Get image dimensions
|
||||||
lv_obj_set_pos(bgImg, 0, 0);
|
lv_image_header_t header;
|
||||||
|
lv_result_t res = lv_image_decoder_get_info(fullPath, &header);
|
||||||
|
|
||||||
// Apply scaling mode
|
if (res == LV_RESULT_OK && header.w > 0 && header.h > 0) {
|
||||||
switch (screen.bgImageMode) {
|
ESP_LOGI(TAG, "Image size: %dx%d", header.w, header.h);
|
||||||
case BgImageMode::STRETCH:
|
|
||||||
lv_obj_set_size(bgImg, lv_pct(100), lv_pct(100));
|
// Get display/canvas size
|
||||||
lv_image_set_inner_align(bgImg, LV_IMAGE_ALIGN_STRETCH);
|
int32_t dispW = lv_obj_get_width(parent);
|
||||||
break;
|
int32_t dispH = lv_obj_get_height(parent);
|
||||||
case BgImageMode::CENTER:
|
if (dispW <= 0) dispW = LV_HOR_RES;
|
||||||
lv_obj_center(bgImg);
|
if (dispH <= 0) dispH = LV_VER_RES;
|
||||||
break;
|
|
||||||
case BgImageMode::TILE:
|
switch (screen.bgImageMode) {
|
||||||
lv_image_set_inner_align(bgImg, LV_IMAGE_ALIGN_TILE);
|
case BgImageMode::STRETCH: {
|
||||||
lv_obj_set_size(bgImg, lv_pct(100), lv_pct(100));
|
// Calculate scale to fill display (in 1/256 units for LVGL)
|
||||||
break;
|
int32_t scaleX = (dispW * 256) / header.w;
|
||||||
default:
|
int32_t scaleY = (dispH * 256) / header.h;
|
||||||
break;
|
lv_image_set_scale_x(bgImg, scaleX);
|
||||||
|
lv_image_set_scale_y(bgImg, scaleY);
|
||||||
|
lv_obj_set_pos(bgImg, 0, 0);
|
||||||
|
ESP_LOGI(TAG, "Stretch scale: %ldx%ld", scaleX, scaleY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BgImageMode::CENTER:
|
||||||
|
lv_obj_center(bgImg);
|
||||||
|
break;
|
||||||
|
case BgImageMode::TILE:
|
||||||
|
lv_image_set_inner_align(bgImg, LV_IMAGE_ALIGN_TILE);
|
||||||
|
lv_obj_set_size(bgImg, lv_pct(100), lv_pct(100));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ESP_LOGW(TAG, "Could not get image info, using default position");
|
||||||
|
lv_obj_set_pos(bgImg, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send to background (behind all widgets)
|
// Send to background (behind all widgets)
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_lv_adapter.h"
|
#include "esp_lv_adapter.h"
|
||||||
|
#include "esp_lv_decoder.h"
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include "Display.hpp"
|
#include "Display.hpp"
|
||||||
#include "Touch.hpp"
|
#include "Touch.hpp"
|
||||||
@ -84,7 +85,17 @@ public:
|
|||||||
if (!SdCard::instance().init()) {
|
if (!SdCard::instance().init()) {
|
||||||
ESP_LOGW(TAG, "SD card not available, using defaults");
|
ESP_LOGW(TAG, "SD card not available, using defaults");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize hardware JPEG/PNG decoder for LVGL (uses ESP32-P4 hardware acceleration)
|
||||||
|
ESP_LOGI(TAG, "INIT IMAGE DECODER");
|
||||||
|
esp_lv_decoder_handle_t decoder_handle = NULL;
|
||||||
|
esp_err_t dec_err = esp_lv_decoder_init(&decoder_handle);
|
||||||
|
if (dec_err != ESP_OK) {
|
||||||
|
ESP_LOGW(TAG, "Failed to init image decoder: %s", esp_err_to_name(dec_err));
|
||||||
|
} else {
|
||||||
|
ESP_LOGI(TAG, "Hardware image decoder initialized");
|
||||||
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG, "START KNX");
|
ESP_LOGI(TAG, "START KNX");
|
||||||
BaseType_t knx_ok = xTaskCreatePinnedToCore(
|
BaseType_t knx_ok = xTaskCreatePinnedToCore(
|
||||||
knx_task, "knx", 4096, &Gui::knxWorker, 5, nullptr, 1);
|
knx_task, "knx", 4096, &Gui::knxWorker, 5, nullptr, 1);
|
||||||
|
|||||||
@ -2979,8 +2979,8 @@ CONFIG_LV_ASSERT_HANDLER_INCLUDE="assert.h"
|
|||||||
# Others
|
# Others
|
||||||
#
|
#
|
||||||
# CONFIG_LV_ENABLE_GLOBAL_CUSTOM is not set
|
# CONFIG_LV_ENABLE_GLOBAL_CUSTOM is not set
|
||||||
CONFIG_LV_CACHE_DEF_SIZE=0
|
CONFIG_LV_CACHE_DEF_SIZE=4194304
|
||||||
CONFIG_LV_IMAGE_HEADER_CACHE_DEF_CNT=0
|
CONFIG_LV_IMAGE_HEADER_CACHE_DEF_CNT=8
|
||||||
CONFIG_LV_GRADIENT_MAX_STOPS=2
|
CONFIG_LV_GRADIENT_MAX_STOPS=2
|
||||||
CONFIG_LV_COLOR_MIX_ROUND_OFS=128
|
CONFIG_LV_COLOR_MIX_ROUND_OFS=128
|
||||||
# CONFIG_LV_OBJ_STYLE_CACHE is not set
|
# CONFIG_LV_OBJ_STYLE_CACHE is not set
|
||||||
@ -3184,7 +3184,7 @@ CONFIG_LV_FS_POSIX_CACHE_SIZE=0
|
|||||||
# CONFIG_LV_USE_LODEPNG is not set
|
# CONFIG_LV_USE_LODEPNG is not set
|
||||||
# CONFIG_LV_USE_LIBPNG is not set
|
# CONFIG_LV_USE_LIBPNG is not set
|
||||||
# CONFIG_LV_USE_BMP is not set
|
# CONFIG_LV_USE_BMP is not set
|
||||||
CONFIG_LV_USE_TJPGD=y
|
# CONFIG_LV_USE_TJPGD is not set
|
||||||
# CONFIG_LV_USE_LIBJPEG_TURBO is not set
|
# CONFIG_LV_USE_LIBJPEG_TURBO is not set
|
||||||
# CONFIG_LV_USE_GIF is not set
|
# CONFIG_LV_USE_GIF is not set
|
||||||
# CONFIG_LV_BIN_DECODER_RAM_LOAD is not set
|
# CONFIG_LV_BIN_DECODER_RAM_LOAD is not set
|
||||||
|
|||||||
@ -219,7 +219,7 @@ const imageExtensions = ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'webp', 'svg'];
|
|||||||
// Image optimization settings for ESP32
|
// Image optimization settings for ESP32
|
||||||
const MAX_IMAGE_WIDTH = 1280; // Display width
|
const MAX_IMAGE_WIDTH = 1280; // Display width
|
||||||
const MAX_IMAGE_HEIGHT = 800; // Display height
|
const MAX_IMAGE_HEIGHT = 800; // Display height
|
||||||
const JPEG_QUALITY = 0.75; // 75% quality
|
const JPEG_QUALITY = 0.80; // 80% quality - good balance
|
||||||
|
|
||||||
function isImageFile(name) {
|
function isImageFile(name) {
|
||||||
const ext = name.split('.').pop().toLowerCase();
|
const ext = name.split('.').pop().toLowerCase();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user