From ec22be1070a3c0a98575ff93ed5a6a46956bfab1 Mon Sep 17 00:00:00 2001 From: Ben Kuper Date: Sat, 22 Jun 2024 13:59:08 +0200 Subject: [PATCH] added "update list" button in prop flasher --- Source/Prop/PropFlasher.cpp | 8 +++++--- Source/Prop/PropFlasher.h | 2 +- Source/Prop/ui/PropFlasherPanel.cpp | 6 +++++- Source/Prop/ui/PropFlasherPanel.h | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Source/Prop/PropFlasher.cpp b/Source/Prop/PropFlasher.cpp index 560935a8..6c67df58 100644 --- a/Source/Prop/PropFlasher.cpp +++ b/Source/Prop/PropFlasher.cpp @@ -22,7 +22,7 @@ PropFlasher::PropFlasher() : filterKnownDevices = addBoolParameter("Filter Known Devices", "Only upload firmware on devices that are compatible. If you don't see your connect props on the list, try disabling this option.", true); - updateFirmwareDefinitionsTrigger = addTrigger("Update Firmware Definitions", "Update the list of available firmwares"); + updateFirmwareDefinitionsTrigger = addTrigger("Update List", "Update the list of available firmwares"); fwType = addEnumParameter("Firmware Type", "Type of prop to upload"); @@ -74,10 +74,12 @@ PropFlasher::~PropFlasher() stopThread(1000); } -void PropFlasher::updateFirmwareDefinitions() +void PropFlasher::updateFirmwareDefinitions(bool force) { fwType->clearOptions(); File f = File::getSpecialLocation(File::userDocumentsDirectory).getChildFile(String(ProjectInfo::projectName) + "/firmwares"); + if(force && f.exists()) f.deleteRecursively(); + if (!f.exists()) { LOG("No firmware folder found, downloading..."); @@ -190,7 +192,7 @@ void PropFlasher::onContainerTriggerTriggered(Trigger* t) { if (t == flashTrigger) flashAll(); else if (t == uploadTrigger) uploadServerFiles(); - if (t == updateFirmwareDefinitionsTrigger) updateFirmwareDefinitions(); + if (t == updateFirmwareDefinitionsTrigger) updateFirmwareDefinitions(true); else if (t == setAllWifiTrigger) flashAll(true); } diff --git a/Source/Prop/PropFlasher.h b/Source/Prop/PropFlasher.h index 60aff8e0..b11c96ff 100644 --- a/Source/Prop/PropFlasher.h +++ b/Source/Prop/PropFlasher.h @@ -88,7 +88,7 @@ class PropFlasher : Array progressions; Array flasherDones; - void updateFirmwareDefinitions(); + void updateFirmwareDefinitions(bool force = false); void setFlashProgression(SingleFlasher*, float val);; void setFlashingDone(SingleFlasher*, FlashResult val); diff --git a/Source/Prop/ui/PropFlasherPanel.cpp b/Source/Prop/ui/PropFlasherPanel.cpp index 9c6e387a..8e6ca5ec 100644 --- a/Source/Prop/ui/PropFlasherPanel.cpp +++ b/Source/Prop/ui/PropFlasherPanel.cpp @@ -18,6 +18,8 @@ PropFlasherPanel::PropFlasherPanel() : filterKnownDevicesUI.reset(PropFlasher::getInstance()->filterKnownDevices->createToggle()); firmwareToUploadUI.reset((EnumParameterUI*)PropFlasher::getInstance()->fwType->createDefaultUI()); firmwareCustomFileUI.reset((StringParameterFileUI*)PropFlasher::getInstance()->fwFileParam->createStringParameterFileUI()); + updateFirmwareDefinitionsUI.reset(PropFlasher::getInstance()->updateFirmwareDefinitionsTrigger->createButtonUI()); + setWifiAfterFlashUI.reset(PropFlasher::getInstance()->setWifiAfterFlash->createToggle()); wifiSSIDUI.reset(PropFlasher::getInstance()->wifiSSID->createStringParameterUI()); wifiPassUI.reset(PropFlasher::getInstance()->wifiPass->createStringParameterUI()); @@ -43,6 +45,7 @@ PropFlasherPanel::PropFlasherPanel() : wifiPassUI->customBGColor = BG_COLOR; wifiPassUI->updateUIParams(); + addAndMakeVisible(updateFirmwareDefinitionsUI.get()); addAndMakeVisible(filterKnownDevicesUI.get()); addAndMakeVisible(firmwareToUploadUI.get()); addAndMakeVisible(firmwareCustomFileUI.get()); @@ -138,6 +141,7 @@ void PropFlasherPanel::resized() fwRect = cr.removeFromTop(68); Rectangle fwr = fwRect.reduced(10); fwr.removeFromTop(20); + updateFirmwareDefinitionsUI->setBounds(fwr.removeFromLeft(120).reduced(4)); firmwareToUploadUI->setBounds(fwr.removeFromLeft(200).reduced(4)); fwr.removeFromLeft(20); firmwareCustomFileUI->setBounds(fwr.reduced(4)); @@ -160,7 +164,7 @@ void PropFlasherPanel::resized() Rectangle fr = flashRect.reduced(10); fr.removeFromTop(20); Rectangle fr2 = fr.removeFromTop(70).withSizeKeepingCentre(jmin(fr.getWidth(), 400), 50); - flashAllUI->setBounds(fr2.removeFromLeft(fr2.getWidth()/2).reduced(4)); + flashAllUI->setBounds(fr2.removeFromLeft(fr2.getWidth() / 2).reduced(4)); setWifiUI->setBounds(fr2.reduced(4)); progressUI->setBounds(fr.removeFromBottom(40)); diff --git a/Source/Prop/ui/PropFlasherPanel.h b/Source/Prop/ui/PropFlasherPanel.h index b2abad00..39ea7c67 100644 --- a/Source/Prop/ui/PropFlasherPanel.h +++ b/Source/Prop/ui/PropFlasherPanel.h @@ -31,6 +31,7 @@ class PropFlasherPanel : std::unique_ptr filterKnownDevicesUI; Label noDeviceLabel; + std::unique_ptr updateFirmwareDefinitionsUI; std::unique_ptr firmwareToUploadUI; std::unique_ptr firmwareCustomFileUI; std::unique_ptr setWifiAfterFlashUI;