diff options
| author | JF <jf@codingfield.com> | 2020-05-24 16:58:29 +0200 |
|---|---|---|
| committer | Gitea <gitea@fake.local> | 2020-05-24 16:58:29 +0200 |
| commit | 82b4ddc25b4c7913e0e6a13a209a4415dff044f1 (patch) | |
| tree | 8eeafef1f4150a1cf238ee80e53c8901b0ec67af /src/DisplayApp/Screens/FirmwareUpdate.cpp | |
| parent | be1ad9b07083e656a649d223750ff4b14b781b7b (diff) | |
| parent | 073717980f5c00f553ac3b58a50b792b32a14c7a (diff) | |
Merge branch 'nimble-ota' of JF/PineTime into develop
Diffstat (limited to 'src/DisplayApp/Screens/FirmwareUpdate.cpp')
| -rw-r--r-- | src/DisplayApp/Screens/FirmwareUpdate.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/DisplayApp/Screens/FirmwareUpdate.cpp b/src/DisplayApp/Screens/FirmwareUpdate.cpp new file mode 100644 index 00000000..f3cf42f9 --- /dev/null +++ b/src/DisplayApp/Screens/FirmwareUpdate.cpp @@ -0,0 +1,49 @@ +#include <libs/lvgl/lvgl.h> +#include "FirmwareUpdate.h" +#include "../DisplayApp.h" + +using namespace Pinetime::Applications::Screens; +extern lv_font_t jetbrains_mono_extrabold_compressed; +extern lv_font_t jetbrains_mono_bold_20; + + +FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Ble& bleController) : + Screen(app), bleController{bleController} { + + titleLabel = lv_label_create(lv_scr_act(), NULL); + lv_label_set_text(titleLabel, "Firmware update"); + lv_obj_set_auto_realign(titleLabel, true); + lv_obj_align(titleLabel, NULL, LV_ALIGN_IN_TOP_MID, 0, 50); + + bar1 = lv_bar_create(lv_scr_act(), NULL); + lv_obj_set_size(bar1, 200, 30); + lv_obj_align(bar1, NULL, LV_ALIGN_CENTER, 0, 0); + lv_bar_set_anim_time(bar1, 10); + lv_bar_set_range(bar1, 0, 100); + lv_bar_set_value(bar1, 0, LV_ANIM_OFF); + + percentLabel = lv_label_create(lv_scr_act(), NULL); + lv_label_set_text(percentLabel, ""); + lv_obj_set_auto_realign(percentLabel, true); + lv_obj_align(percentLabel, bar1, LV_ALIGN_OUT_TOP_MID, 0, 60); +} + +FirmwareUpdate::~FirmwareUpdate() { + lv_obj_clean(lv_scr_act()); +} + +bool FirmwareUpdate::Refresh() { + float current = bleController.FirmwareUpdateCurrentBytes() / 1024.0f; + float total = bleController.FirmwareUpdateTotalBytes() / 1024.0f; + int16_t pc = (current / total) * 100.0f; + sprintf(percentStr, "%d %%", pc); + lv_label_set_text(percentLabel, percentStr); + + lv_bar_set_value(bar1, pc, LV_ANIM_OFF); + return running; +} + +bool FirmwareUpdate::OnButtonPushed() { + running = false; + return true; +} |
