1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-15 20:35:17 +03:00

[Horus] No more errors in Lua interface compilation

This commit is contained in:
Bertrand Songis 2015-11-25 21:38:05 +01:00
parent 791b1173e3
commit 71f08998dd
5 changed files with 29 additions and 19 deletions

View file

@ -393,13 +393,13 @@ void lcdDrawSolidFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, LcdFlag
#endif #endif
#if !defined(BOOT) #if !defined(BOOT)
void lcdDrawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, LcdFlags att) void lcdDrawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att)
{ {
for (scoord_t i=y; i<y+h; i++) { for (scoord_t i=y; i<y+h; i++) {
if ((att&ROUND) && (i==y || i==y+h-1)) if ((att&ROUND) && (i==y || i==y+h-1))
lcdDrawHorizontalLine(x+1, i, w-2, SOLID, att); lcdDrawHorizontalLine(x+1, i, w-2, pat, att);
else else
lcdDrawHorizontalLine(x, i, w, SOLID, att); lcdDrawHorizontalLine(x, i, w, pat, att);
} }
} }
#endif #endif
@ -483,7 +483,7 @@ void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
else if (idx <= MIXSRC_LAST_LUA) { else if (idx <= MIXSRC_LAST_LUA) {
div_t qr = div(idx-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS); div_t qr = div(idx-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
#if defined(LUA_MODEL_SCRIPTS) #if defined(LUA_MODEL_SCRIPTS) && !defined(COLORLCD)
if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) { if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) {
lcdDrawChar(x+2, y+1, '1'+qr.quot, TINSIZE); lcdDrawChar(x+2, y+1, '1'+qr.quot, TINSIZE);
lcdDrawSolidFilledRect(x, y, 7, 7); lcdDrawSolidFilledRect(x, y, 7, 7);
@ -929,7 +929,7 @@ void lcdDrawBitmap(coord_t x, coord_t y, const uint8_t * bmp, coord_t offset, co
void lcdDrawBlackOverlay() void lcdDrawBlackOverlay()
{ {
lcdDrawFilledRect(0, 0, LCD_W, LCD_H, TEXT_COLOR | (8<<24)); lcdDrawFilledRect(0, 0, LCD_W, LCD_H, SOLID, TEXT_COLOR | (8<<24));
} }
void lcdDrawCircle(int x0, int y0, int radius) void lcdDrawCircle(int x0, int y0, int radius)

View file

@ -538,6 +538,7 @@ static int luaKillEvents(lua_State *L)
return 0; return 0;
} }
#if !defined(COLORLCD)
/*luadoc /*luadoc
@function GREY() @function GREY()
@ -552,6 +553,7 @@ static int luaGrey(lua_State *L)
lua_pushunsigned(L, GREY(index)); lua_pushunsigned(L, GREY(index));
return 1; return 1;
} }
#endif
/*luadoc /*luadoc
@function getGeneralSettings() @function getGeneralSettings()
@ -686,7 +688,9 @@ const luaL_Reg opentxLib[] = {
{ "defaultStick", luaDefaultStick }, { "defaultStick", luaDefaultStick },
{ "defaultChannel", luaDefaultChannel }, { "defaultChannel", luaDefaultChannel },
{ "killEvents", luaKillEvents }, { "killEvents", luaKillEvents },
#if !defined(COLORLCD)
{ "GREY", luaGrey }, { "GREY", luaGrey },
#endif
{ NULL, NULL } /* sentinel */ { NULL, NULL } /* sentinel */
}; };

View file

