Merge branch 'JF002:develop' into improve-battery-percentage-to-battery-icon-mapping
This commit is contained in:
@@ -21,6 +21,7 @@ namespace Pinetime {
|
||||
HeartRate,
|
||||
Navigation,
|
||||
StopWatch,
|
||||
Metronome,
|
||||
Motion,
|
||||
Steps,
|
||||
QuickSettings,
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include "displayapp/screens/Paddle.h"
|
||||
#include "displayapp/screens/StopWatch.h"
|
||||
#include "displayapp/screens/Meter.h"
|
||||
#include "displayapp/screens/Metronome.h"
|
||||
#include "displayapp/screens/Music.h"
|
||||
#include "displayapp/screens/Navigation.h"
|
||||
#include "displayapp/screens/Notifications.h"
|
||||
@@ -32,6 +33,7 @@
|
||||
#include "drivers/St7789.h"
|
||||
#include "drivers/Watchdog.h"
|
||||
#include "systemtask/SystemTask.h"
|
||||
#include "systemtask/Messages.h"
|
||||
|
||||
#include "displayapp/screens/settings/QuickSettings.h"
|
||||
#include "displayapp/screens/settings/Settings.h"
|
||||
@@ -44,6 +46,12 @@
|
||||
using namespace Pinetime::Applications;
|
||||
using namespace Pinetime::Applications::Display;
|
||||
|
||||
namespace {
|
||||
static inline bool in_isr(void) {
|
||||
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||
Components::LittleVgl& lvgl,
|
||||
Drivers::Cst816S& touchPanel,
|
||||
@@ -51,7 +59,6 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||
Controllers::Ble& bleController,
|
||||
Controllers::DateTime& dateTimeController,
|
||||
Drivers::WatchdogView& watchdog,
|
||||
System::SystemTask& systemTask,
|
||||
Pinetime::Controllers::NotificationManager& notificationManager,
|
||||
Pinetime::Controllers::HeartRateController& heartRateController,
|
||||
Controllers::Settings& settingsController,
|
||||
@@ -65,19 +72,20 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||
bleController {bleController},
|
||||
dateTimeController {dateTimeController},
|
||||
watchdog {watchdog},
|
||||
systemTask {systemTask},
|
||||
notificationManager {notificationManager},
|
||||
heartRateController {heartRateController},
|
||||
settingsController {settingsController},
|
||||
motorController {motorController},
|
||||
motionController {motionController},
|
||||
timerController {timerController} {
|
||||
msgQueue = xQueueCreate(queueSize, itemSize);
|
||||
// Start clock when smartwatch boots
|
||||
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None);
|
||||
}
|
||||
|
||||
void DisplayApp::Start() {
|
||||
msgQueue = xQueueCreate(queueSize, itemSize);
|
||||
|
||||
// Start clock when smartwatch boots
|
||||
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None);
|
||||
|
||||
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) {
|
||||
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
||||
}
|
||||
@@ -130,7 +138,7 @@ void DisplayApp::Refresh() {
|
||||
vTaskDelay(100);
|
||||
}
|
||||
lcd.DisplayOff();
|
||||
systemTask.PushMessage(System::SystemTask::Messages::OnDisplayTaskSleeping);
|
||||
PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping);
|
||||
state = States::Idle;
|
||||
break;
|
||||
case Messages::GoToRunning:
|
||||
@@ -139,7 +147,7 @@ void DisplayApp::Refresh() {
|
||||
state = States::Running;
|
||||
break;
|
||||
case Messages::UpdateTimeOut:
|
||||
systemTask.PushMessage(System::SystemTask::Messages::UpdateTimeOut);
|
||||
PushMessageToSystemTask(System::Messages::UpdateTimeOut);
|
||||
break;
|
||||
case Messages::UpdateBleConnection:
|
||||
// clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected :
|
||||
@@ -176,7 +184,7 @@ void DisplayApp::Refresh() {
|
||||
LoadApp(Apps::QuickSettings, DisplayApp::FullRefreshDirections::RightAnim);
|
||||
break;
|
||||
case TouchEvents::DoubleTap:
|
||||
systemTask.PushMessage(System::SystemTask::Messages::GoToSleep);
|
||||
PushMessageToSystemTask(System::Messages::GoToSleep);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -188,7 +196,7 @@ void DisplayApp::Refresh() {
|
||||
} break;
|
||||
case Messages::ButtonPushed:
|
||||
if (currentApp == Apps::Clock) {
|
||||
systemTask.PushMessage(System::SystemTask::Messages::GoToSleep);
|
||||
PushMessageToSystemTask(System::Messages::GoToSleep);
|
||||
} else {
|
||||
if (!currentScreen->OnButtonPushed()) {
|
||||
LoadApp(returnToApp, returnDirection);
|
||||
@@ -206,6 +214,11 @@ void DisplayApp::Refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
if(nextApp != Apps::None) {
|
||||
LoadApp(nextApp, nextDirection);
|
||||
nextApp = Apps::None;
|
||||
}
|
||||
|
||||
if (state != States::Idle && touchMode == TouchModes::Polling) {
|
||||
auto info = touchPanel.GetTouchInfo();
|
||||
if (info.action == 2) { // 2 = contact
|
||||
@@ -224,7 +237,8 @@ void DisplayApp::RunningState() {
|
||||
}
|
||||
|
||||
void DisplayApp::StartApp(Apps app, DisplayApp::FullRefreshDirections direction) {
|
||||
LoadApp(app, direction);
|
||||
nextApp = app;
|
||||
nextDirection = direction;
|
||||
}
|
||||
|
||||
void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent) {
|
||||
@@ -267,12 +281,12 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||
|
||||
case Apps::Notifications:
|
||||
currentScreen = std::make_unique<Screens::Notifications>(
|
||||
this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Normal);
|
||||
this, notificationManager, systemTask->nimble().alertService(), Screens::Notifications::Modes::Normal);
|
||||
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
|
||||
break;
|
||||
case Apps::NotificationsPreview:
|
||||
currentScreen = std::make_unique<Screens::Notifications>(
|
||||
this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Preview);
|
||||
this, notificationManager, systemTask->nimble().alertService(), Screens::Notifications::Modes::Preview);
|
||||
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
|
||||
break;
|
||||
case Apps::Timer:
|
||||
@@ -305,7 +319,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||
currentScreen = std::make_unique<Screens::SettingDisplay>(this, settingsController);
|
||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||
break;
|
||||
case Apps::SettingSteps:
|
||||
case Apps::SettingSteps:
|
||||
currentScreen = std::make_unique<Screens::SettingSteps>(this, settingsController);
|
||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||
break;
|
||||
@@ -318,10 +332,8 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||
std::make_unique<Screens::SystemInfo>(this, dateTimeController, batteryController, brightnessController, bleController, watchdog);
|
||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||
break;
|
||||
//
|
||||
|
||||
case Apps::FlashLight:
|
||||
currentScreen = std::make_unique<Screens::FlashLight>(this, systemTask, brightnessController);
|
||||
currentScreen = std::make_unique<Screens::FlashLight>(this, *systemTask, brightnessController);
|
||||
ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None);
|
||||
break;
|
||||
case Apps::StopWatch:
|
||||
@@ -337,18 +349,21 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||
currentScreen = std::make_unique<Screens::Paddle>(this, lvgl);
|
||||
break;
|
||||
case Apps::Music:
|
||||
currentScreen = std::make_unique<Screens::Music>(this, systemTask.nimble().music());
|
||||
currentScreen = std::make_unique<Screens::Music>(this, systemTask->nimble().music());
|
||||
break;
|
||||
case Apps::Navigation:
|
||||
currentScreen = std::make_unique<Screens::Navigation>(this, systemTask.nimble().navigation());
|
||||
currentScreen = std::make_unique<Screens::Navigation>(this, systemTask->nimble().navigation());
|
||||
break;
|
||||
case Apps::HeartRate:
|
||||
currentScreen = std::make_unique<Screens::HeartRate>(this, heartRateController, systemTask);
|
||||
currentScreen = std::make_unique<Screens::HeartRate>(this, heartRateController, *systemTask);
|
||||
break;
|
||||
case Apps::Metronome:
|
||||
currentScreen = std::make_unique<Screens::Metronome>(this, motorController, *systemTask);
|
||||
break;
|
||||
case Apps::Motion:
|
||||
currentScreen = std::make_unique<Screens::Motion>(this, motionController);
|
||||
break;
|
||||
case Apps::Steps:
|
||||
case Apps::Steps:
|
||||
currentScreen = std::make_unique<Screens::Steps>(this, motionController, settingsController);
|
||||
break;
|
||||
}
|
||||
@@ -359,12 +374,15 @@ void DisplayApp::IdleState() {
|
||||
}
|
||||
|
||||
void DisplayApp::PushMessage(Messages msg) {
|
||||
BaseType_t xHigherPriorityTaskWoken;
|
||||
xHigherPriorityTaskWoken = pdFALSE;
|
||||
xQueueSendFromISR(msgQueue, &msg, &xHigherPriorityTaskWoken);
|
||||
if (xHigherPriorityTaskWoken) {
|
||||
/* Actual macro used here is port specific. */
|
||||
// TODO : should I do something here?
|
||||
if(in_isr()) {
|
||||
BaseType_t xHigherPriorityTaskWoken;
|
||||
xHigherPriorityTaskWoken = pdFALSE;
|
||||
xQueueSendFromISR(msgQueue, &msg, &xHigherPriorityTaskWoken);
|
||||
if (xHigherPriorityTaskWoken) {
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
} else {
|
||||
xQueueSend(msgQueue, &msg, portMAX_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,3 +443,12 @@ void DisplayApp::SetFullRefresh(DisplayApp::FullRefreshDirections direction) {
|
||||
void DisplayApp::SetTouchMode(DisplayApp::TouchModes mode) {
|
||||
touchMode = mode;
|
||||
}
|
||||
|
||||
void DisplayApp::PushMessageToSystemTask(Pinetime::System::Messages message) {
|
||||
if(systemTask != nullptr)
|
||||
systemTask->PushMessage(message);
|
||||
}
|
||||
|
||||
void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) {
|
||||
this->systemTask = systemTask;
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#include <queue.h>
|
||||
#include <task.h>
|
||||
#include <memory>
|
||||
#include <systemtask/Messages.h>
|
||||
#include "Apps.h"
|
||||
#include "LittleVgl.h"
|
||||
#include "TouchEvents.h"
|
||||
@@ -49,7 +50,6 @@ namespace Pinetime {
|
||||
Controllers::Ble& bleController,
|
||||
Controllers::DateTime& dateTimeController,
|
||||
Drivers::WatchdogView& watchdog,
|
||||
System::SystemTask& systemTask,
|
||||
Pinetime::Controllers::NotificationManager& notificationManager,
|
||||
Pinetime::Controllers::HeartRateController& heartRateController,
|
||||
Controllers::Settings& settingsController,
|
||||
@@ -64,6 +64,8 @@ namespace Pinetime {
|
||||
void SetFullRefresh(FullRefreshDirections direction);
|
||||
void SetTouchMode(TouchModes mode);
|
||||
|
||||
void Register(Pinetime::System::SystemTask* systemTask);
|
||||
|
||||
private:
|
||||
Pinetime::Drivers::St7789& lcd;
|
||||
Pinetime::Components::LittleVgl& lvgl;
|
||||
@@ -72,7 +74,7 @@ namespace Pinetime {
|
||||
Pinetime::Controllers::Ble& bleController;
|
||||
Pinetime::Controllers::DateTime& dateTimeController;
|
||||
Pinetime::Drivers::WatchdogView& watchdog;
|
||||
Pinetime::System::SystemTask& systemTask;
|
||||
Pinetime::System::SystemTask* systemTask = nullptr;
|
||||
Pinetime::Controllers::NotificationManager& notificationManager;
|
||||
Pinetime::Controllers::HeartRateController& heartRateController;
|
||||
Pinetime::Controllers::Settings& settingsController;
|
||||
@@ -108,6 +110,10 @@ namespace Pinetime {
|
||||
void Refresh();
|
||||
void ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent);
|
||||
void LoadApp(Apps app, DisplayApp::FullRefreshDirections direction);
|
||||
void PushMessageToSystemTask(Pinetime::System::Messages message);
|
||||
|
||||
Apps nextApp = Apps::None;
|
||||
DisplayApp::FullRefreshDirections nextDirection;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -14,7 +14,6 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||
Controllers::Ble& bleController,
|
||||
Controllers::DateTime& dateTimeController,
|
||||
Drivers::WatchdogView& watchdog,
|
||||
System::SystemTask& systemTask,
|
||||
Pinetime::Controllers::NotificationManager& notificationManager,
|
||||
Pinetime::Controllers::HeartRateController& heartRateController,
|
||||
Controllers::Settings& settingsController,
|
||||
@@ -22,10 +21,11 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||
Pinetime::Controllers::MotionController& motionController,
|
||||
Pinetime::Controllers::TimerController& timerController)
|
||||
: lcd {lcd}, bleController {bleController} {
|
||||
msgQueue = xQueueCreate(queueSize, itemSize);
|
||||
|
||||
}
|
||||
|
||||
void DisplayApp::Start() {
|
||||
msgQueue = xQueueCreate(queueSize, itemSize);
|
||||
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 512, this, 0, &taskHandle))
|
||||
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
||||
}
|
||||
@@ -113,4 +113,8 @@ void DisplayApp::PushMessage(Display::Messages msg) {
|
||||
/* Actual macro used here is port specific. */
|
||||
// TODO : should I do something here?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) {
|
||||
|
||||
}
|
||||
|
@@ -39,7 +39,6 @@ namespace Pinetime {
|
||||
Controllers::Ble& bleController,
|
||||
Controllers::DateTime& dateTimeController,
|
||||
Drivers::WatchdogView& watchdog,
|
||||
System::SystemTask& systemTask,
|
||||
Pinetime::Controllers::NotificationManager& notificationManager,
|
||||
Pinetime::Controllers::HeartRateController& heartRateController,
|
||||
Controllers::Settings& settingsController,
|
||||
@@ -48,6 +47,7 @@ namespace Pinetime {
|
||||
Pinetime::Controllers::TimerController& timerController);
|
||||
void Start();
|
||||
void PushMessage(Pinetime::Applications::Display::Messages msg);
|
||||
void Register(Pinetime::System::SystemTask* systemTask);
|
||||
|
||||
private:
|
||||
TaskHandle_t taskHandle;
|
||||
|
@@ -19,6 +19,10 @@ namespace Pinetime {
|
||||
LittleVgl(LittleVgl&&) = delete;
|
||||
LittleVgl& operator=(LittleVgl&&) = delete;
|
||||
|
||||
void Init() {
|
||||
|
||||
}
|
||||
|
||||
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p) {
|
||||
}
|
||||
bool GetTouchPadInfo(lv_indev_data_t* ptr) {
|
||||
|
@@ -23,6 +23,10 @@ bool touchpad_read(lv_indev_drv_t* indev_drv, lv_indev_data_t* data) {
|
||||
|
||||
LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel)
|
||||
: lcd {lcd}, touchPanel {touchPanel}, previousClick {0, 0} {
|
||||
|
||||
}
|
||||
|
||||
void LittleVgl::Init() {
|
||||
lv_init();
|
||||
InitTheme();
|
||||
InitDisplay();
|
||||
|
@@ -19,6 +19,8 @@ namespace Pinetime {
|
||||
LittleVgl(LittleVgl&&) = delete;
|
||||
LittleVgl& operator=(LittleVgl&&) = delete;
|
||||
|
||||
void Init();
|
||||
|
||||
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p);
|
||||
bool GetTouchPadInfo(lv_indev_data_t* ptr);
|
||||
void SetFullRefresh(FullRefreshDirections direction);
|
||||
|
@@ -48,6 +48,7 @@ static lv_style_t style_sw_bg;
|
||||
static lv_style_t style_sw_indic;
|
||||
static lv_style_t style_sw_knob;
|
||||
static lv_style_t style_arc_bg;
|
||||
static lv_style_t style_arc_knob;
|
||||
static lv_style_t style_arc_indic;
|
||||
static lv_style_t style_table_cell;
|
||||
static lv_style_t style_pad_small;
|
||||
@@ -191,6 +192,7 @@ static void basic_init(void) {
|
||||
lv_style_set_text_line_space(&style_ddlist_list, LV_STATE_DEFAULT, LV_VER_RES / 25);
|
||||
lv_style_set_shadow_width(&style_ddlist_list, LV_STATE_DEFAULT, LV_VER_RES / 20);
|
||||
lv_style_set_shadow_color(&style_ddlist_list, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
|
||||
lv_style_set_bg_color(&style_ddlist_list, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
|
||||
|
||||
style_init_reset(&style_ddlist_selected);
|
||||
lv_style_set_bg_opa(&style_ddlist_selected, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
@@ -239,6 +241,13 @@ static void basic_init(void) {
|
||||
lv_style_set_line_color(&style_arc_bg, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
|
||||
lv_style_set_line_width(&style_arc_bg, LV_STATE_DEFAULT, LV_DPX(25));
|
||||
lv_style_set_line_rounded(&style_arc_bg, LV_STATE_DEFAULT, true);
|
||||
lv_style_set_pad_all(&style_arc_bg, LV_STATE_DEFAULT, LV_DPX(5));
|
||||
|
||||
lv_style_reset(&style_arc_knob);
|
||||
lv_style_set_radius(&style_arc_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
||||
lv_style_set_bg_opa(&style_arc_knob, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&style_arc_knob, LV_STATE_DEFAULT, LV_PINETIME_LIGHT_GRAY);
|
||||
lv_style_set_pad_all(&style_arc_knob, LV_STATE_DEFAULT, LV_DPX(5));
|
||||
|
||||
style_init_reset(&style_table_cell);
|
||||
lv_style_set_border_color(&style_table_cell, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
|
||||
@@ -447,6 +456,10 @@ static void theme_apply(lv_obj_t* obj, lv_theme_style_t name) {
|
||||
lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &style_arc_indic);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_ARC_PART_KNOB);
|
||||
list = lv_obj_get_style_list(obj, LV_ARC_PART_KNOB);
|
||||
_lv_style_list_add_style(list, &style_arc_knob);
|
||||
break;
|
||||
|
||||
case LV_THEME_SWITCH:
|
||||
|
@@ -63,7 +63,7 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen2() {
|
||||
{Symbols::paddle, Apps::Paddle},
|
||||
{"2", Apps::Twos},
|
||||
{"M", Apps::Motion},
|
||||
{"", Apps::None},
|
||||
{"b", Apps::Metronome},
|
||||
{"", Apps::None},
|
||||
}};
|
||||
|
||||
|
@@ -33,21 +33,17 @@ Clock::Clock(DisplayApp* app,
|
||||
settingsController {settingsController},
|
||||
heartRateController {heartRateController},
|
||||
motionController {motionController},
|
||||
screens {app,
|
||||
settingsController.GetClockFace(),
|
||||
{
|
||||
[this]() -> std::unique_ptr<Screen> {
|
||||
return WatchFaceDigitalScreen();
|
||||
},
|
||||
[this]() -> std::unique_ptr<Screen> {
|
||||
return WatchFaceAnalogScreen();
|
||||
},
|
||||
// Examples for more watch faces
|
||||
//[this]() -> std::unique_ptr<Screen> { return WatchFaceMinimalScreen(); },
|
||||
//[this]() -> std::unique_ptr<Screen> { return WatchFaceCustomScreen(); }
|
||||
},
|
||||
Screens::ScreenListModes::LongPress} {
|
||||
|
||||
screen {[this, &settingsController]() {
|
||||
switch (settingsController.GetClockFace()) {
|
||||
case 0:
|
||||
return WatchFaceDigitalScreen();
|
||||
break;
|
||||
case 1:
|
||||
return WatchFaceAnalogScreen();
|
||||
break;
|
||||
}
|
||||
return WatchFaceDigitalScreen();
|
||||
}()} {
|
||||
settingsController.SetAppMenu(0);
|
||||
}
|
||||
|
||||
@@ -56,12 +52,12 @@ Clock::~Clock() {
|
||||
}
|
||||
|
||||
bool Clock::Refresh() {
|
||||
screens.Refresh();
|
||||
screen->Refresh();
|
||||
return running;
|
||||
}
|
||||
|
||||
bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
return screens.OnTouchEvent(event);
|
||||
return screen->OnTouchEvent(event);
|
||||
}
|
||||
|
||||
std::unique_ptr<Screen> Clock::WatchFaceDigitalScreen() {
|
||||
|
@@ -4,8 +4,8 @@
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <components/heartrate/HeartRateController.h>
|
||||
#include "Screen.h"
|
||||
#include "ScreenList.h"
|
||||
#include "components/datetime/DateTimeController.h"
|
||||
|
||||
namespace Pinetime {
|
||||
@@ -47,7 +47,7 @@ namespace Pinetime {
|
||||
Controllers::HeartRateController& heartRateController;
|
||||
Controllers::MotionController& motionController;
|
||||
|
||||
ScreenList<2> screens;
|
||||
std::unique_ptr<Screen> screen;
|
||||
std::unique_ptr<Screen> WatchFaceDigitalScreen();
|
||||
std::unique_ptr<Screen> WatchFaceAnalogScreen();
|
||||
|
||||
|
@@ -39,14 +39,14 @@ FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
|
||||
backgroundAction->user_data = this;
|
||||
lv_obj_set_event_cb(backgroundAction, event_handler);
|
||||
|
||||
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::DisableSleeping);
|
||||
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
|
||||
}
|
||||
|
||||
FlashLight::~FlashLight() {
|
||||
lv_obj_clean(lv_scr_act());
|
||||
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||
brightness.Restore();
|
||||
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::EnableSleeping);
|
||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||
}
|
||||
|
||||
void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) {
|
||||
|
@@ -63,12 +63,12 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
|
||||
label_startStop = lv_label_create(btn_startStop, nullptr);
|
||||
UpdateStartStopButton(isHrRunning);
|
||||
if (isHrRunning)
|
||||
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::DisableSleeping);
|
||||
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
|
||||
}
|
||||
|
||||
HeartRate::~HeartRate() {
|
||||
lv_obj_clean(lv_scr_act());
|
||||
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::EnableSleeping);
|
||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||
}
|
||||
|
||||
bool HeartRate::Refresh() {
|
||||
@@ -95,12 +95,12 @@ void HeartRate::OnStartStopEvent(lv_event_t event) {
|
||||
if (heartRateController.State() == Controllers::HeartRateController::States::Stopped) {
|
||||
heartRateController.Start();
|
||||
UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped);
|
||||
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::DisableSleeping);
|
||||
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
|
||||
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
|
||||
} else {
|
||||
heartRateController.Stop();
|
||||
UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped);
|
||||
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::EnableSleeping);
|
||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
|
||||
}
|
||||
}
|
||||
|
169
src/displayapp/screens/Metronome.cpp
Normal file
169
src/displayapp/screens/Metronome.cpp
Normal file
@@ -0,0 +1,169 @@
|
||||
#include "Metronome.h"
|
||||
|
||||
#include "Screen.h"
|
||||
#include "Symbols.h"
|
||||
#include "lvgl/lvgl.h"
|
||||
#include "FreeRTOSConfig.h"
|
||||
#include "task.h"
|
||||
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
namespace {
|
||||
float calculateDelta(const TickType_t startTime, const TickType_t currentTime) {
|
||||
TickType_t delta = 0;
|
||||
// Take care of overflow
|
||||
if (startTime > currentTime) {
|
||||
delta = 0xffffffff - startTime;
|
||||
delta += (currentTime + 1);
|
||||
} else {
|
||||
delta = currentTime - startTime;
|
||||
}
|
||||
return static_cast<float>(delta) / static_cast<float>(configTICK_RATE_HZ);
|
||||
}
|
||||
|
||||
static void eventHandler(lv_obj_t* obj, lv_event_t event) {
|
||||
Metronome* screen = static_cast<Metronome*>(obj->user_data);
|
||||
screen->OnEvent(obj, event);
|
||||
}
|
||||
|
||||
lv_obj_t* createLabel(const char* name, lv_obj_t* reference, lv_align_t align, lv_font_t* font, uint8_t x = 0, uint8_t y = 0) {
|
||||
lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_font(label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font);
|
||||
lv_obj_set_style_local_text_color(label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
|
||||
lv_label_set_text(label, name);
|
||||
lv_obj_align(label, reference, align, x, y);
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask)
|
||||
: Screen(app), running {true}, currentState {States::Stopped}, startTime {}, motorController {motorController}, systemTask {systemTask} {
|
||||
|
||||
bpmArc = lv_arc_create(lv_scr_act(), nullptr);
|
||||
bpmArc->user_data = this;
|
||||
lv_obj_set_event_cb(bpmArc, eventHandler);
|
||||
lv_arc_set_bg_angles(bpmArc, 0, 270);
|
||||
lv_arc_set_rotation(bpmArc, 135);
|
||||
lv_arc_set_range(bpmArc, 40, 220);
|
||||
lv_arc_set_value(bpmArc, bpm);
|
||||
lv_obj_set_size(bpmArc, 210, 210);
|
||||
lv_arc_set_adjustable(bpmArc, true);
|
||||
lv_obj_align(bpmArc, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 7);
|
||||
|
||||
bpmValue = createLabel(std::to_string(lv_arc_get_value(bpmArc)).c_str(), bpmArc, LV_ALIGN_IN_TOP_MID, &jetbrains_mono_76, 0, 55);
|
||||
bpmLegend = createLabel("bpm", bpmValue, LV_ALIGN_OUT_BOTTOM_MID, &jetbrains_mono_bold_20, 0, 0);
|
||||
|
||||
bpmTap = lv_btn_create(lv_scr_act(), nullptr);
|
||||
bpmTap->user_data = this;
|
||||
lv_obj_set_event_cb(bpmTap, eventHandler);
|
||||
lv_obj_set_style_local_bg_opa(bpmTap, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
lv_obj_set_height(bpmTap, 80);
|
||||
lv_obj_align(bpmTap, bpmValue, LV_ALIGN_IN_TOP_MID, 0, 0);
|
||||
|
||||
bpbDropdown = lv_dropdown_create(lv_scr_act(), nullptr);
|
||||
bpbDropdown->user_data = this;
|
||||
lv_obj_set_event_cb(bpbDropdown, eventHandler);
|
||||
lv_obj_set_style_local_pad_left(bpbDropdown, LV_DROPDOWN_PART_MAIN, LV_STATE_DEFAULT, 20);
|
||||
lv_obj_set_style_local_pad_left(bpbDropdown, LV_DROPDOWN_PART_LIST, LV_STATE_DEFAULT, 20);
|
||||
lv_obj_align(bpbDropdown, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 15, -4);
|
||||
lv_dropdown_set_options(bpbDropdown, "1\n2\n3\n4\n5\n6\n7\n8\n9");
|
||||
lv_dropdown_set_selected(bpbDropdown, bpb - 1);
|
||||
bpbLegend = lv_label_create(bpbDropdown, nullptr);
|
||||
lv_label_set_text(bpbLegend, "bpb");
|
||||
lv_obj_align(bpbLegend, bpbDropdown, LV_ALIGN_IN_RIGHT_MID, -15, 0);
|
||||
|
||||
playPause = lv_btn_create(lv_scr_act(), nullptr);
|
||||
playPause->user_data = this;
|
||||
lv_obj_set_event_cb(playPause, eventHandler);
|
||||
lv_obj_align(playPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -15, -10);
|
||||
lv_obj_set_height(playPause, 39);
|
||||
playPauseLabel = lv_label_create(playPause, nullptr);
|
||||
lv_label_set_text(playPauseLabel, Symbols::play);
|
||||
|
||||
app->SetTouchMode(DisplayApp::TouchModes::Polling);
|
||||
}
|
||||
|
||||
Metronome::~Metronome() {
|
||||
app->SetTouchMode(DisplayApp::TouchModes::Gestures);
|
||||
systemTask.PushMessage(System::Messages::EnableSleeping);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool Metronome::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Metronome::Refresh() {
|
||||
switch (currentState) {
|
||||
case States::Stopped: {
|
||||
break;
|
||||
}
|
||||
case States::Running: {
|
||||
if (calculateDelta(startTime, xTaskGetTickCount()) >= (60.0 / bpm)) {
|
||||
counter--;
|
||||
startTime -= 60.0 / bpm;
|
||||
startTime = xTaskGetTickCount();
|
||||
if (counter == 0) {
|
||||
counter = bpb;
|
||||
motorController.SetDuration(90);
|
||||
} else {
|
||||
motorController.SetDuration(30);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
||||
void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
|
||||
switch (event) {
|
||||
case LV_EVENT_VALUE_CHANGED: {
|
||||
if (obj == bpmArc) {
|
||||
bpm = lv_arc_get_value(bpmArc);
|
||||
lv_label_set_text_fmt(bpmValue, "%03d", bpm);
|
||||
} else if (obj == bpbDropdown) {
|
||||
bpb = lv_dropdown_get_selected(obj) + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LV_EVENT_PRESSED: {
|
||||
if (obj == bpmTap) {
|
||||
float timeDelta = calculateDelta(tappedTime, xTaskGetTickCount());
|
||||
if (tappedTime == 0 || timeDelta > 3) {
|
||||
tappedTime = xTaskGetTickCount();
|
||||
} else {
|
||||
bpm = ceil(60.0 / timeDelta);
|
||||
lv_arc_set_value(bpmArc, bpm);
|
||||
lv_label_set_text_fmt(bpmValue, "%03d", bpm);
|
||||
tappedTime = xTaskGetTickCount();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LV_EVENT_CLICKED: {
|
||||
if (obj == playPause) {
|
||||
currentState = (currentState == States::Stopped ? States::Running : States::Stopped);
|
||||
switch (currentState) {
|
||||
case States::Stopped: {
|
||||
lv_label_set_text(playPauseLabel, Symbols::play);
|
||||
systemTask.PushMessage(System::Messages::EnableSleeping);
|
||||
break;
|
||||
}
|
||||
case States::Running: {
|
||||
lv_label_set_text(playPauseLabel, Symbols::pause);
|
||||
systemTask.PushMessage(System::Messages::DisableSleeping);
|
||||
startTime = xTaskGetTickCount();
|
||||
counter = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
34
src/displayapp/screens/Metronome.h
Normal file
34
src/displayapp/screens/Metronome.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "systemtask/SystemTask.h"
|
||||
#include "components/motor/MotorController.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace Pinetime::Applications::Screens {
|
||||
|
||||
class Metronome : public Screen {
|
||||
public:
|
||||
Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask);
|
||||
~Metronome() override;
|
||||
bool Refresh() override;
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
void OnEvent(lv_obj_t* obj, lv_event_t event);
|
||||
enum class States { Running, Stopped };
|
||||
|
||||
private:
|
||||
bool running;
|
||||
States currentState;
|
||||
TickType_t startTime;
|
||||
TickType_t tappedTime = 0;
|
||||
Controllers::MotorController& motorController;
|
||||
System::SystemTask& systemTask;
|
||||
uint16_t bpm = 120;
|
||||
uint8_t bpb = 4;
|
||||
uint8_t counter = 1;
|
||||
|
||||
lv_obj_t *bpmArc, *bpmTap, *bpmValue, *bpmLegend;
|
||||
lv_obj_t *bpbDropdown, *bpbLegend;
|
||||
lv_obj_t *playPause, *playPauseLabel;
|
||||
};
|
||||
}
|
@@ -15,12 +15,17 @@ namespace Pinetime {
|
||||
public:
|
||||
ScreenList(DisplayApp* app,
|
||||
uint8_t initScreen,
|
||||
std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens,
|
||||
const std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens,
|
||||
ScreenListModes mode)
|
||||
: Screen(app), initScreen {initScreen}, screens {std::move(screens)}, mode {mode}, current {this->screens[initScreen]()} {
|
||||
screenIndex = initScreen;
|
||||
: Screen(app), initScreen {initScreen}, screens {std::move(screens)}, mode {mode}, screenIndex{initScreen}, current {this->screens[initScreen]()} {
|
||||
|
||||
}
|
||||
|
||||
ScreenList(const ScreenList&) = delete;
|
||||
ScreenList& operator=(const ScreenList&) = delete;
|
||||
ScreenList(ScreenList&&) = delete;
|
||||
ScreenList& operator=(ScreenList&&) = delete;
|
||||
|
||||
~ScreenList() override {
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
@@ -97,7 +102,7 @@ namespace Pinetime {
|
||||
|
||||
private:
|
||||
uint8_t initScreen = 0;
|
||||
std::array<std::function<std::unique_ptr<Screen>()>, N> screens;
|
||||
const std::array<std::function<std::unique_ptr<Screen>()>, N> screens;
|
||||
ScreenListModes mode = ScreenListModes::UpDown;
|
||||
|
||||
uint8_t screenIndex = 0;
|
||||
|
@@ -61,22 +61,36 @@ StopWatch::StopWatch(DisplayApp* app)
|
||||
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
|
||||
lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
|
||||
lv_label_set_text(time, "00:00");
|
||||
lv_obj_align(time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -45);
|
||||
lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -45);
|
||||
|
||||
msecTime = lv_label_create(lv_scr_act(), nullptr);
|
||||
// lv_obj_set_style_local_text_font(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20);
|
||||
lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
|
||||
lv_label_set_text(msecTime, "00");
|
||||
lv_obj_align(msecTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 108, 3);
|
||||
lv_obj_align(msecTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 3);
|
||||
|
||||
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnPlayPause->user_data = this;
|
||||
lv_obj_set_event_cb(btnPlayPause, play_pause_event_handler);
|
||||
lv_obj_align(btnPlayPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, -10);
|
||||
lv_obj_set_height(btnPlayPause, 40);
|
||||
lv_obj_set_height(btnPlayPause, 50);
|
||||
lv_obj_set_width(btnPlayPause, 115);
|
||||
lv_obj_align(btnPlayPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
|
||||
txtPlayPause = lv_label_create(btnPlayPause, nullptr);
|
||||
lv_label_set_text(txtPlayPause, Symbols::play);
|
||||
|
||||
btnStopLap = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnStopLap->user_data = this;
|
||||
lv_obj_set_event_cb(btnStopLap, stop_lap_event_handler);
|
||||
lv_obj_set_height(btnStopLap, 50);
|
||||
lv_obj_set_width(btnStopLap, 115);
|
||||
lv_obj_align(btnStopLap, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
||||
lv_obj_set_style_local_bg_color(btnStopLap, LV_BTN_PART_MAIN, LV_STATE_DISABLED, lv_color_hex(0x080808));
|
||||
txtStopLap = lv_label_create(btnStopLap, nullptr);
|
||||
lv_obj_set_style_local_text_color(txtStopLap, LV_BTN_PART_MAIN, LV_STATE_DISABLED, lv_color_hex(0x888888));
|
||||
lv_label_set_text(txtStopLap, Symbols::stop);
|
||||
lv_obj_set_state(btnStopLap, LV_STATE_DISABLED);
|
||||
lv_obj_set_state(txtStopLap, LV_STATE_DISABLED);
|
||||
|
||||
lapOneText = lv_label_create(lv_scr_act(), nullptr);
|
||||
// lv_obj_set_style_local_text_font(lapOneText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20);
|
||||
lv_obj_set_style_local_text_color(lapOneText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
|
||||
@@ -88,9 +102,6 @@ StopWatch::StopWatch(DisplayApp* app)
|
||||
lv_obj_set_style_local_text_color(lapTwoText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
|
||||
lv_obj_align(lapTwoText, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 50, 55);
|
||||
lv_label_set_text(lapTwoText, "");
|
||||
|
||||
// We don't want this button in the init state
|
||||
btnStopLap = nullptr;
|
||||
}
|
||||
|
||||
StopWatch::~StopWatch() {
|
||||
@@ -115,10 +126,6 @@ bool StopWatch::Refresh() {
|
||||
// Init state when an user first opens the app
|
||||
// and when a stop/reset button is pressed
|
||||
case States::Init: {
|
||||
if (btnStopLap != nullptr) {
|
||||
lv_obj_del(btnStopLap);
|
||||
btnStopLap = nullptr;
|
||||
}
|
||||
// The initial default value
|
||||
lv_label_set_text(time, "00:00");
|
||||
lv_label_set_text(msecTime, "00");
|
||||
@@ -129,16 +136,14 @@ bool StopWatch::Refresh() {
|
||||
lapNr = 0;
|
||||
|
||||
if (currentEvent == Events::Play) {
|
||||
btnStopLap = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnStopLap->user_data = this;
|
||||
lv_obj_set_event_cb(btnStopLap, stop_lap_event_handler);
|
||||
lv_obj_align(btnStopLap, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0);
|
||||
lv_obj_set_height(btnStopLap, 40);
|
||||
txtStopLap = lv_label_create(btnStopLap, nullptr);
|
||||
lv_label_set_text(txtStopLap, Symbols::lapsFlag);
|
||||
lv_obj_set_state(btnStopLap, LV_STATE_DEFAULT);
|
||||
lv_obj_set_state(txtStopLap, LV_STATE_DEFAULT);
|
||||
|
||||
startTime = xTaskGetTickCount();
|
||||
currentState = States::Running;
|
||||
} else {
|
||||
lv_obj_set_state(btnStopLap, LV_STATE_DISABLED);
|
||||
lv_obj_set_state(txtStopLap, LV_STATE_DISABLED);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@@ -81,7 +81,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
|
||||
__TIME__);
|
||||
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
|
||||
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||
return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label));
|
||||
return std::make_unique<Screens::Label>(0, 5, app, label);
|
||||
}
|
||||
|
||||
std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
|
||||
@@ -161,7 +161,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
|
||||
brightnessController.ToString(),
|
||||
resetReason);
|
||||
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||
return std::unique_ptr<Screen>(new Screens::Label(1, 4, app, label));
|
||||
return std::make_unique<Screens::Label>(1, 5, app, label);
|
||||
}
|
||||
|
||||
std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
|
||||
@@ -195,10 +195,10 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
|
||||
(int) mon.free_biggest_size,
|
||||
0);
|
||||
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||
return std::unique_ptr<Screen>(new Screens::Label(2, 5, app, label));
|
||||
return std::make_unique<Screens::Label>(2, 5, app, label);
|
||||
}
|
||||
|
||||
bool sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
|
||||
bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
|
||||
return lhs.xTaskNumber < rhs.xTaskNumber;
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
|
||||
lv_table_set_cell_value(infoTask, i + 1, 2, std::to_string(tasksStatus[i].usStackHighWaterMark).c_str());
|
||||
}
|
||||
}
|
||||
return std::unique_ptr<Screen>(new Screens::Label(3, 5, app, infoTask));
|
||||
return std::make_unique<Screens::Label>(3, 5, app, infoTask);
|
||||
}
|
||||
|
||||
std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
|
||||
@@ -245,5 +245,5 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
|
||||
"#FFFF00 JF002/InfiniTime#");
|
||||
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
|
||||
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||
return std::unique_ptr<Screen>(new Screens::Label(4, 5, app, label));
|
||||
return std::make_unique<Screens::Label>(4, 5, app, label);
|
||||
}
|
||||
|
@@ -43,6 +43,9 @@ namespace Pinetime {
|
||||
Pinetime::Drivers::WatchdogView& watchdog;
|
||||
|
||||
ScreenList<5> screens;
|
||||
|
||||
static bool sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs);
|
||||
|
||||
std::unique_ptr<Screen> CreateScreen1();
|
||||
std::unique_ptr<Screen> CreateScreen2();
|
||||
std::unique_ptr<Screen> CreateScreen3();
|
||||
|
@@ -7,12 +7,12 @@ using namespace Pinetime::Applications::Screens;
|
||||
|
||||
namespace {
|
||||
static void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) {
|
||||
QuickSettings* screen = static_cast<QuickSettings*>(obj->user_data);
|
||||
auto* screen = static_cast<QuickSettings*>(obj->user_data);
|
||||
screen->OnButtonEvent(obj, event);
|
||||
}
|
||||
|
||||
static void lv_update_task(struct _lv_task_t* task) {
|
||||
auto user_data = static_cast<QuickSettings*>(task->user_data);
|
||||
auto* user_data = static_cast<QuickSettings*>(task->user_data);
|
||||
user_data->UpdateScreen();
|
||||
}
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ std::unique_ptr<Screen> Settings::CreateScreen1() {
|
||||
{Symbols::clock, "Watch face", Apps::SettingWatchFace},
|
||||
}};
|
||||
|
||||
return std::unique_ptr<Screen>(new Screens::List(0, 2, app, settingsController, applications));
|
||||
return std::make_unique<Screens::List>(0, 2, app, settingsController, applications);
|
||||
}
|
||||
|
||||
std::unique_ptr<Screen> Settings::CreateScreen2() {
|
||||
@@ -58,5 +58,5 @@ std::unique_ptr<Screen> Settings::CreateScreen2() {
|
||||
{Symbols::list, "About", Apps::SysInfo},
|
||||
}};
|
||||
|
||||
return std::unique_ptr<Screen>(new Screens::List(1, 2, app, settingsController, applications));
|
||||
return std::make_unique<Screens::List>(1, 2, app, settingsController, applications);
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@ namespace Pinetime {
|
||||
|
||||
bool Refresh() override;
|
||||
|
||||
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
|
||||
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user