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

Projectkk2glider/lua bitmap free (#4075)

* Better memory stats (CLI)

* Bitmap buffer overflow check added

* Lua bitmap improvements

* Proper handling of symbolic links in simulator

* S6R Lua script fixes:
 * added progress screen while loading bitmaps
 * memory for bitmaps is now freed when leaving the script

* S6R Lua script: improved bitmap loading

* * Lua Themes and Widgets moved to separate file and separate Lua state
* Stand-alone, mixer and function scripts now behave the same as on Taranis (restarted after the stand-alone script was run)
* both Lua states are independent: Themes and Widgets is initialized only at the start, the other one is initialized before and after the stand-alone script is run

* Better leak test and report in BitmapBuffer

* Re #3318: Lua compiler enabled in simu and Companion simulator. Usage:
 * any time <xxx>.lua file is about to be loaded and if file <xxx>.lua.src exists:
   * load contents of <xxx>.lua.src
   * compile Lua code
   * save compiled code into <xxx>.lua (effectively overwrites existing file)
 * immediately following the compilation the real file loading is done from <xxx>.lua (which by now contains compiled Lua bytecode)
This commit is contained in:
Damjan Adamic 2016-11-28 23:08:18 +01:00 committed by Bertrand Songis
parent ae383cd6a4
commit 92553b6589
18 changed files with 745 additions and 554 deletions

View file

@ -147,7 +147,7 @@ static int luaGetDateTime(lua_State * L)
return 1;
}
static void luaPushLatLon(TelemetrySensor & telemetrySensor, TelemetryItem & telemetryItem)
static void luaPushLatLon(lua_State* L, TelemetrySensor & telemetrySensor, TelemetryItem & telemetryItem)
/* result is lua table containing members ["lat"] and ["lon"] as lua_Number (doubles) in decimal degrees */
{
lua_createtable(L, 0, 4);
@ -157,13 +157,13 @@ static void luaPushLatLon(TelemetrySensor & telemetrySensor, TelemetryItem & tel
lua_pushtablenumber(L, "pilot-lon", telemetryItem.pilotLongitude / 1000000.0);
}
static void luaPushTelemetryDateTime(TelemetrySensor & telemetrySensor, TelemetryItem & telemetryItem)
static void luaPushTelemetryDateTime(lua_State* L, TelemetrySensor & telemetrySensor, TelemetryItem & telemetryItem)
{
luaPushDateTime(L, telemetryItem.datetime.year, telemetryItem.datetime.month, telemetryItem.datetime.day,
telemetryItem.datetime.hour, telemetryItem.datetime.min, telemetryItem.datetime.sec);
}
static void luaPushCells(TelemetrySensor & telemetrySensor, TelemetryItem & telemetryItem)
static void luaPushCells(lua_State* L, TelemetrySensor & telemetrySensor, TelemetryItem & telemetryItem)
{
if (telemetryItem.cells.count == 0)
lua_pushinteger(L, (int)0); // returns zero if no cells
@ -177,7 +177,7 @@ static void luaPushCells(TelemetrySensor & telemetrySensor, TelemetryItem & tele
}
}
void luaGetValueAndPush(int src)
void luaGetValueAndPush(lua_State* L, int src)
{
getvalue_t value = getValue(src); // ignored for GPS, DATETIME, and CELLS
@ -188,14 +188,14 @@ void luaGetValueAndPush(int src)
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[qr.quot];
switch (telemetrySensor.unit) {
case UNIT_GPS:
luaPushLatLon(telemetrySensor, telemetryItems[qr.quot]);
luaPushLatLon(L, telemetrySensor, telemetryItems[qr.quot]);
break;
case UNIT_DATETIME:
luaPushTelemetryDateTime(telemetrySensor, telemetryItems[qr.quot]);
luaPushTelemetryDateTime(L, telemetrySensor, telemetryItems[qr.quot]);
break;
case UNIT_CELLS:
if (qr.rem == 0) {
luaPushCells(telemetrySensor, telemetryItems[qr.quot]);
luaPushCells(L, telemetrySensor, telemetryItems[qr.quot]);
break;
}
// deliberate no break here to properly return `Cels-` and `Cels+`
@ -566,7 +566,7 @@ static int luaGetValue(lua_State * L)
src = field.id;
}
}
luaGetValueAndPush(src);
luaGetValueAndPush(L, src);
return 1;
}