Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 46 additions & 29 deletions windows/QMK Toolbox/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading.Tasks;

namespace QMK_Toolbox
{
Expand Down Expand Up @@ -293,19 +294,23 @@ private async void FlashAllAsync()

if (!windowState.AutoFlashEnabled)
{
Invoke(new Action(DisableUI));
DisableUI();
}

foreach (BootloaderDevice b in FindBootloaders())
var bootloaders = FindBootloaders();
await Task.Run(async () =>
{
logTextBox.LogBootloader("Attempting to flash, please don't remove device");
await b.Flash(selectedMcu, filePath);
logTextBox.LogBootloader("Flash complete");
}
foreach (BootloaderDevice b in bootloaders)
{
Invoke(new Action(() => logTextBox.LogBootloader("Attempting to flash, please don't remove device")));
await b.Flash(selectedMcu, filePath);
Invoke(new Action(() => logTextBox.LogBootloader("Flash complete")));
}
});

if (!windowState.AutoFlashEnabled)
{
Invoke(new Action(EnableUI));
EnableUI();
}
}

Expand All @@ -315,20 +320,24 @@ private async void ResetAllAsync()

if (!windowState.AutoFlashEnabled)
{
Invoke(new Action(DisableUI));
DisableUI();
}

foreach (BootloaderDevice b in FindBootloaders())
var bootloaders = FindBootloaders();
await Task.Run(async () =>
{
if (b.IsResettable)
foreach (BootloaderDevice b in bootloaders)
{
await b.Reset(selectedMcu);
if (b.IsResettable)
{
await b.Reset(selectedMcu);
}
}
}
});

if (!windowState.AutoFlashEnabled)
{
Invoke(new Action(EnableUI));
EnableUI();
}
}

Expand All @@ -338,22 +347,26 @@ private async void ClearEepromAllAsync()

if (!windowState.AutoFlashEnabled)
{
Invoke(new Action(DisableUI));
DisableUI();
}

foreach (BootloaderDevice b in FindBootloaders())
var bootloaders = FindBootloaders();
await Task.Run(async () =>
{
if (b.IsEepromFlashable)
foreach (BootloaderDevice b in bootloaders)
{
logTextBox.LogBootloader("Attempting to clear EEPROM, please don't remove device");
await b.FlashEeprom(selectedMcu, "reset.eep");
logTextBox.LogBootloader("EEPROM clear complete");
if (b.IsEepromFlashable)
{
Invoke(new Action(() => logTextBox.LogBootloader("Attempting to clear EEPROM, please don't remove device")));
await b.FlashEeprom(selectedMcu, "reset.eep");
Invoke(new Action(() => logTextBox.LogBootloader("EEPROM clear complete")));
}
}
}
});

if (!windowState.AutoFlashEnabled)
{
Invoke(new Action(EnableUI));
EnableUI();
}
}

Expand All @@ -364,22 +377,26 @@ private async void SetHandednessAllAsync(bool left)

if (!windowState.AutoFlashEnabled)
{
Invoke(new Action(DisableUI));
DisableUI();
}

foreach (BootloaderDevice b in FindBootloaders())
var bootloaders = FindBootloaders();
await Task.Run(async () =>
{
if (b.IsEepromFlashable)
foreach (BootloaderDevice b in bootloaders)
{
logTextBox.LogBootloader("Attempting to set handedness, please don't remove device");
await b.FlashEeprom(selectedMcu, file);
logTextBox.LogBootloader("EEPROM write complete");
if (b.IsEepromFlashable)
{
Invoke(new Action(() => logTextBox.LogBootloader("Attempting to set handedness, please don't remove device")));
await b.FlashEeprom(selectedMcu, file);
Invoke(new Action(() => logTextBox.LogBootloader("EEPROM write complete")));
}
}
}
});

if (!windowState.AutoFlashEnabled)
{
Invoke(new Action(EnableUI));
EnableUI();
}
}

Expand Down
Loading