Subversion Repositories group.NITPanels

Rev

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

Rev 3 Rev 5
Line 23... Line 23...
23
 
23
 
24
        public bool avionicsMaster { get; set; }
24
        public bool avionicsMaster { get; set; }
25
 
25
 
26
        private const int TIMER_COUNT = 8;
26
        private const int TIMER_COUNT = 8;
27
        Timer[] timers = new Timer[TIMER_COUNT];
27
        Timer[] timers = new Timer[TIMER_COUNT];
-
 
28
        Timer inputTimer = new Timer();
28
        
29
        
29
        public NITAudioSelDevice(NITDevice nitDevice) :
30
        public NITAudioSelDevice(NITDevice nitDevice) :
30
            base(nitDevice.usbRegistry, "NITAudioSel", nitDevice.vid, nitDevice.pid) {
31
            base(nitDevice.usbRegistry, "NITAudioSel", nitDevice.vid, nitDevice.pid) {
31
            this.init();
32
            this.init();
32
        }
33
        }
Line 49... Line 50...
49
                timer.AutoReset = false;
50
                timer.AutoReset = false;
50
                timer.Interval = NITPanels.CFG_BUTTON_DEBOUNCE_TIME;
51
                timer.Interval = NITPanels.CFG_BUTTON_DEBOUNCE_TIME;
51
                timer.Elapsed += OnDebounceTimer;
52
                timer.Elapsed += OnDebounceTimer;
52
                timers[i] = timer;
53
                timers[i] = timer;
53
            }
54
            }
-
 
55
 
-
 
56
            inputTimer.Enabled = false;
-
 
57
            inputTimer.AutoReset = true;
-
 
58
            inputTimer.Interval = NITPanels.CFG_INPUT_TIMER_INTERVAL;
-
 
59
            inputTimer.Elapsed += inputTimer_Elapsed;
-
 
60
        }
-
 
61
 
-
 
62
        void inputTimer_Elapsed(object sender, ElapsedEventArgs e) {
-
 
63
            this.SimButtons();
54
        }
64
        }
55
 
65
 
56
        private static void OnDebounceTimer(Object source, ElapsedEventArgs e) {
66
        private static void OnDebounceTimer(Object source, ElapsedEventArgs e) {
57
            Timer timer = (Timer)source;
67
            Timer timer = (Timer)source;
58
            timer.Enabled = false;
68
            timer.Enabled = false;
59
        }
69
        }
60
 
70
 
61
        public override bool Close() {
71
        public override bool Close() {
62
            this.ClearDisplay();
72
            this.powerDown();
63
            return base.Close();
73
            return base.Close();
64
        }
74
        }
65
 
75
 
66
        public void powerDown() {
76
        public void powerDown() {
-
 
77
            this.inputTimer.Enabled = false;
67
            this.ClearDisplay();
78
            this.ClearDisplay();
68
            this.simStatus = 2;
79
            this.simStatus = 2;
69
        }
80
        }
70
 
81
 
71
        public void powerUp() {
82
        public void powerUp() {
72
            this.simStatus = 0;
83
            this.simStatus = 0;
73
            this.fsx.requestAudioSelData();
84
            this.fsx.requestAudioSelData();
-
 
85
            this.inputTimer.Enabled = true;
74
        }
86
        }
75
 
87
 
76
        public override void FsxInit() { }
88
        public override void FsxInit() { }
77
 
89
 
78
        public override void MapEvents() {
90
        public override void MapEvents() { }
79
 
91
 
-
 
92
        public override void FsxReady() {
-
 
93
            this.powerUp();
80
        }
94
        }
81
 
95
 
-
 
96
        //public override void FsxClose() {
-
 
97
        //    this.powerDown();
-
 
98
        //}
-
 
99
 
82
        public override void FsxEvent(SIMCONNECT_RECV_SIMOBJECT_DATA data) {
100
        public override void FsxEvent(SIMCONNECT_RECV_SIMOBJECT_DATA data) {
83
 
101
 
84
            if (data.dwRequestID == (uint)FSXObject.DATA_REQUESTS.AVIONICS) {
102
            if (data.dwRequestID == (uint)FSXObject.DATA_REQUESTS.AVIONICS) {
85
                FSXObject.Avionics_Data avionics = (FSXObject.Avionics_Data)data.dwData[0];
103
                FSXObject.Avionics_Data avionics = (FSXObject.Avionics_Data)data.dwData[0];
86
                this.avionicsMaster = avionics.avionics_master;
104
                this.avionicsMaster = avionics.avionics_master;
Line 113... Line 131...
113
            this.setLed(7, audioseldata.adf);
131
            this.setLed(7, audioseldata.adf);
114
 
132
 
115
            this.UpdateDisplay();
133
            this.UpdateDisplay();
116
        }
134
        }
117
 
135
 
118
        public override void FsxReady() { 
-
 
119
 
-
 
120
        }
-
 
121
 
-
 
122
        public override void SimButtons() {
136
        public override void SimButtons() {
123
            if (this.simStatus != 0)
137
            if (this.simStatus != 0)
124
                return;
138
                return;
125
 
139
 
126
            this.updateInput();
140
            this.updateInput();