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 |
|
remove hardcoded properties ...
|
10 |
radios.setValue('xpdr-tuning-fms-method', 1); |
XPDR settings via knob or so...
|
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 { |
|
remove hardcoded properties ...
|
15 |
radios.setValue('xpdr-tuning-digit', 3); |
XPDR settings via knob or so...
|
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); |
|
remove hardcoded properties ...
|
23 |
var digit = radios.getValue('xpdr-tuning-digit'); |
XPDR settings via knob or so...
|
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 { |
|
remove hardcoded properties ...
|
49 |
radios.setValue('xpdr-tuning-fms-method', 1); |
XPDR settings via knob or so...
|
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 { |
|
remove hardcoded properties ...
|
54 |
radios.setValue('xpdr-tuning-digit', 3); |
XPDR settings via knob or so...
|
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); |
|
remove hardcoded properties ...
|
62 |
radios.setValue('xpdr-tuning-digit', 1); |
XPDR settings via knob or so...
|
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) { |
|
fix issue #3
|
77 |
val = object.choices[c + d]; |
simplier references
|
78 |
me.device.windows.window[me.device.windows.selected] |
79 |
.setText(val); |
|
80 |
object.text = val; |
|
81 |
break; |
|
add window management
|
82 |
} |
fix: menu callbacks were alw...
|
83 |
if (find(object.type, 'immediate') > -1) |
in menus some items can be a...
|
84 |
me.device.buttons.ENT(); |
add window management
|
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 | ||
generic function to format t...
|
111 |
val = HMS(hh, mm, ss, d); |
add window management
|
112 | |
113 |
me.device.windows.window[me.device.windows.selected] |
|
forgot to commit this in 14a...
|
114 |
.setText(val); |
115 |
object.text = val; |
|
add window management
|
116 |
} |
117 |
}, |
|
118 | ||
119 |
NavigateMenu : func (d) { |
|
scrolling available
|
120 |
# d: direction for searching the next selection (-1 or +1) |
121 |
# i : index of the object (not the canvas object) |
|
122 |
# state.scroll.offset : offset between canvas object pointed by i |
|
123 |
# and object in state hash, |
|
124 |
# selected : the canvas object id selected |
|
125 |
# id: the id of the window |
|
add window management
|
126 |
var (id, selected) = split('-', me.device.windows.selected); |
127 |
var state = me.device.windows.state[id]; |
|
scrolling available
|
128 |
selected += state.scroll.offset; |
129 |
# foreach object, beginning at the selected object, offset applied |
|
130 |
for (var i = selected + d; i >= 0 and i < size(state.objects); i += d) { |
|
131 |
if (i > state.scroll.end |
|
132 |
and d > 0 |
|
133 |
and state.scroll.lower < state.scroll.last) { |
|
134 |
me._navigatemenu_scrolldown(state, id, i); |
|
135 |
} |
|
136 |
elsif (i - state.scroll.offset < state.scroll.begin |
|
137 |
and d < 0 |
|
138 |
and state.scroll.upper > 0) { |
|
139 |
me._navigatemenu_scrollup(state, id, i); |
|
140 |
} |
|
141 |
if (find('editable', state.objects[i].type) > -1) { |
|
142 |
state.objects[selected].type = string.replace(state.objects[selected].type, |
|
add window management
|
143 |
'selected', 'editable'); |
144 |
me.device.windows.window[me.device.windows.selected] |
|
145 |
.setDrawMode(0x01) |
|
146 |
.setColor(0,1,1); |
|
scrolling available
|
147 |
state.objects[i].type = string.replace(state.objects[i].type, |
148 |
'editable', 'selected'); |
|
149 |
me.device.windows.window[id ~ '-' ~ (i - state.scroll.offset)] |
|
add window management
|
150 |
.setDrawMode(0x05) |
151 |
.setColorFill(0,1,1) |
|
152 |
.setColor(0,0,0); |
|
scrolling available
|
153 |
me.device.windows.selected = id ~ '-' ~ (i - state.scroll.offset); |
add window management
|
154 |
break; |
155 |
} |
|
156 |
} |
|
157 |
}, |
|
158 | ||
scrolling available
|
159 |
_navigatemenu_scrolldown : func (state, id, i) { |
160 |
state.scroll.upper = state.objects[i].scrollgroup - state.scroll.lines + 1; |
|
161 |
state.scroll.lower = state.objects[i].scrollgroup; |
|
162 |
state.scroll.offset = state.scroll.upper * state.scroll.columns; |
|
163 | ||
164 |
# foreach canvas object in the scrolling area |
|
165 |
for (var l = state.scroll.begin; l <= state.scroll.end; l += 1) { |
|
166 |
var t = state.objects[l + state.scroll.offset].text; |
|
167 |
me.device.windows.window[id ~ '-' ~ l] |
|
168 |
.setText(t); |
|
169 |
} |
|
170 |
}, |
|
171 | ||
172 |
_navigatemenu_scrollup : func (state, id, i) { |
|
173 |
state.scroll.upper = state.objects[i].scrollgroup; |
|
174 |
state.scroll.lower = state.objects[i].scrollgroup + state.scroll.lines - 1; |
|
175 |
state.scroll.offset = state.scroll.upper * state.scroll.columns; |
|
176 | ||
177 |
# foreach canvas object in the scrolling area |
|
178 |
for (var l = state.scroll.begin; l <= state.scroll.end; l += 1) { |
|
179 |
var t = state.objects[l + state.scroll.offset].text; |
|
180 |
me.device.windows.window[id ~ '-' ~ l] |
|
181 |
.setText(t); |
|
182 |
} |
|
183 |
}, |
|
184 | ||
adds MFD page selection syst...
|
185 |
MFD_select_page_group : func (d) { |
186 |
if (contains(me.device.windows.state, 'page selection')) { |
|
187 |
if (me.device.display['page selected'] + d < size(me.device.data['page selection']) |
|
188 |
and me.device.display['page selected'] + d >= 0) { |
|
finalize MFD menus
|
189 |
me.device.windows.del('page selection'); |
adds MFD page selection syst...
|
190 |
me.device.display['page selected'] += d; |
191 |
} |
|
192 |
else |
|
193 |
return; |
|
194 |
} |
|
195 |
me.device.windows.draw('page selection', |
|
196 |
me.device.data['page selection'][me.device.display['page selected']].geometry, |
|
197 |
me.device.data['page selection'][me.device.display['page selected']].objects, |
|
198 |
); |
|
199 |
me.FmsInner = me.NavigateMenu; |
|
fix bad behaviour
|
200 |
me.device.buttons.ENT = me.device.buttons.ValidateTMRREF; |
finalize MFD menus
|
201 |
me.device.buttons.CLR = func { |
202 |
me.device.display['page selected'] = 0; |
|
203 |
me.device.windows.del('page selection'); |
|
204 |
me.device.buttons.CLR = func; |
|
205 |
me.device.buttons.ENT = func; |
|
206 |
}; |
|
adds MFD page selection syst...
|
207 |
}, |
208 | ||
commit initial
|
209 |
FmsInner : void, |
slow down FMS knobs
|
210 |
FmsOuter : void, |
211 |
FmsInner_slowdown: 0, |
|
212 |
FmsOuter_slowdown: 0, |
|
commit initial
|
213 |
}; |