fix: Indicator display (#173)

* disable some logs which potentially lead to crash

* indicator: hw rotation + increase frequency

* PSRAM display buffer allocation

* define fast mem

* revert frequency to 6M (to avoid drift)

* trunk fmt
This commit is contained in:
Manuel
2025-08-07 23:34:09 +02:00
committed by GitHub
parent c75d545bf9
commit dec28a4630
6 changed files with 40 additions and 19 deletions
+26 -5
View File
@@ -54,13 +54,35 @@ class LGFX_Touch : public lgfx::LGFX_Device
private:
BBCapTouch bbct;
};
#endif
class Panel_Indicator : public lgfx::Panel_ST7701
{
public:
const uint8_t *getInitCommands(uint8_t listno) const override
{
static constexpr const uint8_t list1[] = {
0x36, 1, 0x10, // MADCTL for vertical flip
0xFF, 5, 0x77, 0x01, 0x00, 0x00, 0x10, // Command2 BK0 SEL
0xC7, 1, 0x04, // SDIR: X-direction Control (Horizontal Flip)
0xFF, 5, 0x77, 0x01, 0x00, 0x00, 0x00 // Command2 BK0 DIS
};
switch (listno) {
case 1:
return list1;
default:
return lgfx::Panel_ST7701::getInitCommands(listno);
}
}
};
#ifdef CUSTOM_TOUCH_DRIVER
class LGFX_INDICATOR : public LGFX_Touch
#else
class LGFX_INDICATOR : public lgfx::LGFX_Device
#endif
{
lgfx::Panel_ST7701 _panel_instance;
Panel_Indicator _panel_instance;
lgfx::Bus_RGB _bus_instance;
lgfx::Light_PWM _light_instance;
lgfx::Touch_FT5x06 _touch_instance;
@@ -81,7 +103,7 @@ class LGFX_INDICATOR : public lgfx::LGFX_Device
cfg.panel_height = screenHeight;
cfg.offset_x = 0;
cfg.offset_y = 0;
cfg.offset_rotation = 2;
cfg.offset_rotation = 0;
_panel_instance.config(cfg);
}
@@ -156,8 +178,8 @@ class LGFX_INDICATOR : public lgfx::LGFX_Device
cfg.x_max = 479;
cfg.y_min = 0;
cfg.y_max = 479;
cfg.pin_int = GPIO_NUM_NC; // don't use IO_EXPANDER!;
cfg.pin_rst = GPIO_NUM_NC; // not needed as well;
cfg.pin_int = GPIO_NUM_NC; // don't use IO_EXPANDER!
cfg.pin_rst = GPIO_NUM_NC; // not needed as well
cfg.bus_shared = false;
cfg.offset_rotation = 0;
@@ -170,7 +192,6 @@ class LGFX_INDICATOR : public lgfx::LGFX_Device
_panel_instance.setTouch(&_touch_instance);
}
#endif
setPanel(&_panel_instance);
}
};
+7 -7
View File
@@ -250,18 +250,18 @@ template <class LGFX> void LGFXDriver<LGFX>::init(DeviceGUI *gui)
#endif
assert(buf1 != 0 /* && buf2 != 0 */);
lv_display_set_buffers(disp, buf1, buf2, bufsize, LV_DISPLAY_RENDER_MODE_DIRECT);
#elif 0 // defined BOARD_HAS_PSRAM
#elif defined(BOARD_HAS_PSRAM)
assert(ESP.getFreePsram());
bufsize = screenWidth * height / 8 * sizeof(lv_color_t);
ILOG_DEBUG("LVGL: allocating %u bytes PSRAM for draw buffer"), bufsize;
buf1 = (lv_color_t *)heap_caps_malloc(bufsize, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); // heap_alloc_psram
bufsize = lgfx->screenWidth * lgfx->screenHeight * sizeof(lv_color_t) / 4;
ILOG_DEBUG("LVGL: allocating %u bytes PSRAM for draw buffer", bufsize);
buf1 = (lv_color_t *)LV_MEM_POOL_ALLOC(bufsize);
assert(buf1 != 0);
lv_display_set_buffers(display, buf1, buf2, bufsize, LV_DISPLAY_RENDER_MODE_PARTIAL);
lv_display_set_buffers(this->display, buf1, buf2, bufsize, LV_DISPLAY_RENDER_MODE_PARTIAL);
#else
bufsize = lgfx->screenWidth * lgfx->screenHeight;
bufsize = lgfx->screenWidth * lgfx->screenHeight / 8;
ILOG_DEBUG("LVGL: allocating %u bytes heap memory for draw buffer", sizeof(lv_color_t) * bufsize);
buf1 = new lv_color_t[bufsize];
assert(buf1 != 0);
ILOG_DEBUG("LVGL: allocating %u bytes heap memory for draw buffer", sizeof(lv_color_t) * bufsize);
lv_display_set_buffers(this->display, buf1, buf2, sizeof(lv_color_t) * bufsize, LV_DISPLAY_RENDER_MODE_PARTIAL);
#endif