Skip to content

Commit

Permalink
Rename labels for Multiplexer Settings and Config (#818)
Browse files Browse the repository at this point in the history
* Rename labels
* Renamed ExtPin to DataPin
  • Loading branch information
DocMoebiuz authored May 29, 2022
1 parent c5aed18 commit 81e7a32
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 84 deletions.
6 changes: 3 additions & 3 deletions MobiFlight/Config/InputMultiplexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -48,7 +48,7 @@ override public String ToInternal()
+ DataPin + Separator
// Selector pins, always sent
+ (Selector?.ToInternalStripped() ?? dummySel)
+ NumModules + Separator
+ NumBytes + Separator
+ Name + End;
}

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions MobiFlight/ExecutionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 6 additions & 6 deletions MobiFlight/InputConfig/InputMultiplexerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, int> GetStatistics()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions UI/Dialogs/InputConfigWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -509,7 +509,7 @@ private void inputTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
Config.InputMultiplexer selectedInputMultiplexer = (inputTypeComboBox.SelectedItem as ListItem<Config.BaseDevice>).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;

Expand Down
16 changes: 5 additions & 11 deletions UI/Panels/Device/MFInputMultiplexerPanel.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions UI/Panels/Device/MFInputMultiplexerPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ public MFInputMultiplexerPanel(InputMultiplexer inputMultiplexer, List<MobiFligh
this.inputMultiplexer = inputMultiplexer;
UpdateFreePinsInDropDowns();

// Set non-pin data values
for (int i = 1; i <= MAX_MODULES; i++)
{
mfNumModulesComboBox.Items.Add(i);
}
ComboBoxHelper.SetSelectedItem(mfNumModulesComboBox, inputMultiplexer.NumModules);
List<ListItem> options = new List<ListItem>();
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;
Expand All @@ -75,7 +78,7 @@ private void receivePinChange(List<MobiFlightPin> 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<MobiFlightPin> newPinList = null)
{
Expand Down
Loading

0 comments on commit 81e7a32

Please sign in to comment.