zkv1000 / Nasal / softkeys.nas /
Newer Older
144 lines | 5.206kb
commit initial
Sébastien MARQUE authored on 2017-03-07
1
var softkeysClass = {
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
2
    new : func (device, node, role) {
commit initial
Sébastien MARQUE authored on 2017-03-07
3
        var m = { parents: [ softkeysClass ] };
4
        m.node = node;
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
5
        m.device = device;
commit initial
Sébastien MARQUE authored on 2017-03-07
6
        m.role = role;
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
7
        m.path = [];
commit initial
Sébastien MARQUE authored on 2017-03-07
8
        return m;
9
    },
10

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
11
    clean : func {
12
        # deletes unsed bindings
fix commit récédent un peu r...
Sébastien MARQUE authored on 2017-03-14
13
        foreach (var b; keys(me.bindings))
14
            if (b != me.role)
15
                delete(me.bindings, b);
commit initial
Sébastien MARQUE authored on 2017-03-07
16
    },
17

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
18
    SoftKey : func (n, a) {
19
        # released key not yet managed
20
        if (a == 1)
21
            return;
22

            
23
        var key = me.device.display.screenElements[sprintf("SoftKey%02i-text",n)].get('text');
24
        if (key == '' or key == nil)
25
            return;
26

            
27
        var path = keyMap[me.role];
28
        foreach(var p; me.path) {
29
            if (contains(path, p))
30
                path = path[p];
31
            else
32
                break;
commit initial
Sébastien MARQUE authored on 2017-03-07
33
        }
34

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
35
        var bindings = me.bindings[me.role];
36
        foreach(var p; me.path) {
37
            if (contains(bindings, p))
38
                bindings = bindings[p];
39
            else
40
                break;
commit initial
Sébastien MARQUE authored on 2017-03-07
41
        }
42

            
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
43
        if (contains(path, key)) {
44
            append(me.path, key);
45
            me.device.display.updateSoftKeys();
commit initial
Sébastien MARQUE authored on 2017-03-07
46
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
47
        elsif (contains(bindings, key)) {
48
            call(bindings[key], [], me);
commit initial
Sébastien MARQUE authored on 2017-03-07
49
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
50
        elsif (key == 'BACK') {
51
            pop(me.path);
52
            me.device.display.updateSoftKeys();
commit initial
Sébastien MARQUE authored on 2017-03-07
53
        }
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
54
        else
55
            print(me.device.role ~ '/' ~ key ~ ' : not yet implemented');
56
    },
57

            
58
    bindings : {
59
        PFD : {
60
            INSET: {
61
                OFF: func {
62
                    pop(me.path);
63
                    me.device.display.updateSoftKeys();
64
                },
65
            },
66
            PFD: {
67
                'STD BARO': func {
68
                    pop(me.path);
69
                    me.device.display.updateSoftKeys();
70
                },
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
71
                'AOA/WIND' : {
72
                    WIND : {
73
                        OPTN1 : func {
74
                            me.device.display._winddata_optn = 1;
75
                            me.device.display.screenElements['WindData'].show();
76
                            me.device.display.screenElements['WindData-OPTN1'].show();
77
                            me.device.display.screenElements['WindData-OPTN1-HDG'].show();
78
                            me.device.display.screenElements['WindData-OPTN2'].hide();
79
                            me.device.display.updateWindData();
80
                        },
81
                        OPTN2 : func {
82
                            me.device.display._winddata_optn = 2;
83
                            me.device.display.screenElements['WindData'].show();
84
                            me.device.display.screenElements['WindData-OPTN1'].hide();
85
                            me.device.display.screenElements['WindData-OPTN2'].show();
86
                            me.device.display.screenElements['WindData-OPTN2-symbol'].show();
87
                            me.device.display.screenElements['WindData-OPTN2-headwind'].show();
88
                            me.device.display.screenElements['WindData-OPTN2-crosswind'].show();
89
                            me.device.display.updateWindData();
90
                        },
91
                        OFF : func {
92
                            me.device.display._winddata_optn = 0;
93
                            me.device.display.screenElements['WindData'].hide();
94
                            me.device.display.screenElements['WindData-OPTN1'].hide();
95
                            me.device.display.screenElements['WindData-OPTN2'].hide();
96
                        },
97
                    },
98
                },
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
99
                BRG1 : func (brg = 1){
100
                    var source = 'brg' ~ brg ~ '-source';
101
                    var list = ['NAV' ~ brg, 'GPS', 'ADF', 'OFF'];
102
                    var index = std.Vector
103
                                   .new(list)
104
                                   .index(radios.getNode(source).getValue());
105
                    var next = (index == size(list) -1) ?  0 : index + 1;
106
                    radios.getNode(source).setValue(list[next]);
107
                },
108
                BRG2 : func {
109
                    call(me.bindings.PFD.PFD.BRG1, [ 2 ], me);
110
                },
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
111
            },
112
            XPDR: {
113
                CODE: {
114
                    IDENT: func {
115
                        me.path = [];
116
                        me.device.display.updateSoftKeys();
117
                    },
118
                    BACK: func {
119
                        me.path = [];
120
                        me.device.display.updateSoftKeys();
121
                    },
122
                },
123
            },
124
        },
125
        MFD : {
126
            ENGINE: {
127
                FUEL: {
128
                    UNDO: func {
129
                        pop(me.path);
130
                        me.device.display.updateSoftKeys();
131
                    },
132
                    ENTER: func {
133
                        pop(me.path);
134
                        me.device.display.updateSoftKeys();
135
                    },
136
                },
137
                ENGINE: func {
138
                    me.path = [];
139
                    me.device.display.updateSoftKeys();
140
                },
141
            },
142
        },
commit initial
Sébastien MARQUE authored on 2017-03-07
143
    },
144
};