feat(lua): Add several Lua API funcs and constants (#2279)

* LUA: Add Bitmap.toMask and lcd.drawBitmapPattern functions

* LUA: Add lcd.invertRect function

* LUA: Add Bitmap.resize function

* LUA: Add getOutputValue function

* LUA: Add timer showElapsed configuration

* LUA: Add model extendedLimits configuration

* LUA: Add some global constants

* Add model jitterFilter configuration

* Add model.getSwashRing and setSwashRing functions
This commit is contained in:
David PHAM-VAN
2022-09-08 20:03:58 +10:00
committed by GitHub
parent ab640e3055
commit 155a854131
3 changed files with 327 additions and 6 deletions
+28
View File
@@ -2447,6 +2447,27 @@ static int luaSources(lua_State * L)
return 3;
}
/*luadoc
@function getOutputValue(outputIndex)
@param outputIndex: integer identifying the output channel number 0 for CH1, up to MAX_OUTPUT_CHANNELS - 1.
@retval value current output value (number). Zero is returned for:
* non-existing outputs
@status current Introduced in 2.8.0
*/
static int luaGetOutputValue(lua_State * L)
{
mixsrc_t idx = luaL_checkinteger(L, 1);
if (idx >= 0 && idx < MAX_OUTPUT_CHANNELS) {
lua_pushinteger(L, channelOutputs[idx]);
} else {
lua_pushinteger(L, 0);
}
return 1;
}
const luaL_Reg opentxLib[] = {
{ "getTime", luaGetTime },
{ "getDateTime", luaGetDateTime },
@@ -2459,6 +2480,7 @@ const luaL_Reg opentxLib[] = {
{ "getRotEncSpeed", luaGetRotEncSpeed },
{ "getRotEncMode", luaGetRotEncMode },
{ "getValue", luaGetValue },
{ "getOutputValue", luaGetOutputValue },
{ "getRAS", luaGetRAS },
{ "getTxGPS", luaGetTxGPS },
{ "getFieldInfo", luaGetFieldInfo },
@@ -2581,6 +2603,10 @@ const luaR_value_entry opentxConstants[] = {
{ "SWITCH_COUNT", SWSRC_COUNT },
{ "MAX_SENSORS", MAX_TELEMETRY_SENSORS },
{ "MAX_OUTPUT_CHANNELS", MAX_OUTPUT_CHANNELS },
{ "LIMIT_EXT_PERCENT", LIMIT_EXT_PERCENT },
{ "LIMIT_STD_PERCENT", LIMIT_STD_PERCENT },
{ "LS_FUNC_NONE", LS_FUNC_NONE },
{ "LS_FUNC_VEQUAL", LS_FUNC_VEQUAL },
{ "LS_FUNC_VALMOSTEQUAL", LS_FUNC_VALMOSTEQUAL },
@@ -2631,6 +2657,8 @@ const luaR_value_entry opentxConstants[] = {
{ "COLOR", ZoneOption::Color },
{ "BOOL", ZoneOption::Bool },
{ "STRING", ZoneOption::String },
{ "TIMER", ZoneOption::Timer },
{ "TEXT_SIZE", ZoneOption::TextSize },
{ "MENU_HEADER_HEIGHT", COLOR2FLAGS(MENU_HEADER_HEIGHT) },
// Colors gui/colorlcd/colors.h