Subversion Repositories group.NITPanels

Rev

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

Rev 16 Rev 19
Line 16... Line 16...
16
 
16
 
17
        public VolumeControl volcontrol = new VolumeControl();
17
        public VolumeControl volcontrol = new VolumeControl();
18
 
18
 
19
        public const byte USBCMD_READ_BUTTONS = 100;
19
        public const byte USBCMD_READ_BUTTONS = 100;
20
        public const byte USBCMD_LEDS_SET = 101;
20
        public const byte USBCMD_LEDS_SET = 101;
-
 
21
        public const byte USBCMD_GET_ANALOG = 102;
-
 
22
        public const byte USBCMD_SET_POWER_LED = 103;
21
 
23
 
22
        private int simStatus { get; set; }
24
        private int simStatus { get; set; }
23
        public byte ledStatus { get; set; }
25
        public byte ledStatus { get; set; }
24
        public byte buttonStatus { get; set; }
26
        public byte buttonStatus { get; set; }
-
 
27
        public byte analogValue { get; set; }
-
 
28
        public byte powerLedStatus { get; set; }
25
 
29
 
26
        public bool avionicsMaster { get; set; }
30
        public bool avionicsMaster { get; set; }
27
 
31
 
28
        private const int TIMER_COUNT = 8;
32
        private const int TIMER_COUNT = 8;
29
        Timer[] timers = new Timer[TIMER_COUNT];
33
        Timer[] timers = new Timer[TIMER_COUNT];
Line 44... Line 48...
44
 
48
 
45
            this.simStatus = 0;
49
            this.simStatus = 0;
46
            this.ledStatus = 0x00;
50
            this.ledStatus = 0x00;
47
            this.buttonStatus = 0x00;
51
            this.buttonStatus = 0x00;
48
 
52
 
-
 
53
            this.analogValue = 0x00;
-
 
54
            this.powerLedStatus = 0;
-
 
55
 
49
            for (int i = 0; i < TIMER_COUNT; i++) {
56
            for (int i = 0; i < TIMER_COUNT; i++) {
50
                Timer timer = new Timer();
57
                Timer timer = new Timer();
51
                timer.Enabled = false;
58
                timer.Enabled = false;
52
                timer.AutoReset = false;
59
                timer.AutoReset = false;
53
                timer.Interval = NITPanels.CFG_BUTTON_DEBOUNCE_TIME;
60
                timer.Interval = NITPanels.CFG_BUTTON_DEBOUNCE_TIME;
Line 154... Line 161...
154
        public void updateInput() {
161
        public void updateInput() {
155
            byte[] data = new byte[8];
162
            byte[] data = new byte[8];
156
            int transferred;
163
            int transferred;
157
            base.SendCommand(NITAudioSelDevice.USBCMD_READ_BUTTONS, 0, 0, data, out transferred);
164
            base.SendCommand(NITAudioSelDevice.USBCMD_READ_BUTTONS, 0, 0, data, out transferred);
158
            this.buttonStatus = data[1];
165
            this.buttonStatus = data[1];
-
 
166
 
-
 
167
            base.SendCommand(NITAudioSelDevice.USBCMD_GET_ANALOG, 0, 0, data, out transferred);
-
 
168
            this.analogValue = data[0];
159
        }
169
        }
160
 
170
 
161
        public void UpdateDisplay() {
171
        public void UpdateDisplay() {
162
            base.SendCommand(NITAudioSelDevice.USBCMD_LEDS_SET, this.ledStatus, 0);
172
            base.SendCommand(NITAudioSelDevice.USBCMD_LEDS_SET, this.ledStatus, 0);
-
 
173
            base.SendCommand(NITAudioSelDevice.USBCMD_SET_POWER_LED, this.powerLedStatus, 0);
163
        }
174
        }
164
 
175
 
165
        public void ClearDisplay() {
176
        public void ClearDisplay() {
166
            this.ledStatus = 0x00;
177
            this.ledStatus = 0x00;
-
 
178
            this.powerLedStatus = 0x00;
167
            this.UpdateDisplay();
179
            this.UpdateDisplay();
168
        }
180
        }
169
 
181
 
170
        public void setLed(int ledNum, double status) {
182
        public void setLed(int ledNum, double status) {
171
            if (status == 1)
183
            if (status == 1)
Line 183... Line 195...
183
 
195
 
184
        public bool isLedSet(int ledNum) {
196
        public bool isLedSet(int ledNum) {
185
            return NITPanels.readBit(this.ledStatus, ledNum);
197
            return NITPanels.readBit(this.ledStatus, ledNum);
186
        }
198
        }
187
 
199
 
-
 
200
        public bool isLedPwrSet() {
-
 
201
            if (this.powerLedStatus>0)
-
 
202
                return true;
-
 
203
            return false;
-
 
204
        }
-
 
205
 
-
 
206
        public void setLedPwr(bool status) {
-
 
207
            if (status)
-
 
208
                this.powerLedStatus = 1;
-
 
209
            else
-
 
210
                this.powerLedStatus = 0;
-
 
211
        }
-
 
212
 
188
        public bool isButtonSet(int buttonNum) {
213
        public bool isButtonSet(int buttonNum) {
189
            return NITPanels.readBit(this.buttonStatus, buttonNum);
214
            return NITPanels.readBit(this.buttonStatus, buttonNum);
190
        }
215
        }
191
    }
216
    }
192
}
217
}