summaryrefslogtreecommitdiff
path: root/src/DisplayApp/Screens
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-06-01 09:22:54 +0200
committerJF <jf@codingfield.com>2020-06-01 09:22:54 +0200
commitdca559aad5a5020ae0d5c1bec08bbf5030e0d718 (patch)
treedf449fb41a14bb321e69f19f646109c2fb79d093 /src/DisplayApp/Screens
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')
-rw-r--r--src/DisplayApp/Screens/FirmwareUpdate.cpp45
-rw-r--r--src/DisplayApp/Screens/FirmwareUpdate.h17
2 files changed, 58 insertions, 4 deletions
diff --git a/src/DisplayApp/Screens/FirmwareUpdate.cpp b/src/DisplayApp/Screens/FirmwareUpdate.cpp
index f3cf42f9..138211c4 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);
+}
diff --git a/src/DisplayApp/Screens/FirmwareUpdate.h b/src/DisplayApp/Screens/FirmwareUpdate.h
index a4cbec62..87e93959 100644
--- a/src/DisplayApp/Screens/FirmwareUpdate.h
+++ b/src/DisplayApp/Screens/FirmwareUpdate.h
@@ -26,13 +26,22 @@ namespace Pinetime {
bool OnButtonPushed() override;
private:
+ enum class States { Idle, Running, Validated, Error };
Pinetime::Controllers::Ble& bleController;
- lv_obj_t * bar1;
- lv_obj_t * percentLabel;
- lv_obj_t * titleLabel;
- char percentStr[10];
+ lv_obj_t* bar1;
+ lv_obj_t* percentLabel;
+ lv_obj_t* titleLabel;
+ lv_obj_t* labelBtn;
+ lv_obj_t* button;
+ mutable char percentStr[10];
bool running = true;
+ States state;
+ bool DisplayProgression() const;
+
+ void UpdateValidated();
+
+ void UpdateError();
};
}
}