mirror of
https://github.com/opentx/opentx.git
synced 2025-07-20 23:05:12 +03:00
using pre-allocated table space via lua_createtable() for GPS, DATETIME, and CELLS
This commit is contained in:
parent
61b701f930
commit
e1b1342655
1 changed files with 3 additions and 3 deletions
|
@ -119,7 +119,7 @@ static int luaGetTime(lua_State *L)
|
||||||
static void luaPushDateTime(lua_State *L, uint32_t year, uint32_t mon, uint32_t day,
|
static void luaPushDateTime(lua_State *L, uint32_t year, uint32_t mon, uint32_t day,
|
||||||
uint32_t hour, uint32_t min, uint32_t sec)
|
uint32_t hour, uint32_t min, uint32_t sec)
|
||||||
{
|
{
|
||||||
lua_newtable(L);
|
lua_createtable(L, 0, 6);
|
||||||
lua_pushtableinteger(L, "year", year);
|
lua_pushtableinteger(L, "year", year);
|
||||||
lua_pushtableinteger(L, "mon", mon);
|
lua_pushtableinteger(L, "mon", mon);
|
||||||
lua_pushtableinteger(L, "day", day);
|
lua_pushtableinteger(L, "day", day);
|
||||||
|
@ -150,7 +150,7 @@ static void luaPushLatLon(TelemetrySensor & telemetrySensor, TelemetryItem & tel
|
||||||
lon = gpsLon / 1000000.0;
|
lon = gpsLon / 1000000.0;
|
||||||
if (telemetryItem.gps.longitudeEW == 'W') lon = -lon;
|
if (telemetryItem.gps.longitudeEW == 'W') lon = -lon;
|
||||||
|
|
||||||
lua_newtable(L);
|
lua_createtable(L, 0, 2);
|
||||||
lua_pushtablenumber(L, "lat", lat);
|
lua_pushtablenumber(L, "lat", lat);
|
||||||
lua_pushtablenumber(L, "lon", lon);
|
lua_pushtablenumber(L, "lon", lon);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ static void luaPushCells(TelemetrySensor & telemetrySensor, TelemetryItem & tele
|
||||||
if (telemetryItem.cells.count == 0)
|
if (telemetryItem.cells.count == 0)
|
||||||
lua_pushinteger(L, (int)0); // returns zero if no cells
|
lua_pushinteger(L, (int)0); // returns zero if no cells
|
||||||
else {
|
else {
|
||||||
lua_createtable(L, 0 /*telemetryItem.cells.count*/, 0);
|
lua_createtable(L, telemetryItem.cells.count, 0);
|
||||||
for (int i = 0; i < telemetryItem.cells.count; i++) {
|
for (int i = 0; i < telemetryItem.cells.count; i++) {
|
||||||
lua_pushnumber(L, i + 1);
|
lua_pushnumber(L, i + 1);
|
||||||
lua_pushnumber(L, telemetryItem.cells.values[i].value / 100.0);
|
lua_pushnumber(L, telemetryItem.cells.values[i].value / 100.0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue