Add new screen that is displayed during the OTA transfert.
This commit is contained in:
parent
87c6556ad0
commit
e20fdfa494
|
@ -305,6 +305,7 @@ list(APPEND SOURCE_FILES
|
||||||
DisplayApp/Screens/Brightness.cpp
|
DisplayApp/Screens/Brightness.cpp
|
||||||
DisplayApp/Screens/ScreenList.cpp
|
DisplayApp/Screens/ScreenList.cpp
|
||||||
DisplayApp/Screens/Label.cpp
|
DisplayApp/Screens/Label.cpp
|
||||||
|
DisplayApp/Screens/FirmwareUpdate.cpp
|
||||||
main.cpp
|
main.cpp
|
||||||
drivers/St7789.cpp
|
drivers/St7789.cpp
|
||||||
drivers/SpiMaster.cpp
|
drivers/SpiMaster.cpp
|
||||||
|
@ -354,6 +355,7 @@ set(INCLUDE_FILES
|
||||||
DisplayApp/Screens/Brightness.h
|
DisplayApp/Screens/Brightness.h
|
||||||
DisplayApp/Screens/ScreenList.h
|
DisplayApp/Screens/ScreenList.h
|
||||||
DisplayApp/Screens/Label.h
|
DisplayApp/Screens/Label.h
|
||||||
|
DisplayApp/Screens/FirmwareUpdate.h
|
||||||
drivers/St7789.h
|
drivers/St7789.h
|
||||||
drivers/SpiMaster.h
|
drivers/SpiMaster.h
|
||||||
drivers/Watchdog.h
|
drivers/Watchdog.h
|
||||||
|
|
|
@ -12,4 +12,20 @@ void Ble::Disconnect() {
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ble::StartFirmwareUpdate() {
|
||||||
|
isFirmwareUpdating = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ble::StopFirmwareUpdate() {
|
||||||
|
isFirmwareUpdating = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ble::FirmwareUpdateTotalBytes(uint32_t totalBytes) {
|
||||||
|
firmwareUpdateTotalBytes = totalBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ble::FirmwareUpdateCurrentBytes(uint32_t currentBytes) {
|
||||||
|
firmwareUpdateCurrentBytes = currentBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,20 @@ namespace Pinetime {
|
||||||
bool IsConnected() const {return isConnected;}
|
bool IsConnected() const {return isConnected;}
|
||||||
void Connect();
|
void Connect();
|
||||||
void Disconnect();
|
void Disconnect();
|
||||||
|
|
||||||
|
void StartFirmwareUpdate();
|
||||||
|
void StopFirmwareUpdate();
|
||||||
|
void FirmwareUpdateTotalBytes(uint32_t totalBytes);
|
||||||
|
void FirmwareUpdateCurrentBytes(uint32_t currentBytes);
|
||||||
|
|
||||||
|
bool IsFirmwareUpdating() const { return isFirmwareUpdating; }
|
||||||
|
uint32_t FirmwareUpdateTotalBytes() const { return firmwareUpdateTotalBytes; }
|
||||||
|
uint32_t FirmwareUpdateCurrentBytes() const { return firmwareUpdateCurrentBytes; }
|
||||||
private:
|
private:
|
||||||
bool isConnected = false;
|
bool isConnected = false;
|
||||||
|
bool isFirmwareUpdating = false;
|
||||||
|
uint32_t firmwareUpdateTotalBytes = 0;
|
||||||
|
uint32_t firmwareUpdateCurrentBytes = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include <Components/Ble/BleController.h>
|
||||||
|
#include <SystemTask/SystemTask.h>
|
||||||
#include "DfuService.h"
|
#include "DfuService.h"
|
||||||
|
|
||||||
using namespace Pinetime::Controllers;
|
using namespace Pinetime::Controllers;
|
||||||
|
@ -13,7 +15,9 @@ int DfuServiceCallback(uint16_t conn_handle, uint16_t attr_handle,
|
||||||
return dfuService->OnServiceData(conn_handle, attr_handle, ctxt);
|
return dfuService->OnServiceData(conn_handle, attr_handle, ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
DfuService::DfuService() :
|
DfuService::DfuService(Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::Ble& bleController) :
|
||||||
|
systemTask{systemTask},
|
||||||
|
bleController{bleController},
|
||||||
characteristicDefinition{
|
characteristicDefinition{
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t *) &packetCharacteristicUuid,
|
.uuid = (ble_uuid_t *) &packetCharacteristicUuid,
|
||||||
|
@ -102,6 +106,7 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf *om) {
|
||||||
case States::Data: {
|
case States::Data: {
|
||||||
nbPacketReceived++;
|
nbPacketReceived++;
|
||||||
bytesReceived += om->om_len;
|
bytesReceived += om->om_len;
|
||||||
|
bleController.FirmwareUpdateCurrentBytes(bytesReceived);
|
||||||
NRF_LOG_INFO("[DFU] -> Bytes received : %d in %d packets", bytesReceived, nbPacketReceived);
|
NRF_LOG_INFO("[DFU] -> Bytes received : %d in %d packets", bytesReceived, nbPacketReceived);
|
||||||
|
|
||||||
if((nbPacketReceived % nbPacketsToNotify) == 0) {
|
if((nbPacketReceived % nbPacketsToNotify) == 0) {
|
||||||
|
@ -139,6 +144,10 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf *om) {
|
||||||
if(imageType == ImageTypes::Application) {
|
if(imageType == ImageTypes::Application) {
|
||||||
NRF_LOG_INFO("[DFU] -> Start DFU, mode = Application");
|
NRF_LOG_INFO("[DFU] -> Start DFU, mode = Application");
|
||||||
state = States::Start;
|
state = States::Start;
|
||||||
|
bleController.StartFirmwareUpdate();
|
||||||
|
bleController.FirmwareUpdateTotalBytes(175280);
|
||||||
|
bleController.FirmwareUpdateCurrentBytes(0);
|
||||||
|
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleFirmwareUpdateStarted);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
NRF_LOG_INFO("[DFU] -> Start DFU, mode %d not supported!", imageType);
|
NRF_LOG_INFO("[DFU] -> Start DFU, mode %d not supported!", imageType);
|
||||||
|
@ -194,6 +203,8 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf *om) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
NRF_LOG_INFO("[DFU] -> Activate image and reset!");
|
NRF_LOG_INFO("[DFU] -> Activate image and reset!");
|
||||||
|
bleController.StopFirmwareUpdate();
|
||||||
|
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleFirmwareUpdateFinished);
|
||||||
return 0;
|
return 0;
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,14 +5,21 @@
|
||||||
#include <host/ble_gap.h>
|
#include <host/ble_gap.h>
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
|
namespace System {
|
||||||
|
class SystemTask;
|
||||||
|
}
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
|
class Ble;
|
||||||
class DfuService {
|
class DfuService {
|
||||||
public:
|
public:
|
||||||
DfuService();
|
DfuService(Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::Ble& bleController);
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
int OnServiceData(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context);
|
int OnServiceData(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context);
|
||||||
private:
|
private:
|
||||||
|
Pinetime::System::SystemTask& systemTask;
|
||||||
|
Pinetime::Controllers::Ble& bleController;
|
||||||
|
|
||||||
static constexpr uint16_t dfuServiceId {0x1530};
|
static constexpr uint16_t dfuServiceId {0x1530};
|
||||||
static constexpr uint16_t packetCharacteristicId {0x1532};
|
static constexpr uint16_t packetCharacteristicId {0x1532};
|
||||||
static constexpr uint16_t controlPointCharacteristicId {0x1531};
|
static constexpr uint16_t controlPointCharacteristicId {0x1531};
|
||||||
|
|
|
@ -29,6 +29,7 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask,
|
||||||
bleController{bleController},
|
bleController{bleController},
|
||||||
dateTimeController{dateTimeController},
|
dateTimeController{dateTimeController},
|
||||||
notificationManager{notificationManager},
|
notificationManager{notificationManager},
|
||||||
|
dfuService{systemTask, bleController},
|
||||||
currentTimeClient{dateTimeController},
|
currentTimeClient{dateTimeController},
|
||||||
alertNotificationClient{systemTask, notificationManager} {
|
alertNotificationClient{systemTask, notificationManager} {
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::Ble& bleController;
|
Pinetime::Controllers::Ble& bleController;
|
||||||
DateTime& dateTimeController;
|
DateTime& dateTimeController;
|
||||||
Pinetime::Controllers::NotificationManager& notificationManager;
|
Pinetime::Controllers::NotificationManager& notificationManager;
|
||||||
DfuService dfuService;
|
Pinetime::Controllers::DfuService dfuService;
|
||||||
|
|
||||||
DeviceInformationService deviceInformationService;
|
DeviceInformationService deviceInformationService;
|
||||||
CurrentTimeClient currentTimeClient;
|
CurrentTimeClient currentTimeClient;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <DisplayApp/Screens/Brightness.h>
|
#include <DisplayApp/Screens/Brightness.h>
|
||||||
#include <DisplayApp/Screens/ScreenList.h>
|
#include <DisplayApp/Screens/ScreenList.h>
|
||||||
#include <Components/Ble/NotificationManager.h>
|
#include <Components/Ble/NotificationManager.h>
|
||||||
|
#include <DisplayApp/Screens/FirmwareUpdate.h>
|
||||||
#include "../SystemTask/SystemTask.h"
|
#include "../SystemTask/SystemTask.h"
|
||||||
|
|
||||||
using namespace Pinetime::Applications;
|
using namespace Pinetime::Applications;
|
||||||
|
@ -157,6 +158,17 @@ void DisplayApp::Refresh() {
|
||||||
// toggle = true;
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace Pinetime {
|
||||||
public:
|
public:
|
||||||
enum class States {Idle, Running};
|
enum class States {Idle, Running};
|
||||||
enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, SwitchScreen,ButtonPushed,
|
enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, SwitchScreen,ButtonPushed,
|
||||||
NewNotification
|
NewNotification, BleFirmwareUpdateStarted, BleFirmwareUpdateFinished
|
||||||
};
|
};
|
||||||
enum class FullRefreshDirections { None, Up, Down };
|
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;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -104,6 +104,12 @@ void SystemTask::Work() {
|
||||||
isBleDiscoveryTimerRunning = true;
|
isBleDiscoveryTimerRunning = true;
|
||||||
bleDiscoveryTimer = 5;
|
bleDiscoveryTimer = 5;
|
||||||
break;
|
break;
|
||||||
|
case Messages::BleFirmwareUpdateStarted:
|
||||||
|
displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::BleFirmwareUpdateStarted);
|
||||||
|
break;
|
||||||
|
case Messages::BleFirmwareUpdateFinished:
|
||||||
|
displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::BleFirmwareUpdateFinished);
|
||||||
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@ namespace Pinetime {
|
||||||
namespace System {
|
namespace System {
|
||||||
class SystemTask {
|
class SystemTask {
|
||||||
public:
|
public:
|
||||||
enum class Messages {GoToSleep, GoToRunning, OnNewTime, OnNewNotification, BleConnected
|
enum class Messages {GoToSleep, GoToRunning, OnNewTime, OnNewNotification, BleConnected,
|
||||||
|
BleFirmwareUpdateStarted, BleFirmwareUpdateFinished
|
||||||
};
|
};
|
||||||
|
|
||||||
SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd, Drivers::Cst816S &touchPanel,
|
SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd, Drivers::Cst816S &touchPanel,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user