Showing 1 changed files with 47 additions and 49 deletions
+47 -49
Nasal/afcs.nas
... ...
@@ -205,10 +205,13 @@ var APClass = {
205 205
 # {{{
206 206
             _aliases: {
207 207
                 hdg:          afcs.getNode('heading-bug-deg'),
208
-                alt:          afcs.getNode('selected-alt-ft'),
209 208
                 NAVCourse:    cdi.getNode('course'),
210 209
                 OBSNAVNeedle: cdi.getNode('course-deflection'),
211 210
             },
211
+            ap_annun_color: {
212
+                rdy: "white",
213
+                fail: "red",
214
+            },
212 215
             hook : func {
213 216
                 me.trimTarget = 0;
214 217
                 foreach (var a; keys(me._aliases)) stec55x[a].alias(me._aliases[a]);
... ...
@@ -218,43 +221,41 @@ var APClass = {
218 221
                 var armed     = '';
219 222
                 var active    = '';
220 223
                 var reference = '';
221
-                if (stec55x.pitchMode != 1) {
222
-                    if (stec55x.ALT_annun.getBoolValue()) {
223
-                        if (abs(data.alt - afcs.getValue('selected-alt-ft')) < 150) {
224
-                            active    = 'ALT';
225
-                            reference = sprintf('%5d ft', afcs.getValue('selected-alt-ft'));
226
-                            armed     = 'ALTS'
227
-                        }
228
-                        else {
229
-                            active    = 'ALT';
230
-                            reference = sprintf('%5d ft', math.round(data.alt, 10));
231
-                            armed     = 'ALT';
232
-                        }
233
-                    }
234
-                    elsif (stec55x.VS_annun.getBoolValue()) {
235
-                        active    = 'VS';
236
-                        reference = sprintf('%s%4d fpm',
237
-                                        utf8.chstr(stec55x.vs.getValue() > 0 ? 9650 : 9660),
238
-                                        math.abs(math.round(stec55x.vs.getValue(), 10)));
239
-                    }
240
-                    elsif (stec55x.GSArmed.getBoolValue()) {
241
-                        armed  = 'VPATH';
242
-                        active = 'GS';
243
-                    }
244
-# TODO: ask Octal450 which prop or variable can be used here
245
-#                    elsif (stec55x.???) {
246
-#                        armed  = 'PIT';
247
-#                        active = 'ALT';
248
-#                        reference = sprintf("%d°", autopilot.systems.STEC55X.trim);
249
-#                    }
224
+                if (stec55x.ALT_annun.getBoolValue()) {
225
+                    active    = 'ALT';
226
+                    reference = sprintf('%5d ft', abs(data.alt - afcs.getValue('selected-alt-ft')) < 150 ? afcs.getValue('selected-alt-ft') : math.round(data.alt, 10));
227
+                    armed     = sprintf('%.2f inHg', stec55x.alt.getValue());
250 228
                 }
229
+                elsif (stec55x.VS_annun.getBoolValue()) {
230
+                    active    = 'VS';
231
+                    reference = sprintf('%s%4d fpm',
232
+                                    utf8.chstr(stec55x.vs.getValue() > 0 ? 9650 : 9660),
233
+                                    math.abs(math.round(stec55x.vs.getValue(), 10)));
234
+                }
235
+                elsif (stec55x.GSArmed.getBoolValue()) {
236
+                    armed  = 'VPATH';
237
+                    active = 'GS';
238
+                }
239
+
240
+                var ap_state = [];
241
+                if (stec55x.RDY_annun.getBoolValue())
242
+                    ap_state = ["RDY", "white", "black"];
243
+                elsif (stec55x.FAIL_annun.getBoolValue())
244
+                    ap_state = ["FAIL", "black", "red"];
245
+                elsif (stec55x.systemAlive.getBoolValue())
246
+                    ap_state = ["AP", "black", "green"];
247
+                else
248
+                    ap_state = ["", "black", "black"];
251 249
 
252 250
                 foreach (var terminal; me.terminals) {
253 251
                     var se = flightdeck[terminal].display.screenElements;
254 252
                     se['VERMOD-Active-text'].setVisible(size(active)).setText(active);
255 253
                     se['VERMOD-Armed-text'].setVisible(size(armed)).setText(armed);
256 254
                     se['VERMOD-Reference-text'].setVisible(size(reference)).setText(reference);
257
-                    se['AP-Status-text'].setVisible(stec55x.rollMode  != -1 or stec55x.pitchMode != -1);
255
+                    se['AP-Status-text'].setColorFill(flightdeck[terminal].display.colors[ap_state[2]])
256
+                                        .setColor(ap_state[1])
257
+                                        .setVisible(size(ap_state[0]))
258
+                                        .setText(ap_state[0]);
258 259
                     se['YD-Status-text'].setVisible(stec55x.yaw.getValue() != -1);
259 260
                     if (stec55x.rollMode  != -1) {
260 261
                         se['LATMOD-Active-text'].setVisible(1).setText('ROL');
... ...
@@ -263,7 +264,7 @@ var APClass = {
263 264
                             if (stec55x[m]) armed = m;
264 265
                         if (stec55x.roll.getValue() == 0) armed = 'HDG';
265 266
                         elsif (stec55x.roll.getValue() == 2) armed = 'GPS';
266
-                        elsif (stec55x.APR_annun.getValue()) armed = 'APR';
267
+                        elsif (stec55x.APR_annun.getValue()) armed = 'LOC';
267 268
                         se['LATMOD-Armed-text']
268 269
                             .setVisible(size(armed))
269 270
                             .setText(armed);
... ...
@@ -276,10 +277,13 @@ var APClass = {
276 277
 
277 278
             },
278 279
             L: [
279
-                func,
280 280
                 func {
281
-#                    var apfd_master_sw = '/it-stec55x/input/apfd-master-sw';
282
-#                    setprop(apfd_master_sw, !getprop(apfd_master_sw));
281
+                    var ap_master_sw = '/it-stec55x/input/ap-master-sw';
282
+                    setprop(ap_master_sw, !getprop(ap_master_sw));
283
+                },
284
+                func {
285
+                    var apfd_master_sw = '/it-stec55x/input/apfd-master-sw';
286
+                    setprop(apfd_master_sw, !getprop(apfd_master_sw));
283 287
                 },
284 288
                 func {
285 289
                     var _roll = stec55x.roll.getValue();
... ...
@@ -291,18 +295,18 @@ var APClass = {
291 295
                     }
292 296
                 },
293 297
                 func {
294
-#                    call(stec55x.button.ALT, [], nil, stec55x);
298
+                    call(stec55x.button.ALT, [], nil, stec55x);
295 299
                 },
296 300
                 func {
297
-#                    stec55x.vs.setValue(math.round(data.vsi, 100));
298
-#                    call(stec55x.button.VS, [], nil, stec55x);
301
+                    stec55x.vs.setValue(math.round(data.vsi, 100));
302
+                    call(stec55x.button.VS, [], nil, stec55x);
299 303
                 },
300 304
                 func,
301 305
             ],
302 306
             R: [
303 307
                 func {
304
-#                    var yaw_dumper_sw = '/it-stec55x/input/yaw-damper-sw';
305
-#                    setprop(yaw_dumper_sw, !getprop(yaw_dumper_sw));
308
+                    var yaw_dumper_sw = '/it-stec55x/input/yaw-damper-sw';
309
+                    setprop(yaw_dumper_sw, !getprop(yaw_dumper_sw));
306 310
                 },
307 311
                 func {
308 312
                     if (stec55x.roll.getValue() == 0)
... ...
@@ -311,20 +315,14 @@ var APClass = {
311 315
                         call(stec55x.button.HDG, [], nil, stec55x);
312 316
                 },
313 317
                 func {
314
-#                    call(stec55x.button.APR, [], nil, stec55x);
318
+                    call(stec55x.button.APR, [], nil, stec55x);
315 319
                 },
316 320
                 func,
317 321
                 func { # UP (trim)
318
-#                    if (autopilot.systems.STEC55X.trimTarget > -15)
319
-#                        autopilot.systems.STEC55X.trimTarget -= 1;
320
-#                    fgcommand('property-assign', {property: '/it-stec55x/input/man-trim', value: -1});
321
-#                    fgcommand('property-assign', {property: '/it-stec55x/input/man-trim', value:  0});
322
+                    call(stec55x.button.Knob, [1], nil, stec55x);
322 323
                 },
323 324
                 func { # DN (trim)
324
-#                    if (autopilot.systems.STEC55X.trimTarget < 20)
325
-#                        autopilot.systems.STEC55X.trimTarget += 1;
326
-#                    fgcommand('property-assign', {property: '/it-stec55x/input/man-trim', value: 1});
327
-#                    fgcommand('property-assign', {property: '/it-stec55x/input/man-trim', value: 0});
325
+                    call(func{stec55x.button.Knob(-1)}, [], nil, stec55x);
328 326
                 },
329 327
             ],
330 328
         },