Subversion Repositories group.NITPanels

Rev

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

Rev 11 Rev 12
Line 41... Line 41...
41
        private const int TIMER_NAVFLIP = 3;
41
        private const int TIMER_NAVFLIP = 3;
42
        Timer[] timers = new Timer[TIMER_COUNT];
42
        Timer[] timers = new Timer[TIMER_COUNT];
43
 
43
 
44
        Timer inputTimer = new Timer();
44
        Timer inputTimer = new Timer();
45
 
45
 
-
 
46
        private const int POINT_FREQ = 0x0084;
-
 
47
        private const int POINT_MHZ = 0x00a4;
-
 
48
        private const int POINT_KHZ = 0x0284;
-
 
49
 
-
 
50
        private const int TIMER_FLIP_SHOW_COUNT = 1000;
-
 
51
        Timer flipShowTimer = new Timer();
-
 
52
 
46
        public NITNavCommDevice(NITDevice nitDevice) :
53
        public NITNavCommDevice(NITDevice nitDevice) :
47
            base(nitDevice.usbRegistry, "NITNavComm", nitDevice.vid, nitDevice.pid) {
54
            base(nitDevice.usbRegistry, "NITNavComm", nitDevice.vid, nitDevice.pid) {
48
            this.init();
55
            this.init();
49
        }
56
        }
50
 
57
 
Line 89... Line 96...
89
 
96
 
90
            inputTimer.Enabled = false;
97
            inputTimer.Enabled = false;
91
            inputTimer.AutoReset = true;
98
            inputTimer.AutoReset = true;
92
            inputTimer.Interval = NITPanels.CFG_INPUT_TIMER_INTERVAL;
99
            inputTimer.Interval = NITPanels.CFG_INPUT_TIMER_INTERVAL;
93
            inputTimer.Elapsed += inputTimer_Elapsed;
100
            inputTimer.Elapsed += inputTimer_Elapsed;
-
 
101
 
-
 
102
            flipShowTimer.Enabled = false;
-
 
103
            flipShowTimer.AutoReset = false;
-
 
104
            flipShowTimer.Interval = NITNavCommDevice.TIMER_FLIP_SHOW_COUNT;
-
 
105
            flipShowTimer.Elapsed += flipShowTimer_Elapsed;
94
            
106
            
95
        }
107
        }
96
 
108
 
-
 
109
        void flipShowTimer_Elapsed(object sender, ElapsedEventArgs e) {
-
 
110
            this.points[0] = NITNavCommDevice.POINT_FREQ;
-
 
111
            this.points[1] = NITNavCommDevice.POINT_FREQ;
-
 
112
            this.UpdatePoints();
-
 
113
        }
-
 
114
 
97
        void inputTimer_Elapsed(object sender, ElapsedEventArgs e) {
115
        void inputTimer_Elapsed(object sender, ElapsedEventArgs e) {
98
            this.SimButtons();
116
            this.SimButtons();
99
        }
117
        }
100
 
118
 
101
        private static void OnDebounceTimer(Object source, ElapsedEventArgs e) {
119
        private static void OnDebounceTimer(Object source, ElapsedEventArgs e) {
Line 122... Line 140...
122
            this.inputTimer.Enabled = true;
140
            this.inputTimer.Enabled = true;
123
 
141
 
124
            this.points[0] = 0x0084;
142
            this.points[0] = 0x0084;
125
            this.points[1] = 0x0084;
143
            this.points[1] = 0x0084;
126
 
144
 
127
            this.sendPoints();
145
            this.UpdatePoints();
128
           
146
           
129
            if (this.assigned == 1)
147
            if (this.assigned == 1)
130
                this.fsx.requestNavComm1Data();
148
                this.fsx.requestNavComm1Data();
131
            else if (this.assigned == 2)
149
            else if (this.assigned == 2)
132
                this.fsx.requestNavComm2Data();
150
                this.fsx.requestNavComm2Data();
Line 225... Line 243...
225
        public void UpdateDisplay(byte dis) {
243
        public void UpdateDisplay(byte dis) {
226
            this.sendData(dis);
244
            this.sendData(dis);
227
            this.latchDisplay(dis);
245
            this.latchDisplay(dis);
228
        }
246
        }
229
 
247
 
-
 
248
        public void UpdatePoints() {
-
 
249
            if (this.simStatus == 0)
-
 
250
                this.sendPoints();
-
 
251
        }
-
 
252
 
230
        public void setDisplay(byte dis, ref byte[] data) {
253
        public void setDisplay(byte dis, ref byte[] data) {
231
            for (byte i = 0; i < data.Length; i++) {
254
            for (byte i = 0; i < data.Length; i++) {
232
                display[dis, i] = data[i];
255
                display[dis, i] = data[i];
233
            }
256
            }
234
        }
257
        }
Line 403... Line 426...
403
 
426
 
404
            // Check if the MHz/KHz has been pressed
427
            // Check if the MHz/KHz has been pressed
405
            if (!timers[TIMER_COMMFLIP].Enabled && this.isFlipSet(0)) {
428
            if (!timers[TIMER_COMMFLIP].Enabled && this.isFlipSet(0)) {
406
                this.flipcomm = 1 - this.flipcomm;
429
                this.flipcomm = 1 - this.flipcomm;
407
                timers[TIMER_COMMFLIP].Enabled = true;
430
                timers[TIMER_COMMFLIP].Enabled = true;
-
 
431
                
-
 
432
                if (this.flipcomm == 0) {
-
 
433
                    this.points[0] = NITNavCommDevice.POINT_MHZ;
-
 
434
                } else {
-
 
435
                    this.points[0] = NITNavCommDevice.POINT_KHZ;
-
 
436
                }
-
 
437
                this.UpdatePoints();
-
 
438
                this.flipShowTimer.Enabled = true;
-
 
439
 
408
            }
440
            }
409
 
441
 
410
            if (!timers[TIMER_NAVFLIP].Enabled && this.isFlipSet(1)) {
442
            if (!timers[TIMER_NAVFLIP].Enabled && this.isFlipSet(1)) {
411
                this.flipnav = 1 - this.flipnav;
443
                this.flipnav = 1 - this.flipnav;
412
                timers[TIMER_NAVFLIP].Enabled = true;
444
                timers[TIMER_NAVFLIP].Enabled = true;
-
 
445
 
-
 
446
                if (this.flipnav == 0) {
-
 
447
                    this.points[1] = NITNavCommDevice.POINT_MHZ;
-
 
448
                } else {
-
 
449
                    this.points[1] = NITNavCommDevice.POINT_KHZ;
-
 
450
                }
-
 
451
                this.UpdatePoints();
-
 
452
                this.flipShowTimer.Enabled = true;
413
            }
453
            }
414
 
454
 
415
            // Process the rotary encoders COMM1
455
            // Process the rotary encoders COMM1
416
            sbyte delta = this.getRotary(0, 0);
456
            sbyte delta = this.getRotary(0, 0);
417
            this.resetRotary(0, 0);
457
            this.resetRotary(0, 0);