Add config for swapping bytes when using pushImage

This commit is contained in:
CommanderRedYT
2022-12-25 17:04:14 +01:00
parent 8c891bb556
commit 7f24e4bc37
2 changed files with 22 additions and 1 deletions

View File

@ -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

View File

@ -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;