Subversion Repositories group.NITPanels

Rev

Rev 19 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19 Rev 22
Line 52... Line 52...
52
            this.led4.On = device.isLedSet(4);
52
            this.led4.On = device.isLedSet(4);
53
            this.led5.On = device.isLedSet(5);
53
            this.led5.On = device.isLedSet(5);
54
            this.led6.On = device.isLedSet(6);
54
            this.led6.On = device.isLedSet(6);
55
            this.led7.On = device.isLedSet(7);
55
            this.led7.On = device.isLedSet(7);
56
            this.ledPwr.On = device.isLedPwrSet();
56
            this.ledPwr.On = device.isLedPwrSet();
57
        }
-
 
58
 
57
 
59
        private void cmdUpdate_Click(object sender, EventArgs e) {
-
 
60
            uint selectAudioDevice = (uint)this.lstAudioDevices.SelectedIndex;
-
 
61
 
-
 
62
            txtAnalog.Text = Convert.ToString(device.analogValue);
-
 
63
            float volume = map_f(device.analogValue, 5, 255, 0.00F, 1.00F);
58
            float setVolume = NITPanels.map_f(device.analogValue, NITAudioSelDevice.DEV_ANALOG_MIN, 255, 0.00F, 1.00F);
64
            txtScalar.Text = Convert.ToString(volume);
59
            float devVolume = device.volcontrol.getDeviceVolume();
65
            device.volcontrol.setDeviceVolume(selectAudioDevice, volume);
60
            if (setVolume != devVolume)
66
            txtVol.Text = Convert.ToString(device.volcontrol.getDeviceVolume(selectAudioDevice));
61
                device.volcontrol.setDeviceVolume(setVolume);
67
            this.device.powerLedStatus = 0;
-
 
68
            this.device.UpdateDisplay();
-
 
69
 
62
 
-
 
63
            uint volPercent = NITPanels.map_ui(this.device.analogValue, NITAudioSelDevice.DEV_ANALOG_MIN, 255, 0, 100);
-
 
64
            txtVol.Text = Convert.ToString(volPercent);
70
        }
65
        }
71
 
66
 
72
        private float map_f(uint x, uint in_min, uint in_max, float out_min, float out_max) {
-
 
73
            float var = (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
-
 
74
            return var;
-
 
75
        }
-
 
76
 
67
 
77
        public void setDevice(NITAudioSelDevice audiosel) {
68
        public void setDevice(NITAudioSelDevice audiosel) {
78
            this.device = audiosel;
69
            this.device = audiosel;
79
 
70
 
80
            foreach (string audio in device.volcontrol.devices) {
71
            foreach (string audio in device.volcontrol.devices) {
81
                lstAudioDevices.Items.Add(audio);
72
                lstAudioDevices.Items.Add(audio);
82
            }
73
            }
-
 
74
            lstAudioDevices.SelectedIndex = (int)device.volcontrol.selectedDeviceIndex;
83
 
75
 
84
            if (!this.device.isOpen())
76
            if (!this.device.isOpen())
85
                this.device.Open();
77
                this.device.Open();
86
 
78
 
87
            if (this.device.isOpen())
79
            if (this.device.isOpen())
88
                this.controlStatus(true);
80
                this.controlStatus(true);
89
        }
81
        }
90
 
82
 
-
 
83
        private void cmdUpdate_Click(object sender, EventArgs e) {
-
 
84
            /*
-
 
85
            uint selectedAudioDevice = (uint)this.lstAudioDevices.SelectedIndex;
-
 
86
            txtAnalog.Text = Convert.ToString(device.analogValue);
-
 
87
            float volume = map_f(device.analogValue, 5, 255, 0.00F, 1.00F);
-
 
88
            txtScalar.Text = Convert.ToString(volume);
-
 
89
            device.volcontrol.setDeviceVolume(selectedAudioDevice, volume);
-
 
90
            txtVol.Text = Convert.ToString(device.volcontrol.getDeviceVolume(selectedAudioDevice));
-
 
91
            */
-
 
92
 
-
 
93
            this.device.UpdateDisplay();
-
 
94
        }
-
 
95
 
91
        private void inputTimer_Tick(object sender, EventArgs e) {
96
        private void inputTimer_Tick(object sender, EventArgs e) {
92
            this.UpdateInput();
97
            this.UpdateInput();
93
        }
98
        }
94
 
99
 
95
        private void cmdClose_Click(object sender, EventArgs e) {
100
        private void cmdClose_Click(object sender, EventArgs e) {
Line 150... Line 155...
150
        private void ledPwr_Click(object sender, EventArgs e) {
155
        private void ledPwr_Click(object sender, EventArgs e) {
151
            bool status = this.device.isLedPwrSet();
156
            bool status = this.device.isLedPwrSet();
152
            this.device.setLedPwr(!status);
157
            this.device.setLedPwr(!status);
153
            this.device.UpdateDisplay();
158
            this.device.UpdateDisplay();
154
        }
159
        }
-
 
160
 
-
 
161
        private void lstAudioDevices_SelectedIndexChanged(object sender, EventArgs e) {
-
 
162
            device.volcontrol.selectedDeviceIndex = (uint)lstAudioDevices.SelectedIndex;
-
 
163
            Properties.Settings.Default.volcontroldevice = device.volcontrol.getDeviceName();
-
 
164
            Properties.Settings.Default.Save();
-
 
165
        }
155
    }
166
    }
156
}
167
}