Subversion Repositories group.electronics

Rev

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

Rev 188 Rev 189
Line 88... Line 88...
88
            this.addLed(new Led(0, 10, 0x10da, 0x0100, 8));     // L_ELEVATOR_EMER_DISENGAGE 
88
            this.addLed(new Led(0, 10, 0x10da, 0x0100, 8));     // L_ELEVATOR_EMER_DISENGAGE 
89
            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 
90
            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
91
 
91
 
92
            
92
            
93
 
-
 
94
            flap_background = new BitImage(new Bitmap(nitdcscore.Properties.Resources.flap_bg));
93
            flap_background = new BitImage(new Bitmap(nitdcscore.Properties.Resources.flap_bg));
95
            flap_needle = new BitImage(new Bitmap(nitdcscore.Properties.Resources.flap_needle));
94
            flap_needle = new BitImage(new Bitmap(nitdcscore.Properties.Resources.flap_needle));
96
 
95
 
97
            
-
 
98
            oled = new Oled(Oled.SWITCHCAPVCC, 0x3d, mcp);
96
            oled = new Oled(Oled.SWITCHCAPVCC, 0x3d, mcp);
99
            oled.init();
97
            oled.init();
100
            oled.display();
98
            //oled.display();
101
 
99
 
102
            // Register the flap gauge position address
100
            // Register the flap gauge position address
103
            UInt16 din; // Addr 10A0, Mask FFFF, Max Val FFFF, Shift 0
101
            UInt16 din; // Addr 10A0, Mask FFFF, Max Val FFFF, Shift 0
104
            if (!Globals.BiosOutput.TryGetValue(0x10A0, out din)) {
102
            if (!Globals.BiosOutput.TryGetValue(0x10A0, out din)) {
105
                Globals.BiosOutput.Add(0x10A0, 0x0000);
103
                Globals.BiosOutput.Add(0x10A0, 0x0000);
106
            }
104
            }
107
 
105
 
108
            data.axis[0].mapsize = 0xFFFF;
106
            data.axis[0].mapsize = 0xFFFF;
109
            data.axis[0].thres = 10;
107
            data.axis[0].thres = 8;
110
 
108
 
111
            this.Refresh();
109
            this.Refresh();
112
            data.prev = data.buttons;
110
            data.prev = data.buttons;
113
            data.axis[0].prev = data.axis[0].value;
111
            data.axis[0].prev = data.axis[0].value;
114
            data.changed = false;
112
            data.changed = false;
Line 129... Line 127...
129
            data.buttons |= (UInt64)bytes[0] << 8;
127
            data.buttons |= (UInt64)bytes[0] << 8;
130
            data.buttons |= (UInt64)bytes[1];
128
            data.buttons |= (UInt64)bytes[1];
131
 
129
 
132
            data.axis[0].value = mcp.ReadADC(0); // Y Axis
130
            data.axis[0].value = mcp.ReadADC(0); // Y Axis
133
 
131
 
-
 
132
            if (data.buttons != data.prev || data.axis[0].value != data.axis[0].prev) {
134
            Globals.BiosOutput.TryGetValue(0x10A0, out this.flap_value);
133
                foreach (Control control in this.controls) {
135
 
-
 
136
            //ushort tmpval = 0;
134
                    control.data = this.data;
137
            //bool changed = data.axis[0].getPosition(ref tmpval);
135
                    control.Tick();
138
            //tmpval = 0;
136
                }
139
            if (data.buttons != data.prev || data.axis[0].value != data.axis[0].prev )
137
                data.prev = data.buttons;
140
                data.changed = true;
138
            }
-
 
139
            
141
            else
140
            
142
                data.changed = false;
141
            // Update the leds if they have changed
143
 
-
 
144
            UInt16 tmpShadow = this.ledShadowA;
142
            UInt16 tmpShadow = this.ledShadowA;
145
            foreach (Led led in this.leds) {
143
            foreach (Led led in this.leds) {
146
                led.Tick(ref ledShadowA);
144
                led.Tick(ref ledShadowA);
147
            }
145
            }
148
 
146
 
149
            // Only update if leds have changed
-
 
150
            if (tmpShadow != this.ledShadowA) {
147
            if (tmpShadow != this.ledShadowA) {
151
                byte gpa = (byte)ledShadowA;
148
                byte gpa = (byte)ledShadowA;
152
                byte gpb = (byte)(ledShadowA >> 8);
149
                byte gpb = (byte)(ledShadowA >> 8);
153
                
150
                
154
                chips[2].SetBank(0, (byte)gpa);
151
                chips[2].SetBank(0, (byte)gpa);
155
                chips[2].SetBank(1, (byte)gpb);
152
                chips[2].SetBank(1, (byte)gpb);
156
            }
153
            }
157
 
154
 
158
            
-
 
159
 
-
 
160
 
-
 
161
            return rslt;
-
 
162
        }
-
 
163
 
-
 
164
        public override int Input() {
-
 
165
            foreach (Control control in this.controls) {
-
 
166
                control.data = this.data;
155
            // Check if the flaps need to be updated
167
                control.Tick();
-
 
168
            }
-
 
169
            
-
 
170
            data.axis[0].prev = data.axis[0].value;
156
            Globals.BiosOutput.TryGetValue(0x10A0, out this.flap_value);
171
            data.prev = data.buttons;
-
 
172
            data.changed = false;
-
 
173
 
-
 
174
 
-
 
175
            if (this.flap_value != this.flap_shadow) {
157
            if (this.flap_value != this.flap_shadow) {
176
                
-
 
177
 
158
 
178
                BitImage flap_rotate = new BitImage(flap_needle);
159
                BitImage flap_rotate = new BitImage(flap_needle);
179
                BitImage flap_display = new BitImage(flap_background);
160
                BitImage flap_display = new BitImage(flap_background);
180
 
161
 
181
                UInt16 flap_set = Globals.map_uint16(flap_value, 0, 0xffff, 0, 90);
162
                UInt16 flap_set = Globals.map_uint16(flap_value, 0, 0xffff, 0, 90);
Line 185... Line 166...
185
                oled.i2c.SetGpio(1, 1);
166
                oled.i2c.SetGpio(1, 1);
186
                oled.display();
167
                oled.display();
187
                oled.i2c.SetGpio(1, 0);
168
                oled.i2c.SetGpio(1, 0);
188
 
169
 
189
                this.flap_shadow = this.flap_value;
170
                this.flap_shadow = this.flap_value;
-
 
171
 
-
 
172
                Console.WriteLine("Oled Flap Position: {0}", flap_value);
190
            }
173
            }
191
 
174
 
-
 
175
            return rslt;
-
 
176
        }
-
 
177
 
-
 
178
        public override int Input() {
-
 
179
            data.changed = false;
192
            return 1;
180
            return 1;
193
        }
181
        }
194
    }
182
    }
195
}
183
}
196
 
184