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:
parent
81a7a554c3
commit
75e1bead3f
16 changed files with 119 additions and 69 deletions
|
@ -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 */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue