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

S.PORT to Lua telemetry passthrough

The Fifo is created with ```telemetryRegister``` and elements (ID + Value) are taken from the Fifo with ```telemetryPop```
Not tested at all. Just for review / discussion
This commit is contained in:
Bertrand Songis 2016-02-28 11:56:54 +01:00
parent 81a7a554c3
commit 75e1bead3f
16 changed files with 119 additions and 69 deletions

View file

@ -326,6 +326,32 @@ bool luaFindFieldByName(const char * name, LuaField & field, unsigned int flags)
return false; // not found
}
static int luaTelemetryRegister(lua_State *L)
{
if (!luaTelemetryFifo) {
luaTelemetryFifo = new Fifo<LuaTelemetryValue, 16>();
if (!luaTelemetryFifo) {
return -1;
}
}
return 0;
}
static int luaTelemetryPop(lua_State *L)
{
if (luaTelemetryFifo) {
LuaTelemetryValue value;
if (luaTelemetryFifo->pop(value)) {
lua_pushnumber(L, value.id);
lua_pushunsigned(L, value.value);
return 2;
}
}
return 0;
}
/*luadoc
@function getFieldInfo(name)
@ -794,6 +820,8 @@ const luaL_Reg opentxLib[] = {
#if !defined(COLORLCD)
{ "GREY", luaGrey },
#endif
{ "telemetryRegister", luaTelemetryRegister },
{ "telemetryPop", luaTelemetryPop },
{ NULL, NULL } /* sentinel */
};