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
+1 -1
View File
@@ -464,7 +464,7 @@
#define LV_ATTRIBUTE_LARGE_RAM_ARRAY
/*Place performance critical functions into a faster memory (e.g RAM)*/
#define LV_ATTRIBUTE_FAST_MEM
#define LV_ATTRIBUTE_FAST_MEM IRAM_ATTR
/*Export integer constant to binding. This macro is used with constants in the form of LV_<CONST> that
*should also appear on LVGL binding API such as MicroPython.*/
+3 -3
View File
@@ -6293,9 +6293,9 @@ void TFTView_320x240::newMessage(uint32_t nodeNum, lv_obj_t *container, uint8_t
*/
void TFTView_320x240::restoreMessage(const LogMessage &msg)
{
((uint8_t *)msg.bytes)[msg._size] = 0;
ILOG_DEBUG("restoring msg from:0x%08x, to:0x%08x, ch:%d, time:%d, status:%d, trash:%d, size:%d, '%s'", msg.from, msg.to,
msg.ch, msg.time, (int)msg.status, msg.trashFlag, msg._size, msg.bytes);
//((uint8_t *)msg.bytes)[msg._size] = 0;
// ILOG_DEBUG("restoring msg from:0x%08x, to:0x%08x, ch:%d, time:%d, status:%d, trash:%d, size:%d, '%s'", msg.from, msg.to,
// msg.ch, msg.time, (int)msg.status, msg.trashFlag, msg._size, msg.bytes);
if (msg.from == ownNode) {
lv_obj_t *container = nullptr;
+1 -1
View File
@@ -477,7 +477,7 @@ void ViewController::sendTextMessage(uint32_t to, uint8_t ch, uint8_t hopLimit,
assert(msgLen <= (size_t)DATA_PAYLOAD_LEN);
if (send(to, ch, hopLimit, requestId, meshtastic_PortNum_TEXT_MESSAGE_APP, false, usePkc, (const uint8_t *)textmsg, msgLen)) {
ILOG_DEBUG("storing msg to:0x%08x, ch:%d, time:%d, size:%d, '%s'", to, ch, msgTime, msgLen, textmsg);
// ILOG_DEBUG("storing msg to:0x%08x, ch:%d, time:%d, size:%d, '%s'", to, ch, msgTime, msgLen, textmsg);
log.write(LogMessageEnv(myNodeNum, to, ch, msgTime, LogMessage::eDefault, false, msgLen, (const uint8_t *)textmsg));
}
}
+2 -2
View File
@@ -104,8 +104,8 @@ bool LogRotate::write(const ILogEntry &entry)
currentSize += entry.size();
totalSize += entry.size();
ILOG_DEBUG("LogRotate: %d bytes written in %d ms to %s (%d/%d bytes, total: %d)", entry.size(), millis() - start,
currentLogName.c_str(), currentSize, c_maxFileSize, totalSize);
// ILOG_DEBUG("LogRotate: %d bytes written in %d ms to %s (%d/%d bytes, total: %d)", entry.size(), millis() - start,
// currentLogName.c_str(), currentSize, c_maxFileSize, totalSize);
return true;
}