From 821e24a6c12a893ebe128f3724be8bf560bff9fe Mon Sep 17 00:00:00 2001 From: Sebastian M Date: Fri, 23 Feb 2024 10:40:40 +0100 Subject: [PATCH] Community board options are displayed for Picos (#1711) * Community board options are displayed for Picos * Updated comments in code * Fixed comment --- MobiFlight/BoardDefinitions.cs | 12 ++++++++++++ UI/Panels/Settings/MobiFlightPanel.cs | 7 ++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/MobiFlight/BoardDefinitions.cs b/MobiFlight/BoardDefinitions.cs index 204d3917a..de774b576 100644 --- a/MobiFlight/BoardDefinitions.cs +++ b/MobiFlight/BoardDefinitions.cs @@ -33,6 +33,18 @@ public static Board GetBoardByUsbVolumeLabel(String volumeLabel) return boards.Find(board => board.UsbDriveSettings?.VolumeLabel == volumeLabel); } + /// + /// 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. + /// + /// The volume label to match + /// All board definitions matching the volumeLabel, or an empty list if none found. + public static List GetBoardsByUsbVolumeLabel(String volumeLabel) + { + return boards.FindAll(board => board.UsbDriveSettings?.VolumeLabel == volumeLabel); + } + /// /// Finds a board definition by matching against the USB VID/PID. /// diff --git a/UI/Panels/Settings/MobiFlightPanel.cs b/UI/Panels/Settings/MobiFlightPanel.cs index a7007caeb..032c3a925 100644 --- a/UI/Panels/Settings/MobiFlightPanel.cs +++ b/UI/Panels/Settings/MobiFlightPanel.cs @@ -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)