Move away from color table for low level ops
This commit is contained in:
committed by
Raphael Coeffic
parent
1fa99fdeb2
commit
f1be9157ae
@@ -75,6 +75,7 @@ static int luaLcdResetBacklightTimeout(lua_State * L)
|
||||
{
|
||||
if (!luaLcdAllowed)
|
||||
return 0;
|
||||
|
||||
resetBacklightTimeout();
|
||||
return 0;
|
||||
}
|
||||
@@ -104,7 +105,9 @@ static int luaLcdDrawPoint(lua_State *L)
|
||||
int x = luaL_checkinteger(L, 1);
|
||||
int y = luaL_checkinteger(L, 2);
|
||||
LcdFlags att = luaL_optunsigned(L, 3, 0);
|
||||
luaLcdBuffer->drawPixel(x, y, lcdColorTable[COLOR_IDX(att)]);
|
||||
|
||||
// here another definition should be used
|
||||
luaLcdBuffer->drawPixel(x, y, COLOR(att));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -144,16 +147,20 @@ static int luaLcdDrawLine(lua_State *L)
|
||||
|
||||
if (pat == SOLID) {
|
||||
if (x1 == x2) {
|
||||
luaLcdBuffer->drawSolidVerticalLine(x1, y1<y2 ? y1 : y2, y1<y2 ? (y2-y1)+1 : (y1-y2)+1, flags);
|
||||
luaLcdBuffer->drawSolidVerticalLine(x1, y1<y2 ? y1 : y2,
|
||||
y1<y2 ? (y2-y1)+1 : (y1-y2)+1,
|
||||
COLOR2FLAGS(COLOR(flags)));
|
||||
return 0;
|
||||
}
|
||||
else if (y1 == y2) {
|
||||
luaLcdBuffer->drawSolidHorizontalLine(x1<x2 ? x1 : x2, y1, x1<x2 ? (x2-x1)+1 : (x1-x2)+1, flags);
|
||||
luaLcdBuffer->drawSolidHorizontalLine(x1<x2 ? x1 : x2,
|
||||
y1, x1<x2 ? (x2-x1)+1 : (x1-x2)+1,
|
||||
COLOR2FLAGS(COLOR(flags)));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
luaLcdBuffer->drawLine(x1, y1, x2, y2, pat, flags);
|
||||
luaLcdBuffer->drawLine(x1, y1, x2, y2, pat, COLOR2FLAGS(COLOR(flags)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -192,9 +199,9 @@ static int luaLcdDrawText(lua_State *L)
|
||||
unsigned int att = luaL_optunsigned(L, 4, 0);
|
||||
|
||||
if ((att&SHADOWED) && !(att&INVERS)) {
|
||||
luaLcdBuffer->drawText(x+1, y+1, s, att&0xFFFF);
|
||||
luaLcdBuffer->drawText(x+1, y+1, s, att & 0xFFFF);
|
||||
}
|
||||
luaLcdBuffer->drawText(x, y, s, att);
|
||||
luaLcdBuffer->drawText(x, y, s, (att & 0xFFFF) | (COLOR2FLAGS(COLOR(att))));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -265,9 +272,9 @@ static int luaLcdDrawNumber(lua_State *L)
|
||||
unsigned int att = luaL_optunsigned(L, 4, 0);
|
||||
|
||||
if ((att&SHADOWED) && !(att&INVERS)) {
|
||||
luaLcdBuffer->drawNumber(x, y, val, att&0xFFFF);
|
||||
luaLcdBuffer->drawNumber(x, y, val, att & 0xFFFF);
|
||||
}
|
||||
luaLcdBuffer->drawNumber(x, y, val, att);
|
||||
luaLcdBuffer->drawNumber(x, y, val, (att & 0xFFFF) | COLOR2FLAGS(COLOR(att)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -555,7 +562,9 @@ static int luaLcdDrawRectangle(lua_State *L)
|
||||
|
||||
unsigned int flags = luaL_optunsigned(L, 5, 0);
|
||||
unsigned int t = luaL_optunsigned(L, 6, 1);
|
||||
luaLcdBuffer->drawRect(x, y, w, h, t, 0xff, flags);
|
||||
luaLcdBuffer->drawRect(x, y, w, h, t, SOLID,
|
||||
COLOR2FLAGS(COLOR(flags)) | (flags & 0xFFFF),
|
||||
flags >> 24);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -586,7 +595,9 @@ static int luaLcdDrawFilledRectangle(lua_State *L)
|
||||
int h = luaL_checkinteger(L, 4);
|
||||
|
||||
unsigned int flags = luaL_optunsigned(L, 5, 0);
|
||||
luaLcdBuffer->drawFilledRect(x, y, w, h, SOLID, flags);
|
||||
luaLcdBuffer->drawFilledRect(x, y, w, h, SOLID,
|
||||
COLOR2FLAGS(COLOR(flags)) | (flags & 0xFFFF),
|
||||
flags >> 24);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1845,24 +1845,24 @@ const luaR_value_entry opentxConstants[] = {
|
||||
{ "COLOR", ZoneOption::Color },
|
||||
{ "BOOL", ZoneOption::Bool },
|
||||
{ "STRING", ZoneOption::String },
|
||||
{ "DEFAULT_COLOR", DEFAULT_COLOR },
|
||||
{ "DEFAULT_BGCOLOR", DEFAULT_BGCOLOR },
|
||||
{ "FOCUS_COLOR", FOCUS_COLOR },
|
||||
{ "FOCUS_BGCOLOR", FOCUS_BGCOLOR },
|
||||
{ "DISABLE_COLOR", DISABLE_COLOR },
|
||||
{ "HIGHLIGHT_COLOR", HIGHLIGHT_COLOR },
|
||||
{ "CHECKBOX_COLOR", CHECKBOX_COLOR },
|
||||
{ "SCROLLBAR_COLOR", SCROLLBAR_COLOR },
|
||||
{ "MENU_COLOR", MENU_COLOR },
|
||||
{ "MENU_BGCOLOR", MENU_BGCOLOR },
|
||||
{ "DEFAULT_COLOR", DEFAULT_COLOR_INDEX },
|
||||
{ "DEFAULT_BGCOLOR", DEFAULT_BGCOLOR_INDEX },
|
||||
{ "FOCUS_COLOR", FOCUS_COLOR_INDEX },
|
||||
{ "FOCUS_BGCOLOR", FOCUS_BGCOLOR_INDEX },
|
||||
{ "DISABLE_COLOR", DISABLE_COLOR_INDEX },
|
||||
{ "HIGHLIGHT_COLOR", HIGHLIGHT_COLOR_INDEX },
|
||||
{ "CHECKBOX_COLOR", CHECKBOX_COLOR_INDEX },
|
||||
{ "SCROLLBAR_COLOR", SCROLLBAR_COLOR_INDEX },
|
||||
{ "MENU_COLOR", MENU_COLOR_INDEX },
|
||||
{ "MENU_BGCOLOR", MENU_BGCOLOR_INDEX },
|
||||
// TODO : FIX { "MENU_TITLE_BGCOLOR", MENU_TITLE_BGCOLOR },
|
||||
{ "MENU_LINE_COLOR", MENU_LINE_COLOR },
|
||||
{ "MENU_HIGHLIGHT_COLOR", MENU_HIGHLIGHT_COLOR },
|
||||
{ "MENU_HIGHLIGHT_BGCOLOR", MENU_HIGHLIGHT_BGCOLOR },
|
||||
{ "OVERLAY_COLOR", OVERLAY_COLOR },
|
||||
{ "TABLE_BGCOLOR", TABLE_BGCOLOR },
|
||||
{ "TABLE_HEADER_BGCOLOR", TABLE_HEADER_BGCOLOR },
|
||||
{ "CUSTOM_COLOR", CUSTOM_COLOR },
|
||||
{ "MENU_LINE_COLOR", MENU_LINE_COLOR_INDEX },
|
||||
{ "MENU_HIGHLIGHT_COLOR", MENU_HIGHLIGHT_COLOR_INDEX },
|
||||
{ "MENU_HIGHLIGHT_BGCOLOR", MENU_HIGHLIGHT_BGCOLOR_INDEX },
|
||||
{ "OVERLAY_COLOR", OVERLAY_COLOR_INDEX },
|
||||
{ "TABLE_BGCOLOR", TABLE_BGCOLOR_INDEX },
|
||||
{ "TABLE_HEADER_BGCOLOR", TABLE_HEADER_BGCOLOR_INDEX },
|
||||
{ "CUSTOM_COLOR", CUSTOM_COLOR_INDEX },
|
||||
{ "MENU_HEADER_HEIGHT", MENU_HEADER_HEIGHT },
|
||||
{ "WHITE", (double)WHITE },
|
||||
{ "GREY", (double)GREY },
|
||||
|
||||
Reference in New Issue
Block a user