Skip to content

Commit

Permalink
Check for max number of output shifters (#823)
Browse files Browse the repository at this point in the history
* Check for max number of output shifters

* Use correct device type in error message.

Co-authored-by: Neil Enns <{ID}+{username}@users.noreply.github.com>
  • Loading branch information
neilenns and Neil Enns committed May 30, 2022
1 parent c55b69c commit a18d6c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions MobiFlight/Board.cs
Expand Up @@ -164,6 +164,11 @@ public class ModuleLimits
/// </summary>
public int MaxServos = 0;

/// <summary>
/// Maximum number of output shifters supported by the board.
/// </summary>
public int MaxShifters = 0;

/// <summary>
/// Maximum number of steppers supported by the board.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions UI/Panels/Settings/MobiFlightPanel.cs
Expand Up @@ -546,6 +546,10 @@ private void addDeviceTypeToolStripMenuItem_Click(object sender, EventArgs e)

case "ShiftRegisterToolStripMenuItem":
case "addShiftRegisterToolStripMenuItem":
if (statistics[MobiFlightShiftRegister.TYPE] == tempModule.Board.ModuleLimits.MaxShifters)
{
throw new MaximumDeviceNumberReachedMobiFlightException(MobiFlightShiftRegister.TYPE, tempModule.Board.ModuleLimits.MaxShifters);
}
cfgItem = new MobiFlight.Config.ShiftRegister();
(cfgItem as MobiFlight.Config.ShiftRegister).DataPin = freePinList.ElementAt(0).ToString();
(cfgItem as MobiFlight.Config.ShiftRegister).ClockPin = freePinList.ElementAt(1).ToString();
Expand Down

0 comments on commit a18d6c0

Please sign in to comment.