summaryrefslogtreecommitdiff
path: root/src/DisplayApp/Screens/FirmwareUpdate.cpp
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-06-01 07:22:54 (GMT)
committerJF <jf@codingfield.com>2020-06-01 07:22:54 (GMT)
commitdca559aad5a5020ae0d5c1bec08bbf5030e0d718 (patch)
treedf449fb41a14bb321e69f19f646109c2fb79d093 /src/DisplayApp/Screens/FirmwareUpdate.cpp
parent4717cf0a1d6c210a362e8bdf63265c4910e2c8cc (diff)
Improve DFU procedure :
- correctly write all bytes to flash - check CRC - Fix bug in notification : they cannot be sent from the control point handler (because it seems you cannot send a notification and a write acknowledge at the same time) using a timer (quick'n'dirty implementation to be improved) - Improve dfu screen - Reset if dfu image is correctly copied into flash and crc is ok.
Diffstat (limited to 'src/DisplayApp/Screens/FirmwareUpdate.cpp')
-rw-r--r--src/DisplayApp/Screens/FirmwareUpdate.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/DisplayApp/Screens/FirmwareUpdate.cpp b/src/DisplayApp/Screens/FirmwareUpdate.cpp
index f3cf42f..138211c 100644
--- a/src/DisplayApp/Screens/FirmwareUpdate.cpp
+++ b/src/DisplayApp/Screens/FirmwareUpdate.cpp
@@ -26,6 +26,15 @@ FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp *app, Pinetime
lv_label_set_text(percentLabel, "");
lv_obj_set_auto_realign(percentLabel, true);
lv_obj_align(percentLabel, bar1, LV_ALIGN_OUT_TOP_MID, 0, 60);
+
+ button = lv_btn_create(lv_scr_act(), NULL);
+ //lv_obj_set_event_cb(button, event_handler);
+ lv_obj_align(button, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+ lv_obj_set_hidden(button, true);
+
+ labelBtn = lv_label_create(button, NULL);
+ lv_label_set_text(labelBtn, "Back");
+ lv_obj_set_hidden(labelBtn, true);
}
FirmwareUpdate::~FirmwareUpdate() {
@@ -33,6 +42,29 @@ FirmwareUpdate::~FirmwareUpdate() {
}
bool FirmwareUpdate::Refresh() {
+ switch(bleController.State()) {
+ default:
+ case Pinetime::Controllers::Ble::FirmwareUpdateStates::Idle:
+ case Pinetime::Controllers::Ble::FirmwareUpdateStates::Running:
+ if(state != States::Running)
+ state = States::Running;
+ return DisplayProgression();
+ case Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated:
+ if(state != States::Validated) {
+ UpdateValidated();
+ state = States::Validated;
+ }
+ return running;
+ case Pinetime::Controllers::Ble::FirmwareUpdateStates::Error:
+ if(state != States::Error) {
+ UpdateError();
+ state = States::Error;
+ }
+ return running;
+ }
+}
+
+bool FirmwareUpdate::DisplayProgression() const {
float current = bleController.FirmwareUpdateCurrentBytes() / 1024.0f;
float total = bleController.FirmwareUpdateTotalBytes() / 1024.0f;
int16_t pc = (current / total) * 100.0f;
@@ -47,3 +79,16 @@ bool FirmwareUpdate::OnButtonPushed() {
running = false;
return true;
}
+
+void FirmwareUpdate::UpdateValidated() {
+ lv_label_set_recolor(percentLabel, true);
+ lv_label_set_text(percentLabel, "#00ff00 Image Ok!#");
+}
+
+void FirmwareUpdate::UpdateError() {
+ lv_label_set_recolor(percentLabel, true);
+ lv_label_set_text(percentLabel, "#ff0000 Error!#");
+
+ lv_obj_set_hidden(labelBtn, false);
+ lv_obj_set_hidden(button, false);
+}