mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 20:35:17 +03:00
Lua telemetryPush function now added
This commit is contained in:
parent
fe901dabdf
commit
56fb01a958
4 changed files with 27 additions and 8 deletions
|
@ -328,15 +328,15 @@ bool luaFindFieldByName(const char * name, LuaField & field, unsigned int flags)
|
|||
|
||||
static int luaTelemetryPop(lua_State *L)
|
||||
{
|
||||
if (!luaTelemetryFifo) {
|
||||
luaTelemetryFifo = new Fifo<LuaTelemetryValue, 16>();
|
||||
if (!luaTelemetryFifo) {
|
||||
if (!luaInputTelemetryFifo) {
|
||||
luaInputTelemetryFifo = new Fifo<LuaTelemetryValue, 16>();
|
||||
if (!luaInputTelemetryFifo) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
LuaTelemetryValue value;
|
||||
if (luaTelemetryFifo->pop(value)) {
|
||||
if (luaInputTelemetryFifo->pop(value)) {
|
||||
lua_pushnumber(L, value.id);
|
||||
lua_pushunsigned(L, value.value);
|
||||
return 2;
|
||||
|
@ -345,6 +345,22 @@ static int luaTelemetryPop(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int luaTelemetryPush(lua_State *L)
|
||||
{
|
||||
if (!luaOutputTelemetryFifo) {
|
||||
luaOutputTelemetryFifo = new Fifo<LuaTelemetryValue, 16>();
|
||||
if (!luaOutputTelemetryFifo) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int id = luaL_checkunsigned(L, 1);
|
||||
unsigned int value = luaL_checkunsigned(L, 2);
|
||||
|
||||
luaOutputTelemetryFifo->push((LuaTelemetryValue){ id, value });
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*luadoc
|
||||
@function getFieldInfo(name)
|
||||
|
||||
|
@ -814,6 +830,7 @@ const luaL_Reg opentxLib[] = {
|
|||
{ "GREY", luaGrey },
|
||||
#endif
|
||||
{ "telemetryPop", luaTelemetryPop },
|
||||
{ "telemetryPush", luaTelemetryPush },
|
||||
{ NULL, NULL } /* sentinel */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue