diff --git a/Base/ComboBoxHelper.cs b/Base/ComboBoxHelper.cs index a8804df97..08da3d4f7 100644 --- a/Base/ComboBoxHelper.cs +++ b/Base/ComboBoxHelper.cs @@ -80,8 +80,8 @@ static public bool BindMobiFlightFreePins(ComboBox comboBox, List // Deep-clone list as 'Used' list List UsablePins = Pins.ConvertAll(pin => new MobiFlightPin(pin)); // Mark current pin (if any specified) as free - if (CurrentPin != "" && UsablePins.Exists(x => x.Pin == byte.Parse(CurrentPin))) { - UsablePins.Find(x => x.Pin == byte.Parse(CurrentPin)).Used = false; + if (CurrentPin != "" && UsablePins.Exists(x => x.Pin == uint.Parse(CurrentPin))) { + UsablePins.Find(x => x.Pin == uint.Parse(CurrentPin)).Used = false; } if (analogOnly == true) @@ -96,7 +96,7 @@ static public bool BindMobiFlightFreePins(ComboBox comboBox, List // Restore the original item selection (if any) if (CurrentPin != "") { - var pinNo = byte.Parse(CurrentPin); + var pinNo = uint.Parse(CurrentPin); try { comboBox.SelectedValue = pinNo; } @@ -126,7 +126,7 @@ static public void reassignPin(string newPin, List pinList, ref s } static public void freePin(List pinList, string currentPin) { - byte nBefore = byte.Parse(currentPin); + uint nBefore = uint.Parse(currentPin); try { MobiFlightPin p; p = pinList.Find(x => x.Pin == nBefore); @@ -145,7 +145,7 @@ static public void assignPin(List pinList, ref string newPin) MobiFlightPin p = null; if (newPin != "") { // A desired pin is specified: seek it - byte newPinNo = byte.Parse(newPin); + uint newPinNo = uint.Parse(newPin); p = pinList.Find(x => x.Pin == newPinNo); if (p == null) throw new Exception("Nonexistent pin number"); } diff --git a/MobiFlight/MobiFlightModule.cs b/MobiFlight/MobiFlightModule.cs index 4d8cddc43..64db52a95 100644 --- a/MobiFlight/MobiFlightModule.cs +++ b/MobiFlight/MobiFlightModule.cs @@ -1323,7 +1323,7 @@ public List GetPins(bool FreeOnly = false, bool ExcludeI2CDevices List ResultPins = new List(); ResultPins.AddRange(Board.Pins.Select(x => new MobiFlightPin(x))); - List usedPins = new List(); + List usedPins = new List(); foreach (Config.BaseDevice device in Config.Items) { @@ -1331,43 +1331,43 @@ public List GetPins(bool FreeOnly = false, bool ExcludeI2CDevices switch (device.Type) { case DeviceType.LedModule: - usedPins.Add(Convert.ToByte((device as LedModule).ClkPin)); + usedPins.Add(Convert.ToUInt32((device as LedModule).ClkPin)); if ((device as LedModule).ModelType == LedModule.MODEL_TYPE_MAX72xx) { if ((device as LedModule).ClsPin != "") - usedPins.Add(Convert.ToByte((device as LedModule).ClsPin)); + usedPins.Add(Convert.ToUInt32((device as LedModule).ClsPin)); } - usedPins.Add(Convert.ToByte((device as LedModule).DinPin)); + usedPins.Add(Convert.ToUInt32((device as LedModule).DinPin)); break; case DeviceType.Stepper: - usedPins.Add(Convert.ToByte((device as Stepper).Pin1)); - usedPins.Add(Convert.ToByte((device as Stepper).Pin2)); - usedPins.Add(Convert.ToByte((device as Stepper).Pin3)); - usedPins.Add(Convert.ToByte((device as Stepper).Pin4)); + usedPins.Add(Convert.ToUInt32((device as Stepper).Pin1)); + usedPins.Add(Convert.ToUInt32((device as Stepper).Pin2)); + usedPins.Add(Convert.ToUInt32((device as Stepper).Pin3)); + usedPins.Add(Convert.ToUInt32((device as Stepper).Pin4)); // We don't have to set the default 0 pin (for none auto zero) if ((device as MobiFlight.Config.Stepper).BtnPin != "0") - usedPins.Add(Convert.ToByte((device as Stepper).BtnPin)); + usedPins.Add(Convert.ToUInt32((device as Stepper).BtnPin)); break; case DeviceType.Servo: - usedPins.Add(Convert.ToByte((device as Servo).DataPin)); + usedPins.Add(Convert.ToUInt32((device as Servo).DataPin)); break; case DeviceType.Button: - usedPins.Add(Convert.ToByte((device as Button).Pin)); + usedPins.Add(Convert.ToUInt32((device as Button).Pin)); break; case DeviceType.Encoder: - usedPins.Add(Convert.ToByte((device as Config.Encoder).PinLeft)); - usedPins.Add(Convert.ToByte((device as Config.Encoder).PinRight)); + usedPins.Add(Convert.ToUInt32((device as Config.Encoder).PinLeft)); + usedPins.Add(Convert.ToUInt32((device as Config.Encoder).PinRight)); break; case DeviceType.InputShiftRegister: - usedPins.Add(Convert.ToByte((device as InputShiftRegister).ClockPin)); - usedPins.Add(Convert.ToByte((device as InputShiftRegister).DataPin)); - usedPins.Add(Convert.ToByte((device as InputShiftRegister).LatchPin)); + usedPins.Add(Convert.ToUInt32((device as InputShiftRegister).ClockPin)); + usedPins.Add(Convert.ToUInt32((device as InputShiftRegister).DataPin)); + usedPins.Add(Convert.ToUInt32((device as InputShiftRegister).LatchPin)); break; case DeviceType.LcdDisplay: @@ -1379,44 +1379,44 @@ public List GetPins(bool FreeOnly = false, bool ExcludeI2CDevices // Statically add correct I2C pins foreach (MobiFlightPin pin in Board.Pins.FindAll(x => x.isI2C)) { - if (usedPins.Contains(Convert.ToByte(pin.Pin))) continue; - usedPins.Add(Convert.ToByte(pin.Pin)); + if (usedPins.Contains(Convert.ToUInt32(pin.Pin))) continue; + usedPins.Add(Convert.ToUInt32(pin.Pin)); } break; case DeviceType.Output: - usedPins.Add(Convert.ToByte((device as Output).Pin)); + usedPins.Add(Convert.ToUInt32((device as Output).Pin)); break; case DeviceType.AnalogInput: - usedPins.Add(Convert.ToByte((device as AnalogInput).Pin)); + usedPins.Add(Convert.ToUInt32((device as AnalogInput).Pin)); break; case DeviceType.ShiftRegister: - usedPins.Add(Convert.ToByte((device as ShiftRegister).ClockPin)); - usedPins.Add(Convert.ToByte((device as ShiftRegister).LatchPin)); - usedPins.Add(Convert.ToByte((device as ShiftRegister).DataPin)); + usedPins.Add(Convert.ToUInt32((device as ShiftRegister).ClockPin)); + usedPins.Add(Convert.ToUInt32((device as ShiftRegister).LatchPin)); + usedPins.Add(Convert.ToUInt32((device as ShiftRegister).DataPin)); break; case DeviceType.InputMultiplexer: - usedPins.Add(Convert.ToByte((device as InputMultiplexer).DataPin)); - usedPins.Add(Convert.ToByte((device as InputMultiplexer).Selector.PinSx[0])); - usedPins.Add(Convert.ToByte((device as InputMultiplexer).Selector.PinSx[1])); - usedPins.Add(Convert.ToByte((device as InputMultiplexer).Selector.PinSx[2])); - usedPins.Add(Convert.ToByte((device as InputMultiplexer).Selector.PinSx[3])); + usedPins.Add(Convert.ToUInt32((device as InputMultiplexer).DataPin)); + usedPins.Add(Convert.ToUInt32((device as InputMultiplexer).Selector.PinSx[0])); + usedPins.Add(Convert.ToUInt32((device as InputMultiplexer).Selector.PinSx[1])); + usedPins.Add(Convert.ToUInt32((device as InputMultiplexer).Selector.PinSx[2])); + usedPins.Add(Convert.ToUInt32((device as InputMultiplexer).Selector.PinSx[3])); break; case DeviceType.CustomDevice: - (device as CustomDevice).ConfiguredPins.ForEach(p => usedPins.Add(Convert.ToByte((p)))); + (device as CustomDevice).ConfiguredPins.ForEach(p => usedPins.Add(Convert.ToUInt32((p)))); break; // If the multiplexerDriver is to be handled as a regular device // but explicitly defined by its own config line, following 'case' is required: //case DeviceType.MultiplexerDriver: - // usedPins.Add(Convert.ToByte((device as MultiplexerDriver).PinSx[0])); - // usedPins.Add(Convert.ToByte((device as MultiplexerDriver).PinSx[1])); - // usedPins.Add(Convert.ToByte((device as MultiplexerDriver).PinSx[2])); - // usedPins.Add(Convert.ToByte((device as MultiplexerDriver).PinSx[3])); + // usedPins.Add(Convert.ToUInt32((device as MultiplexerDriver).PinSx[0])); + // usedPins.Add(Convert.ToUInt32((device as MultiplexerDriver).PinSx[1])); + // usedPins.Add(Convert.ToUInt32((device as MultiplexerDriver).PinSx[2])); + // usedPins.Add(Convert.ToUInt32((device as MultiplexerDriver).PinSx[3])); // break; default: @@ -1425,7 +1425,7 @@ public List GetPins(bool FreeOnly = false, bool ExcludeI2CDevices } // Mark all the used pins as used in the result list. - foreach (byte pinNo in usedPins) + foreach (uint pinNo in usedPins) { MobiFlightPin pin = ResultPins.Find(resultPin => resultPin.Pin == pinNo); if (pin != null) pin.Used = true; diff --git a/MobiFlight/MobiFlightPin.cs b/MobiFlight/MobiFlightPin.cs index bec423dc7..261ad0b83 100644 --- a/MobiFlight/MobiFlightPin.cs +++ b/MobiFlight/MobiFlightPin.cs @@ -6,7 +6,7 @@ namespace MobiFlight public class MobiFlightPin { [XmlAttribute] - public byte Pin { get; set; } + public uint Pin { get; set; } [XmlAttribute] public bool isAnalog = false; [XmlAttribute] diff --git a/UI/Panels/Device/MFAnalogPanel.cs b/UI/Panels/Device/MFAnalogPanel.cs index f10dd6a42..5060e3c9c 100644 --- a/UI/Panels/Device/MFAnalogPanel.cs +++ b/UI/Panels/Device/MFAnalogPanel.cs @@ -42,7 +42,7 @@ public MFAnalogPanel(MobiFlight.Config.AnalogInput analogDevice, List Pins): ComboBoxHelper.BindMobiFlightFreePins(mfPinComboBox, Pins, button.Pin); this.button = button; - mfPinComboBox.SelectedValue = byte.Parse(button.Pin); + mfPinComboBox.SelectedValue = uint.Parse(button.Pin); textBox1.Text = button.Name; ////setValues(); diff --git a/UI/Panels/Device/MFOutputPanel.cs b/UI/Panels/Device/MFOutputPanel.cs index 7e80abefd..259534bb6 100644 --- a/UI/Panels/Device/MFOutputPanel.cs +++ b/UI/Panels/Device/MFOutputPanel.cs @@ -47,7 +47,7 @@ private void value_Changed(object sender, EventArgs e) private bool isPwmPin() { bool result = false; - byte bPin = byte.Parse(mfPinComboBox.SelectedItem.ToString()); + uint bPin = uint.Parse(mfPinComboBox.SelectedItem.ToString()); var pin = MobiFlightBoard.Pins.Find(x => (x.Pin == bPin)); return pin.isPWM; } diff --git a/UI/Panels/Device/MFServoPanel.Designer.cs b/UI/Panels/Device/MFServoPanel.Designer.cs index 7b6c42497..69caf7bbb 100644 --- a/UI/Panels/Device/MFServoPanel.Designer.cs +++ b/UI/Panels/Device/MFServoPanel.Designer.cs @@ -62,7 +62,7 @@ private void InitializeComponent() this.mfPinComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.mfPinComboBox.FormattingEnabled = true; this.mfPinComboBox.Location = new System.Drawing.Point(18, 19); - this.mfPinComboBox.MaxLength = 2; + this.mfPinComboBox.MaxLength = 5; this.mfPinComboBox.Name = "mfPinComboBox"; this.mfPinComboBox.Size = new System.Drawing.Size(45, 21); this.mfPinComboBox.TabIndex = 13; diff --git a/UI/Panels/Output/DisplayPinPanel.cs b/UI/Panels/Output/DisplayPinPanel.cs index 7a361fa6d..4afa32cac 100644 --- a/UI/Panels/Output/DisplayPinPanel.cs +++ b/UI/Panels/Output/DisplayPinPanel.cs @@ -182,7 +182,7 @@ private void displayPinComboBox_SelectedIndexChanged(object sender, EventArgs e) { pwmPinPanel.Enabled = pwmPinPanel.Visible = Module.getPwmPins() - .Find(x => x.Pin == (byte)(item as MobiFlightOutput).Pin) != null; + .Find(x => x.Pin == (uint)(item as MobiFlightOutput).Pin) != null; return; } }