commit initial
|
1 |
var knobsClass = { |
XPDR settings via knob or so...
|
2 |
new : func (device) { |
commit initial
|
3 |
var m = { parents: [ knobsClass ] }; |
XPDR settings via knob or so...
|
4 |
m.device = device; |
commit initial
|
5 |
return m; |
6 |
}, |
|
7 | ||
XPDR settings via knob or so...
|
8 |
XPDRCodeSetDigits : func (d) { |
9 |
# disable SoftKey entering method |
|
10 |
setprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method', 1); |
|
11 |
if (!contains(me.device.softkeys.bindings.PFD.XPDR.CODE, 'on_change_inactivity')) { |
|
12 |
me.device.softkeys.bindings.PFD.XPDR.CODE.inactivity.stop(); |
|
13 |
me.device.softkeys.bindings.PFD.XPDR.CODE.on_change_inactivity = maketimer(10, |
|
14 |
func { |
|
15 |
setprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit', 3); |
|
16 |
call(me.device.softkeys.bindings.PFD.XPDR.CODE.restore, [], me); |
|
17 |
}); |
|
18 |
me.device.softkeys.bindings.PFD.XPDR.CODE.on_change_inactivity.singleShot = 1; |
|
19 |
me.device.softkeys.bindings.PFD.XPDR.CODE.on_change_inactivity.start(); |
|
20 |
} |
|
21 |
else |
|
22 |
me.device.softkeys.bindings.PFD.XPDR.CODE.on_change_inactivity.restart(10); |
|
23 |
var digit = getprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit'); |
|
24 |
var code = getprop('/instrumentation/transponder/id-code'); |
|
25 |
if (digit == 3) |
|
26 |
var val = int(code/100) + d; |
|
27 |
else |
|
28 |
var val = math.mod(code, 100) + d; |
|
29 |
if (math.mod(val, 10) == 8) { |
|
30 |
if (val > 77) |
|
31 |
val = 0; |
|
32 |
else |
|
33 |
val += 2; |
|
34 |
} |
|
35 |
elsif (val < 0) |
|
36 |
val = 77; |
|
37 |
elsif (math.mod(val, 10) == 9) |
|
38 |
val -= 2; |
|
39 |
if (digit == 3) |
|
40 |
setprop('/instrumentation/transponder/id-code', |
|
41 |
sprintf('%i', val * 100 + math.mod(code, 100))); |
|
42 |
else |
|
43 |
setprop('/instrumentation/transponder/id-code', |
|
44 |
sprintf('%i', int(code/100) * 100 + val)); |
|
45 |
me.device.display.updateXPDR(); |
|
46 |
}, |
|
47 | ||
48 |
XPDRCodeNextDigits : func { |
|
49 |
setprop('/instrumentation/zkv1000/radios/xpdr-tuning-fms-method', 1); |
|
50 |
if (!contains(me.device.softkeys.bindings.PFD.XPDR.CODE, 'on_change_inactivity')) { |
|
51 |
me.device.softkeys.bindings.PFD.XPDR.CODE.inactivity.stop(); |
|
52 |
me.device.softkeys.bindings.PFD.XPDR.CODE.on_change_inactivity = maketimer(10, |
|
53 |
func { |
|
54 |
setprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit', 3); |
|
55 |
call(me.device.softkeys.bindings.PFD.XPDR.CODE.restore, [], me); |
|
56 |
}); |
|
57 |
me.device.softkeys.bindings.PFD.XPDR.CODE.on_change_inactivity.singleShot = 1; |
|
58 |
me.device.softkeys.bindings.PFD.XPDR.CODE.on_change_inactivity.start(); |
|
59 |
} |
|
60 |
else |
|
61 |
me.device.softkeys.bindings.PFD.XPDR.CODE.on_change_inactivity.restart(10); |
|
62 |
setprop('/instrumentation/zkv1000/radios/xpdr-tuning-digit', 1); |
|
63 |
me.device.display.updateXPDR(); |
|
64 |
}, |
|
65 | ||
add window management
|
66 |
MenuSettings : func (d) { |
67 |
var (id, selected) = split('-', me.device.windows.selected); |
|
68 |
var state = me.device.windows.state[id]; |
|
69 |
if (find('choices', state.lines[selected].type) > -1) { |
|
70 |
var val = me.device.windows.window[me.device.windows.selected] |
|
71 |
.get('text'); |
|
72 |
forindex (var i; state.lines[selected].choices) |
|
73 |
if (state.lines[selected].choices[i] == val) { |
|
74 |
if (i == size(state.lines[selected].choices) - 1) |
|
75 |
me.device.windows.window[me.device.windows.selected] |
|
76 |
.setText(state.lines[selected].choices[0]); |
|
77 |
else |
|
78 |
me.device.windows.window[me.device.windows.selected] |
|
79 |
.setText(state.lines[selected].choices[i + 1]); |
|
80 |
break; |
|
81 |
} |
|
82 |
} |
|
83 |
elsif (find('time', state.lines[selected].type) > -1) { |
|
84 |
var val = me.device.windows.window[me.device.windows.selected] |
|
85 |
.get('text'); |
|
86 |
var (hh, mm, ss) = split(':', val); |
|
87 |
var time = hh * 3600 + mm * 60 + ss; |
|
88 |
if (time >= 600) # 10 min |
|
89 |
d *= 60; |
|
90 |
elsif (time >= 300) # 5 minutes |
|
91 |
d *= 30; |
|
92 |
elsif (time >= 180) # 3 minutes |
|
93 |
d *= 10; |
|
94 | ||
95 |
ss += d; |
|
96 | ||
97 |
if (ss > 59) { |
|
98 |
ss -= 60; |
|
99 |
mm += 1; |
|
100 |
if (mm > 59) { |
|
101 |
mm = 0; |
|
102 |
hh += 1; |
|
103 |
} |
|
104 |
} |
|
105 |
elsif (ss < 0) { |
|
106 |
if (mm > 0) { |
|
107 |
ss += 60; |
|
108 |
mm -= 1; |
|
109 |
} |
|
110 |
elsif (mm == 0 and hh > 0) { |
|
111 |
ss += 60; |
|
112 |
mm = 59; |
|
113 |
hh -= 1; |
|
114 |
} |
|
115 |
elsif (mm == 0 and hh == 0) |
|
116 |
ss = 0; |
|
117 |
} |
|
118 |
me.device.windows.window[me.device.windows.selected] |
|
119 |
.setText(sprintf('%02i:%02i:%02i', hh, mm, ss)); |
|
120 |
} |
|
121 |
}, |
|
122 | ||
123 |
NavigateMenu : func (d) { |
|
124 |
var (id, selected) = split('-', me.device.windows.selected); |
|
125 |
var state = me.device.windows.state[id]; |
|
126 |
for (var i = selected + d; i >= 0 and i < size(state.lines); i += d) { |
|
127 |
if (find('editable', state.lines[i].type) > -1) { |
|
128 |
state.lines[i].type = string.replace(state.lines[i].type, |
|
129 |
'editable', 'selected'); |
|
130 |
state.lines[selected].type = string.replace(state.lines[selected].type, |
|
131 |
'selected', 'editable'); |
|
132 |
me.device.windows.window[me.device.windows.selected] |
|
133 |
.setDrawMode(0x01) |
|
134 |
.setColor(0,1,1); |
|
135 |
me.device.windows.window[id ~ '-' ~ i] |
|
136 |
.setDrawMode(0x05) |
|
137 |
.setColorFill(0,1,1) |
|
138 |
.setColor(0,0,0); |
|
139 |
me.device.windows.selected = id ~ '-' ~ i; |
|
140 |
break; |
|
141 |
} |
|
142 |
} |
|
143 |
}, |
|
144 | ||
commit initial
|
145 |
FmsInner : void, |
146 |
FmsOuter : void |
|
147 |
}; |