Firmware update screen fixes

This commit is contained in:
Riku Isokoski 2022-04-09 14:47:43 +03:00
parent 129dd97b51
commit d7441d18be

View file

@ -16,18 +16,17 @@ FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp* app, Pinetime
titleLabel = lv_label_create(lv_scr_act(), nullptr); titleLabel = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(titleLabel, "Firmware update"); lv_label_set_text_static(titleLabel, "Firmware update");
lv_obj_set_auto_realign(titleLabel, true);
lv_obj_align(titleLabel, nullptr, LV_ALIGN_IN_TOP_MID, 0, 50); lv_obj_align(titleLabel, nullptr, LV_ALIGN_IN_TOP_MID, 0, 50);
bar1 = lv_bar_create(lv_scr_act(), nullptr); bar1 = lv_bar_create(lv_scr_act(), nullptr);
lv_obj_set_size(bar1, 200, 30); lv_obj_set_size(bar1, 200, 30);
lv_obj_align(bar1, nullptr, LV_ALIGN_CENTER, 0, 0); lv_obj_align(bar1, nullptr, LV_ALIGN_CENTER, 0, 0);
lv_bar_set_anim_time(bar1, 10); lv_bar_set_range(bar1, 0, 1000);
lv_bar_set_range(bar1, 0, 100);
lv_bar_set_value(bar1, 0, LV_ANIM_OFF); lv_bar_set_value(bar1, 0, LV_ANIM_OFF);
percentLabel = lv_label_create(lv_scr_act(), nullptr); percentLabel = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(percentLabel, "Waiting..."); lv_label_set_text_static(percentLabel, "Waiting...");
lv_label_set_recolor(percentLabel, true);
lv_obj_set_auto_realign(percentLabel, true); lv_obj_set_auto_realign(percentLabel, true);
lv_obj_align(percentLabel, bar1, LV_ALIGN_OUT_TOP_MID, 0, 60); lv_obj_align(percentLabel, bar1, LV_ALIGN_OUT_TOP_MID, 0, 60);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
@ -55,8 +54,9 @@ void FirmwareUpdate::Refresh() {
} }
break; break;
case Pinetime::Controllers::Ble::FirmwareUpdateStates::Running: case Pinetime::Controllers::Ble::FirmwareUpdateStates::Running:
if (state != States::Running) if (state != States::Running) {
state = States::Running; state = States::Running;
}
DisplayProgression(); DisplayProgression();
break; break;
case Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated: case Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated:
@ -78,21 +78,20 @@ void FirmwareUpdate::Refresh() {
} }
void FirmwareUpdate::DisplayProgression() const { void FirmwareUpdate::DisplayProgression() const {
float current = bleController.FirmwareUpdateCurrentBytes() / 1024.0f; const uint32_t current = bleController.FirmwareUpdateCurrentBytes();
float total = bleController.FirmwareUpdateTotalBytes() / 1024.0f; const uint32_t total = bleController.FirmwareUpdateTotalBytes();
int16_t pc = (current / total) * 100.0f; const int16_t permille = current / (total / 1000);
lv_label_set_text_fmt(percentLabel, "%d %%", pc);
lv_bar_set_value(bar1, pc, LV_ANIM_OFF); lv_label_set_text_fmt(percentLabel, "%d %%", permille / 10);
lv_bar_set_value(bar1, permille, LV_ANIM_OFF);
} }
void FirmwareUpdate::UpdateValidated() { void FirmwareUpdate::UpdateValidated() {
lv_label_set_recolor(percentLabel, true);
lv_label_set_text_static(percentLabel, "#00ff00 Image Ok!#"); lv_label_set_text_static(percentLabel, "#00ff00 Image Ok!#");
} }
void FirmwareUpdate::UpdateError() { void FirmwareUpdate::UpdateError() {
lv_label_set_recolor(percentLabel, true);
lv_label_set_text_static(percentLabel, "#ff0000 Error!#"); lv_label_set_text_static(percentLabel, "#ff0000 Error!#");
startTime = xTaskGetTickCount(); startTime = xTaskGetTickCount();
} }