zkv1000 / Nasal / buttons.nas /
Newer Older
161 lines | 6.789kb
commit initial
Sébastien MARQUE authored on 2017-03-07
1
var buttonsClass = {
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
2
    new : func (device) {
commit initial
Sébastien MARQUE authored on 2017-03-07
3
        var m = { parents: [ buttonsClass ] };
improves role/name variables...
Sébastien MARQUE authored on 2017-04-08
4
        m.device = device;
commit initial
Sébastien MARQUE authored on 2017-03-07
5
        return m;
6
    },
7

            
8
    PAN : func (xdir = 0, ydir = 0) {
9
    },
10

            
11
    AsSwitchNAV : func {
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
12
        var n = radios.getValue('nav-tune');
commit initial
Sébastien MARQUE authored on 2017-03-07
13
        var tmp = getprop('/instrumentation/nav[' ~ n ~ ']/frequencies/selected-mhz');
14
        setprop('/instrumentation/nav[' ~ n ~ ']/frequencies/selected-mhz', getprop('/instrumentation/nav[' ~ n ~ ']/frequencies/standby-mhz'));
15
        setprop('/instrumentation/nav[' ~ n ~ ']/frequencies/standby-mhz', tmp);
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
16
        foreach (var c; keys(flightdeck))
17
            if (contains(flightdeck[c], 'display'))
18
                flightdeck[c].display.updateNAV({refresh: n+1});
commit initial
Sébastien MARQUE authored on 2017-03-07
19
    },
20

            
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
21
    AsSwitchCOM : func (x) {
commit initial
Sébastien MARQUE authored on 2017-03-07
22
        if (x) {
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
23
            me.AsSwitchCOM_pushed = getprop('/sim/time/elapsed-sec');
commit initial
Sébastien MARQUE authored on 2017-03-07
24
        }
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
25
        else {
26
            var pressed = getprop('/sim/time/elapsed-sec') - me.AsSwitchCOM_pushed;
27
            if (pressed > 2) {
28
                setprop('/instrumentation/comm/frequencies/selected-mhz', 121.500);
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
29
                radios.setValue('comm1-selected', 1);
30
                radios.setValue('comm2-selected', 0);
fix COMM display standby fre...
Sébastien MARQUE authored on 2017-04-09
31
                foreach (var d; keys(flightdeck))
32
                    if (contains(flightdeck[d], 'display')) {
33
                        flightdeck[d].display.updateCOMM({refresh: 1});
34
                        flightdeck[d].display.updateCOMM({refresh: 2});
35
                    }
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
36
            }
37
            else {
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
38
                var c = radios.getValue('comm-tune');
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
39
                var tmp = getprop('/instrumentation/comm[' ~ c ~ ']/frequencies/selected-mhz');
40
                setprop('/instrumentation/comm[' ~ c ~ ']/frequencies/selected-mhz', getprop('/instrumentation/comm[' ~ c ~ ']/frequencies/standby-mhz'));
41
                setprop('/instrumentation/comm[' ~ c ~ ']/frequencies/standby-mhz', tmp);
fix COMM display standby fre...
Sébastien MARQUE authored on 2017-04-09
42
                foreach (var d; keys(flightdeck))
43
                    if (contains(flightdeck[d], 'display'))
44
                        flightdeck[d].display.updateCOMM({refresh: c+1});
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
45
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
46
        }
47
    },
48

            
ajout de l'animation des bou...
Sébastien MARQUE authored on 2017-03-08
49
    ALT : func () {
50
        var alt = getprop('instrumentation/altimeter/indicated-altitude-ft');
remove hardcoded properties ...
Sébastien MARQUE authored on 2020-04-27
51
        afcs.setIntValue('selected-alt-ft', math.round(alt, 10));
commit initial
Sébastien MARQUE authored on 2017-03-07
52
    },
53

            
TMR/REF available
Sébastien MARQUE authored on 2017-04-10
54
    ValidateTMRREF : func (a = 0) {
55
        if (a)
56
            return;
57
        var (id, selected) = split('-', me.device.windows.selected);
58
        var state = me.device.windows.state[id];
59
        selected += state.scroll.offset;
60
        if (contains(state.objects[selected], 'callback'))
61
            call(state.objects[selected].callback, [id, selected], me);
62
    },
63

            
64
    ClearTMRREF : func (a = 0) {
65
        if (a)
66
            return;
67
        me.device.windows.del();
68
        me.device.data.TMRtimer = nil;
69
        me.device.knobs.FmsInner = func;
70
        me.device.knobs.FmsOuter = func;
71
        me.device.buttons.ENT = func;
72
        me.device.buttons.FMS = func;
73
        me.device.buttons.CLR = func;
74
    },
75

            
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
76
    MFD_page_wrapper : func (id, selected) {
77
        var s = me.device.data[id][me.device.display['page selected']];
78
        var group = s.name;
79
        var subpage = s.objects[selected].text;
80

            
81
        foreach (var k; keys(me.device.windows.window))
allows only implemented MFD ...
Sébastien MARQUE authored on 2017-06-02
82
            if (find(id, k) == 0) {
83
                me.device.windows.del(id);
84
                break;
85
            }
86
        call(me.device.display.MFD[group][subpage], [], me);
fix MFD page selection syste...
Sébastien MARQUE authored on 2017-04-13
87
    },
88

            
massive code reorganisation ...
Sébastien MARQUE authored on 2017-05-01
89
    MapMenu : func (a = 0) {
90
        if (a == 1)
91
            return;
92
        var menu_label = 'MAP MENU';
93
        if (!contains(me.device.windows.window, menu_label ~ '-bg')) {
94
            var level_min = 13;
95
            var level_max = 7;
96
            var levels = [ sprintf('  % 2u >', level_max) ];
97
            for (var i = level_max + 1; i <= level_min; i += 1)
98
                append(levels, sprintf(i < level_min ? '< % 2u >' : '< % 2u  ', i));
99
            var orientation = [ '  NORTH UP >', '<  TRK UP  >' ];
100
            if (getprop('/instrumentation/gps/route-distance-nm') != nil)
101
                append(orientation, '<  DTK UP  >');
102
            append(orientation, '<  HDG UP   ');
103
            me.device.windows.draw(
104
                    menu_label,
105
                    {x: 720, y: 100, w: 300, l:3, sep: 1},
106
                    [
107
                        {text: menu_label, type: 'title'},
108
                        {type: 'separator'},
109
                        {text: 'ZOOM LEVEL', type: 'normal'},
110
                        {text: sprintf('%s % 2u %s',
111
                                me.device.data.zoom > level_max ? '<' : ' ',
112
                                me.device.data.zoom,
113
                                me.device.data.zoom < level_min ? '>' : ' '),
114
                         type: 'selected|end-of-line',
115
                         choices: levels,
116
                         callback: func (id, selected) {
117
                             var z = me.device.windows.state[id].objects[selected].text;
118
                             foreach (var c; [' ', '<', '>'])
119
                                 z = string.replace(z, c, '');
120
                             me.device.data.zoom = z;
121
                             me.device.map.changeZoom();
122
                             me.device.map.update();
123
                         }
124
                        },
125
                        {text: 'ORIENTATION', type: 'normal'},
126
                        {text: (func foreach (var o; orientation) if (find(me.device.data.orientation.text, o) > -1) return o;)(),
127
                         type: 'editable|end-of-line',
128
                         choices: orientation,
129
                         callback: func (id, selected) {
130
                             var o = me.device.windows.state[id].objects[selected].text;
131
                             o = substr(o, 2);
132
                             o = substr(o, 0, size(o) - 2);
133
                             o = string.trim(o);
134
                             me.device.data.orientation.text = o;
135
                             me.device.map.update();
136
                         }
137
                        },
138
                    ]
139
                );
140
            me.device.knobs.FmsOuter = me.device.knobs.NavigateMenu;
141
            me.device.knobs.FmsInner = me.device.knobs.MenuSettings;
142
            me.device.buttons.CLR = me.device.buttons.MapMenu;
143
            me.device.buttons.ENT = me.device.buttons.ValidateTMRREF;
144
        }
145
        else {
146
            me.device.buttons.ENT = func;
147
            me.device.buttons.CLR = func;
148
            me.device.knobs.FmsInner = func;
149
            me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
150
            me.device.windows.del(menu_label);
151
        }
152
    },
153

            
commit initial
Sébastien MARQUE authored on 2017-03-07
154
    DirectTo : void,
155
    MENU : void,
156
    FPL : void,
157
    PROC : void,
158
    CLR : void,
159
    ENT : void,
160
    FMS : void,
161
};