Subversion Repositories group.electronics

Rev

Rev 185 | Rev 187 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 185 Rev 186
Line 11... Line 11...
11
 
11
 
12
        private mcp23017[] chips;
12
        private mcp23017[] chips;
13
        private Oled oled;
13
        private Oled oled;
14
        public UInt16 ledShadowA = 0x0000;
14
        public UInt16 ledShadowA = 0x0000;
15
 
15
 
-
 
16
        public UInt16 flap_value = 0;
-
 
17
        public UInt16 flap_shadow = 1;
-
 
18
 
-
 
19
        BitImage flap_background;
-
 
20
        BitImage flap_needle;
-
 
21
 
16
        public NitAuxPanel(mcp2221 mcp) : base(mcp) {
22
        public NitAuxPanel(mcp2221 mcp) : base(mcp) {
17
            chips = new mcp23017[3] { new mcp23017(mcp, 0x20), new mcp23017(mcp, 0x21), new mcp23017(mcp, 0x22) };
23
            chips = new mcp23017[3] { new mcp23017(mcp, 0x20), new mcp23017(mcp, 0x21), new mcp23017(mcp, 0x22) };
18
 
24
 
19
            this.Init();
25
            this.Init();
20
        }
26
        }
Line 83... Line 89...
83
            this.addLed(new Led(0, 9, 0x10da, 0x0200, 9));     // R_ELEVATOR_EMER_DISENGAGE 
89
            this.addLed(new Led(0, 9, 0x10da, 0x0200, 9));     // R_ELEVATOR_EMER_DISENGAGE 
84
            this.addLed(new Led(0, 8, 0x1026, 0x0400, 10));    // TAKE_OFF_TRIM
90
            this.addLed(new Led(0, 8, 0x1026, 0x0400, 10));    // TAKE_OFF_TRIM
85
 
91
 
86
            
92
            
87
 
93
 
88
            //Bitmap flap = new Bitmap(nitdcscore.Properties.Resources.flap_bg);
94
            flap_background = new BitImage(new Bitmap(nitdcscore.Properties.Resources.flap_bg));
89
            BitImage bi = new BitImage(new Bitmap(nitdcscore.Properties.Resources.flap_bg));
95
            flap_needle = new BitImage(new Bitmap(nitdcscore.Properties.Resources.flap_needle));
-
 
96
 
90
            
97
            
91
            oled = new Oled(Oled.SWITCHCAPVCC, 0x3d, mcp);
98
            oled = new Oled(Oled.SWITCHCAPVCC, 0x3d, mcp);
92
            oled.init();
99
            oled.init();
93
            //oled.buffer = bi.toByteArray();
-
 
94
            oled.display();
100
            oled.display();
95
 
101
 
96
            // Register the flap gauge position address
102
            // Register the flap gauge position address
97
            UInt16 din; // Addr 10A0, Mask FFFF, Max Val FFFF, Shift 0
103
            UInt16 din; // Addr 10A0, Mask FFFF, Max Val FFFF, Shift 0
98
            if (!Globals.BiosOutput.TryGetValue(0x10A0, out din)) {
104
            if (!Globals.BiosOutput.TryGetValue(0x10A0, out din)) {
Line 123... Line 129...
123
            data.buttons |= (UInt64)bytes[0] << 8;
129
            data.buttons |= (UInt64)bytes[0] << 8;
124
            data.buttons |= (UInt64)bytes[1];
130
            data.buttons |= (UInt64)bytes[1];
125
 
131
 
126
            data.axis[0].value = mcp.ReadADC(0); // Y Axis
132
            data.axis[0].value = mcp.ReadADC(0); // Y Axis
127
 
133
 
-
 
134
            Globals.BiosOutput.TryGetValue(0x10A0, out this.flap_value);
-
 
135
 
128
            //ushort tmpval = 0;
136
            //ushort tmpval = 0;
129
            //bool changed = data.axis[0].getPosition(ref tmpval);
137
            //bool changed = data.axis[0].getPosition(ref tmpval);
130
            //tmpval = 0;
138
            //tmpval = 0;
131
            if (data.buttons != data.prev || data.axis[0].value != data.axis[0].prev)
139
            if (data.buttons != data.prev || data.axis[0].value != data.axis[0].prev )
132
                data.changed = true;
140
                data.changed = true;
133
            else
141
            else
134
                data.changed = false;
142
                data.changed = false;
135
 
143
 
136
            UInt16 tmpShadow = this.ledShadowA;
144
            UInt16 tmpShadow = this.ledShadowA;
Line 145... Line 153...
145
                
153
                
146
                chips[2].SetBank(0, (byte)gpa);
154
                chips[2].SetBank(0, (byte)gpa);
147
                chips[2].SetBank(1, (byte)gpb);
155
                chips[2].SetBank(1, (byte)gpb);
148
            }
156
            }
149
 
157
 
-
 
158
            
-
 
159
 
150
 
160
 
151
            return rslt;
161
            return rslt;
152
        }
162
        }
153
 
163
 
154
        public override int Input() {
164
        public override int Input() {
Line 159... Line 169...
159
            }
169
            }
160
            
170
            
161
            data.axis[0].prev = data.axis[0].value;
171
            data.axis[0].prev = data.axis[0].value;
162
            data.prev = data.buttons;
172
            data.prev = data.buttons;
163
            data.changed = false;
173
            data.changed = false;
-
 
174
 
-
 
175
 
-
 
176
            if (this.flap_value != this.flap_shadow) {
-
 
177
                
-
 
178
 
-
 
179
                BitImage flap_rotate = new BitImage(flap_needle);
-
 
180
                BitImage flap_display = new BitImage(flap_background);
-
 
181
 
-
 
182
                UInt16 flap_set = Globals.map_uint16(flap_value, 0, 0xffff, 0, 90);
-
 
183
                Console.WriteLine("{0} {1} {2}", flap_set, flap_value, flap_shadow);
-
 
184
                flap_rotate.rotate(flap_set);
-
 
185
                flap_display.blit(flap_rotate, 60, 4);
-
 
186
                oled.buffer = flap_display.toByteArray();
-
 
187
                oled.display();
-
 
188
 
-
 
189
                this.flap_shadow = this.flap_value;
-
 
190
            }
-
 
191
 
164
            return 1;
192
            return 1;
165
        }
193
        }
166
    }
194
    }
167
}
195
}
168
 
196