Skip to content
Merged
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
19 changes: 10 additions & 9 deletions python-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ function web_editor(config) {

function doFlash() {
var startTime = new Date().getTime();

// Hide serial and disconnect if open
if ($("#repl").css('display') != 'none') {
$("#repl").hide();
Expand All @@ -1495,7 +1495,12 @@ function web_editor(config) {
}
}

var p = Promise.resolve();
// Get the hex to flash in bytes format, exit if there is an error
try {
var output = generateFullHex('bytes');
} catch(e) {
return alert(config.translate.alerts.error + e.message);
}

$("#webusb-flashing-progress").val(0).hide();
$("#webusb-flashing-complete").hide();
Expand All @@ -1504,6 +1509,7 @@ function web_editor(config) {
$("#flashing-info").removeClass('hidden');
$("#flashing-overlay-container").css("display", "flex");

var p = Promise.resolve();
if (usePartialFlashing) {
REPL = null;
$("#repl").empty();
Expand All @@ -1513,15 +1519,13 @@ function web_editor(config) {
return PartialFlashing.connectDapAsync();
})
.then(function() {
var output = generateFullHex("bytes");
var updateProgress = function(progress) {
$("#webusb-flashing-progress").val(progress).css("display", "inline-block");
}
$("#webusb-flashing-loader").hide();
$("#webusb-flashing-progress").val(0).css("display", "inline-block");
return PartialFlashing.flashAsync(window.dapwrapper, output, updateProgress);
})

});
}
else {
// Push binary to board
Expand All @@ -1533,12 +1537,10 @@ function web_editor(config) {
$("#webusb-flashing-progress").val(progress).css("display", "inline-block");
});

var output = generateFullHex("string");

// Encode firmware for flashing
var enc = new TextEncoder();
var image = enc.encode(output).buffer;

$("#webusb-flashing-loader").hide();
$("#webusb-flashing-progress").val(0).css("display", "inline-block");
return window.daplink.flash(image);
Expand Down Expand Up @@ -1566,7 +1568,6 @@ function web_editor(config) {
.finally(function() {
// Remove event listener
window.removeEventListener("unhandledrejection", webusbErrorHandler);

});
}

Expand Down