@ -123,6 +123,7 @@ static int luaLcdDrawLine(lua_State *L)
return 0; return 0;
} }
#if !defined(COLORLCD)
/*luadoc /*luadoc
@function lcd.getLastPos() @function lcd.getLastPos()
@ -137,6 +138,7 @@ static int luaLcdGetLastPos(lua_State *L)
lua_pushinteger(L, lcdLastPos); lua_pushinteger(L, lcdLastPos);
return 1; return 1;
} }
#endif
/*luadoc /*luadoc
@function lcd.drawText(x, y, text [, flags]) @function lcd.drawText(x, y, text [, flags])
@ -194,7 +196,7 @@ static int luaLcdDrawTimer(lua_State *L)
int y = luaL_checkinteger(L, 2); int y = luaL_checkinteger(L, 2);
int seconds = luaL_checkinteger(L, 3); int seconds = luaL_checkinteger(L, 3);
unsigned int att = luaL_optunsigned(L, 4, 0); unsigned int att = luaL_optunsigned(L, 4, 0);
#if defined(PCBFLAMENCO) #if defined(COLORLCD)
putsTimer(x, y, seconds, att|LEFT); putsTimer(x, y, seconds, att|LEFT);
#else #else
putsTimer(x, y, seconds, att|LEFT, att); putsTimer(x, y, seconds, att|LEFT, att);
@ -323,6 +325,7 @@ static int luaLcdDrawSource(lua_State *L)
return 0; return 0;
} }
#if !defined(COLORLCD)
/*luadoc /*luadoc
@function lcd.drawPixmap(x, y, name) @function lcd.drawPixmap(x, y, name)
@ -336,7 +339,6 @@ Draws a bitmap at (x,y)
@status current Introduced in 2.0.0 @status current Introduced in 2.0.0
*/ */
#if !defined(COLORLCD)
static int luaLcdDrawPixmap(lua_State *L) static int luaLcdDrawPixmap(lua_State *L)
{ {
if (!luaLcdAllowed) return 0; if (!luaLcdAllowed) return 0;
@ -406,6 +408,7 @@ static int luaLcdDrawFilledRectangle(lua_State *L)
return 0; return 0;
} }
#if !defined(COLORLCD)
/*luadoc /*luadoc
@function lcd.drawGauge(x, y, w, h, fill, maxfill) @function lcd.drawGauge(x, y, w, h, fill, maxfill)
@ -437,12 +440,12 @@ static int luaLcdDrawGauge(lua_State *L)
// int flags = luaL_checkinteger(L, 7); // int flags = luaL_checkinteger(L, 7);
lcdDrawRect(x, y, w, h); lcdDrawRect(x, y, w, h);
uint8_t len = limit((uint8_t)1, uint8_t(w*num/den), uint8_t(w)); uint8_t len = limit((uint8_t)1, uint8_t(w*num/den), uint8_t(w));
for (int i=1; i<h-1; i++) { lcdDrawSolidFilledRect(x+1, y+1, len, h-2);
lcdDrawSolidHorizontalLine(x+1, y+i, len);
}
return 0; return 0;
} }
#endif
#if !defined(COLORLCD)
/*luadoc /*luadoc
@function lcd.drawScreenTitle(title, page, pages) @function lcd.drawScreenTitle(title, page, pages)
@ -459,7 +462,6 @@ the right side of title bar. (i.e. idx=2, cnt=5, display `2/5`)
@status current Introduced in 2.0.0 @status current Introduced in 2.0.0
*/ */
#if !defined(COLORLCD)
static int luaLcdDrawScreenTitle(lua_State *L) static int luaLcdDrawScreenTitle(lua_State *L)
{ {
if (!luaLcdAllowed) return 0; if (!luaLcdAllowed) return 0;
@ -475,8 +477,7 @@ static int luaLcdDrawScreenTitle(lua_State *L)
} }
#endif #endif
#if defined(PCBTARANIS) #if !defined(COLORLCD)
/*luadoc /*luadoc
@function lcd.drawCombobox(x, y, w, list, idx [, flags]) @function lcd.drawCombobox(x, y, w, list, idx [, flags])
@ -551,21 +552,21 @@ static int luaLcdDrawCombobox(lua_State *L)
const luaL_Reg lcdLib[] = { const luaL_Reg lcdLib[] = {
{ "lock", luaLcdLock }, { "lock", luaLcdLock },
{ "clear", luaLcdClear }, { "clear", luaLcdClear },
{ "getLastPos", luaLcdGetLastPos },
{ "drawPoint", luaLcdDrawPoint }, { "drawPoint", luaLcdDrawPoint },
{ "drawLine", luaLcdDrawLine }, { "drawLine", luaLcdDrawLine },
{ "drawRectangle", luaLcdDrawRectangle }, { "drawRectangle", luaLcdDrawRectangle },
{ "drawFilledRectangle", luaLcdDrawFilledRectangle }, { "drawFilledRectangle", luaLcdDrawFilledRectangle },
{ "drawGauge", luaLcdDrawGauge },
{ "drawText", luaLcdDrawText }, { "drawText", luaLcdDrawText },
{ "drawTimer", luaLcdDrawTimer }, { "drawTimer", luaLcdDrawTimer },
{ "drawNumber", luaLcdDrawNumber }, { "drawNumber", luaLcdDrawNumber },
{ "drawChannel", luaLcdDrawChannel }, { "drawChannel", luaLcdDrawChannel },
{ "drawSwitch", luaLcdDrawSwitch }, { "drawSwitch", luaLcdDrawSwitch },
{ "drawSource", luaLcdDrawSource }, { "drawSource", luaLcdDrawSource },
#if !defined(COLORLCD)
{ "getLastPos", luaLcdGetLastPos },
{ "drawGauge", luaLcdDrawGauge },
{ "drawPixmap", luaLcdDrawPixmap }, { "drawPixmap", luaLcdDrawPixmap },
{ "drawScreenTitle", luaLcdDrawScreenTitle }, { "drawScreenTitle", luaLcdDrawScreenTitle },
#if defined(PCBTARANIS)
{ "drawCombobox", luaLcdDrawCombobox }, { "drawCombobox", luaLcdDrawCombobox },
#endif #endif
{ NULL, NULL } /* sentinel */ { NULL, NULL } /* sentinel */

