diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index 544417dda..e480eaec5 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -375,6 +375,26 @@ bool luaFindFieldByName(const char * name, LuaField & field, unsigned int flags) return false; // not found } +/*luadoc +@function getRotEncSpeed() + +Return rotary encoder current speed + +@retval number in list: ROTENC_LOWSPEED, ROTENC_MIDSPEED, ROTENC_HIGHSPEED + return 0 on radio without rotary encoder + +@status current Introduced in 2.3.10 +*/ +static int luGetRotEncSpeed(lua_State * L) +{ +#if defined(ROTARY_ENCODER_NAVIGATION) + lua_pushunsigned(L, rotencSpeed); +#else + lua_pushunsigned(L, 0); +#endif + return 1; +} + /*luadoc @function sportTelemetryPop() @@ -1680,6 +1700,7 @@ const luaL_Reg opentxLib[] = { { "getVersion", luaGetVersion }, { "getGeneralSettings", luaGetGeneralSettings }, { "getGlobalTimer", luaGetGlobalTimer }, + { "getRotEncSpeed", luGetRotEncSpeed }, { "getValue", luaGetValue }, { "getRAS", luaGetRAS }, { "getTxGPS", luaGetTxGPS }, @@ -1814,6 +1835,9 @@ const luaR_value_entry opentxConstants[] = { { "EVT_VIRTUAL_NEXT", EVT_ROTARY_RIGHT }, { "EVT_VIRTUAL_DEC", EVT_ROTARY_LEFT }, { "EVT_VIRTUAL_INC", EVT_ROTARY_RIGHT }, + { "ROTENC_LOWSPEED", ROTENC_LOWSPEED }, + { "ROTENC_MIDSPEED", ROTENC_MIDSPEED }, + { "ROTENC_HIGHSPEED", ROTENC_HIGHSPEED }, #elif defined(PCBX9D) || defined(PCBX9DP) // key reverted between field nav and value change { "EVT_VIRTUAL_PREV", EVT_KEY_FIRST(KEY_PLUS) }, { "EVT_VIRTUAL_PREV_REPT", EVT_KEY_REPT(KEY_PLUS) },