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]; |
|
simplier references
|
69 |
var object = state.objects[selected + state.scroll.offset]; |
70 |
var val = object.text; |
|
71 |
if (contains(object, 'choices')) { |
|
some choices may be unidirec...
|
72 |
if ((d > 0 and val[size(val)-1] != `>`) |
73 |
or (d < 0 and val[0] != `<`)) |
|
74 |
return; |
|
simplier references
|
75 |
forindex (var c; object.choices) |
76 |
if (object.choices[c] == val) { |
|
77 |
if (c == size(object.choices) - 1) val = object.choices[0]; |
|
78 |
else val = object.choices[c + 1]; |
|
79 | ||
80 |
me.device.windows.window[me.device.windows.selected] |
|
81 |
.setText(val); |
|
82 |
object.text = val; |
|
83 |
break; |
|
add window management
|
84 |
} |
85 |
} |
|
add the availibility to modi...
|
86 |
elsif (contains(object, 'format')) { |
87 |
var v = substr(val, find('%', object.format)); |
|
88 |
for (var c = 0; c < size(v); c +=1 ) |
|
89 |
if ((v[c] < `0` or v[c] > `9`) |
|
90 |
and v[c] != `.` and v[c] != ` ` |
|
91 |
and v[c] != `-` and v[c] != `+`) { |
|
92 |
v = string.trim(substr(v, 0, c)); |
|
93 |
break; |
|
94 |
} |
|
95 |
v += d * (contains(object, 'factor') ? object.factor : 1); |
|
96 |
val = sprintf(object.format, v); |
|
97 |
me.device.windows.window[me.device.windows.selected] |
|
98 |
.setText(val); |
|
99 |
object.text = val; |
|
100 |
} |
|
simplier references
|
101 |
elsif (find('time', object.type) > -1) { |
add window management
|
102 |
var (hh, mm, ss) = split(':', val); |
103 |
var time = hh * 3600 + mm * 60 + ss; |
|
104 |
if (time >= 600) # 10 min |
|
105 |
d *= 60; |
|
106 |
elsif (time >= 300) # 5 minutes |
|
107 |
d *= 30; |
|
108 |
elsif (time >= 180) # 3 minutes |
|
109 |
d *= 10; |
|
110 | ||
111 |
ss += d; |
|
112 | ||
113 |
if (ss > 59) { |
|
114 |
ss -= 60; |
|
115 |
mm += 1; |
|
116 |
if (mm > 59) { |
|
117 |
mm = 0; |
|
118 |
hh += 1; |
|
119 |
} |
|
120 |
} |
|
121 |
elsif (ss < 0) { |
|
122 |
if (mm > 0) { |
|
123 |
ss += 60; |
|
124 |
mm -= 1; |
|
125 |
} |
|
126 |
elsif (mm == 0 and hh > 0) { |
|
127 |
ss += 60; |
|
128 |
mm = 59; |
|
129 |
hh -= 1; |
|
130 |
} |
|
131 |
elsif (mm == 0 and hh == 0) |
|
132 |
ss = 0; |
|
133 |
} |
|
forgot to commit this in 14a...
|
134 |
val = sprintf('%02i:%02i:%02i', hh, mm, ss); |
add window management
|
135 |
me.device.windows.window[me.device.windows.selected] |
forgot to commit this in 14a...
|
136 |
.setText(val); |
137 |
object.text = val; |
|
add window management
|
138 |
} |
139 |
}, |
|
140 | ||
141 |
NavigateMenu : func (d) { |
|
scrolling available
|
142 |
# d: direction for searching the next selection (-1 or +1) |
143 |
# i : index of the object (not the canvas object) |
|
144 |
# state.scroll.offset : offset between canvas object pointed by i |
|
145 |
# and object in state hash, |
|
146 |
# selected : the canvas object id selected |
|
147 |
# id: the id of the window |
|
add window management
|
148 |
var (id, selected) = split('-', me.device.windows.selected); |
149 |
var state = me.device.windows.state[id]; |
|
scrolling available
|
150 |
selected += state.scroll.offset; |
151 |
# foreach object, beginning at the selected object, offset applied |
|
152 |
for (var i = selected + d; i >= 0 and i < size(state.objects); i += d) { |
|
153 |
if (i > state.scroll.end |
|
154 |
and d > 0 |
|
155 |
and state.scroll.lower < state.scroll.last) { |
|
156 |
me._navigatemenu_scrolldown(state, id, i); |
|
157 |
} |
|
158 |
elsif (i - state.scroll.offset < state.scroll.begin |
|
159 |
and d < 0 |
|
160 |
and state.scroll.upper > 0) { |
|
161 |
me._navigatemenu_scrollup(state, id, i); |
|
162 |
} |
|
163 |
if (find('editable', state.objects[i].type) > -1) { |
|
164 |
state.objects[selected].type = string.replace(state.objects[selected].type, |
|
add window management
|
165 |
'selected', 'editable'); |
166 |
me.device.windows.window[me.device.windows.selected] |
|
167 |
.setDrawMode(0x01) |
|
168 |
.setColor(0,1,1); |
|
scrolling available
|
169 |
state.objects[i].type = string.replace(state.objects[i].type, |
170 |
'editable', 'selected'); |
|
171 |
me.device.windows.window[id ~ '-' ~ (i - state.scroll.offset)] |
|
add window management
|
172 |
.setDrawMode(0x05) |
173 |
.setColorFill(0,1,1) |
|
174 |
.setColor(0,0,0); |
|
scrolling available
|
175 |
me.device.windows.selected = id ~ '-' ~ (i - state.scroll.offset); |
add window management
|
176 |
break; |
177 |
} |
|
178 |
} |
|
179 |
}, |
|
180 | ||
scrolling available
|
181 |
_navigatemenu_scrolldown : func (state, id, i) { |
182 |
state.scroll.upper = state.objects[i].scrollgroup - state.scroll.lines + 1; |
|
183 |
state.scroll.lower = state.objects[i].scrollgroup; |
|
184 |
state.scroll.offset = state.scroll.upper * state.scroll.columns; |
|
185 | ||
186 |
# foreach canvas object in the scrolling area |
|
187 |
for (var l = state.scroll.begin; l <= state.scroll.end; l += 1) { |
|
188 |
var t = state.objects[l + state.scroll.offset].text; |
|
189 |
me.device.windows.window[id ~ '-' ~ l] |
|
190 |
.setText(t); |
|
191 |
} |
|
192 |
}, |
|
193 | ||
194 |
_navigatemenu_scrollup : func (state, id, i) { |
|
195 |
state.scroll.upper = state.objects[i].scrollgroup; |
|
196 |
state.scroll.lower = state.objects[i].scrollgroup + state.scroll.lines - 1; |
|
197 |
state.scroll.offset = state.scroll.upper * state.scroll.columns; |
|
198 | ||
199 |
# foreach canvas object in the scrolling area |
|
200 |
for (var l = state.scroll.begin; l <= state.scroll.end; l += 1) { |
|
201 |
var t = state.objects[l + state.scroll.offset].text; |
|
202 |
me.device.windows.window[id ~ '-' ~ l] |
|
203 |
.setText(t); |
|
204 |
} |
|
205 |
}, |
|
206 | ||
commit initial
|
207 |
FmsInner : void, |
208 |
FmsOuter : void |
|
209 |
}; |