Skip to content

Commit

Permalink
added "update list" button in prop flasher
Browse files Browse the repository at this point in the history
  • Loading branch information
benkuper committed Jun 22, 2024
1 parent 75308e3 commit ec22be1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
8 changes: 5 additions & 3 deletions Source/Prop/PropFlasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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...");
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Prop/PropFlasher.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class PropFlasher :
Array<float> progressions;
Array<FlashResult> flasherDones;

void updateFirmwareDefinitions();
void updateFirmwareDefinitions(bool force = false);

void setFlashProgression(SingleFlasher*, float val);;
void setFlashingDone(SingleFlasher*, FlashResult val);
Expand Down
6 changes: 5 additions & 1 deletion Source/Prop/ui/PropFlasherPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -43,6 +45,7 @@ PropFlasherPanel::PropFlasherPanel() :
wifiPassUI->customBGColor = BG_COLOR;
wifiPassUI->updateUIParams();

addAndMakeVisible(updateFirmwareDefinitionsUI.get());
addAndMakeVisible(filterKnownDevicesUI.get());
addAndMakeVisible(firmwareToUploadUI.get());
addAndMakeVisible(firmwareCustomFileUI.get());
Expand Down Expand Up @@ -138,6 +141,7 @@ void PropFlasherPanel::resized()
fwRect = cr.removeFromTop(68);
Rectangle<int> 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));
Expand All @@ -160,7 +164,7 @@ void PropFlasherPanel::resized()
Rectangle<int> fr = flashRect.reduced(10);
fr.removeFromTop(20);
Rectangle<int> 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));

Expand Down
1 change: 1 addition & 0 deletions Source/Prop/ui/PropFlasherPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class PropFlasherPanel :
std::unique_ptr<BoolToggleUI> filterKnownDevicesUI;
Label noDeviceLabel;

std::unique_ptr<TriggerButtonUI> updateFirmwareDefinitionsUI;
std::unique_ptr<EnumParameterUI> firmwareToUploadUI;
std::unique_ptr<StringParameterFileUI> firmwareCustomFileUI;
std::unique_ptr<BoolToggleUI> setWifiAfterFlashUI;
Expand Down

0 comments on commit ec22be1

Please sign in to comment.