feat(lua): add state & persistent properties to the logical switch API (#6327)
Co-authored-by: philmoz <phil.a.mitchell@gmail.com> Co-authored-by: Peter Feerick <pfeerick@users.noreply.github.com>
This commit is contained in:
co-authored by
philmoz
Peter Feerick
parent
aa6938eed7
commit
1611c1ff52
@@ -1037,8 +1037,10 @@ Get Logical Switch parameters
|
|||||||
* `and` (number) AND switch index
|
* `and` (number) AND switch index
|
||||||
* `delay` (number) delay (time in 1/10 s)
|
* `delay` (number) delay (time in 1/10 s)
|
||||||
* `duration` (number) duration (time in 1/10 s)
|
* `duration` (number) duration (time in 1/10 s)
|
||||||
|
* `state` (boolean) current state of the logical switch
|
||||||
|
* `persistent` (boolean) if true then the state is persistent across reboot of the radio
|
||||||
|
|
||||||
@status current Introduced in 2.0.0
|
@status current Introduced in 2.0.0, state and persistent added in 2.11.2
|
||||||
*/
|
*/
|
||||||
static int luaModelGetLogicalSwitch(lua_State *L)
|
static int luaModelGetLogicalSwitch(lua_State *L)
|
||||||
{
|
{
|
||||||
@@ -1053,6 +1055,8 @@ static int luaModelGetLogicalSwitch(lua_State *L)
|
|||||||
lua_pushtableinteger(L, "and", sw->andsw);
|
lua_pushtableinteger(L, "and", sw->andsw);
|
||||||
lua_pushtableinteger(L, "delay", sw->delay);
|
lua_pushtableinteger(L, "delay", sw->delay);
|
||||||
lua_pushtableinteger(L, "duration", sw->duration);
|
lua_pushtableinteger(L, "duration", sw->duration);
|
||||||
|
lua_pushtableboolean(L, "state", sw->lsState);
|
||||||
|
lua_pushtableboolean(L, "persistent", sw->lsPersist);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
@@ -1075,7 +1079,7 @@ that parameter remains unchanged.
|
|||||||
@notice To set the `and` member (which is Lua keyword)
|
@notice To set the `and` member (which is Lua keyword)
|
||||||
use the following syntax: `model.setLogicalSwitch(30, {func=4,v1=1,v2=-99, ["and"]=24})`
|
use the following syntax: `model.setLogicalSwitch(30, {func=4,v1=1,v2=-99, ["and"]=24})`
|
||||||
|
|
||||||
@status current Introduced in 2.0.0
|
@status current Introduced in 2.0.0, state and persistent added in 2.11.2
|
||||||
*/
|
*/
|
||||||
static int luaModelSetLogicalSwitch(lua_State *L)
|
static int luaModelSetLogicalSwitch(lua_State *L)
|
||||||
{
|
{
|
||||||
@@ -1108,6 +1112,12 @@ static int luaModelSetLogicalSwitch(lua_State *L)
|
|||||||
else if (!strcmp(key, "duration")) {
|
else if (!strcmp(key, "duration")) {
|
||||||
sw->duration = luaL_checkinteger(L, -1);
|
sw->duration = luaL_checkinteger(L, -1);
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(key, "state")) {
|
||||||
|
sw->lsState = lua_toboolean(L, -1);
|
||||||
|
}
|
||||||
|
else if (!strcmp(key, "persistent")) {
|
||||||
|
sw->lsPersist = lua_toboolean(L, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
storageDirty(EE_MODEL);
|
storageDirty(EE_MODEL);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user