View file

@ -80,7 +80,9 @@ static int luaModelSetInfo(lua_State *L)
if (!strcmp(key, "name")) { if (!strcmp(key, "name")) {
const char * name = luaL_checkstring(L, -1); const char * name = luaL_checkstring(L, -1);
str2zchar(g_model.header.name, name, sizeof(g_model.header.name)); str2zchar(g_model.header.name, name, sizeof(g_model.header.name));
#if defined(EEPROM)
memcpy(modelHeaders[g_eeGeneral.currModel].name, g_model.header.name, sizeof(g_model.header.name)); memcpy(modelHeaders[g_eeGeneral.currModel].name, g_model.header.name, sizeof(g_model.header.name));
#endif
} }
else if (!strcmp(key, "bitmap")) { else if (!strcmp(key, "bitmap")) {
const char * name = luaL_checkstring(L, -1); const char * name = luaL_checkstring(L, -1);
@ -153,7 +155,10 @@ static int luaModelSetModule(lua_State *L)
module.rfProtocol = luaL_checkinteger(L, -1); module.rfProtocol = luaL_checkinteger(L, -1);
} }
else if (!strcmp(key, "modelId")) { else if (!strcmp(key, "modelId")) {
g_model.header.modelId[idx] = modelHeaders[g_eeGeneral.currModel].modelId[idx] = luaL_checkinteger(L, -1); g_model.header.modelId[idx] = luaL_checkinteger(L, -1);
#if defined(EEPROM)
modelHeaders[g_eeGeneral.currModel].modelId[idx] = g_model.header.modelId[idx];
#endif
} }
else if (!strcmp(key, "firstChannel")) { else if (!strcmp(key, "firstChannel")) {
module.channelsStart = luaL_checkinteger(L, -1); module.channelsStart = luaL_checkinteger(L, -1);

View file

@ -546,7 +546,7 @@ void luaExec(const char *filename)
} }
} }
void luaDoOneRunStandalone(uint8_t evt) void luaDoOneRunStandalone(evt_t evt)
{ {
static uint8_t luaDisplayStatistics = false; static uint8_t luaDisplayStatistics = false;
@ -663,7 +663,7 @@ bool luaDoOneRunPermanentScript(uint8_t evt, int i, uint32_t scriptType)
filename = script.file; filename = script.file;
#endif #endif
if ((scriptType & RUN_TELEM_FG_SCRIPT) && if ((scriptType & RUN_TELEM_FG_SCRIPT) &&
#if defined(PCBFLAMENCO) #if defined(COLORLCD)
(g_menuStack[0]==menuMainView && sid.reference==SCRIPT_TELEMETRY_FIRST+g_eeGeneral.view-VIEW_TELEM1)) { (g_menuStack[0]==menuMainView && sid.reference==SCRIPT_TELEMETRY_FIRST+g_eeGeneral.view-VIEW_TELEM1)) {
#else #else
(g_menuStack[0]==menuTelemetryFrsky && sid.reference==SCRIPT_TELEMETRY_FIRST+s_frsky_view)) { (g_menuStack[0]==menuTelemetryFrsky && sid.reference==SCRIPT_TELEMETRY_FIRST+s_frsky_view)) {