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

Add getRAS to Lua interface (#3742)

* Add getRAS lua function

* Add warning

* Return nil is case of bad antenna

* Check for valid SWR

* Typo

* Cosmetic

* Clarify that it is 0x33
This commit is contained in:
Andre Bernet 2016-08-31 23:12:18 +02:00 committed by GitHub
parent 830593d62e
commit aaf7f67ebb

View file

@ -23,6 +23,7 @@
#include "opentx.h" #include "opentx.h"
#include "stamp.h" #include "stamp.h"
#include "lua/lua_api.h" #include "lua/lua_api.h"
#include "telemetry/frsky.h"
#if defined(PCBHORUS) #if defined(PCBHORUS)
#include "lua/lua_exports_horus.inc" // this line must be after lua headers #include "lua/lua_exports_horus.inc" // this line must be after lua headers
@ -498,6 +499,27 @@ static int luaGetValue(lua_State * L)
return 1; return 1;
} }
/*luadoc
@function getRAS()
Return the RAS value or nil if no valid hardware found
@retval number representing RAS value. Value bellow 0x33 (51 decimal) are all ok, value above 0x33 indicate a hardware antenna issue.
This is just a hardware pass/fail measure and does not represent the quality of the radio link
@status current Introduced in 2.2.0
*/
static int luaGetRAS(lua_State * L)
{
if (IS_SWR_VALUE_VALID()) {
lua_pushinteger(L, telemetryData.swr.value);
}
else {
lua_pushnil(L);
}
return 1;
}
/*luadoc /*luadoc
@function getFlightMode(mode) @function getFlightMode(mode)
@ -886,6 +908,7 @@ const luaL_Reg opentxLib[] = {
{ "getVersion", luaGetVersion }, { "getVersion", luaGetVersion },
{ "getGeneralSettings", luaGetGeneralSettings }, { "getGeneralSettings", luaGetGeneralSettings },
{ "getValue", luaGetValue }, { "getValue", luaGetValue },
{ "getRAS", luaGetRAS },
{ "getFieldInfo", luaGetFieldInfo }, { "getFieldInfo", luaGetFieldInfo },
{ "getFlightMode", luaGetFlightMode }, { "getFlightMode", luaGetFlightMode },
{ "playFile", luaPlayFile }, { "playFile", luaPlayFile },