From 7f24e4bc37755249e762edfa974f4388742224d7 Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Sun, 25 Dec 2022 17:04:14 +0100 Subject: [PATCH] Add config for swapping bytes when using pushImage --- Kconfig.projbuild | 4 ++++ src/menudisplay.cpp | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Kconfig.projbuild b/Kconfig.projbuild index 7e989b9..c516931 100644 --- a/Kconfig.projbuild +++ b/Kconfig.projbuild @@ -4,4 +4,8 @@ config ESPGUI_MENUDISPLAY_ROWS int "Number of rows for MenuDisplays" default 10 +config ESPGUI_ICONS_SWAPBYTES + bool "Swap bytes in icons" + default n + endmenu diff --git a/src/menudisplay.cpp b/src/menudisplay.cpp index f831c28..a1c3eb7 100644 --- a/src/menudisplay.cpp +++ b/src/menudisplay.cpp @@ -161,7 +161,16 @@ void MenuDisplay::redraw(TftInterface &tft) labelsIter->start(tft); if (auto icon = item.selectedIcon()) - tft.pushImage(tft.width() - 6 - icon->WIDTH, labelsIter->y() + 1, icon->WIDTH, icon->HEIGHT, icon->buffer); + { +#ifdef CONFIG_ESPGUI_ICONS_SWAPBYTES + tft.setSwapBytes(true); +#endif + tft.pushImage(tft.width() - 6 - icon->WIDTH, labelsIter->y() + 1, icon->WIDTH, icon->HEIGHT, + icon->buffer); +#ifdef CONFIG_ESPGUI_ICONS_SWAPBYTES + tft.setSwapBytes(false); +#endif + } } } else if (relativeIndex == m_highlightedIndex) @@ -177,7 +186,15 @@ void MenuDisplay::redraw(TftInterface &tft) { auto icon = item.icon(); if (icon) + { +#ifdef CONFIG_ESPGUI_ICONS_SWAPBYTES + tft.setSwapBytes(true); +#endif tft.pushImage(6, labelsIter->y() + 1, icon->WIDTH, icon->HEIGHT, icon->buffer); +#ifdef CONFIG_ESPGUI_ICONS_SWAPBYTES + tft.setSwapBytes(false); +#endif + } else if (*iconsIter) tft.fillRect(6, labelsIter->y() + 1, 24, 24, selected ? TFT_GREY : TFT_BLACK); *iconsIter = icon;