From d301462298ac5046dd122982fec26d32b042cd19 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Sun, 1 Oct 2023 13:48:02 +0700 Subject: [PATCH] Update espmega_iot_core.cpp --- src/espmega_iot_core.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/espmega_iot_core.cpp b/src/espmega_iot_core.cpp index 50bf3c7..7e9a142 100644 --- a/src/espmega_iot_core.cpp +++ b/src/espmega_iot_core.cpp @@ -266,12 +266,15 @@ void ota_begin() if (upload.status == UPLOAD_FILE_START) { lcd_send_command("page ota"); + Serial.println(upload.currentSize); + String otafiletxt = "Downloading File : " + upload.filename; - panel.writeStr("otatxt.txt",otafiletxt); + lcd_send_stop_bit(); + panel.writeStr("otatxt.txt", otafiletxt); Serial.printf("Update: %s\n", upload.filename.c_str()); if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { - panel.writeStr("otatxt.txt","Update Failed, Rebooting . . ."); + panel.writeStr("otatxt.txt", "Update Failed, Rebooting . . ."); Update.printError(Serial); } } @@ -279,20 +282,29 @@ void ota_begin() { if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) { - panel.writeStr("otatxt.txt","Update Failed, Rebooting . . ."); + panel.writeStr("otatxt.txt", "Update Failed, Rebooting . . ."); Update.printError(Serial); } + if (upload.currentSize != 0 && upload.totalSize != 0) + { + lcd_send_stop_bit(); + uint32_t totalsize_kb = upload.totalSize / 1000; + uint32_t upload_pct = 100 * upload.totalSize/1000000; + String otafiletxt = "Downloading File : " + upload.filename + " ("+String(totalsize_kb) + "KB)"; + panel.writeNum("prog.val", upload_pct); + panel.writeStr("otatxt.txt", otafiletxt); + } } else if (upload.status == UPLOAD_FILE_END) { if (Update.end(true)) { - panel.writeStr("otatxt.txt","Update Completed, Rebooting . . ."); + panel.writeStr("otatxt.txt", "Update Completed, Rebooting . . ."); Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize); } else { - panel.writeStr("otatxt.txt","Update Failed, Rebooting . . ."); + panel.writeStr("otatxt.txt", "Update Failed, Rebooting . . ."); Update.printError(Serial); } }