diff --git a/MobiFlight/Config/InputMultiplexer.cs b/MobiFlight/Config/InputMultiplexer.cs index 84230953b..8bc5e6d12 100644 --- a/MobiFlight/Config/InputMultiplexer.cs +++ b/MobiFlight/Config/InputMultiplexer.cs @@ -17,7 +17,7 @@ public class InputMultiplexer : BaseDevice [XmlAttribute] public String DataPin = "-1"; [XmlAttribute] - public String NumModules = "2"; // defaults to CD4067 + public String NumBytes = "2"; // defaults to CD4067 public InputMultiplexer() { @@ -48,7 +48,7 @@ override public String ToInternal() + DataPin + Separator // Selector pins, always sent + (Selector?.ToInternalStripped() ?? dummySel) - + NumModules + Separator + + NumBytes + Separator + Name + End; } @@ -62,7 +62,7 @@ override public bool FromInternal(String value) } DataPin = paramList[1]; - NumModules = paramList[6]; + NumBytes = paramList[6]; Name = paramList[7]; // pass the MultiplexerDriver pins, but only if the multiplexerDriver wasn't already set diff --git a/MobiFlight/ExecutionManager.cs b/MobiFlight/ExecutionManager.cs index 28bed9fee..c7e02d201 100644 --- a/MobiFlight/ExecutionManager.cs +++ b/MobiFlight/ExecutionManager.cs @@ -1578,8 +1578,8 @@ void mobiFlightCache_OnButtonPressed(object sender, InputEventArgs e) { continue; } - // similarly also for digital input Muxes - if (e.Type == DeviceType.InputMultiplexer && cfg.inputMultiplexer != null && cfg.inputMultiplexer.ExtPin != e.ExtPin) + // similarly also for digital input Multiplexer + if (e.Type == DeviceType.InputMultiplexer && cfg.inputMultiplexer != null && cfg.inputMultiplexer.DataPin != e.ExtPin) { continue; } diff --git a/MobiFlight/InputConfig/InputMultiplexerConfig.cs b/MobiFlight/InputConfig/InputMultiplexerConfig.cs index 09c173cbc..78775baec 100644 --- a/MobiFlight/InputConfig/InputMultiplexerConfig.cs +++ b/MobiFlight/InputConfig/InputMultiplexerConfig.cs @@ -14,34 +14,34 @@ namespace MobiFlight.InputConfig // its fundamental capabilities stay in sync with buttons. public class InputMultiplexerConfig : ButtonInputConfig { - public int ExtPin; + public int DataPin; public new object Clone() { InputMultiplexerConfig clone = new InputMultiplexerConfig(); if (onPress != null) clone.onPress = (InputAction)onPress.Clone(); if (onRelease != null) clone.onRelease = (InputAction)onRelease.Clone(); - clone.ExtPin = ExtPin; + clone.DataPin = DataPin; return clone; } public new void ReadXml(System.Xml.XmlReader reader) { - ExtPin = Convert.ToInt32(reader.GetAttribute(ExtPin)); + DataPin = Convert.ToInt32(reader.GetAttribute(DataPin)); base.ReadXml(reader); } public new void WriteXml(System.Xml.XmlWriter writer) { - writer.WriteAttributeString("ExtPin", ExtPin.ToString()); + writer.WriteAttributeString("DataPin", DataPin.ToString()); base.WriteXml(writer); } public override bool Equals(object obj) { - // Digital input multiplexer configurations are equal when their data ExtPin is the same + // Digital input multiplexer configurations are equal when their DataPin is the same // and all of the button configuration from the base class matches. - return (obj is InputMultiplexerConfig) && ((obj as InputMultiplexerConfig).ExtPin == ExtPin) && base.Equals(obj); + return (obj is InputMultiplexerConfig) && ((obj as InputMultiplexerConfig).DataPin == DataPin) && base.Equals(obj); } public new Dictionary GetStatistics() diff --git a/MobiFlightUnitTests/MobiFlight/InputConfig/InputMultiplexerConfigTests.cs b/MobiFlightUnitTests/MobiFlight/InputConfig/InputMultiplexerConfigTests.cs index 8bf5572df..912994d07 100644 --- a/MobiFlightUnitTests/MobiFlight/InputConfig/InputMultiplexerConfigTests.cs +++ b/MobiFlightUnitTests/MobiFlight/InputConfig/InputMultiplexerConfigTests.cs @@ -27,7 +27,7 @@ public void CloneTest() private InputMultiplexerConfig generateTestObject() { InputMultiplexerConfig o = new InputMultiplexerConfig(); - o.ExtPin = 1; + o.DataPin = 1; o.onPress = new EventIdInputAction() { EventId = 12345 }; o.onRelease = new JeehellInputAction() { EventId = 127, Param = "123" }; return o; @@ -53,7 +53,7 @@ public void ReadXmlTest() xmlReader.ReadToDescendant("inputMultiplexer"); o.ReadXml(xmlReader); - Assert.AreEqual(1, o.ExtPin, "ExtPin not the same"); + Assert.AreEqual(1, o.DataPin, "ExtPin not the same"); Assert.AreEqual(12345, (o.onPress as EventIdInputAction).EventId, "EventId not the same"); Assert.AreEqual(127, (o.onRelease as JeehellInputAction).EventId, "EventId not the same"); } diff --git a/MobiFlightUnitTests/assets/MobiFlight/InputConfig/InputMultiplexerConfig/WriteXmlTest.1.xml b/MobiFlightUnitTests/assets/MobiFlight/InputConfig/InputMultiplexerConfig/WriteXmlTest.1.xml index 9daba545f..8cde72566 100644 Binary files a/MobiFlightUnitTests/assets/MobiFlight/InputConfig/InputMultiplexerConfig/WriteXmlTest.1.xml and b/MobiFlightUnitTests/assets/MobiFlight/InputConfig/InputMultiplexerConfig/WriteXmlTest.1.xml differ diff --git a/UI/Dialogs/InputConfigWizard.cs b/UI/Dialogs/InputConfigWizard.cs index 9df40f661..577e98c5b 100644 --- a/UI/Dialogs/InputConfigWizard.cs +++ b/UI/Dialogs/InputConfigWizard.cs @@ -322,7 +322,7 @@ protected bool _syncFormToConfig() case DeviceType.InputMultiplexer: config.Type = InputConfigItem.TYPE_INPUT_MULTIPLEXER; if (config.inputMultiplexer == null) config.inputMultiplexer = new InputConfig.InputMultiplexerConfig(); - config.inputMultiplexer.ExtPin = (int)inputPinDropDown.SelectedItem; + config.inputMultiplexer.DataPin = (int)inputPinDropDown.SelectedItem; if (groupBoxInputSettings.Controls[0] != null) (groupBoxInputSettings.Controls[0] as InputMultiplexerPanel).ToConfig(config.inputMultiplexer); break; @@ -509,7 +509,7 @@ private void inputTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) Config.InputMultiplexer selectedInputMultiplexer = (inputTypeComboBox.SelectedItem as ListItem).Value as Config.InputMultiplexer; panel = new Panels.Input.InputMultiplexerPanel(); (panel as Panels.Input.InputMultiplexerPanel).syncFromConfig(config.inputMultiplexer); - PopulateInputPinDropdown(Convert.ToInt32(selectedInputMultiplexer.NumModules), config.inputMultiplexer?.ExtPin); + PopulateInputPinDropdown(Convert.ToInt32(selectedInputMultiplexer.NumBytes), config.inputMultiplexer?.DataPin); inputPinDropDown.Visible = true; break; diff --git a/UI/Panels/Device/MFInputMultiplexerPanel.Designer.cs b/UI/Panels/Device/MFInputMultiplexerPanel.Designer.cs index 8e19b0b92..2b68fad5a 100644 --- a/UI/Panels/Device/MFInputMultiplexerPanel.Designer.cs +++ b/UI/Panels/Device/MFInputMultiplexerPanel.Designer.cs @@ -31,7 +31,6 @@ private void InitializeComponent() this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MFInputMultiplexerPanel)); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.mfNumModulesComboBox = new System.Windows.Forms.ComboBox(); this.numberOfModulesLabel = new System.Windows.Forms.Label(); @@ -47,21 +46,15 @@ private void InitializeComponent() // // groupBox1 // - resources.ApplyResources(this.groupBox1, "groupBox1"); - this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.mfNumModulesComboBox); this.groupBox1.Controls.Add(this.numberOfModulesLabel); this.groupBox1.Controls.Add(this.mfPin1Label); this.groupBox1.Controls.Add(this.mfPin1ComboBox); + resources.ApplyResources(this.groupBox1, "groupBox1"); this.groupBox1.Name = "groupBox1"; this.groupBox1.TabStop = false; // - // label2 - // - resources.ApplyResources(this.label2, "label2"); - this.label2.Name = "label2"; - // // label1 // resources.ApplyResources(this.label1, "label1"); @@ -70,6 +63,7 @@ private void InitializeComponent() // mfNumModulesComboBox // this.mfNumModulesComboBox.BackColor = System.Drawing.SystemColors.Window; + this.mfNumModulesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.mfNumModulesComboBox.FormattingEnabled = true; resources.ApplyResources(this.mfNumModulesComboBox, "mfNumModulesComboBox"); this.mfNumModulesComboBox.Name = "mfNumModulesComboBox"; @@ -89,6 +83,7 @@ private void InitializeComponent() // mfPin1ComboBox // this.mfPin1ComboBox.BackColor = System.Drawing.SystemColors.Window; + this.mfPin1ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.mfPin1ComboBox.FormattingEnabled = true; resources.ApplyResources(this.mfPin1ComboBox, "mfPin1ComboBox"); this.mfPin1ComboBox.Name = "mfPin1ComboBox"; @@ -97,8 +92,8 @@ private void InitializeComponent() // // groupBox2 // - resources.ApplyResources(this.groupBox2, "groupBox2"); this.groupBox2.Controls.Add(this.textBox1); + resources.ApplyResources(this.groupBox2, "groupBox2"); this.groupBox2.Name = "groupBox2"; this.groupBox2.TabStop = false; // @@ -117,9 +112,9 @@ private void InitializeComponent() // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.muxDrvPanel); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); + this.Controls.Add(this.muxDrvPanel); this.Name = "MFInputMultiplexerPanel"; this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); @@ -139,7 +134,6 @@ private void InitializeComponent() private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; private System.Windows.Forms.Panel muxDrvPanel; } } \ No newline at end of file diff --git a/UI/Panels/Device/MFInputMultiplexerPanel.cs b/UI/Panels/Device/MFInputMultiplexerPanel.cs index a2c43e149..430b833d9 100644 --- a/UI/Panels/Device/MFInputMultiplexerPanel.cs +++ b/UI/Panels/Device/MFInputMultiplexerPanel.cs @@ -45,12 +45,15 @@ public MFInputMultiplexerPanel(InputMultiplexer inputMultiplexer, List options = new List(); + options.Add(new ListItem() { Value = "1", Label = "8-bit multiplexer" }); + options.Add(new ListItem() { Value = "2", Label = "16-bit multiplexer" }); + + mfNumModulesComboBox.DataSource = options; + mfNumModulesComboBox.ValueMember = "Value"; + mfNumModulesComboBox.DisplayMember = "Label"; + + ComboBoxHelper.SetSelectedItemByValue(mfNumModulesComboBox, inputMultiplexer.NumBytes); textBox1.Text = inputMultiplexer.Name; initialized = true; @@ -75,7 +78,7 @@ private void receivePinChange(List newPinList) private void setNonPinValues() { inputMultiplexer.Name = textBox1.Text; - inputMultiplexer.NumModules = string.IsNullOrEmpty(mfNumModulesComboBox.Text) ? "1" : mfNumModulesComboBox.Text; + inputMultiplexer.NumBytes = string.IsNullOrEmpty(mfNumModulesComboBox.SelectedValue.ToString()) ? "1" : mfNumModulesComboBox.SelectedValue.ToString(); } public void UpdateFreePinsInDropDowns(List newPinList = null) { diff --git a/UI/Panels/Device/MFInputMultiplexerPanel.resx b/UI/Panels/Device/MFInputMultiplexerPanel.resx index 15233407d..30e8ebb56 100644 --- a/UI/Panels/Device/MFInputMultiplexerPanel.resx +++ b/UI/Panels/Device/MFInputMultiplexerPanel.resx @@ -117,47 +117,19 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Top, Left, Right - - - 6, 94 - - - 249, 31 - - - - 27 - - - Choose respectively 1 or 2 8bit registers for the two types. - - - label2 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 0 - 6, 65 249, 30 + 25 - Supports multiplexed digital inputs using 74x4051 (8bit) or 74x4067 (16 bit) multiplexers. + Select data pin and multiplexer type 8-bit (74x4051) or 16-bit (74x4067). label1 @@ -169,13 +141,13 @@ groupBox1 - 1 + 0 69, 38 - 67, 21 + 122, 21 21 @@ -190,8 +162,9 @@ groupBox1 - 2 + 1 + NoControl @@ -205,7 +178,7 @@ 19 - # of 8 bit registers + Type numberOfModulesLabel @@ -217,7 +190,7 @@ groupBox1 - 3 + 2 NoControl @@ -244,7 +217,7 @@ groupBox1 - 4 + 3 9, 38 @@ -265,19 +238,22 @@ groupBox1 - 5 + 4 + + + Top - 0, 162 + 0, 160 - 255, 127 + 255, 106 2 - Pin and number of modules + Data pin and type groupBox1 @@ -289,10 +265,7 @@ $this - 2 - - - Top, Left, Right + 1 9, 19 @@ -315,8 +288,11 @@ 0 + + Top + - 0, 290 + 0, 266 255, 57 @@ -337,13 +313,13 @@ $this - 1 + 0 24, 33 - - Top, Left, Right + + Top 0, 0 @@ -364,7 +340,7 @@ $this - 0 + 2 True @@ -376,7 +352,7 @@ 2, 2, 2, 2 - 255, 352 + 255, 330 toolTip1 diff --git a/UI/Panels/InputConfigPanel.cs b/UI/Panels/InputConfigPanel.cs index 72c80d3a8..14e94bae3 100644 --- a/UI/Panels/InputConfigPanel.cs +++ b/UI/Panels/InputConfigPanel.cs @@ -418,7 +418,7 @@ public void RestoreValuesInGridView() } else if (cfg.Type == InputConfigItem.TYPE_INPUT_MULTIPLEXER) { - row["inputName"] = $"{cfg.Name}:{cfg.inputMultiplexer?.ExtPin}"; + row["inputName"] = $"{cfg.Name}:{cfg.inputMultiplexer?.DataPin}"; } else {