1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-14 20:10:08 +03:00

LUA: add ability to read rotenc speed (#7918)

Add getRotEncSpeed()
This commit is contained in:
3djc 2020-09-04 18:24:41 +02:00 committed by GitHub
parent 6eb38bd048
commit f7153ababb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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) },