Do not reload bitmps during theme update, unless reload argument is true (#661)

* Do not reload bitmps during theme update, unless reload argument is true
Trying to optimize speed for theme color changes.
FlySky is not optimized yet.

* Do not update theme from Lua lcd.setColor(CUSTOM_COLOR, x)
Some widgets like e.g. Timer2 constantly change CUSTOM_COLOR, and this seems to slow down things

* Lua function lcd.setColor() only updates if color is changed
To avoid that scripts calling lcd.setColor() repeatedly trash performance
This commit is contained in:
Jesper Frickmann
2021-09-01 11:10:52 +10:00
committed by GitHub
parent cf91c87c77
commit cea723c56e
4 changed files with 84 additions and 75 deletions
+5 -4
View File
@@ -726,11 +726,12 @@ Please notice that changing theme colors affects not only other Lua widgets, but
static int luaLcdSetColor(lua_State *L)
{
unsigned int index = COLOR_VAL(luaL_checkunsigned(L, 1));
LcdFlags flags = luaL_checkunsigned(L, 2);
uint16_t color = COLOR_VAL(flagsRGB(luaL_checkunsigned(L, 2)));
if (index < LCD_COLOR_COUNT) {
lcdColorTable[index] = COLOR_VAL(flagsRGB(flags));
OpenTxTheme::instance()->update();
if (index < LCD_COLOR_COUNT && lcdColorTable[index] != color) {
lcdColorTable[index] = color;
if (index != CUSTOM_COLOR_INDEX)
OpenTxTheme::instance()->update(false);
}
return 0;
}