|
@@ -36,7 +36,9 @@ const flashButton = $("flash-button");
|
|
const appStatus = $("status");
|
|
const appStatus = $("status");
|
|
const portsSelect = new PortSelect($("ports"));
|
|
const portsSelect = new PortSelect($("ports"));
|
|
const manifestsSelect = $("manifests");
|
|
const manifestsSelect = $("manifests");
|
|
|
|
+const progressHolder = $("progressBar");
|
|
const progressBar = $("progress");
|
|
const progressBar = $("progress");
|
|
|
|
+const form = $("form");
|
|
|
|
|
|
/************************
|
|
/************************
|
|
* Utility Functions
|
|
* Utility Functions
|
|
@@ -98,6 +100,8 @@ serialScanner.on("error", onError);
|
|
* Updates UI to say it's ready
|
|
* Updates UI to say it's ready
|
|
*/
|
|
*/
|
|
function readyToFlash() {
|
|
function readyToFlash() {
|
|
|
|
+ progressHolder.style.display = "none";
|
|
|
|
+ form.style.display = "block";
|
|
appStatus.textContent = "Ready";
|
|
appStatus.textContent = "Ready";
|
|
enableInputs();
|
|
enableInputs();
|
|
}
|
|
}
|
|
@@ -151,22 +155,30 @@ function getManifests() {
|
|
}
|
|
}
|
|
|
|
|
|
function flashWithManifest(manifest) {
|
|
function flashWithManifest(manifest) {
|
|
|
|
+ form.style.display = "none";
|
|
|
|
+ progressHolder.style.display = "block";
|
|
appStatus.textContent = `Flashing ${portsSelect.value}`;
|
|
appStatus.textContent = `Flashing ${portsSelect.value}`;
|
|
|
|
+ const numberOfSteps = manifest.flash.length * 2;
|
|
|
|
+ let currectStepNumber = 1;
|
|
prepareBinaries(manifest, (err, flashSpec) => {
|
|
prepareBinaries(manifest, (err, flashSpec) => {
|
|
if(err) throw err;
|
|
if(err) throw err;
|
|
|
|
|
|
const esp = new RomComm({
|
|
const esp = new RomComm({
|
|
portName: portsSelect.value,
|
|
portName: portsSelect.value,
|
|
- baudRate: 115200,
|
|
|
|
|
|
+ baudRate: 115200
|
|
});
|
|
});
|
|
|
|
|
|
esp.on('progress', (progress) => {
|
|
esp.on('progress', (progress) => {
|
|
- applicationCache.textContent = progress.display;
|
|
|
|
- progressBar.style.width = `${Math.round((progress.details.flashedBytes/progress.details.totalBytes) * 100)}%`;
|
|
|
|
|
|
+ const flashPercent = Math.round((progress.details.flashedBytes/progress.details.totalBytes) * 100);
|
|
|
|
+ const processSoFar = 50; //From download and extracting.
|
|
|
|
+ const flashProcess = flashPercent / 2; //To add to the overall progress
|
|
|
|
+ updateProgressBar(processSoFar + flashProcess);
|
|
|
|
+ appStatus.textContent = `${progress.display} - ${flashPercent}%`;
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
esp.open().then((result) => {
|
|
esp.open().then((result) => {
|
|
- appStatus.textContent = `Flashing ${portsSelect.value}...Opened Port.`;
|
|
|
|
|
|
+ appStatus.textContent = `Flashing device connected to ${portsSelect.value}`;
|
|
let promise = Promise.resolve();
|
|
let promise = Promise.resolve();
|
|
return esp.flashSpecifications(flashSpec)
|
|
return esp.flashSpecifications(flashSpec)
|
|
.then(() => esp.close())
|
|
.then(() => esp.close())
|
|
@@ -176,11 +188,22 @@ function flashWithManifest(manifest) {
|
|
log.info("Flashed to latest Espruino build!", result);
|
|
log.info("Flashed to latest Espruino build!", result);
|
|
});
|
|
});
|
|
}).catch((error) => {
|
|
}).catch((error) => {
|
|
|
|
+ new Notification("An error occured during flashing.");
|
|
|
|
+ readyToFlash();
|
|
log.error("Oh noes!", error);
|
|
log.error("Oh noes!", error);
|
|
});
|
|
});
|
|
|
|
+ }).on("entry", (progress) => {
|
|
|
|
+ //For the download/extract progress. The other half is flashing.
|
|
|
|
+ const extractPercent = Math.round((currectStepNumber++/numberOfSteps) * 50);
|
|
|
|
+ updateProgressBar(extractPercent);
|
|
|
|
+ appStatus.textContent = progress.display;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function updateProgressBar(percent) {
|
|
|
|
+ progressBar.style.width = `${percent}%`;
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Get's manifest list for possibilities for flashing,
|
|
* Get's manifest list for possibilities for flashing,
|
|
* scans serial ports and sets up timer for checking for changes.
|
|
* scans serial ports and sets up timer for checking for changes.
|