Skip to content

Commit

Permalink
Community board options are displayed for Picos (#1711)
Browse files Browse the repository at this point in the history
* Community board options are displayed for Picos

* Updated comments in code

* Fixed comment
  • Loading branch information
DocMoebiuz authored Feb 23, 2024
1 parent d4364e1 commit 821e24a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 12 additions & 0 deletions MobiFlight/BoardDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ public static Board GetBoardByUsbVolumeLabel(String volumeLabel)
return boards.Find(board => board.UsbDriveSettings?.VolumeLabel == volumeLabel);
}

/// <summary>
/// Finds board definitions by matching against USB drive volume label. This does not check for the
/// presence of a secondary file on the drive to confirm it is a supported USB drive.
/// This is used for offering different community board options.
/// </summary>
/// <param name="volumeLabel">The volume label to match</param>
/// <returns>All board definitions matching the volumeLabel, or an empty list if none found.</returns>
public static List<Board> GetBoardsByUsbVolumeLabel(String volumeLabel)
{
return boards.FindAll(board => board.UsbDriveSettings?.VolumeLabel == volumeLabel);
}

/// <summary>
/// Finds a board definition by matching against the USB VID/PID.
/// </summary>
Expand Down
7 changes: 2 additions & 5 deletions UI/Panels/Settings/MobiFlightPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,13 @@ private void UpdateToolbarAndPanelAfterNodeHasChanged(TreeNode node)

if (!isMobiFlightBoard)
{
// TODO: Show an option to upload the VID PID compatible firmwares
var boards = BoardDefinitions.GetBoardsByHardwareId(module.HardwareId);

// we don't have ambiguous boards
// but we have a device like the pico
if (boards.Count == 0 && module.Board.UsbDriveSettings != null)
{
// at the moment we don't support
// alternatives for the USB type device
boards.Add(module.Board);
// find all alternatives for the USB type device
boards = BoardDefinitions.GetBoardsByUsbVolumeLabel(module.HardwareId);
}

if (boards.Count > 0)
Expand Down

0 comments on commit 821e24a

Please sign in to comment.