-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathf_xpsw.lua
More file actions
69 lines (52 loc) · 1.92 KB
/
Copy pathf_xpsw.lua
File metadata and controls
69 lines (52 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-- TNS|n-POSITION-SWITCH|TNE
---- ########################################################
---- # #
---- # Copyright (C) arminRC #
---- # YouTube channel: https://www.youtube.com/@arminrc #
---- # !!! Please like and subscribe !!! #
---- # #
---- # Script Type: Function #
---- # #
---- ########################################################
TRIG1_IDX = 0 -- index of the 1st logical switch that trigger the script (up)
TRIG2_IDX = 1 -- index of the 2nd logical switch that trigger the script (down)
START_IDX = 4 -- index of the 1st logical switch in the multi-position-switch
local current_idx = START_IDX -- index of the currently active switch-position
local function incrementSticky()
local sw_val = model.getLogicalSwitch(current_idx + 1)
if sw_val == nil then
return
end
if sw_val["func"] ~= LS_FUNC_STICKY then
return
end
setStickySwitch(current_idx, false)
setStickySwitch(current_idx + 1, true)
current_idx = current_idx + 1
end
local function decrementSticky()
if current_idx == START_IDX then
return
end
setStickySwitch(current_idx, false)
setStickySwitch(current_idx - 1, true)
current_idx = current_idx - 1
end
-- Called once when the script is loaded
local function init()
setStickySwitch(START_IDX, true)
end
-- Called periodically while the Special Function switch is on
local function run()
local trig1_val = getLogicalSwitchValue(TRIG1_IDX)
local trig2_val = getLogicalSwitchValue(TRIG2_IDX)
if trig1_val == true then
incrementSticky()
elseif trig2_val == true then
decrementSticky()
end
end
-- Called periodically while the Special Function switch is off
local function background()
end
return { run=run, background=background, init=init }