From 55de43255cd71310dac8ce8f183e4f6e85220233 Mon Sep 17 00:00:00 2001 From: cTn Date: Sat, 16 Nov 2013 13:03:42 +0100 Subject: [PATCH] implements progress bar fix #7 --- js/stm32.js | 16 ++++++++++++++++ tabs/firmware_flasher.html | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/js/stm32.js b/js/stm32.js index 4f2efd34..df32826e 100644 --- a/js/stm32.js +++ b/js/stm32.js @@ -145,6 +145,11 @@ STM32_protocol.prototype.initialize = function() { self.steps_executed = 0; self.steps_executed_last = 0; + + // reset progress bar to initial state + self.progress_bar_e = $('.progress'); + self.progress_bar_e.val(0); + self.progress_bar_e.removeClass('valid invalid'); GUI.interval_add('firmware_uploader_read', function() { self.read(); @@ -437,6 +442,8 @@ STM32_protocol.prototype.upload_procedure = function(step) { } }); + // update progress bar + self.progress_bar_e.val(self.bytes_flashed / (self.hex.bytes * 2) * 100); } else { console.log('Writing: done'); console.log('Verifying data ...'); @@ -485,6 +492,9 @@ STM32_protocol.prototype.upload_procedure = function(step) { }); } }); + + // update progress bar + self.progress_bar_e.val((self.bytes_flashed + self.bytes_verified) / (self.hex.bytes * 2) * 100); } else { var result = self.verify_flash(self.hex.data, self.verify_hex); @@ -493,6 +503,9 @@ STM32_protocol.prototype.upload_procedure = function(step) { console.log('Programming: SUCCESSFUL'); STM32.GUI_status('Programming: SUCCESSFUL'); + // update progress bar + self.progress_bar_e.addClass('valid'); + // proceed to next step self.upload_procedure(7); } else { @@ -500,6 +513,9 @@ STM32_protocol.prototype.upload_procedure = function(step) { console.log('Programming: FAILED'); STM32.GUI_status('Programming: FAILED'); + // update progress bar + self.progress_bar_e.addClass('invalid'); + // disconnect self.upload_procedure(99); } diff --git a/tabs/firmware_flasher.html b/tabs/firmware_flasher.html index f1fee958..daf6458a 100644 --- a/tabs/firmware_flasher.html +++ b/tabs/firmware_flasher.html @@ -5,6 +5,20 @@ .tab-firmware_flasher .info strong { margin-right: 5px; } + .tab-firmware_flasher .info .progress { + width: 140px; + + border: 1px solid silver; + } + .tab-firmware_flasher .info .progress::-webkit-progress-value { + background-color: #f4af4d; + } + .tab-firmware_flasher .info .progress.valid::-webkit-progress-value { + background-color: #43c232; + } + .tab-firmware_flasher .info .progress.invalid::-webkit-progress-value { + background-color: #cf2222; + } .tab-firmware_flasher .note { float: left; @@ -108,6 +122,7 @@ Path:empty
Size:0.000 kb
Status:Firmware not loaded
+ Progress: