mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 08:15:17 +03:00
Merge pull request #4009 from opentx/raphaelcoeffic/lua_sport_buffer_query
lua: allow telemtry output buffer availability to be queried
This commit is contained in:
commit
95598e5de0
1 changed files with 8 additions and 2 deletions
|
@ -333,7 +333,10 @@ uint8_t getDataId(uint8_t physicalId)
|
||||||
|
|
||||||
static int luaSportTelemetryPush(lua_State * L)
|
static int luaSportTelemetryPush(lua_State * L)
|
||||||
{
|
{
|
||||||
if (isSportOutputBufferAvailable()) {
|
if (lua_gettop(L) == 0) {
|
||||||
|
lua_pushboolean(L, isSportOutputBufferAvailable());
|
||||||
|
}
|
||||||
|
else if (isSportOutputBufferAvailable()) {
|
||||||
SportTelemetryPacket packet;
|
SportTelemetryPacket packet;
|
||||||
packet.physicalId = getDataId(luaL_checkunsigned(L, 1));
|
packet.physicalId = getDataId(luaL_checkunsigned(L, 1));
|
||||||
packet.primId = luaL_checkunsigned(L, 2);
|
packet.primId = luaL_checkunsigned(L, 2);
|
||||||
|
@ -378,7 +381,10 @@ static int luaCrossfireTelemetryPop(lua_State * L)
|
||||||
|
|
||||||
static int luaCrossfireTelemetryPush(lua_State * L)
|
static int luaCrossfireTelemetryPush(lua_State * L)
|
||||||
{
|
{
|
||||||
if (isCrossfireOutputBufferAvailable()) {
|
if (lua_gettop(L) == 0) {
|
||||||
|
lua_pushboolean(L, isCrossfireOutputBufferAvailable());
|
||||||
|
}
|
||||||
|
else if (isCrossfireOutputBufferAvailable()) {
|
||||||
uint8_t command = luaL_checkunsigned(L, 1);
|
uint8_t command = luaL_checkunsigned(L, 1);
|
||||||
luaL_checktype(L, 2, LUA_TTABLE);
|
luaL_checktype(L, 2, LUA_TTABLE);
|
||||||
uint8_t length = luaL_len(L, 2);
|
uint8_t length = luaL_len(L, 2);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue