From aaf7f67ebb3a511e05dcabe0f1b07164f70c6749 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Wed, 31 Aug 2016 23:12:18 +0200 Subject: [PATCH] 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 --- radio/src/lua/api_general.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index ac72e89fd9..1fa8dcd04e 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -23,6 +23,7 @@ #include "opentx.h" #include "stamp.h" #include "lua/lua_api.h" +#include "telemetry/frsky.h" #if defined(PCBHORUS) #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; } +/*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 @function getFlightMode(mode) @@ -886,6 +908,7 @@ const luaL_Reg opentxLib[] = { { "getVersion", luaGetVersion }, { "getGeneralSettings", luaGetGeneralSettings }, { "getValue", luaGetValue }, + { "getRAS", luaGetRAS }, { "getFieldInfo", luaGetFieldInfo }, { "getFlightMode", luaGetFlightMode }, { "playFile", luaPlayFile },