Add new screen that is displayed during the OTA transfert.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <DisplayApp/Screens/Brightness.h>
|
||||
#include <DisplayApp/Screens/ScreenList.h>
|
||||
#include <Components/Ble/NotificationManager.h>
|
||||
#include <DisplayApp/Screens/FirmwareUpdate.h>
|
||||
#include "../SystemTask/SystemTask.h"
|
||||
|
||||
using namespace Pinetime::Applications;
|
||||
@@ -157,6 +158,17 @@ void DisplayApp::Refresh() {
|
||||
// toggle = true;
|
||||
// }
|
||||
|
||||
break;
|
||||
case Messages::BleFirmwareUpdateStarted:
|
||||
lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Down);
|
||||
currentScreen.reset(nullptr);
|
||||
currentScreen.reset(new Screens::FirmwareUpdate(this, bleController));
|
||||
|
||||
break;
|
||||
case Messages::BleFirmwareUpdateFinished:
|
||||
lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Down);
|
||||
currentScreen.reset(nullptr);
|
||||
currentScreen.reset(new Screens::Clock(this, dateTimeController, batteryController, bleController));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ namespace Pinetime {
|
||||
public:
|
||||
enum class States {Idle, Running};
|
||||
enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, SwitchScreen,ButtonPushed,
|
||||
NewNotification
|
||||
NewNotification, BleFirmwareUpdateStarted, BleFirmwareUpdateFinished
|
||||
};
|
||||
enum class FullRefreshDirections { None, Up, Down };
|
||||
|
||||
|
49
src/DisplayApp/Screens/FirmwareUpdate.cpp
Normal file
49
src/DisplayApp/Screens/FirmwareUpdate.cpp
Normal file
@@ -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;
|
||||
}
|
39
src/DisplayApp/Screens/FirmwareUpdate.h
Normal file
39
src/DisplayApp/Screens/FirmwareUpdate.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <chrono>
|
||||
#include <Components/Gfx/Gfx.h>
|
||||
#include "Screen.h"
|
||||
#include <bits/unique_ptr.h>
|
||||
#include <libs/lvgl/src/lv_core/lv_style.h>
|
||||
#include <libs/lvgl/src/lv_core/lv_obj.h>
|
||||
#include <Components/Battery/BatteryController.h>
|
||||
#include <Components/Ble/BleController.h>
|
||||
#include "../Fonts/lcdfont14.h"
|
||||
#include "../Fonts/lcdfont70.h"
|
||||
#include "../../Version.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Applications {
|
||||
namespace Screens {
|
||||
|
||||
class FirmwareUpdate : public Screen{
|
||||
public:
|
||||
FirmwareUpdate(DisplayApp* app, Pinetime::Controllers::Ble& bleController);
|
||||
~FirmwareUpdate() override;
|
||||
|
||||
bool Refresh() override;
|
||||
bool OnButtonPushed() override;
|
||||
|
||||
private:
|
||||
Pinetime::Controllers::Ble& bleController;
|
||||
lv_obj_t * bar1;
|
||||
lv_obj_t * percentLabel;
|
||||
lv_obj_t * titleLabel;
|
||||
char percentStr[10];
|
||||
bool running = true;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user