Merge branch 'develop' into pinmap
This commit is contained in:
commit
8390d0ef72
|
@ -418,6 +418,7 @@ list(APPEND SOURCE_FILES
|
||||||
displayapp/screens/BatteryInfo.cpp
|
displayapp/screens/BatteryInfo.cpp
|
||||||
displayapp/screens/Steps.cpp
|
displayapp/screens/Steps.cpp
|
||||||
displayapp/screens/Timer.cpp
|
displayapp/screens/Timer.cpp
|
||||||
|
displayapp/Colors.cpp
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
displayapp/screens/settings/QuickSettings.cpp
|
displayapp/screens/settings/QuickSettings.cpp
|
||||||
|
@ -427,6 +428,7 @@ list(APPEND SOURCE_FILES
|
||||||
displayapp/screens/settings/SettingWakeUp.cpp
|
displayapp/screens/settings/SettingWakeUp.cpp
|
||||||
displayapp/screens/settings/SettingDisplay.cpp
|
displayapp/screens/settings/SettingDisplay.cpp
|
||||||
displayapp/screens/settings/SettingSteps.cpp
|
displayapp/screens/settings/SettingSteps.cpp
|
||||||
|
displayapp/screens/settings/SettingPineTimeStyle.cpp
|
||||||
|
|
||||||
## Watch faces
|
## Watch faces
|
||||||
displayapp/icons/bg_clock.c
|
displayapp/icons/bg_clock.c
|
||||||
|
@ -495,6 +497,8 @@ list(APPEND SOURCE_FILES
|
||||||
components/heartrate/Biquad.cpp
|
components/heartrate/Biquad.cpp
|
||||||
components/heartrate/Ptagc.cpp
|
components/heartrate/Ptagc.cpp
|
||||||
components/heartrate/HeartRateController.cpp
|
components/heartrate/HeartRateController.cpp
|
||||||
|
|
||||||
|
touchhandler/TouchHandler.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND RECOVERY_SOURCE_FILES
|
list(APPEND RECOVERY_SOURCE_FILES
|
||||||
|
@ -552,6 +556,7 @@ list(APPEND RECOVERY_SOURCE_FILES
|
||||||
components/heartrate/Ptagc.cpp
|
components/heartrate/Ptagc.cpp
|
||||||
components/motor/MotorController.cpp
|
components/motor/MotorController.cpp
|
||||||
components/fs/FS.cpp
|
components/fs/FS.cpp
|
||||||
|
touchhandler/TouchHandler.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND RECOVERYLOADER_SOURCE_FILES
|
list(APPEND RECOVERYLOADER_SOURCE_FILES
|
||||||
|
@ -607,6 +612,7 @@ set(INCLUDE_FILES
|
||||||
displayapp/screens/Metronome.h
|
displayapp/screens/Metronome.h
|
||||||
displayapp/screens/Motion.h
|
displayapp/screens/Motion.h
|
||||||
displayapp/screens/Timer.h
|
displayapp/screens/Timer.h
|
||||||
|
displayapp/Colors.h
|
||||||
drivers/St7789.h
|
drivers/St7789.h
|
||||||
drivers/SpiNorFlash.h
|
drivers/SpiNorFlash.h
|
||||||
drivers/SpiMaster.h
|
drivers/SpiMaster.h
|
||||||
|
@ -661,6 +667,7 @@ set(INCLUDE_FILES
|
||||||
components/heartrate/Ptagc.h
|
components/heartrate/Ptagc.h
|
||||||
components/heartrate/HeartRateController.h
|
components/heartrate/HeartRateController.h
|
||||||
components/motor/MotorController.h
|
components/motor/MotorController.h
|
||||||
|
touchhandler/TouchHandler.h
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
|
|
@ -17,6 +17,14 @@ namespace Pinetime {
|
||||||
DoubleTap = 1,
|
DoubleTap = 1,
|
||||||
RaiseWrist = 2,
|
RaiseWrist = 2,
|
||||||
};
|
};
|
||||||
|
enum class Colors : uint8_t {
|
||||||
|
White, Silver, Gray, Black, Red, Maroon, Yellow, Olive, Lime, Green, Cyan, Teal, Blue, Navy, Magenta, Purple, Orange
|
||||||
|
};
|
||||||
|
struct PineTimeStyle {
|
||||||
|
Colors ColorTime = Colors::Teal;
|
||||||
|
Colors ColorBar = Colors::Teal;
|
||||||
|
Colors ColorBG = Colors::Black;
|
||||||
|
};
|
||||||
|
|
||||||
Settings(Pinetime::Controllers::FS& fs);
|
Settings(Pinetime::Controllers::FS& fs);
|
||||||
|
|
||||||
|
@ -33,10 +41,38 @@ namespace Pinetime {
|
||||||
return settings.clockFace;
|
return settings.clockFace;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void SetPTSColorTime(Colors colorTime) {
|
||||||
|
if (colorTime != settings.PTS.ColorTime)
|
||||||
|
settingsChanged = true;
|
||||||
|
settings.PTS.ColorTime = colorTime;
|
||||||
|
};
|
||||||
|
Colors GetPTSColorTime() const {
|
||||||
|
return settings.PTS.ColorTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
void SetPTSColorBar(Colors colorBar) {
|
||||||
|
if (colorBar != settings.PTS.ColorBar)
|
||||||
|
settingsChanged = true;
|
||||||
|
settings.PTS.ColorBar = colorBar;
|
||||||
|
};
|
||||||
|
Colors GetPTSColorBar() const {
|
||||||
|
return settings.PTS.ColorBar;
|
||||||
|
};
|
||||||
|
|
||||||
|
void SetPTSColorBG(Colors colorBG) {
|
||||||
|
if (colorBG != settings.PTS.ColorBG)
|
||||||
|
settingsChanged = true;
|
||||||
|
settings.PTS.ColorBG = colorBG;
|
||||||
|
};
|
||||||
|
Colors GetPTSColorBG() const {
|
||||||
|
return settings.PTS.ColorBG;
|
||||||
|
};
|
||||||
|
|
||||||
void SetAppMenu(uint8_t menu) {
|
void SetAppMenu(uint8_t menu) {
|
||||||
appMenu = menu;
|
appMenu = menu;
|
||||||
};
|
};
|
||||||
uint8_t GetAppMenu() {
|
|
||||||
|
uint8_t GetAppMenu() const {
|
||||||
return appMenu;
|
return appMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -127,9 +163,8 @@ namespace Pinetime {
|
||||||
private:
|
private:
|
||||||
Pinetime::Controllers::FS& fs;
|
Pinetime::Controllers::FS& fs;
|
||||||
|
|
||||||
static constexpr uint32_t settingsVersion = 0x0001;
|
static constexpr uint32_t settingsVersion = 0x0002;
|
||||||
struct SettingsData {
|
struct SettingsData {
|
||||||
|
|
||||||
uint32_t version = settingsVersion;
|
uint32_t version = settingsVersion;
|
||||||
uint32_t stepsGoal = 10000;
|
uint32_t stepsGoal = 10000;
|
||||||
uint32_t screenTimeOut = 15000;
|
uint32_t screenTimeOut = 15000;
|
||||||
|
@ -139,6 +174,8 @@ namespace Pinetime {
|
||||||
|
|
||||||
uint8_t clockFace = 0;
|
uint8_t clockFace = 0;
|
||||||
|
|
||||||
|
PineTimeStyle PTS;
|
||||||
|
|
||||||
std::bitset<3> wakeUpMode {0};
|
std::bitset<3> wakeUpMode {0};
|
||||||
|
|
||||||
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
|
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
|
||||||
|
|
|
@ -30,7 +30,8 @@ namespace Pinetime {
|
||||||
SettingTimeFormat,
|
SettingTimeFormat,
|
||||||
SettingDisplay,
|
SettingDisplay,
|
||||||
SettingWakeUp,
|
SettingWakeUp,
|
||||||
SettingSteps
|
SettingSteps,
|
||||||
|
SettingPineTimeStyle
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
27
src/displayapp/Colors.cpp
Normal file
27
src/displayapp/Colors.cpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#include "Colors.h"
|
||||||
|
|
||||||
|
using namespace Pinetime::Applications;
|
||||||
|
using namespace Pinetime::Controllers;
|
||||||
|
|
||||||
|
lv_color_t Pinetime::Applications::Convert(Pinetime::Controllers::Settings::Colors color) {
|
||||||
|
switch (color) {
|
||||||
|
case Pinetime::Controllers::Settings::Colors::White: return LV_COLOR_WHITE;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Silver: return LV_COLOR_SILVER;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Gray: return LV_COLOR_GRAY;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Black: return LV_COLOR_BLACK;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Red: return LV_COLOR_RED;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Maroon: return LV_COLOR_MAROON;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Yellow: return LV_COLOR_YELLOW;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Olive: return LV_COLOR_OLIVE;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Lime: return LV_COLOR_LIME;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Green: return LV_COLOR_GREEN;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Cyan: return LV_COLOR_CYAN;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Teal: return LV_COLOR_TEAL;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Blue: return LV_COLOR_BLUE;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Navy: return LV_COLOR_NAVY;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Magenta: return LV_COLOR_MAGENTA;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Purple: return LV_COLOR_PURPLE;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Orange: return LV_COLOR_ORANGE;
|
||||||
|
default: return LV_COLOR_WHITE;
|
||||||
|
}
|
||||||
|
}
|
10
src/displayapp/Colors.h
Normal file
10
src/displayapp/Colors.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <lvgl/src/lv_misc/lv_color.h>
|
||||||
|
#include <components/settings/Settings.h>
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
namespace Applications {
|
||||||
|
lv_color_t Convert(Controllers::Settings::Colors color);
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,6 +42,7 @@
|
||||||
#include "displayapp/screens/settings/SettingWakeUp.h"
|
#include "displayapp/screens/settings/SettingWakeUp.h"
|
||||||
#include "displayapp/screens/settings/SettingDisplay.h"
|
#include "displayapp/screens/settings/SettingDisplay.h"
|
||||||
#include "displayapp/screens/settings/SettingSteps.h"
|
#include "displayapp/screens/settings/SettingSteps.h"
|
||||||
|
#include "displayapp/screens/settings/SettingPineTimeStyle.h"
|
||||||
|
|
||||||
#include "libs/lv_conf.h"
|
#include "libs/lv_conf.h"
|
||||||
|
|
||||||
|
@ -53,29 +54,26 @@ namespace {
|
||||||
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
|
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TouchEvents Convert(Pinetime::Drivers::Cst816S::TouchInfos info) {
|
TouchEvents ConvertGesture(Pinetime::Drivers::Cst816S::Gestures gesture) {
|
||||||
if (info.isTouch) {
|
switch (gesture) {
|
||||||
switch (info.gesture) {
|
case Pinetime::Drivers::Cst816S::Gestures::SingleTap:
|
||||||
case Pinetime::Drivers::Cst816S::Gestures::SingleTap:
|
return TouchEvents::Tap;
|
||||||
return TouchEvents::Tap;
|
case Pinetime::Drivers::Cst816S::Gestures::LongPress:
|
||||||
case Pinetime::Drivers::Cst816S::Gestures::LongPress:
|
return TouchEvents::LongTap;
|
||||||
return TouchEvents::LongTap;
|
case Pinetime::Drivers::Cst816S::Gestures::DoubleTap:
|
||||||
case Pinetime::Drivers::Cst816S::Gestures::DoubleTap:
|
return TouchEvents::DoubleTap;
|
||||||
return TouchEvents::DoubleTap;
|
case Pinetime::Drivers::Cst816S::Gestures::SlideRight:
|
||||||
case Pinetime::Drivers::Cst816S::Gestures::SlideRight:
|
return TouchEvents::SwipeRight;
|
||||||
return TouchEvents::SwipeRight;
|
case Pinetime::Drivers::Cst816S::Gestures::SlideLeft:
|
||||||
case Pinetime::Drivers::Cst816S::Gestures::SlideLeft:
|
return TouchEvents::SwipeLeft;
|
||||||
return TouchEvents::SwipeLeft;
|
case Pinetime::Drivers::Cst816S::Gestures::SlideDown:
|
||||||
case Pinetime::Drivers::Cst816S::Gestures::SlideDown:
|
return TouchEvents::SwipeDown;
|
||||||
return TouchEvents::SwipeDown;
|
case Pinetime::Drivers::Cst816S::Gestures::SlideUp:
|
||||||
case Pinetime::Drivers::Cst816S::Gestures::SlideUp:
|
return TouchEvents::SwipeUp;
|
||||||
return TouchEvents::SwipeUp;
|
case Pinetime::Drivers::Cst816S::Gestures::None:
|
||||||
case Pinetime::Drivers::Cst816S::Gestures::None:
|
default:
|
||||||
default:
|
return TouchEvents::None;
|
||||||
return TouchEvents::None;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TouchEvents::None;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +89,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||||
Controllers::Settings& settingsController,
|
Controllers::Settings& settingsController,
|
||||||
Pinetime::Controllers::MotorController& motorController,
|
Pinetime::Controllers::MotorController& motorController,
|
||||||
Pinetime::Controllers::MotionController& motionController,
|
Pinetime::Controllers::MotionController& motionController,
|
||||||
Pinetime::Controllers::TimerController& timerController)
|
Pinetime::Controllers::TimerController& timerController,
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler)
|
||||||
: lcd {lcd},
|
: lcd {lcd},
|
||||||
lvgl {lvgl},
|
lvgl {lvgl},
|
||||||
touchPanel {touchPanel},
|
touchPanel {touchPanel},
|
||||||
|
@ -104,7 +103,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
motorController {motorController},
|
motorController {motorController},
|
||||||
motionController {motionController},
|
motionController {motionController},
|
||||||
timerController {timerController} {
|
timerController {timerController},
|
||||||
|
touchHandler {touchHandler} {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::Start() {
|
void DisplayApp::Start() {
|
||||||
|
@ -212,8 +212,7 @@ void DisplayApp::Refresh() {
|
||||||
if (state != States::Running) {
|
if (state != States::Running) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto info = touchPanel.GetTouchInfo();
|
auto gesture = ConvertGesture(touchHandler.GestureGet());
|
||||||
auto gesture = Convert(info);
|
|
||||||
if (gesture == TouchEvents::None) {
|
if (gesture == TouchEvents::None) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -239,11 +238,9 @@ void DisplayApp::Refresh() {
|
||||||
LoadApp(returnToApp, returnDirection);
|
LoadApp(returnToApp, returnDirection);
|
||||||
brightnessController.Set(settingsController.GetBrightness());
|
brightnessController.Set(settingsController.GetBrightness());
|
||||||
brightnessController.Backup();
|
brightnessController.Backup();
|
||||||
} else if (touchMode == TouchModes::Gestures) {
|
|
||||||
if (gesture == TouchEvents::Tap) {
|
|
||||||
lvgl.SetNewTapEvent(info.x, info.y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
touchHandler.CancelTap();
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case Messages::ButtonPushed:
|
case Messages::ButtonPushed:
|
||||||
|
@ -273,18 +270,13 @@ void DisplayApp::Refresh() {
|
||||||
nextApp = Apps::None;
|
nextApp = Apps::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state != States::Idle && touchMode == TouchModes::Polling) {
|
if (touchHandler.IsTouching()) {
|
||||||
auto info = touchPanel.GetTouchInfo();
|
currentScreen->OnTouchEvent(touchHandler.GetX(), touchHandler.GetY());
|
||||||
if (info.action == 2) { // 2 = contact
|
|
||||||
if (!currentScreen->OnTouchEvent(info.x, info.y)) {
|
|
||||||
lvgl.SetNewTapEvent(info.x, info.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::RunningState() {
|
void DisplayApp::RunningState() {
|
||||||
if (!currentScreen->Refresh()) {
|
if (!currentScreen->IsRunning()) {
|
||||||
LoadApp(returnToApp, returnDirection);
|
LoadApp(returnToApp, returnDirection);
|
||||||
}
|
}
|
||||||
lv_task_handler();
|
lv_task_handler();
|
||||||
|
@ -302,6 +294,7 @@ void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) {
|
void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) {
|
||||||
|
touchHandler.CancelTap();
|
||||||
currentScreen.reset(nullptr);
|
currentScreen.reset(nullptr);
|
||||||
SetFullRefresh(direction);
|
SetFullRefresh(direction);
|
||||||
|
|
||||||
|
@ -378,6 +371,10 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
currentScreen = std::make_unique<Screens::SettingSteps>(this, settingsController);
|
currentScreen = std::make_unique<Screens::SettingSteps>(this, settingsController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
break;
|
break;
|
||||||
|
case Apps::SettingPineTimeStyle:
|
||||||
|
currentScreen = std::make_unique<Screens::SettingPineTimeStyle>(this, settingsController);
|
||||||
|
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
|
break;
|
||||||
case Apps::BatteryInfo:
|
case Apps::BatteryInfo:
|
||||||
currentScreen = std::make_unique<Screens::BatteryInfo>(this, batteryController);
|
currentScreen = std::make_unique<Screens::BatteryInfo>(this, batteryController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
|
@ -467,10 +464,6 @@ void DisplayApp::SetFullRefresh(DisplayApp::FullRefreshDirections direction) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::SetTouchMode(DisplayApp::TouchModes mode) {
|
|
||||||
touchMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DisplayApp::PushMessageToSystemTask(Pinetime::System::Messages message) {
|
void DisplayApp::PushMessageToSystemTask(Pinetime::System::Messages message) {
|
||||||
if (systemTask != nullptr)
|
if (systemTask != nullptr)
|
||||||
systemTask->PushMessage(message);
|
systemTask->PushMessage(message);
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "components/settings/Settings.h"
|
#include "components/settings/Settings.h"
|
||||||
#include "displayapp/screens/Screen.h"
|
#include "displayapp/screens/Screen.h"
|
||||||
#include "components/timer/TimerController.h"
|
#include "components/timer/TimerController.h"
|
||||||
|
#include "touchhandler/TouchHandler.h"
|
||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
|
@ -31,6 +32,7 @@ namespace Pinetime {
|
||||||
class NotificationManager;
|
class NotificationManager;
|
||||||
class HeartRateController;
|
class HeartRateController;
|
||||||
class MotionController;
|
class MotionController;
|
||||||
|
class TouchHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace System {
|
namespace System {
|
||||||
|
@ -41,7 +43,6 @@ namespace Pinetime {
|
||||||
public:
|
public:
|
||||||
enum class States { Idle, Running };
|
enum class States { Idle, Running };
|
||||||
enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim };
|
enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim };
|
||||||
enum class TouchModes { Gestures, Polling };
|
|
||||||
|
|
||||||
DisplayApp(Drivers::St7789& lcd,
|
DisplayApp(Drivers::St7789& lcd,
|
||||||
Components::LittleVgl& lvgl,
|
Components::LittleVgl& lvgl,
|
||||||
|
@ -55,14 +56,14 @@ namespace Pinetime {
|
||||||
Controllers::Settings& settingsController,
|
Controllers::Settings& settingsController,
|
||||||
Pinetime::Controllers::MotorController& motorController,
|
Pinetime::Controllers::MotorController& motorController,
|
||||||
Pinetime::Controllers::MotionController& motionController,
|
Pinetime::Controllers::MotionController& motionController,
|
||||||
Pinetime::Controllers::TimerController& timerController);
|
Pinetime::Controllers::TimerController& timerController,
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler);
|
||||||
void Start();
|
void Start();
|
||||||
void PushMessage(Display::Messages msg);
|
void PushMessage(Display::Messages msg);
|
||||||
|
|
||||||
void StartApp(Apps app, DisplayApp::FullRefreshDirections direction);
|
void StartApp(Apps app, DisplayApp::FullRefreshDirections direction);
|
||||||
|
|
||||||
void SetFullRefresh(FullRefreshDirections direction);
|
void SetFullRefresh(FullRefreshDirections direction);
|
||||||
void SetTouchMode(TouchModes mode);
|
|
||||||
|
|
||||||
void Register(Pinetime::System::SystemTask* systemTask);
|
void Register(Pinetime::System::SystemTask* systemTask);
|
||||||
|
|
||||||
|
@ -81,6 +82,7 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::MotorController& motorController;
|
Pinetime::Controllers::MotorController& motorController;
|
||||||
Pinetime::Controllers::MotionController& motionController;
|
Pinetime::Controllers::MotionController& motionController;
|
||||||
Pinetime::Controllers::TimerController& timerController;
|
Pinetime::Controllers::TimerController& timerController;
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler;
|
||||||
|
|
||||||
Pinetime::Controllers::FirmwareValidator validator;
|
Pinetime::Controllers::FirmwareValidator validator;
|
||||||
Controllers::BrightnessController brightnessController;
|
Controllers::BrightnessController brightnessController;
|
||||||
|
@ -100,8 +102,7 @@ namespace Pinetime {
|
||||||
FullRefreshDirections returnDirection = FullRefreshDirections::None;
|
FullRefreshDirections returnDirection = FullRefreshDirections::None;
|
||||||
TouchEvents returnTouchEvent = TouchEvents::None;
|
TouchEvents returnTouchEvent = TouchEvents::None;
|
||||||
|
|
||||||
TouchModes touchMode = TouchModes::Gestures;
|
TouchEvents GetGesture();
|
||||||
|
|
||||||
void RunningState();
|
void RunningState();
|
||||||
void IdleState();
|
void IdleState();
|
||||||
static void Process(void* instance);
|
static void Process(void* instance);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <task.h>
|
#include <task.h>
|
||||||
#include <libraries/log/nrf_log.h>
|
#include <libraries/log/nrf_log.h>
|
||||||
#include <components/rle/RleDecoder.h>
|
#include <components/rle/RleDecoder.h>
|
||||||
|
#include <touchhandler/TouchHandler.h>
|
||||||
#include "displayapp/icons/infinitime/infinitime-nb.c"
|
#include "displayapp/icons/infinitime/infinitime-nb.c"
|
||||||
|
|
||||||
using namespace Pinetime::Applications;
|
using namespace Pinetime::Applications;
|
||||||
|
@ -19,7 +20,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||||
Controllers::Settings& settingsController,
|
Controllers::Settings& settingsController,
|
||||||
Pinetime::Controllers::MotorController& motorController,
|
Pinetime::Controllers::MotorController& motorController,
|
||||||
Pinetime::Controllers::MotionController& motionController,
|
Pinetime::Controllers::MotionController& motionController,
|
||||||
Pinetime::Controllers::TimerController& timerController)
|
Pinetime::Controllers::TimerController& timerController,
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler)
|
||||||
: lcd {lcd}, bleController {bleController} {
|
: lcd {lcd}, bleController {bleController} {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,9 @@ namespace Pinetime {
|
||||||
namespace System {
|
namespace System {
|
||||||
class SystemTask;
|
class SystemTask;
|
||||||
};
|
};
|
||||||
|
namespace Controllers {
|
||||||
|
class TouchHandler;
|
||||||
|
}
|
||||||
namespace Applications {
|
namespace Applications {
|
||||||
class DisplayApp {
|
class DisplayApp {
|
||||||
public:
|
public:
|
||||||
|
@ -44,7 +47,8 @@ namespace Pinetime {
|
||||||
Controllers::Settings& settingsController,
|
Controllers::Settings& settingsController,
|
||||||
Pinetime::Controllers::MotorController& motorController,
|
Pinetime::Controllers::MotorController& motorController,
|
||||||
Pinetime::Controllers::MotionController& motionController,
|
Pinetime::Controllers::MotionController& motionController,
|
||||||
Pinetime::Controllers::TimerController& timerController);
|
Pinetime::Controllers::TimerController& timerController,
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler);
|
||||||
void Start();
|
void Start();
|
||||||
void PushMessage(Pinetime::Applications::Display::Messages msg);
|
void PushMessage(Pinetime::Applications::Display::Messages msg);
|
||||||
void Register(Pinetime::System::SystemTask* systemTask);
|
void Register(Pinetime::System::SystemTask* systemTask);
|
||||||
|
|
|
@ -32,6 +32,9 @@ namespace Pinetime {
|
||||||
}
|
}
|
||||||
void SetNewTapEvent(uint16_t x, uint16_t y) {
|
void SetNewTapEvent(uint16_t x, uint16_t y) {
|
||||||
}
|
}
|
||||||
|
void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) {
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,43 +166,21 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) {
|
||||||
lv_disp_flush_ready(&disp_drv);
|
lv_disp_flush_ready(&disp_drv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LittleVgl::SetNewTapEvent(uint16_t x, uint16_t y) {
|
void LittleVgl::SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) {
|
||||||
tap_x = x;
|
tap_x = x;
|
||||||
tap_y = y;
|
tap_y = y;
|
||||||
tapped = true;
|
tapped = contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
|
bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
|
||||||
|
ptr->point.x = tap_x;
|
||||||
|
ptr->point.y = tap_y;
|
||||||
if (tapped) {
|
if (tapped) {
|
||||||
ptr->point.x = tap_x;
|
|
||||||
ptr->point.y = tap_y;
|
|
||||||
ptr->state = LV_INDEV_STATE_PR;
|
ptr->state = LV_INDEV_STATE_PR;
|
||||||
tapped = false;
|
|
||||||
} else {
|
} else {
|
||||||
ptr->state = LV_INDEV_STATE_REL;
|
ptr->state = LV_INDEV_STATE_REL;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
/*
|
|
||||||
auto info = touchPanel.GetTouchInfo();
|
|
||||||
|
|
||||||
if((previousClick.x != info.x || previousClick.y != info.y) &&
|
|
||||||
(info.gesture == Drivers::Cst816S::Gestures::SingleTap)) {
|
|
||||||
// TODO For an unknown reason, the first touch is taken twice into account.
|
|
||||||
// 'firstTouch' is a quite'n'dirty workaound until I find a better solution
|
|
||||||
if(firstTouch) ptr->state = LV_INDEV_STATE_REL;
|
|
||||||
else ptr->state = LV_INDEV_STATE_PR;
|
|
||||||
firstTouch = false;
|
|
||||||
previousClick.x = info.x;
|
|
||||||
previousClick.y = info.y;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ptr->state = LV_INDEV_STATE_REL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr->point.x = info.x;
|
|
||||||
ptr->point.y = info.y;
|
|
||||||
return false;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LittleVgl::InitTheme() {
|
void LittleVgl::InitTheme() {
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Pinetime {
|
||||||
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p);
|
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p);
|
||||||
bool GetTouchPadInfo(lv_indev_data_t* ptr);
|
bool GetTouchPadInfo(lv_indev_data_t* ptr);
|
||||||
void SetFullRefresh(FullRefreshDirections direction);
|
void SetFullRefresh(FullRefreshDirections direction);
|
||||||
void SetNewTapEvent(uint16_t x, uint16_t y);
|
void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitDisplay();
|
void InitDisplay();
|
||||||
|
|
|
@ -34,12 +34,6 @@ ApplicationList::~ApplicationList() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApplicationList::Refresh() {
|
|
||||||
if (running)
|
|
||||||
running = screens.Refresh();
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
return screens.OnTouchEvent(event);
|
return screens.OnTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::Battery& batteryController,
|
Pinetime::Controllers::Battery& batteryController,
|
||||||
Controllers::DateTime& dateTimeController);
|
Controllers::DateTime& dateTimeController);
|
||||||
~ApplicationList() override;
|
~ApplicationList() override;
|
||||||
bool Refresh() override;
|
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -33,4 +32,4 @@ namespace Pinetime {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,6 @@
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
static void lv_update_task(struct _lv_task_t* task) {
|
|
||||||
auto user_data = static_cast<BatteryInfo*>(task->user_data);
|
|
||||||
user_data->UpdateScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Battery& batteryController)
|
BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Battery& batteryController)
|
||||||
: Screen(app), batteryController {batteryController} {
|
: Screen(app), batteryController {batteryController} {
|
||||||
|
|
||||||
|
@ -49,16 +44,16 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont
|
||||||
lv_obj_set_pos(backgroundLabel, 0, 0);
|
lv_obj_set_pos(backgroundLabel, 0, 0);
|
||||||
lv_label_set_text_static(backgroundLabel, "");
|
lv_label_set_text_static(backgroundLabel, "");
|
||||||
|
|
||||||
taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_LOW, this);
|
taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this);
|
||||||
UpdateScreen();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
BatteryInfo::~BatteryInfo() {
|
BatteryInfo::~BatteryInfo() {
|
||||||
lv_task_del(taskUpdate);
|
lv_task_del(taskRefresh);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatteryInfo::UpdateScreen() {
|
void BatteryInfo::Refresh() {
|
||||||
|
|
||||||
batteryController.Update();
|
batteryController.Update();
|
||||||
|
|
||||||
|
@ -85,7 +80,3 @@ void BatteryInfo::UpdateScreen() {
|
||||||
lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10);
|
lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10);
|
||||||
lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON);
|
lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BatteryInfo::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
|
@ -19,9 +19,7 @@ namespace Pinetime {
|
||||||
BatteryInfo(DisplayApp* app, Pinetime::Controllers::Battery& batteryController);
|
BatteryInfo(DisplayApp* app, Pinetime::Controllers::Battery& batteryController);
|
||||||
~BatteryInfo() override;
|
~BatteryInfo() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
void UpdateScreen();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Pinetime::Controllers::Battery& batteryController;
|
Pinetime::Controllers::Battery& batteryController;
|
||||||
|
@ -31,7 +29,7 @@ namespace Pinetime {
|
||||||
lv_obj_t* charging_bar;
|
lv_obj_t* charging_bar;
|
||||||
lv_obj_t* status;
|
lv_obj_t* status;
|
||||||
|
|
||||||
lv_task_t* taskUpdate;
|
lv_task_t* taskRefresh;
|
||||||
|
|
||||||
uint8_t batteryPercent = 0;
|
uint8_t batteryPercent = 0;
|
||||||
uint16_t batteryVoltage = 0;
|
uint16_t batteryVoltage = 0;
|
||||||
|
|
|
@ -30,10 +30,6 @@ Brightness::~Brightness() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Brightness::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* Brightness::LevelToString(Pinetime::Controllers::BrightnessController::Levels level) {
|
const char* Brightness::LevelToString(Pinetime::Controllers::BrightnessController::Levels level) {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case Pinetime::Controllers::BrightnessController::Levels::Off:
|
case Pinetime::Controllers::BrightnessController::Levels::Off:
|
||||||
|
|
|
@ -12,7 +12,6 @@ namespace Pinetime {
|
||||||
public:
|
public:
|
||||||
Brightness(DisplayApp* app, Controllers::BrightnessController& brightness);
|
Brightness(DisplayApp* app, Controllers::BrightnessController& brightness);
|
||||||
~Brightness() override;
|
~Brightness() override;
|
||||||
bool Refresh() override;
|
|
||||||
|
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
|
||||||
|
@ -31,4 +30,4 @@ namespace Pinetime {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,11 +50,6 @@ Clock::~Clock() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Clock::Refresh() {
|
|
||||||
screen->Refresh();
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
return screen->OnTouchEvent(event);
|
return screen->OnTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -83,4 +78,4 @@ std::unique_ptr<Screen> Clock::PineTimeStyleScreen() {
|
||||||
notificatioManager,
|
notificatioManager,
|
||||||
settingsController,
|
settingsController,
|
||||||
motionController);
|
motionController);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,6 @@ namespace Pinetime {
|
||||||
Controllers::MotionController& motionController);
|
Controllers::MotionController& motionController);
|
||||||
~Clock() override;
|
~Clock() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
|
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -30,14 +30,16 @@ FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp* app, Pinetime
|
||||||
lv_label_set_text(percentLabel, "Waiting...");
|
lv_label_set_text(percentLabel, "Waiting...");
|
||||||
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);
|
||||||
startTime = xTaskGetTickCount();
|
startTime = xTaskGetTickCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
FirmwareUpdate::~FirmwareUpdate() {
|
FirmwareUpdate::~FirmwareUpdate() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FirmwareUpdate::Refresh() {
|
void FirmwareUpdate::Refresh() {
|
||||||
switch (bleController.State()) {
|
switch (bleController.State()) {
|
||||||
default:
|
default:
|
||||||
case Pinetime::Controllers::Ble::FirmwareUpdateStates::Idle:
|
case Pinetime::Controllers::Ble::FirmwareUpdateStates::Idle:
|
||||||
|
@ -73,7 +75,6 @@ bool FirmwareUpdate::Refresh() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return running;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FirmwareUpdate::DisplayProgression() const {
|
void FirmwareUpdate::DisplayProgression() const {
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Pinetime {
|
||||||
FirmwareUpdate(DisplayApp* app, Pinetime::Controllers::Ble& bleController);
|
FirmwareUpdate(DisplayApp* app, Pinetime::Controllers::Ble& bleController);
|
||||||
~FirmwareUpdate() override;
|
~FirmwareUpdate() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class States { Idle, Running, Validated, Error };
|
enum class States { Idle, Running, Validated, Error };
|
||||||
|
@ -36,6 +36,7 @@ namespace Pinetime {
|
||||||
|
|
||||||
void UpdateError();
|
void UpdateError();
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
TickType_t startTime;
|
TickType_t startTime;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,15 +63,11 @@ FirmwareValidation::~FirmwareValidation() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FirmwareValidation::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FirmwareValidation::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
void FirmwareValidation::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
||||||
if (object == buttonValidate && event == LV_EVENT_PRESSED) {
|
if (object == buttonValidate && event == LV_EVENT_CLICKED) {
|
||||||
validator.Validate();
|
validator.Validate();
|
||||||
running = false;
|
running = false;
|
||||||
} else if (object == buttonReset && event == LV_EVENT_PRESSED) {
|
} else if (object == buttonReset && event == LV_EVENT_CLICKED) {
|
||||||
validator.Reset();
|
validator.Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,6 @@ namespace Pinetime {
|
||||||
FirmwareValidation(DisplayApp* app, Pinetime::Controllers::FirmwareValidator& validator);
|
FirmwareValidation(DisplayApp* app, Pinetime::Controllers::FirmwareValidator& validator);
|
||||||
~FirmwareValidation() override;
|
~FirmwareValidation() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
|
|
||||||
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
|
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -65,10 +65,6 @@ void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FlashLight::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FlashLight::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
bool FlashLight::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,6 @@ namespace Pinetime {
|
||||||
FlashLight(DisplayApp* app, System::SystemTask& systemTask, Controllers::BrightnessController& brightness);
|
FlashLight(DisplayApp* app, System::SystemTask& systemTask, Controllers::BrightnessController& brightness);
|
||||||
~FlashLight() override;
|
~FlashLight() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
|
|
||||||
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
||||||
void OnClickEvent(lv_obj_t* obj, lv_event_t event);
|
void OnClickEvent(lv_obj_t* obj, lv_event_t event);
|
||||||
|
|
||||||
|
|
|
@ -64,14 +64,17 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
|
||||||
UpdateStartStopButton(isHrRunning);
|
UpdateStartStopButton(isHrRunning);
|
||||||
if (isHrRunning)
|
if (isHrRunning)
|
||||||
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
|
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
|
||||||
|
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
HeartRate::~HeartRate() {
|
HeartRate::~HeartRate() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HeartRate::Refresh() {
|
void HeartRate::Refresh() {
|
||||||
|
|
||||||
auto state = heartRateController.State();
|
auto state = heartRateController.State();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
@ -86,8 +89,6 @@ bool HeartRate::Refresh() {
|
||||||
|
|
||||||
lv_label_set_text(label_status, ToString(state));
|
lv_label_set_text(label_status, ToString(state));
|
||||||
lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
|
lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
|
||||||
|
|
||||||
return running;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeartRate::OnStartStopEvent(lv_event_t event) {
|
void HeartRate::OnStartStopEvent(lv_event_t event) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Pinetime {
|
||||||
HeartRate(DisplayApp* app, Controllers::HeartRateController& HeartRateController, System::SystemTask& systemTask);
|
HeartRate(DisplayApp* app, Controllers::HeartRateController& HeartRateController, System::SystemTask& systemTask);
|
||||||
~HeartRate() override;
|
~HeartRate() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
void OnStartStopEvent(lv_event_t event);
|
void OnStartStopEvent(lv_event_t event);
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@ namespace Pinetime {
|
||||||
lv_obj_t* label_status;
|
lv_obj_t* label_status;
|
||||||
lv_obj_t* btn_startStop;
|
lv_obj_t* btn_startStop;
|
||||||
lv_obj_t* label_startStop;
|
lv_obj_t* label_startStop;
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,20 +5,13 @@
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl {lvgl} {
|
InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl {lvgl} {
|
||||||
app->SetTouchMode(DisplayApp::TouchModes::Polling);
|
|
||||||
std::fill(b, b + bufferSize, selectColor);
|
std::fill(b, b + bufferSize, selectColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
InfiniPaint::~InfiniPaint() {
|
InfiniPaint::~InfiniPaint() {
|
||||||
// Reset the touchmode
|
|
||||||
app->SetTouchMode(DisplayApp::TouchModes::Gestures);
|
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InfiniPaint::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case Pinetime::Applications::TouchEvents::LongTap:
|
case Pinetime::Applications::TouchEvents::LongTap:
|
||||||
|
|
|
@ -17,8 +17,6 @@ namespace Pinetime {
|
||||||
|
|
||||||
~InfiniPaint() override;
|
~InfiniPaint() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
|
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
|
||||||
bool OnTouchEvent(uint16_t x, uint16_t y) override;
|
bool OnTouchEvent(uint16_t x, uint16_t y) override;
|
||||||
|
|
|
@ -36,7 +36,3 @@ Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::Displ
|
||||||
Label::~Label() {
|
Label::~Label() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Label::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
|
@ -12,8 +12,6 @@ namespace Pinetime {
|
||||||
Label(uint8_t screenID, uint8_t numScreens, DisplayApp* app, lv_obj_t* labelText);
|
Label(uint8_t screenID, uint8_t numScreens, DisplayApp* app, lv_obj_t* labelText);
|
||||||
~Label() override;
|
~Label() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lv_obj_t* labelText = nullptr;
|
lv_obj_t* labelText = nullptr;
|
||||||
lv_point_t pageIndicatorBasePoints[2];
|
lv_point_t pageIndicatorBasePoints[2];
|
||||||
|
|
|
@ -98,13 +98,8 @@ List::~List() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool List::Refresh() {
|
|
||||||
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
void List::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
void List::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
||||||
if (event == LV_EVENT_RELEASED) {
|
if (event == LV_EVENT_CLICKED) {
|
||||||
for (int i = 0; i < MAXLISTITEMS; i++) {
|
for (int i = 0; i < MAXLISTITEMS; i++) {
|
||||||
if (apps[i] != Apps::None && object == itemApps[i]) {
|
if (apps[i] != Apps::None && object == itemApps[i]) {
|
||||||
app->StartApp(apps[i], DisplayApp::FullRefreshDirections::Up);
|
app->StartApp(apps[i], DisplayApp::FullRefreshDirections::Up);
|
||||||
|
|
|
@ -27,8 +27,6 @@ namespace Pinetime {
|
||||||
std::array<Applications, MAXLISTITEMS>& applications);
|
std::array<Applications, MAXLISTITEMS>& applications);
|
||||||
~List() override;
|
~List() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
|
|
||||||
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
|
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -20,17 +20,17 @@ Meter::Meter(Pinetime::Applications::DisplayApp* app) : Screen(app) {
|
||||||
|
|
||||||
lv_obj_set_size(lmeter, 200, 200);
|
lv_obj_set_size(lmeter, 200, 200);
|
||||||
lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0);
|
lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||||
|
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Meter::~Meter() {
|
Meter::~Meter() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Meter::Refresh() {
|
void Meter::Refresh() {
|
||||||
lv_linemeter_set_value(lmeter, value++); /*Set the current value*/
|
lv_linemeter_set_value(lmeter, value++); /*Set the current value*/
|
||||||
if (value >= 60)
|
if (value >= 60)
|
||||||
value = 0;
|
value = 0;
|
||||||
|
|
||||||
return running;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,13 +14,15 @@ namespace Pinetime {
|
||||||
Meter(DisplayApp* app);
|
Meter(DisplayApp* app);
|
||||||
~Meter() override;
|
~Meter() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lv_style_t style_lmeter;
|
lv_style_t style_lmeter;
|
||||||
lv_obj_t* lmeter;
|
lv_obj_t* lmeter;
|
||||||
|
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,16 +67,16 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl
|
||||||
lv_obj_align(playPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
|
lv_obj_align(playPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
|
||||||
lv_obj_set_style_local_value_str(playPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Symbols::play);
|
lv_obj_set_style_local_value_str(playPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Symbols::play);
|
||||||
|
|
||||||
app->SetTouchMode(DisplayApp::TouchModes::Polling);
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Metronome::~Metronome() {
|
Metronome::~Metronome() {
|
||||||
app->SetTouchMode(DisplayApp::TouchModes::Gestures);
|
lv_task_del(taskRefresh);
|
||||||
systemTask.PushMessage(System::Messages::EnableSleeping);
|
systemTask.PushMessage(System::Messages::EnableSleeping);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Metronome::Refresh() {
|
void Metronome::Refresh() {
|
||||||
if (metronomeStarted) {
|
if (metronomeStarted) {
|
||||||
if (xTaskGetTickCount() - startTime > 60 * configTICK_RATE_HZ / bpm) {
|
if (xTaskGetTickCount() - startTime > 60 * configTICK_RATE_HZ / bpm) {
|
||||||
startTime += 60 * configTICK_RATE_HZ / bpm;
|
startTime += 60 * configTICK_RATE_HZ / bpm;
|
||||||
|
@ -89,7 +89,6 @@ bool Metronome::Refresh() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return running;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
|
void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Pinetime {
|
||||||
public:
|
public:
|
||||||
Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask);
|
Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask);
|
||||||
~Metronome() override;
|
~Metronome() override;
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
void OnEvent(lv_obj_t* obj, lv_event_t event);
|
void OnEvent(lv_obj_t* obj, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -28,6 +28,8 @@ namespace Pinetime {
|
||||||
lv_obj_t *bpmArc, *bpmTap, *bpmValue;
|
lv_obj_t *bpmArc, *bpmTap, *bpmValue;
|
||||||
lv_obj_t *bpbDropdown, *currentBpbText;
|
lv_obj_t *bpbDropdown, *currentBpbText;
|
||||||
lv_obj_t *playPause;
|
lv_obj_t *playPause;
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,13 +36,16 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr
|
||||||
labelStep = lv_label_create(lv_scr_act(), NULL);
|
labelStep = lv_label_create(lv_scr_act(), NULL);
|
||||||
lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
||||||
lv_label_set_text(labelStep, "Steps ---");
|
lv_label_set_text(labelStep, "Steps ---");
|
||||||
|
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Motion::~Motion() {
|
Motion::~Motion() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Motion::Refresh() {
|
void Motion::Refresh() {
|
||||||
lv_chart_set_next(chart, ser1, motionController.X());
|
lv_chart_set_next(chart, ser1, motionController.X());
|
||||||
lv_chart_set_next(chart, ser2, motionController.Y());
|
lv_chart_set_next(chart, ser2, motionController.Y());
|
||||||
lv_chart_set_next(chart, ser3, motionController.Z());
|
lv_chart_set_next(chart, ser3, motionController.Z());
|
||||||
|
@ -55,6 +58,4 @@ bool Motion::Refresh() {
|
||||||
motionController.Y() / 0x10,
|
motionController.Y() / 0x10,
|
||||||
motionController.Z() / 0x10);
|
motionController.Z() / 0x10);
|
||||||
lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
|
lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
|
||||||
|
|
||||||
return running;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Pinetime {
|
||||||
Motion(DisplayApp* app, Controllers::MotionController& motionController);
|
Motion(DisplayApp* app, Controllers::MotionController& motionController);
|
||||||
~Motion() override;
|
~Motion() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Controllers::MotionController& motionController;
|
Controllers::MotionController& motionController;
|
||||||
|
@ -28,6 +28,7 @@ namespace Pinetime {
|
||||||
lv_obj_t* label;
|
lv_obj_t* label;
|
||||||
|
|
||||||
lv_obj_t* labelStep;
|
lv_obj_t* labelStep;
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,14 +139,17 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus
|
||||||
frameB = false;
|
frameB = false;
|
||||||
|
|
||||||
musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);
|
musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);
|
||||||
|
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Music::~Music() {
|
Music::~Music() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
lv_style_reset(&btn_style);
|
lv_style_reset(&btn_style);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Music::Refresh() {
|
void Music::Refresh() {
|
||||||
if (artist != musicService.getArtist()) {
|
if (artist != musicService.getArtist()) {
|
||||||
artist = musicService.getArtist();
|
artist = musicService.getArtist();
|
||||||
currentLength = 0;
|
currentLength = 0;
|
||||||
|
@ -210,8 +213,6 @@ bool Music::Refresh() {
|
||||||
} else {
|
} else {
|
||||||
lv_label_set_text(txtPlayPause, Symbols::play);
|
lv_label_set_text(txtPlayPause, Symbols::play);
|
||||||
}
|
}
|
||||||
|
|
||||||
return running;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Music::UpdateLength() {
|
void Music::UpdateLength() {
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Pinetime {
|
||||||
|
|
||||||
~Music() override;
|
~Music() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
|
void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
|
||||||
|
|
||||||
|
@ -79,6 +79,8 @@ namespace Pinetime {
|
||||||
|
|
||||||
bool playing;
|
bool playing;
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
|
|
||||||
/** Watchapp */
|
/** Watchapp */
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,13 +161,16 @@ Navigation::Navigation(Pinetime::Applications::DisplayApp* app, Pinetime::Contro
|
||||||
lv_bar_set_anim_time(barProgress, 500);
|
lv_bar_set_anim_time(barProgress, 500);
|
||||||
lv_bar_set_range(barProgress, 0, 100);
|
lv_bar_set_range(barProgress, 0, 100);
|
||||||
lv_bar_set_value(barProgress, 0, LV_ANIM_OFF);
|
lv_bar_set_value(barProgress, 0, LV_ANIM_OFF);
|
||||||
|
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Navigation::~Navigation() {
|
Navigation::~Navigation() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Navigation::Refresh() {
|
void Navigation::Refresh() {
|
||||||
if (flag != navService.getFlag()) {
|
if (flag != navService.getFlag()) {
|
||||||
flag = navService.getFlag();
|
flag = navService.getFlag();
|
||||||
lv_label_set_text(imgFlag, iconForName(flag));
|
lv_label_set_text(imgFlag, iconForName(flag));
|
||||||
|
@ -192,8 +195,4 @@ bool Navigation::Refresh() {
|
||||||
lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
|
lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return running;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Pinetime {
|
||||||
Navigation(DisplayApp* app, Pinetime::Controllers::NavigationService& nav);
|
Navigation(DisplayApp* app, Pinetime::Controllers::NavigationService& nav);
|
||||||
~Navigation() override;
|
~Navigation() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lv_obj_t* imgFlag;
|
lv_obj_t* imgFlag;
|
||||||
|
@ -49,6 +49,8 @@ namespace Pinetime {
|
||||||
std::string narrative;
|
std::string narrative;
|
||||||
std::string manDist;
|
std::string manDist;
|
||||||
int progress;
|
int progress;
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,15 +52,18 @@ Notifications::Notifications(DisplayApp* app,
|
||||||
timeoutTickCountEnd = timeoutTickCountStart + (5 * 1024);
|
timeoutTickCountEnd = timeoutTickCountStart + (5 * 1024);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Notifications::~Notifications() {
|
Notifications::~Notifications() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
// make sure we stop any vibrations before exiting
|
// make sure we stop any vibrations before exiting
|
||||||
Controllers::MotorController::StopRinging();
|
Controllers::MotorController::StopRinging();
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Notifications::Refresh() {
|
void Notifications::Refresh() {
|
||||||
if (mode == Modes::Preview && timeoutLine != nullptr) {
|
if (mode == Modes::Preview && timeoutLine != nullptr) {
|
||||||
auto tick = xTaskGetTickCount();
|
auto tick = xTaskGetTickCount();
|
||||||
int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240));
|
int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240));
|
||||||
|
@ -70,7 +73,7 @@ bool Notifications::Refresh() {
|
||||||
timeoutLinePoints[1].x = pos;
|
timeoutLinePoints[1].x = pos;
|
||||||
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
|
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
|
||||||
}
|
}
|
||||||
return running && currentItem->IsRunning();
|
running = currentItem->IsRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Pinetime {
|
||||||
Modes mode);
|
Modes mode);
|
||||||
~Notifications() override;
|
~Notifications() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
||||||
|
|
||||||
class NotificationItem {
|
class NotificationItem {
|
||||||
|
@ -79,6 +79,8 @@ namespace Pinetime {
|
||||||
lv_obj_t* timeoutLine = nullptr;
|
lv_obj_t* timeoutLine = nullptr;
|
||||||
uint32_t timeoutTickCountStart;
|
uint32_t timeoutTickCountStart;
|
||||||
uint32_t timeoutTickCountEnd;
|
uint32_t timeoutTickCountEnd;
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl {lvgl} {
|
Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl {lvgl} {
|
||||||
app->SetTouchMode(DisplayApp::TouchModes::Polling);
|
|
||||||
|
|
||||||
background = lv_obj_create(lv_scr_act(), nullptr);
|
background = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_size(background, LV_HOR_RES + 1, LV_VER_RES);
|
lv_obj_set_size(background, LV_HOR_RES + 1, LV_VER_RES);
|
||||||
lv_obj_set_pos(background, -1, 0);
|
lv_obj_set_pos(background, -1, 0);
|
||||||
|
@ -29,15 +27,16 @@ Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::Li
|
||||||
lv_obj_set_style_local_bg_color(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
lv_obj_set_style_local_bg_color(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
lv_obj_set_style_local_radius(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
lv_obj_set_style_local_radius(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
||||||
lv_obj_set_size(ball, ballSize, ballSize);
|
lv_obj_set_size(ball, ballSize, ballSize);
|
||||||
|
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Paddle::~Paddle() {
|
Paddle::~Paddle() {
|
||||||
// Reset the touchmode
|
lv_task_del(taskRefresh);
|
||||||
app->SetTouchMode(DisplayApp::TouchModes::Gestures);
|
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Paddle::Refresh() {
|
void Paddle::Refresh() {
|
||||||
ballX += dx;
|
ballX += dx;
|
||||||
ballY += dy;
|
ballY += dy;
|
||||||
|
|
||||||
|
@ -69,7 +68,6 @@ bool Paddle::Refresh() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lv_label_set_text_fmt(points, "%04d", score);
|
lv_label_set_text_fmt(points, "%04d", score);
|
||||||
return running;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Paddle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
bool Paddle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Pinetime {
|
||||||
Paddle(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
|
Paddle(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
|
||||||
~Paddle() override;
|
~Paddle() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
bool OnTouchEvent(uint16_t x, uint16_t y) override;
|
bool OnTouchEvent(uint16_t x, uint16_t y) override;
|
||||||
|
@ -40,6 +40,8 @@ namespace Pinetime {
|
||||||
lv_obj_t* paddle;
|
lv_obj_t* paddle;
|
||||||
lv_obj_t* ball;
|
lv_obj_t* ball;
|
||||||
lv_obj_t* background;
|
lv_obj_t* background;
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <date/date.h>
|
#include <date/date.h>
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <displayapp/Colors.h>
|
||||||
#include "BatteryIcon.h"
|
#include "BatteryIcon.h"
|
||||||
#include "BleIcon.h"
|
#include "BleIcon.h"
|
||||||
#include "NotificationIcon.h"
|
#include "NotificationIcon.h"
|
||||||
|
@ -51,7 +52,8 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
notificatioManager {notificatioManager},
|
notificatioManager {notificatioManager},
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
motionController {motionController} {
|
motionController {motionController} {
|
||||||
/* This sets the watchface number to return to after leaving the menu */
|
|
||||||
|
// This sets the watchface number to return to after leaving the menu
|
||||||
settingsController.SetClockFace(2);
|
settingsController.SetClockFace(2);
|
||||||
|
|
||||||
displayedChar[0] = 0;
|
displayedChar[0] = 0;
|
||||||
|
@ -60,40 +62,40 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
displayedChar[3] = 0;
|
displayedChar[3] = 0;
|
||||||
displayedChar[4] = 0;
|
displayedChar[4] = 0;
|
||||||
|
|
||||||
/* Create a 200px wide background rectangle */
|
//Create a 200px wide background rectangle
|
||||||
timebar = lv_obj_create(lv_scr_act(), nullptr);
|
timebar = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
|
||||||
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
lv_obj_set_size(timebar, 200, 240);
|
lv_obj_set_size(timebar, 200, 240);
|
||||||
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
|
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
|
||||||
|
|
||||||
/* Display the time */
|
// Display the time
|
||||||
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
|
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
||||||
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
lv_label_set_text(timeDD1, "12");
|
lv_label_set_text(timeDD1, "12");
|
||||||
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
|
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
|
||||||
|
|
||||||
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
|
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
||||||
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
lv_label_set_text(timeDD2, "34");
|
lv_label_set_text(timeDD2, "34");
|
||||||
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
|
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
|
||||||
|
|
||||||
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
|
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
|
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
|
||||||
lv_label_set_text(timeAMPM, "");
|
lv_label_set_text(timeAMPM, "");
|
||||||
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
|
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
|
||||||
|
|
||||||
/* Create a 40px wide bar down the right side of the screen */
|
// Create a 40px wide bar down the right side of the screen
|
||||||
sidebar = lv_obj_create(lv_scr_act(), nullptr);
|
sidebar = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
|
||||||
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
lv_obj_set_size(sidebar, 40, 240);
|
lv_obj_set_size(sidebar, 40, 240);
|
||||||
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
||||||
|
|
||||||
/* Display icons */
|
// Display icons
|
||||||
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
|
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
lv_label_set_text(batteryIcon, Symbols::batteryFull);
|
lv_label_set_text(batteryIcon, Symbols::batteryFull);
|
||||||
|
@ -111,7 +113,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 40);
|
lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 40);
|
||||||
|
|
||||||
/* Calendar icon */
|
// Calendar icon
|
||||||
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
|
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
|
@ -148,7 +150,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
lv_obj_set_size(calendarCrossBar2, 8, 3);
|
lv_obj_set_size(calendarCrossBar2, 8, 3);
|
||||||
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||||
|
|
||||||
/* Display date */
|
// Display date
|
||||||
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
|
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
lv_label_set_text(dateDayOfWeek, "THU");
|
lv_label_set_text(dateDayOfWeek, "THU");
|
||||||
|
@ -184,7 +186,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
|
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
|
||||||
lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
|
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||||
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
|
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
|
||||||
lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
|
lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
|
||||||
|
|
||||||
backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
|
backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
@ -193,13 +195,17 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
lv_obj_set_size(backgroundLabel, 240, 240);
|
lv_obj_set_size(backgroundLabel, 240, 240);
|
||||||
lv_obj_set_pos(backgroundLabel, 0, 0);
|
lv_obj_set_pos(backgroundLabel, 0, 0);
|
||||||
lv_label_set_text(backgroundLabel, "");
|
lv_label_set_text(backgroundLabel, "");
|
||||||
|
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
PineTimeStyle::~PineTimeStyle() {
|
PineTimeStyle::~PineTimeStyle() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PineTimeStyle::Refresh() {
|
void PineTimeStyle::Refresh() {
|
||||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||||
if (batteryPercentRemaining.IsUpdated()) {
|
if (batteryPercentRemaining.IsUpdated()) {
|
||||||
auto batteryPercent = batteryPercentRemaining.Get();
|
auto batteryPercent = batteryPercentRemaining.Get();
|
||||||
|
@ -303,6 +309,4 @@ bool PineTimeStyle::Refresh() {
|
||||||
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace Pinetime {
|
||||||
Controllers::MotionController& motionController);
|
Controllers::MotionController& motionController);
|
||||||
~PineTimeStyle() override;
|
~PineTimeStyle() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char displayedChar[5];
|
char displayedChar[5];
|
||||||
|
@ -75,6 +75,8 @@ namespace Pinetime {
|
||||||
Controllers::NotificationManager& notificatioManager;
|
Controllers::NotificationManager& notificatioManager;
|
||||||
Controllers::Settings& settingsController;
|
Controllers::Settings& settingsController;
|
||||||
Controllers::MotionController& motionController;
|
Controllers::MotionController& motionController;
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
void Screen::RefreshTaskCallback(lv_task_t* task) {
|
||||||
|
static_cast<Screen*>(task->user_data)->Refresh();
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include "../TouchEvents.h"
|
#include "../TouchEvents.h"
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Applications {
|
namespace Applications {
|
||||||
|
@ -38,25 +39,20 @@ namespace Pinetime {
|
||||||
};
|
};
|
||||||
|
|
||||||
class Screen {
|
class Screen {
|
||||||
|
private:
|
||||||
|
virtual void Refresh() {
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Screen(DisplayApp* app) : app {app} {
|
explicit Screen(DisplayApp* app) : app {app} {
|
||||||
}
|
}
|
||||||
virtual ~Screen() = default;
|
virtual ~Screen() = default;
|
||||||
|
|
||||||
/**
|
static void RefreshTaskCallback(lv_task_t* task);
|
||||||
* Most of the time, apps only react to events (touch events, for example).
|
|
||||||
* In this case you don't need to do anything in this method.
|
bool IsRunning() const {
|
||||||
*
|
return running;
|
||||||
* For example, InfiniPaint does nothing in Refresh().
|
}
|
||||||
* But, if you want to update your display periodically, draw an animation...
|
|
||||||
* you cannot do it in a touch event handler because these handlers are not
|
|
||||||
* called if the user does not touch the screen.
|
|
||||||
*
|
|
||||||
* That's why Refresh() is there: update the display periodically.
|
|
||||||
*
|
|
||||||
* @return false if the app can be closed, true if it must continue to run
|
|
||||||
**/
|
|
||||||
virtual bool Refresh() = 0;
|
|
||||||
|
|
||||||
/** @return false if the button hasn't been handled by the app, true if it has been handled */
|
/** @return false if the button hasn't been handled by the app, true if it has been handled */
|
||||||
virtual bool OnButtonPushed() {
|
virtual bool OnButtonPushed() {
|
||||||
|
@ -64,6 +60,7 @@ namespace Pinetime {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return false if the event hasn't been handled by the app, true if it has been handled */
|
/** @return false if the event hasn't been handled by the app, true if it has been handled */
|
||||||
|
// Returning true will cancel lvgl tap
|
||||||
virtual bool OnTouchEvent(TouchEvents event) {
|
virtual bool OnTouchEvent(TouchEvents event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,6 @@ namespace Pinetime {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Refresh() override {
|
|
||||||
running = current->Refresh();
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OnTouchEvent(TouchEvents event) override {
|
bool OnTouchEvent(TouchEvents event) override {
|
||||||
|
|
||||||
if (mode == ScreenListModes::UpDown) {
|
if (mode == ScreenListModes::UpDown) {
|
||||||
|
@ -110,4 +105,4 @@ namespace Pinetime {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,20 +47,20 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
|
||||||
lv_obj_set_size(backgroundLabel, 240, 240);
|
lv_obj_set_size(backgroundLabel, 240, 240);
|
||||||
lv_obj_set_pos(backgroundLabel, 0, 0);
|
lv_obj_set_pos(backgroundLabel, 0, 0);
|
||||||
lv_label_set_text_static(backgroundLabel, "");
|
lv_label_set_text_static(backgroundLabel, "");
|
||||||
|
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Steps::~Steps() {
|
Steps::~Steps() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Steps::Refresh() {
|
void Steps::Refresh() {
|
||||||
|
|
||||||
stepsCount = motionController.NbSteps();
|
stepsCount = motionController.NbSteps();
|
||||||
|
|
||||||
lv_label_set_text_fmt(lSteps, "%li", stepsCount);
|
lv_label_set_text_fmt(lSteps, "%li", stepsCount);
|
||||||
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20);
|
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||||
|
|
||||||
lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal()));
|
lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal()));
|
||||||
|
|
||||||
return running;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,24 +15,23 @@ namespace Pinetime {
|
||||||
namespace Screens {
|
namespace Screens {
|
||||||
|
|
||||||
class Steps : public Screen {
|
class Steps : public Screen {
|
||||||
public:
|
public:
|
||||||
Steps(DisplayApp* app, Controllers::MotionController& motionController, Controllers::Settings &settingsController);
|
Steps(DisplayApp* app, Controllers::MotionController& motionController, Controllers::Settings& settingsController);
|
||||||
~Steps() override;
|
~Steps() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Controllers::MotionController& motionController;
|
||||||
|
Controllers::Settings& settingsController;
|
||||||
|
|
||||||
Controllers::MotionController& motionController;
|
lv_obj_t* lSteps;
|
||||||
Controllers::Settings& settingsController;
|
lv_obj_t* lStepsIcon;
|
||||||
|
lv_obj_t* stepsArc;
|
||||||
|
|
||||||
lv_obj_t * lSteps;
|
uint32_t stepsCount;
|
||||||
lv_obj_t * lStepsIcon;
|
|
||||||
lv_obj_t * stepsArc;
|
|
||||||
|
|
||||||
uint32_t stepsCount;
|
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ static void stop_lap_event_handler(lv_obj_t* obj, lv_event_t event) {
|
||||||
StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
|
StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
|
||||||
: Screen(app),
|
: Screen(app),
|
||||||
systemTask {systemTask},
|
systemTask {systemTask},
|
||||||
running {true},
|
|
||||||
currentState {States::Init},
|
currentState {States::Init},
|
||||||
startTime {},
|
startTime {},
|
||||||
oldTimeElapsed {},
|
oldTimeElapsed {},
|
||||||
|
@ -101,9 +100,12 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
|
||||||
lv_obj_set_style_local_text_color(lapTwoText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
|
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_obj_align(lapTwoText, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 50, 55);
|
||||||
lv_label_set_text(lapTwoText, "");
|
lv_label_set_text(lapTwoText, "");
|
||||||
|
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
StopWatch::~StopWatch() {
|
StopWatch::~StopWatch() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
@ -149,7 +151,7 @@ void StopWatch::pause() {
|
||||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StopWatch::Refresh() {
|
void StopWatch::Refresh() {
|
||||||
if (currentState == States::Running) {
|
if (currentState == States::Running) {
|
||||||
timeElapsed = calculateDelta(startTime, xTaskGetTickCount());
|
timeElapsed = calculateDelta(startTime, xTaskGetTickCount());
|
||||||
currentTimeSeparated = convertTicksToTimeSegments((oldTimeElapsed + timeElapsed));
|
currentTimeSeparated = convertTicksToTimeSegments((oldTimeElapsed + timeElapsed));
|
||||||
|
@ -157,11 +159,10 @@ bool StopWatch::Refresh() {
|
||||||
lv_label_set_text_fmt(time, "%02d:%02d", currentTimeSeparated.mins, currentTimeSeparated.secs);
|
lv_label_set_text_fmt(time, "%02d:%02d", currentTimeSeparated.mins, currentTimeSeparated.secs);
|
||||||
lv_label_set_text_fmt(msecTime, "%02d", currentTimeSeparated.hundredths);
|
lv_label_set_text_fmt(msecTime, "%02d", currentTimeSeparated.hundredths);
|
||||||
}
|
}
|
||||||
return running;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
|
void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
|
||||||
if (event != LV_EVENT_PRESSED) {
|
if (event != LV_EVENT_CLICKED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (currentState == States::Init) {
|
if (currentState == States::Init) {
|
||||||
|
@ -174,7 +175,7 @@ void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
|
void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
|
||||||
if (event != LV_EVENT_PRESSED) {
|
if (event != LV_EVENT_CLICKED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If running, then this button is used to save laps
|
// If running, then this button is used to save laps
|
||||||
|
@ -196,8 +197,7 @@ void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
|
||||||
bool StopWatch::OnButtonPushed() {
|
bool StopWatch::OnButtonPushed() {
|
||||||
if (currentState == States::Running) {
|
if (currentState == States::Running) {
|
||||||
pause();
|
pause();
|
||||||
} else {
|
return true;
|
||||||
running = false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace Pinetime::Applications::Screens {
|
||||||
public:
|
public:
|
||||||
StopWatch(DisplayApp* app, System::SystemTask& systemTask);
|
StopWatch(DisplayApp* app, System::SystemTask& systemTask);
|
||||||
~StopWatch() override;
|
~StopWatch() override;
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
void playPauseBtnEventHandler(lv_event_t event);
|
void playPauseBtnEventHandler(lv_event_t event);
|
||||||
void stopLapBtnEventHandler(lv_event_t event);
|
void stopLapBtnEventHandler(lv_event_t event);
|
||||||
|
@ -77,7 +77,6 @@ namespace Pinetime::Applications::Screens {
|
||||||
private:
|
private:
|
||||||
Pinetime::System::SystemTask& systemTask;
|
Pinetime::System::SystemTask& systemTask;
|
||||||
TickType_t timeElapsed;
|
TickType_t timeElapsed;
|
||||||
bool running;
|
|
||||||
States currentState;
|
States currentState;
|
||||||
TickType_t startTime;
|
TickType_t startTime;
|
||||||
TickType_t oldTimeElapsed;
|
TickType_t oldTimeElapsed;
|
||||||
|
@ -86,5 +85,7 @@ namespace Pinetime::Applications::Screens {
|
||||||
int lapNr = 0;
|
int lapNr = 0;
|
||||||
lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap;
|
lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap;
|
||||||
lv_obj_t *lapOneText, *lapTwoText;
|
lv_obj_t *lapOneText, *lapTwoText;
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,13 +65,6 @@ SystemInfo::~SystemInfo() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemInfo::Refresh() {
|
|
||||||
if (running) {
|
|
||||||
screens.Refresh();
|
|
||||||
}
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SystemInfo::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
bool SystemInfo::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
return screens.OnTouchEvent(event);
|
return screens.OnTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -207,7 +200,7 @@ bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
|
std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
|
||||||
TaskStatus_t tasksStatus[7];
|
TaskStatus_t tasksStatus[10];
|
||||||
lv_obj_t* infoTask = lv_table_create(lv_scr_act(), NULL);
|
lv_obj_t* infoTask = lv_table_create(lv_scr_act(), NULL);
|
||||||
lv_table_set_col_cnt(infoTask, 4);
|
lv_table_set_col_cnt(infoTask, 4);
|
||||||
lv_table_set_row_cnt(infoTask, 8);
|
lv_table_set_row_cnt(infoTask, 8);
|
||||||
|
@ -222,9 +215,9 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
|
||||||
lv_table_set_cell_value(infoTask, 0, 3, "Free");
|
lv_table_set_cell_value(infoTask, 0, 3, "Free");
|
||||||
lv_table_set_col_width(infoTask, 3, 90);
|
lv_table_set_col_width(infoTask, 3, 90);
|
||||||
|
|
||||||
auto nb = uxTaskGetSystemState(tasksStatus, 7, nullptr);
|
auto nb = uxTaskGetSystemState(tasksStatus, sizeof(tasksStatus) / sizeof(tasksStatus[0]), nullptr);
|
||||||
std::sort(tasksStatus, tasksStatus + nb, sortById);
|
std::sort(tasksStatus, tasksStatus + nb, sortById);
|
||||||
for (uint8_t i = 0; i < nb; i++) {
|
for (uint8_t i = 0; i < nb && i < 7; i++) {
|
||||||
|
|
||||||
lv_table_set_cell_value(infoTask, i + 1, 0, std::to_string(tasksStatus[i].xTaskNumber).c_str());
|
lv_table_set_cell_value(infoTask, i + 1, 0, std::to_string(tasksStatus[i].xTaskNumber).c_str());
|
||||||
char state[2] = {0};
|
char state[2] = {0};
|
||||||
|
|
|
@ -30,7 +30,6 @@ namespace Pinetime {
|
||||||
Pinetime::Drivers::WatchdogView& watchdog,
|
Pinetime::Drivers::WatchdogView& watchdog,
|
||||||
Pinetime::Controllers::MotionController& motionController);
|
Pinetime::Controllers::MotionController& motionController);
|
||||||
~SystemInfo() override;
|
~SystemInfo() override;
|
||||||
bool Refresh() override;
|
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -95,6 +95,7 @@ Tile::Tile(uint8_t screenID,
|
||||||
lv_obj_set_style_local_pad_inner(btnm1, LV_BTNMATRIX_PART_BG, LV_STATE_DEFAULT, 10);
|
lv_obj_set_style_local_pad_inner(btnm1, LV_BTNMATRIX_PART_BG, LV_STATE_DEFAULT, 10);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 6; i++) {
|
for (uint8_t i = 0; i < 6; i++) {
|
||||||
|
lv_btnmatrix_set_btn_ctrl(btnm1, i, LV_BTNMATRIX_CTRL_CLICK_TRIG);
|
||||||
if (applications[i].application == Apps::None) {
|
if (applications[i].application == Apps::None) {
|
||||||
lv_btnmatrix_set_btn_ctrl(btnm1, i, LV_BTNMATRIX_CTRL_DISABLED);
|
lv_btnmatrix_set_btn_ctrl(btnm1, i, LV_BTNMATRIX_CTRL_DISABLED);
|
||||||
}
|
}
|
||||||
|
@ -122,10 +123,6 @@ void Tile::UpdateScreen() {
|
||||||
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
|
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tile::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) {
|
void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) {
|
||||||
if(obj != btnm1) return;
|
if(obj != btnm1) return;
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ namespace Pinetime {
|
||||||
|
|
||||||
~Tile() override;
|
~Tile() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
void UpdateScreen();
|
void UpdateScreen();
|
||||||
void OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId);
|
void OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId);
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,8 @@
|
||||||
#include "Symbols.h"
|
#include "Symbols.h"
|
||||||
#include "lvgl/lvgl.h"
|
#include "lvgl/lvgl.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
|
||||||
static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
|
static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
|
||||||
Timer* screen = static_cast<Timer*>(obj->user_data);
|
Timer* screen = static_cast<Timer*>(obj->user_data);
|
||||||
screen->OnButtonEvent(obj, event);
|
screen->OnButtonEvent(obj, event);
|
||||||
|
@ -22,7 +20,7 @@ void Timer::createButtons() {
|
||||||
lv_obj_set_width(btnMinutesUp, 60);
|
lv_obj_set_width(btnMinutesUp, 60);
|
||||||
txtMUp = lv_label_create(btnMinutesUp, nullptr);
|
txtMUp = lv_label_create(btnMinutesUp, nullptr);
|
||||||
lv_label_set_text(txtMUp, "+");
|
lv_label_set_text(txtMUp, "+");
|
||||||
|
|
||||||
btnMinutesDown = lv_btn_create(lv_scr_act(), nullptr);
|
btnMinutesDown = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
btnMinutesDown->user_data = this;
|
btnMinutesDown->user_data = this;
|
||||||
lv_obj_set_event_cb(btnMinutesDown, btnEventHandler);
|
lv_obj_set_event_cb(btnMinutesDown, btnEventHandler);
|
||||||
|
@ -31,7 +29,7 @@ void Timer::createButtons() {
|
||||||
lv_obj_set_width(btnMinutesDown, 60);
|
lv_obj_set_width(btnMinutesDown, 60);
|
||||||
txtMDown = lv_label_create(btnMinutesDown, nullptr);
|
txtMDown = lv_label_create(btnMinutesDown, nullptr);
|
||||||
lv_label_set_text(txtMDown, "-");
|
lv_label_set_text(txtMDown, "-");
|
||||||
|
|
||||||
btnSecondsUp = lv_btn_create(lv_scr_act(), nullptr);
|
btnSecondsUp = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
btnSecondsUp->user_data = this;
|
btnSecondsUp->user_data = this;
|
||||||
lv_obj_set_event_cb(btnSecondsUp, btnEventHandler);
|
lv_obj_set_event_cb(btnSecondsUp, btnEventHandler);
|
||||||
|
@ -40,7 +38,7 @@ void Timer::createButtons() {
|
||||||
lv_obj_set_width(btnSecondsUp, 60);
|
lv_obj_set_width(btnSecondsUp, 60);
|
||||||
txtSUp = lv_label_create(btnSecondsUp, nullptr);
|
txtSUp = lv_label_create(btnSecondsUp, nullptr);
|
||||||
lv_label_set_text(txtSUp, "+");
|
lv_label_set_text(txtSUp, "+");
|
||||||
|
|
||||||
btnSecondsDown = lv_btn_create(lv_scr_act(), nullptr);
|
btnSecondsDown = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
btnSecondsDown->user_data = this;
|
btnSecondsDown->user_data = this;
|
||||||
lv_obj_set_event_cb(btnSecondsDown, btnEventHandler);
|
lv_obj_set_event_cb(btnSecondsDown, btnEventHandler);
|
||||||
|
@ -49,24 +47,20 @@ void Timer::createButtons() {
|
||||||
lv_obj_set_width(btnSecondsDown, 60);
|
lv_obj_set_width(btnSecondsDown, 60);
|
||||||
txtSDown = lv_label_create(btnSecondsDown, nullptr);
|
txtSDown = lv_label_create(btnSecondsDown, nullptr);
|
||||||
lv_label_set_text(txtSDown, "-");
|
lv_label_set_text(txtSDown, "-");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
|
Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
|
||||||
: Screen(app),
|
: Screen(app), running {true}, timerController {timerController} {
|
||||||
running{true},
|
|
||||||
timerController{timerController} {
|
|
||||||
|
|
||||||
time = lv_label_create(lv_scr_act(), nullptr);
|
time = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
|
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_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
|
||||||
|
|
||||||
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
|
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
|
||||||
lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60);
|
lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60);
|
||||||
|
|
||||||
lv_obj_align(time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
|
lv_obj_align(time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
|
||||||
|
|
||||||
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
|
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
btnPlayPause->user_data = this;
|
btnPlayPause->user_data = this;
|
||||||
lv_obj_set_event_cb(btnPlayPause, btnEventHandler);
|
lv_obj_set_event_cb(btnPlayPause, btnEventHandler);
|
||||||
|
@ -79,20 +73,20 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
|
||||||
lv_label_set_text(txtPlayPause, Symbols::play);
|
lv_label_set_text(txtPlayPause, Symbols::play);
|
||||||
createButtons();
|
createButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer::~Timer() {
|
Timer::~Timer() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Timer::Refresh() {
|
void Timer::Refresh() {
|
||||||
if (timerController.IsRunning()) {
|
if (timerController.IsRunning()) {
|
||||||
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
|
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
|
||||||
lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60);
|
lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60);
|
||||||
}
|
}
|
||||||
return running;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
|
@ -105,11 +99,11 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
secondsToSet = seconds % 60;
|
secondsToSet = seconds % 60;
|
||||||
timerController.StopTimer();
|
timerController.StopTimer();
|
||||||
createButtons();
|
createButtons();
|
||||||
|
|
||||||
} else if (secondsToSet + minutesToSet > 0) {
|
} else if (secondsToSet + minutesToSet > 0) {
|
||||||
lv_label_set_text(txtPlayPause, Symbols::pause);
|
lv_label_set_text(txtPlayPause, Symbols::pause);
|
||||||
timerController.StartTimer((secondsToSet + minutesToSet * 60) * 1000);
|
timerController.StartTimer((secondsToSet + minutesToSet * 60) * 1000);
|
||||||
|
|
||||||
lv_obj_del(btnSecondsDown);
|
lv_obj_del(btnSecondsDown);
|
||||||
btnSecondsDown = nullptr;
|
btnSecondsDown = nullptr;
|
||||||
lv_obj_del(btnSecondsUp);
|
lv_obj_del(btnSecondsUp);
|
||||||
|
@ -118,7 +112,6 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
btnMinutesDown = nullptr;
|
btnMinutesDown = nullptr;
|
||||||
lv_obj_del(btnMinutesUp);
|
lv_obj_del(btnMinutesUp);
|
||||||
btnMinutesUp = nullptr;
|
btnMinutesUp = nullptr;
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!timerController.IsRunning()) {
|
if (!timerController.IsRunning()) {
|
||||||
|
@ -129,7 +122,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
minutesToSet++;
|
minutesToSet++;
|
||||||
}
|
}
|
||||||
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
|
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
|
||||||
|
|
||||||
} else if (obj == btnMinutesDown) {
|
} else if (obj == btnMinutesDown) {
|
||||||
if (minutesToSet == 0) {
|
if (minutesToSet == 0) {
|
||||||
minutesToSet = 59;
|
minutesToSet = 59;
|
||||||
|
@ -137,7 +130,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
minutesToSet--;
|
minutesToSet--;
|
||||||
}
|
}
|
||||||
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
|
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
|
||||||
|
|
||||||
} else if (obj == btnSecondsUp) {
|
} else if (obj == btnSecondsUp) {
|
||||||
if (secondsToSet >= 59) {
|
if (secondsToSet >= 59) {
|
||||||
secondsToSet = 0;
|
secondsToSet = 0;
|
||||||
|
@ -145,7 +138,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
secondsToSet++;
|
secondsToSet++;
|
||||||
}
|
}
|
||||||
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
|
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
|
||||||
|
|
||||||
} else if (obj == btnSecondsDown) {
|
} else if (obj == btnSecondsDown) {
|
||||||
if (secondsToSet == 0) {
|
if (secondsToSet == 0) {
|
||||||
secondsToSet = 59;
|
secondsToSet = 59;
|
||||||
|
@ -153,21 +146,16 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
secondsToSet--;
|
secondsToSet--;
|
||||||
}
|
}
|
||||||
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
|
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Timer::setDone() {
|
void Timer::setDone() {
|
||||||
lv_label_set_text(time, "00:00");
|
lv_label_set_text(time, "00:00");
|
||||||
lv_label_set_text(txtPlayPause, Symbols::play);
|
lv_label_set_text(txtPlayPause, Symbols::play);
|
||||||
secondsToSet = 0;
|
secondsToSet = 0;
|
||||||
minutesToSet = 0;
|
minutesToSet = 0;
|
||||||
createButtons();
|
createButtons();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,35 +8,32 @@
|
||||||
#include "components/timer/TimerController.h"
|
#include "components/timer/TimerController.h"
|
||||||
|
|
||||||
namespace Pinetime::Applications::Screens {
|
namespace Pinetime::Applications::Screens {
|
||||||
|
|
||||||
|
|
||||||
class Timer : public Screen {
|
class Timer : public Screen {
|
||||||
public:
|
public:
|
||||||
|
enum class Modes { Normal, Done };
|
||||||
enum class Modes {
|
|
||||||
Normal, Done
|
|
||||||
};
|
|
||||||
|
|
||||||
Timer(DisplayApp* app, Controllers::TimerController& timerController);
|
Timer(DisplayApp* app, Controllers::TimerController& timerController);
|
||||||
|
|
||||||
~Timer() override;
|
~Timer() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
void setDone();
|
void setDone();
|
||||||
|
|
||||||
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
|
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool running;
|
bool running;
|
||||||
uint8_t secondsToSet = 0;
|
uint8_t secondsToSet = 0;
|
||||||
uint8_t minutesToSet = 0;
|
uint8_t minutesToSet = 0;
|
||||||
Controllers::TimerController& timerController;
|
Controllers::TimerController& timerController;
|
||||||
|
|
||||||
void createButtons();
|
void createButtons();
|
||||||
|
|
||||||
lv_obj_t* time, * msecTime, * btnPlayPause, * txtPlayPause, * btnMinutesUp, * btnMinutesDown, * btnSecondsUp, * btnSecondsDown, * txtMUp,
|
lv_obj_t *time, *msecTime, *btnPlayPause, *txtPlayPause, *btnMinutesUp, *btnMinutesDown, *btnSecondsUp, *btnSecondsDown, *txtMUp,
|
||||||
* txtMDown, * txtSUp, * txtSDown;
|
*txtMDown, *txtSUp, *txtSDown;
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,10 +102,6 @@ Twos::~Twos() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Twos::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Twos::placeNewTile() {
|
bool Twos::placeNewTile() {
|
||||||
std::vector<std::pair<int, int>> availableCells;
|
std::vector<std::pair<int, int>> availableCells;
|
||||||
for (int row = 0; row < 4; row++) {
|
for (int row = 0; row < 4; row++) {
|
||||||
|
@ -295,4 +291,4 @@ void Twos::updateGridDisplay(Tile grid[][4]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ namespace Pinetime {
|
||||||
public:
|
public:
|
||||||
Twos(DisplayApp* app);
|
Twos(DisplayApp* app);
|
||||||
~Twos() override;
|
~Twos() override;
|
||||||
bool Refresh() override;
|
|
||||||
|
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
|
||||||
|
@ -36,4 +35,4 @@ namespace Pinetime {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,10 +118,13 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
|
||||||
lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false);
|
lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false);
|
||||||
lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace);
|
lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace);
|
||||||
|
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
UpdateClock();
|
UpdateClock();
|
||||||
}
|
}
|
||||||
|
|
||||||
WatchFaceAnalog::~WatchFaceAnalog() {
|
WatchFaceAnalog::~WatchFaceAnalog() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
|
|
||||||
lv_style_reset(&hour_line_style);
|
lv_style_reset(&hour_line_style);
|
||||||
lv_style_reset(&hour_line_style_trace);
|
lv_style_reset(&hour_line_style_trace);
|
||||||
lv_style_reset(&minute_line_style);
|
lv_style_reset(&minute_line_style);
|
||||||
|
@ -173,7 +176,7 @@ void WatchFaceAnalog::UpdateClock() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WatchFaceAnalog::Refresh() {
|
void WatchFaceAnalog::Refresh() {
|
||||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||||
if (batteryPercentRemaining.IsUpdated()) {
|
if (batteryPercentRemaining.IsUpdated()) {
|
||||||
auto batteryPercent = batteryPercentRemaining.Get();
|
auto batteryPercent = batteryPercentRemaining.Get();
|
||||||
|
@ -203,6 +206,4 @@ bool WatchFaceAnalog::Refresh() {
|
||||||
currentDay = day;
|
currentDay = day;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Pinetime {
|
||||||
|
|
||||||
~WatchFaceAnalog() override;
|
~WatchFaceAnalog() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t sHour, sMinute, sSecond;
|
uint8_t sHour, sMinute, sSecond;
|
||||||
|
@ -81,6 +81,8 @@ namespace Pinetime {
|
||||||
Controllers::Settings& settingsController;
|
Controllers::Settings& settingsController;
|
||||||
|
|
||||||
void UpdateClock();
|
void UpdateClock();
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,13 +91,17 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
|
||||||
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
|
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
|
||||||
lv_label_set_text(stepIcon, Symbols::shoe);
|
lv_label_set_text(stepIcon, Symbols::shoe);
|
||||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||||
|
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
WatchFaceDigital::~WatchFaceDigital() {
|
WatchFaceDigital::~WatchFaceDigital() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WatchFaceDigital::Refresh() {
|
void WatchFaceDigital::Refresh() {
|
||||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||||
if (batteryPercentRemaining.IsUpdated()) {
|
if (batteryPercentRemaining.IsUpdated()) {
|
||||||
auto batteryPercent = batteryPercentRemaining.Get();
|
auto batteryPercent = batteryPercentRemaining.Get();
|
||||||
|
@ -219,6 +223,4 @@ bool WatchFaceDigital::Refresh() {
|
||||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
|
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
|
||||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return running;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Pinetime {
|
||||||
Controllers::MotionController& motionController);
|
Controllers::MotionController& motionController);
|
||||||
~WatchFaceDigital() override;
|
~WatchFaceDigital() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char displayedChar[5] {};
|
char displayedChar[5] {};
|
||||||
|
@ -72,6 +72,8 @@ namespace Pinetime {
|
||||||
Controllers::Settings& settingsController;
|
Controllers::Settings& settingsController;
|
||||||
Controllers::HeartRateController& heartRateController;
|
Controllers::HeartRateController& heartRateController;
|
||||||
Controllers::MotionController& motionController;
|
Controllers::MotionController& motionController;
|
||||||
|
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,12 +128,12 @@ void QuickSettings::UpdateScreen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
||||||
if (object == btn2 && event == LV_EVENT_PRESSED) {
|
if (object == btn2 && event == LV_EVENT_CLICKED) {
|
||||||
|
|
||||||
running = false;
|
running = false;
|
||||||
app->StartApp(Apps::FlashLight, DisplayApp::FullRefreshDirections::None);
|
app->StartApp(Apps::FlashLight, DisplayApp::FullRefreshDirections::None);
|
||||||
|
|
||||||
} else if (object == btn1 && event == LV_EVENT_PRESSED) {
|
} else if (object == btn1 && event == LV_EVENT_CLICKED) {
|
||||||
|
|
||||||
brightness.Step();
|
brightness.Step();
|
||||||
lv_label_set_text_static(btn1_lvl, brightness.GetIcon());
|
lv_label_set_text_static(btn1_lvl, brightness.GetIcon());
|
||||||
|
@ -150,13 +150,9 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
||||||
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff);
|
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (object == btn4 && event == LV_EVENT_PRESSED) {
|
} else if (object == btn4 && event == LV_EVENT_CLICKED) {
|
||||||
running = false;
|
running = false;
|
||||||
settingsController.SetSettingsMenu(0);
|
settingsController.SetSettingsMenu(0);
|
||||||
app->StartApp(Apps::Settings, DisplayApp::FullRefreshDirections::Up);
|
app->StartApp(Apps::Settings, DisplayApp::FullRefreshDirections::Up);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QuickSettings::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
|
@ -27,8 +27,6 @@ namespace Pinetime {
|
||||||
|
|
||||||
~QuickSettings() override;
|
~QuickSettings() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
|
|
||||||
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
|
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
|
||||||
|
|
||||||
void UpdateScreen();
|
void UpdateScreen();
|
||||||
|
|
|
@ -80,12 +80,8 @@ SettingDisplay::~SettingDisplay() {
|
||||||
settingsController.SaveSettings();
|
settingsController.SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingDisplay::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
if (event == LV_EVENT_CLICKED) {
|
||||||
for (int i = 0; i < optionsTotal; i++) {
|
for (int i = 0; i < optionsTotal; i++) {
|
||||||
if (object == cbOption[i]) {
|
if (object == cbOption[i]) {
|
||||||
lv_checkbox_set_checked(cbOption[i], true);
|
lv_checkbox_set_checked(cbOption[i], true);
|
||||||
|
@ -110,4 +106,4 @@ void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ namespace Pinetime {
|
||||||
SettingDisplay(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
SettingDisplay(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||||
~SettingDisplay() override;
|
~SettingDisplay() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
318
src/displayapp/screens/settings/SettingPineTimeStyle.cpp
Normal file
318
src/displayapp/screens/settings/SettingPineTimeStyle.cpp
Normal file
|
@ -0,0 +1,318 @@
|
||||||
|
#include "SettingPineTimeStyle.h"
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
#include <displayapp/Colors.h>
|
||||||
|
#include "displayapp/DisplayApp.h"
|
||||||
|
#include "displayapp/screens/Symbols.h"
|
||||||
|
|
||||||
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
static void event_handler(lv_obj_t* obj, lv_event_t event) {
|
||||||
|
SettingPineTimeStyle* screen = static_cast<SettingPineTimeStyle*>(obj->user_data);
|
||||||
|
screen->UpdateSelected(obj, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
|
||||||
|
: Screen(app), settingsController {settingsController} {
|
||||||
|
timebar = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
|
||||||
|
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
|
lv_obj_set_size(timebar, 200, 240);
|
||||||
|
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
|
||||||
|
|
||||||
|
// Display the time
|
||||||
|
|
||||||
|
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
||||||
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
|
lv_label_set_text(timeDD1, "12");
|
||||||
|
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
|
||||||
|
|
||||||
|
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
||||||
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
|
lv_label_set_text(timeDD2, "34");
|
||||||
|
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
|
||||||
|
|
||||||
|
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
|
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
|
||||||
|
lv_label_set_text(timeAMPM, "A\nM");
|
||||||
|
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
|
||||||
|
|
||||||
|
// Create a 40px wide bar down the right side of the screen
|
||||||
|
|
||||||
|
sidebar = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
|
||||||
|
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
|
lv_obj_set_size(sidebar, 40, 240);
|
||||||
|
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
||||||
|
|
||||||
|
// Display icons
|
||||||
|
|
||||||
|
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
|
lv_label_set_text(batteryIcon, Symbols::batteryFull);
|
||||||
|
lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
|
||||||
|
|
||||||
|
bleIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
|
lv_label_set_text(bleIcon, Symbols::bluetooth);
|
||||||
|
lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25);
|
||||||
|
|
||||||
|
// Calendar icon
|
||||||
|
|
||||||
|
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
|
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
|
lv_obj_set_size(calendarOuter, 34, 34);
|
||||||
|
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
|
||||||
|
|
||||||
|
calendarInner = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff));
|
||||||
|
lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
|
lv_obj_set_size(calendarInner, 27, 27);
|
||||||
|
lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0);
|
||||||
|
|
||||||
|
calendarBar1 = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
|
lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
|
lv_obj_set_size(calendarBar1, 3, 12);
|
||||||
|
lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3);
|
||||||
|
|
||||||
|
calendarBar2 = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
|
lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
|
lv_obj_set_size(calendarBar2, 3, 12);
|
||||||
|
lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3);
|
||||||
|
|
||||||
|
calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
|
lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
|
lv_obj_set_size(calendarCrossBar1, 8, 3);
|
||||||
|
lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||||
|
|
||||||
|
calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
|
lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
|
lv_obj_set_size(calendarCrossBar2, 8, 3);
|
||||||
|
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||||
|
|
||||||
|
// Display date
|
||||||
|
|
||||||
|
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
|
lv_label_set_text(dateDayOfWeek, "THU");
|
||||||
|
lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
|
||||||
|
|
||||||
|
dateDay = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
|
lv_label_set_text(dateDay, "25");
|
||||||
|
lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
|
||||||
|
|
||||||
|
dateMonth = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
|
lv_label_set_text(dateMonth, "MAR");
|
||||||
|
lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
|
||||||
|
|
||||||
|
// Step count gauge
|
||||||
|
needle_colors[0] = LV_COLOR_WHITE;
|
||||||
|
stepGauge = lv_gauge_create(lv_scr_act(), nullptr);
|
||||||
|
lv_gauge_set_needle_count(stepGauge, 1, needle_colors);
|
||||||
|
lv_obj_set_size(stepGauge, 40, 40);
|
||||||
|
lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||||
|
lv_gauge_set_scale(stepGauge, 360, 11, 0);
|
||||||
|
lv_gauge_set_angle_offset(stepGauge, 180);
|
||||||
|
lv_gauge_set_critical_value(stepGauge, (100));
|
||||||
|
lv_gauge_set_range(stepGauge, 0, (100));
|
||||||
|
lv_gauge_set_value(stepGauge, 0, 0);
|
||||||
|
|
||||||
|
lv_obj_set_style_local_pad_right(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
||||||
|
lv_obj_set_style_local_pad_left(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
||||||
|
lv_obj_set_style_local_pad_bottom(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
||||||
|
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||||
|
lv_obj_set_style_local_scale_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
|
||||||
|
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
|
||||||
|
lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
|
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||||
|
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
|
||||||
|
lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
|
||||||
|
|
||||||
|
backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_click(backgroundLabel, true);
|
||||||
|
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
|
||||||
|
lv_obj_set_size(backgroundLabel, 240, 240);
|
||||||
|
lv_obj_set_pos(backgroundLabel, 0, 0);
|
||||||
|
lv_label_set_text(backgroundLabel, "");
|
||||||
|
|
||||||
|
btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnNextTime->user_data = this;
|
||||||
|
lv_obj_set_size(btnNextTime, 60, 60);
|
||||||
|
lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, -80);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
||||||
|
lv_obj_set_style_local_value_str(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
|
||||||
|
lv_obj_set_event_cb(btnNextTime, event_handler);
|
||||||
|
|
||||||
|
btnPrevTime = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnPrevTime->user_data = this;
|
||||||
|
lv_obj_set_size(btnPrevTime, 60, 60);
|
||||||
|
lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, -80);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
||||||
|
lv_obj_set_style_local_value_str(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
|
||||||
|
lv_obj_set_event_cb(btnPrevTime, event_handler);
|
||||||
|
|
||||||
|
btnNextBar = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnNextBar->user_data = this;
|
||||||
|
lv_obj_set_size(btnNextBar, 60, 60);
|
||||||
|
lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
||||||
|
lv_obj_set_style_local_value_str(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
|
||||||
|
lv_obj_set_event_cb(btnNextBar, event_handler);
|
||||||
|
|
||||||
|
btnPrevBar = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnPrevBar->user_data = this;
|
||||||
|
lv_obj_set_size(btnPrevBar, 60, 60);
|
||||||
|
lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
||||||
|
lv_obj_set_style_local_value_str(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
|
||||||
|
lv_obj_set_event_cb(btnPrevBar, event_handler);
|
||||||
|
|
||||||
|
btnNextBG = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnNextBG->user_data = this;
|
||||||
|
lv_obj_set_size(btnNextBG, 60, 60);
|
||||||
|
lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 80);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
||||||
|
lv_obj_set_style_local_value_str(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
|
||||||
|
lv_obj_set_event_cb(btnNextBG, event_handler);
|
||||||
|
|
||||||
|
btnPrevBG = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnPrevBG->user_data = this;
|
||||||
|
lv_obj_set_size(btnPrevBG, 60, 60);
|
||||||
|
lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 80);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
||||||
|
lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
|
||||||
|
lv_obj_set_event_cb(btnPrevBG, event_handler);
|
||||||
|
|
||||||
|
btnReset = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnReset->user_data = this;
|
||||||
|
lv_obj_set_size(btnReset, 60, 60);
|
||||||
|
lv_obj_align(btnReset, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
||||||
|
lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst");
|
||||||
|
lv_obj_set_event_cb(btnReset, event_handler);
|
||||||
|
|
||||||
|
btnRandom = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnRandom->user_data = this;
|
||||||
|
lv_obj_set_size(btnRandom, 60, 60);
|
||||||
|
lv_obj_align(btnRandom, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
||||||
|
lv_obj_set_style_local_value_str(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rnd");
|
||||||
|
lv_obj_set_event_cb(btnRandom, event_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingPineTimeStyle::~SettingPineTimeStyle() {
|
||||||
|
lv_obj_clean(lv_scr_act());
|
||||||
|
settingsController.SaveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
|
auto valueTime = settingsController.GetPTSColorTime();
|
||||||
|
auto valueBar = settingsController.GetPTSColorBar();
|
||||||
|
auto valueBG = settingsController.GetPTSColorBG();
|
||||||
|
|
||||||
|
if (event == LV_EVENT_CLICKED) {
|
||||||
|
if (object == btnNextTime) {
|
||||||
|
valueTime = GetNext(valueTime);
|
||||||
|
|
||||||
|
settingsController.SetPTSColorTime(valueTime);
|
||||||
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
||||||
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
||||||
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
||||||
|
}
|
||||||
|
if (object == btnPrevTime) {
|
||||||
|
valueTime = GetPrevious(valueTime);
|
||||||
|
settingsController.SetPTSColorTime(valueTime);
|
||||||
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
||||||
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
||||||
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
||||||
|
}
|
||||||
|
if (object == btnNextBar) {
|
||||||
|
valueBar = GetNext(valueBar);
|
||||||
|
if(valueBar == Controllers::Settings::Colors::Black)
|
||||||
|
valueBar = GetNext(valueBar);
|
||||||
|
settingsController.SetPTSColorBar(valueBar);
|
||||||
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
|
||||||
|
}
|
||||||
|
if (object == btnPrevBar) {
|
||||||
|
valueBar = GetPrevious(valueBar);
|
||||||
|
if(valueBar == Controllers::Settings::Colors::Black)
|
||||||
|
valueBar = GetPrevious(valueBar);
|
||||||
|
settingsController.SetPTSColorBar(valueBar);
|
||||||
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
|
||||||
|
}
|
||||||
|
if (object == btnNextBG) {
|
||||||
|
valueBG = GetNext(valueBG);
|
||||||
|
settingsController.SetPTSColorBG(valueBG);
|
||||||
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
||||||
|
}
|
||||||
|
if (object == btnPrevBG) {
|
||||||
|
valueBG = GetPrevious(valueBG);
|
||||||
|
settingsController.SetPTSColorBG(valueBG);
|
||||||
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
||||||
|
}
|
||||||
|
if (object == btnReset) {
|
||||||
|
settingsController.SetPTSColorTime(Controllers::Settings::Colors::Teal);
|
||||||
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
|
||||||
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
|
||||||
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
|
||||||
|
settingsController.SetPTSColorBar(Controllers::Settings::Colors::Teal);
|
||||||
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
|
||||||
|
settingsController.SetPTSColorBG(Controllers::Settings::Colors::Black);
|
||||||
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black));
|
||||||
|
}
|
||||||
|
if (object == btnRandom) {
|
||||||
|
uint8_t randTime = rand() % 17;
|
||||||
|
uint8_t randBar = rand() % 17;
|
||||||
|
uint8_t randBG = rand() % 17;
|
||||||
|
// Check if the time color is the same as its background, or if the sidebar is black. If so, change them to more useful values.
|
||||||
|
if (randTime == randBG) {
|
||||||
|
randBG += 1;
|
||||||
|
}
|
||||||
|
if (randBar == 3) {
|
||||||
|
randBar -= 1;
|
||||||
|
}
|
||||||
|
settingsController.SetPTSColorTime(static_cast<Controllers::Settings::Colors>(randTime));
|
||||||
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
|
||||||
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
|
||||||
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
|
||||||
|
settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(randBar));
|
||||||
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBar)));
|
||||||
|
settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(randBG));
|
||||||
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBG)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
|
||||||
|
auto colorAsInt = static_cast<uint8_t>(color);
|
||||||
|
Pinetime::Controllers::Settings::Colors nextColor;
|
||||||
|
if (colorAsInt < 16) {
|
||||||
|
nextColor = static_cast<Controllers::Settings::Colors>(colorAsInt + 1);
|
||||||
|
} else {
|
||||||
|
nextColor = static_cast<Controllers::Settings::Colors>(0);
|
||||||
|
}
|
||||||
|
return nextColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
|
||||||
|
auto colorAsInt = static_cast<uint8_t>(color);
|
||||||
|
Pinetime::Controllers::Settings::Colors prevColor;
|
||||||
|
|
||||||
|
if (colorAsInt > 0) {
|
||||||
|
prevColor = static_cast<Controllers::Settings::Colors>(colorAsInt - 1);
|
||||||
|
} else {
|
||||||
|
prevColor = static_cast<Controllers::Settings::Colors>(16);
|
||||||
|
}
|
||||||
|
return prevColor;
|
||||||
|
}
|
56
src/displayapp/screens/settings/SettingPineTimeStyle.h
Normal file
56
src/displayapp/screens/settings/SettingPineTimeStyle.h
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
#include "components/settings/Settings.h"
|
||||||
|
#include "displayapp/screens/Screen.h"
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
|
||||||
|
namespace Applications {
|
||||||
|
namespace Screens {
|
||||||
|
|
||||||
|
class SettingPineTimeStyle : public Screen{
|
||||||
|
public:
|
||||||
|
SettingPineTimeStyle(DisplayApp* app, Pinetime::Controllers::Settings &settingsController);
|
||||||
|
~SettingPineTimeStyle() override;
|
||||||
|
|
||||||
|
void UpdateSelected(lv_obj_t *object, lv_event_t event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Controllers::Settings& settingsController;
|
||||||
|
|
||||||
|
Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color);
|
||||||
|
Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color);
|
||||||
|
|
||||||
|
lv_obj_t * btnNextTime;
|
||||||
|
lv_obj_t * btnPrevTime;
|
||||||
|
lv_obj_t * btnNextBar;
|
||||||
|
lv_obj_t * btnPrevBar;
|
||||||
|
lv_obj_t * btnNextBG;
|
||||||
|
lv_obj_t * btnPrevBG;
|
||||||
|
lv_obj_t * btnReset;
|
||||||
|
lv_obj_t * btnRandom;
|
||||||
|
lv_obj_t * timebar;
|
||||||
|
lv_obj_t * sidebar;
|
||||||
|
lv_obj_t * timeDD1;
|
||||||
|
lv_obj_t * timeDD2;
|
||||||
|
lv_obj_t * timeAMPM;
|
||||||
|
lv_obj_t * dateDayOfWeek;
|
||||||
|
lv_obj_t * dateDay;
|
||||||
|
lv_obj_t * dateMonth;
|
||||||
|
lv_obj_t * backgroundLabel;
|
||||||
|
lv_obj_t * batteryIcon;
|
||||||
|
lv_obj_t * bleIcon;
|
||||||
|
lv_obj_t * calendarOuter;
|
||||||
|
lv_obj_t * calendarInner;
|
||||||
|
lv_obj_t * calendarBar1;
|
||||||
|
lv_obj_t * calendarBar2;
|
||||||
|
lv_obj_t * calendarCrossBar1;
|
||||||
|
lv_obj_t * calendarCrossBar2;
|
||||||
|
lv_obj_t * stepGauge;
|
||||||
|
lv_color_t needle_colors[1];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -70,11 +70,6 @@ SettingSteps::~SettingSteps() {
|
||||||
settingsController.SaveSettings();
|
settingsController.SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingSteps::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) {
|
void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) {
|
||||||
uint32_t value = settingsController.GetStepsGoal();
|
uint32_t value = settingsController.GetStepsGoal();
|
||||||
if(object == btnPlus && (event == LV_EVENT_PRESSED)) {
|
if(object == btnPlus && (event == LV_EVENT_PRESSED)) {
|
||||||
|
@ -95,4 +90,4 @@ void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,22 +10,19 @@ namespace Pinetime {
|
||||||
namespace Applications {
|
namespace Applications {
|
||||||
namespace Screens {
|
namespace Screens {
|
||||||
|
|
||||||
class SettingSteps : public Screen{
|
class SettingSteps : public Screen {
|
||||||
public:
|
public:
|
||||||
SettingSteps(DisplayApp* app, Pinetime::Controllers::Settings &settingsController);
|
SettingSteps(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||||
~SettingSteps() override;
|
~SettingSteps() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||||
void UpdateSelected(lv_obj_t *object, lv_event_t event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
Controllers::Settings& settingsController;
|
private:
|
||||||
|
Controllers::Settings& settingsController;
|
||||||
|
|
||||||
lv_obj_t * stepValue;
|
lv_obj_t* stepValue;
|
||||||
lv_obj_t * btnPlus;
|
lv_obj_t* btnPlus;
|
||||||
lv_obj_t * btnMinus;
|
lv_obj_t* btnMinus;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,10 +64,6 @@ SettingTimeFormat::~SettingTimeFormat() {
|
||||||
settingsController.SaveSettings();
|
settingsController.SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingTimeFormat::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
if (event == LV_EVENT_VALUE_CHANGED) {
|
||||||
for (int i = 0; i < optionsTotal; i++) {
|
for (int i = 0; i < optionsTotal; i++) {
|
||||||
|
@ -86,4 +82,4 @@ void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ namespace Pinetime {
|
||||||
SettingTimeFormat(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
SettingTimeFormat(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||||
~SettingTimeFormat() override;
|
~SettingTimeFormat() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -72,10 +72,6 @@ SettingWakeUp::~SettingWakeUp() {
|
||||||
settingsController.SaveSettings();
|
settingsController.SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingWakeUp::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingWakeUp::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
void SettingWakeUp::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
using WakeUpMode = Pinetime::Controllers::Settings::WakeUpMode;
|
using WakeUpMode = Pinetime::Controllers::Settings::WakeUpMode;
|
||||||
if (event == LV_EVENT_VALUE_CHANGED && !ignoringEvents) {
|
if (event == LV_EVENT_VALUE_CHANGED && !ignoringEvents) {
|
||||||
|
|
|
@ -15,7 +15,6 @@ namespace Pinetime {
|
||||||
SettingWakeUp(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
SettingWakeUp(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||||
~SettingWakeUp() override;
|
~SettingWakeUp() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -75,10 +75,6 @@ SettingWatchFace::~SettingWatchFace() {
|
||||||
settingsController.SaveSettings();
|
settingsController.SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingWatchFace::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
if (event == LV_EVENT_VALUE_CHANGED) {
|
||||||
for (uint8_t i = 0; i < optionsTotal; i++) {
|
for (uint8_t i = 0; i < optionsTotal; i++) {
|
||||||
|
|
|
@ -15,7 +15,6 @@ namespace Pinetime {
|
||||||
SettingWatchFace(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
SettingWatchFace(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||||
~SettingWatchFace() override;
|
~SettingWatchFace() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -18,6 +18,9 @@ Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controller
|
||||||
},
|
},
|
||||||
[this]() -> std::unique_ptr<Screen> {
|
[this]() -> std::unique_ptr<Screen> {
|
||||||
return CreateScreen2();
|
return CreateScreen2();
|
||||||
|
},
|
||||||
|
[this]() -> std::unique_ptr<Screen> {
|
||||||
|
return CreateScreen3();
|
||||||
}},
|
}},
|
||||||
Screens::ScreenListModes::UpDown} {
|
Screens::ScreenListModes::UpDown} {
|
||||||
}
|
}
|
||||||
|
@ -26,13 +29,6 @@ Settings::~Settings() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::Refresh() {
|
|
||||||
|
|
||||||
if (running)
|
|
||||||
running = screens.Refresh();
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
return screens.OnTouchEvent(event);
|
return screens.OnTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +42,7 @@ std::unique_ptr<Screen> Settings::CreateScreen1() {
|
||||||
{Symbols::home, "Watch face", Apps::SettingWatchFace},
|
{Symbols::home, "Watch face", Apps::SettingWatchFace},
|
||||||
}};
|
}};
|
||||||
|
|
||||||
return std::make_unique<Screens::List>(0, 2, app, settingsController, applications);
|
return std::make_unique<Screens::List>(0, 3, app, settingsController, applications);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Screen> Settings::CreateScreen2() {
|
std::unique_ptr<Screen> Settings::CreateScreen2() {
|
||||||
|
@ -58,5 +54,17 @@ std::unique_ptr<Screen> Settings::CreateScreen2() {
|
||||||
{Symbols::list, "About", Apps::SysInfo},
|
{Symbols::list, "About", Apps::SysInfo},
|
||||||
}};
|
}};
|
||||||
|
|
||||||
return std::make_unique<Screens::List>(1, 2, app, settingsController, applications);
|
return std::make_unique<Screens::List>(1, 3, app, settingsController, applications);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Screen> Settings::CreateScreen3() {
|
||||||
|
|
||||||
|
std::array<Screens::List::Applications, 4> applications {{
|
||||||
|
{Symbols::paintbrush, "PTS Colors", Apps::SettingPineTimeStyle},
|
||||||
|
{Symbols::none, "None", Apps::None},
|
||||||
|
{Symbols::none, "None", Apps::None},
|
||||||
|
{Symbols::none, "None", Apps::None},
|
||||||
|
}};
|
||||||
|
|
||||||
|
return std::make_unique<Screens::List>(2, 3, app, settingsController, applications);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,17 +14,16 @@ namespace Pinetime {
|
||||||
Settings(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
Settings(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||||
~Settings() override;
|
~Settings() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
|
|
||||||
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Controllers::Settings& settingsController;
|
Controllers::Settings& settingsController;
|
||||||
|
|
||||||
ScreenList<2> screens;
|
ScreenList<3> screens;
|
||||||
|
|
||||||
std::unique_ptr<Screen> CreateScreen1();
|
std::unique_ptr<Screen> CreateScreen1();
|
||||||
std::unique_ptr<Screen> CreateScreen2();
|
std::unique_ptr<Screen> CreateScreen2();
|
||||||
|
std::unique_ptr<Screen> CreateScreen3();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,38 +41,40 @@ void Cst816S::Init() {
|
||||||
*/
|
*/
|
||||||
static constexpr uint8_t motionMask = 0b00000101;
|
static constexpr uint8_t motionMask = 0b00000101;
|
||||||
twiMaster.Write(twiAddress, 0xEC, &motionMask, 1);
|
twiMaster.Write(twiAddress, 0xEC, &motionMask, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
[7] EnTest - Interrupt pin to test, enable automatic periodic issued after a low pulse.
|
||||||
|
[6] EnTouch - When a touch is detected, a periodic pulsed Low.
|
||||||
|
[5] EnChange - Upon detecting a touch state changes, pulsed Low.
|
||||||
|
[4] EnMotion - When the detected gesture is pulsed Low.
|
||||||
|
[0] OnceWLP - Press gesture only issue a pulse signal is low.
|
||||||
|
*/
|
||||||
|
static constexpr uint8_t irqCtl = 0b01110000;
|
||||||
|
twiMaster.Write(twiAddress, 0xFA, &irqCtl, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cst816S::TouchInfos Cst816S::GetTouchInfo() {
|
Cst816S::TouchInfos Cst816S::GetTouchInfo() {
|
||||||
Cst816S::TouchInfos info;
|
Cst816S::TouchInfos info;
|
||||||
|
|
||||||
auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData));
|
auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData));
|
||||||
if (ret != TwiMaster::ErrorCodes::NoError)
|
if (ret != TwiMaster::ErrorCodes::NoError) {
|
||||||
return {};
|
info.isValid = false;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
auto nbTouchPoints = touchData[2] & 0x0f;
|
auto nbTouchPoints = touchData[2] & 0x0f;
|
||||||
|
|
||||||
uint8_t i = 0;
|
auto xHigh = touchData[touchXHighIndex] & 0x0f;
|
||||||
|
auto xLow = touchData[touchXLowIndex];
|
||||||
uint8_t pointId = (touchData[touchIdIndex + (touchStep * i)]) >> 4;
|
|
||||||
if (nbTouchPoints == 0 && pointId == lastTouchId)
|
|
||||||
return info;
|
|
||||||
|
|
||||||
info.isTouch = true;
|
|
||||||
|
|
||||||
auto xHigh = touchData[touchXHighIndex + (touchStep * i)] & 0x0f;
|
|
||||||
auto xLow = touchData[touchXLowIndex + (touchStep * i)];
|
|
||||||
uint16_t x = (xHigh << 8) | xLow;
|
uint16_t x = (xHigh << 8) | xLow;
|
||||||
|
|
||||||
auto yHigh = touchData[touchYHighIndex + (touchStep * i)] & 0x0f;
|
auto yHigh = touchData[touchYHighIndex] & 0x0f;
|
||||||
auto yLow = touchData[touchYLowIndex + (touchStep * i)];
|
auto yLow = touchData[touchYLowIndex];
|
||||||
uint16_t y = (yHigh << 8) | yLow;
|
uint16_t y = (yHigh << 8) | yLow;
|
||||||
|
|
||||||
auto action = touchData[touchEventIndex + (touchStep * i)] >> 6; /* 0 = Down, 1 = Up, 2 = contact*/
|
|
||||||
|
|
||||||
info.x = x;
|
info.x = x;
|
||||||
info.y = y;
|
info.y = y;
|
||||||
info.action = action;
|
info.touching = (nbTouchPoints > 0);
|
||||||
info.gesture = static_cast<Gestures>(touchData[gestureIndex]);
|
info.gesture = static_cast<Gestures>(touchData[gestureIndex]);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
|
@ -91,4 +93,4 @@ void Cst816S::Sleep() {
|
||||||
void Cst816S::Wakeup() {
|
void Cst816S::Wakeup() {
|
||||||
Init();
|
Init();
|
||||||
NRF_LOG_INFO("[TOUCHPANEL] Wakeup");
|
NRF_LOG_INFO("[TOUCHPANEL] Wakeup");
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,9 @@ namespace Pinetime {
|
||||||
struct TouchInfos {
|
struct TouchInfos {
|
||||||
uint16_t x = 0;
|
uint16_t x = 0;
|
||||||
uint16_t y = 0;
|
uint16_t y = 0;
|
||||||
uint8_t action = 0;
|
|
||||||
uint8_t finger = 0;
|
|
||||||
uint8_t pressure = 0;
|
|
||||||
uint8_t area = 0;
|
|
||||||
Gestures gesture = Gestures::None;
|
Gestures gesture = Gestures::None;
|
||||||
bool isTouch = false;
|
bool touching = false;
|
||||||
|
bool isValid = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
Cst816S(TwiMaster& twiMaster, uint8_t twiAddress);
|
Cst816S(TwiMaster& twiMaster, uint8_t twiAddress);
|
||||||
|
@ -39,23 +36,23 @@ namespace Pinetime {
|
||||||
void Wakeup();
|
void Wakeup();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr uint8_t lastTouchId = 0x0f;
|
// Unused/Unavailable commented out
|
||||||
|
static constexpr uint8_t gestureIndex = 1;
|
||||||
static constexpr uint8_t touchPointNumIndex = 2;
|
static constexpr uint8_t touchPointNumIndex = 2;
|
||||||
static constexpr uint8_t touchMiscIndex = 8;
|
//static constexpr uint8_t touchEventIndex = 3;
|
||||||
static constexpr uint8_t touchXYIndex = 7;
|
|
||||||
static constexpr uint8_t touchEventIndex = 3;
|
|
||||||
static constexpr uint8_t touchXHighIndex = 3;
|
static constexpr uint8_t touchXHighIndex = 3;
|
||||||
static constexpr uint8_t touchXLowIndex = 4;
|
static constexpr uint8_t touchXLowIndex = 4;
|
||||||
|
//static constexpr uint8_t touchIdIndex = 5;
|
||||||
static constexpr uint8_t touchYHighIndex = 5;
|
static constexpr uint8_t touchYHighIndex = 5;
|
||||||
static constexpr uint8_t touchYLowIndex = 6;
|
static constexpr uint8_t touchYLowIndex = 6;
|
||||||
static constexpr uint8_t touchIdIndex = 5;
|
//static constexpr uint8_t touchStep = 6;
|
||||||
static constexpr uint8_t touchStep = 6;
|
//static constexpr uint8_t touchXYIndex = 7;
|
||||||
static constexpr uint8_t gestureIndex = 1;
|
//static constexpr uint8_t touchMiscIndex = 8;
|
||||||
|
|
||||||
uint8_t touchData[10];
|
uint8_t touchData[7];
|
||||||
TwiMaster& twiMaster;
|
TwiMaster& twiMaster;
|
||||||
uint8_t twiAddress;
|
uint8_t twiAddress;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,45 +8,39 @@ using namespace Pinetime::Drivers;
|
||||||
// TODO use shortcut to automatically send STOP when receive LastTX, for example
|
// TODO use shortcut to automatically send STOP when receive LastTX, for example
|
||||||
// TODO use DMA/IRQ
|
// TODO use DMA/IRQ
|
||||||
|
|
||||||
TwiMaster::TwiMaster(const Modules module, const Parameters& params) : module {module}, params {params} {
|
TwiMaster::TwiMaster(NRF_TWIM_Type* module, uint32_t frequency, uint8_t pinSda, uint8_t pinScl)
|
||||||
|
: module {module}, frequency {frequency}, pinSda {pinSda}, pinScl {pinScl} {
|
||||||
|
}
|
||||||
|
|
||||||
|
void TwiMaster::ConfigurePins() const {
|
||||||
|
NRF_GPIO->PIN_CNF[pinScl] =
|
||||||
|
(GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) |
|
||||||
|
(GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
|
||||||
|
(GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) |
|
||||||
|
(GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
|
||||||
|
(GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
|
||||||
|
|
||||||
|
NRF_GPIO->PIN_CNF[pinSda] =
|
||||||
|
(GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) |
|
||||||
|
(GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
|
||||||
|
(GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) |
|
||||||
|
(GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
|
||||||
|
(GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwiMaster::Init() {
|
void TwiMaster::Init() {
|
||||||
if(mutex == nullptr)
|
if (mutex == nullptr) {
|
||||||
mutex = xSemaphoreCreateBinary();
|
mutex = xSemaphoreCreateBinary();
|
||||||
|
|
||||||
NRF_GPIO->PIN_CNF[params.pinScl] =
|
|
||||||
((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
|
|
||||||
((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
|
|
||||||
((uint32_t) GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
|
|
||||||
|
|
||||||
NRF_GPIO->PIN_CNF[params.pinSda] =
|
|
||||||
((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
|
|
||||||
((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
|
|
||||||
((uint32_t) GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
|
|
||||||
|
|
||||||
switch (module) {
|
|
||||||
case Modules::TWIM1:
|
|
||||||
twiBaseAddress = NRF_TWIM1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (static_cast<Frequencies>(params.frequency)) {
|
ConfigurePins();
|
||||||
case Frequencies::Khz100:
|
|
||||||
twiBaseAddress->FREQUENCY = TWIM_FREQUENCY_FREQUENCY_K100;
|
|
||||||
break;
|
|
||||||
case Frequencies::Khz250:
|
|
||||||
twiBaseAddress->FREQUENCY = TWIM_FREQUENCY_FREQUENCY_K250;
|
|
||||||
break;
|
|
||||||
case Frequencies::Khz400:
|
|
||||||
twiBaseAddress->FREQUENCY = TWIM_FREQUENCY_FREQUENCY_K400;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
twiBaseAddress->PSEL.SCL = params.pinScl;
|
twiBaseAddress = module;
|
||||||
twiBaseAddress->PSEL.SDA = params.pinSda;
|
|
||||||
|
twiBaseAddress->FREQUENCY = frequency;
|
||||||
|
|
||||||
|
twiBaseAddress->PSEL.SCL = pinScl;
|
||||||
|
twiBaseAddress->PSEL.SDA = pinSda;
|
||||||
twiBaseAddress->EVENTS_LASTRX = 0;
|
twiBaseAddress->EVENTS_LASTRX = 0;
|
||||||
twiBaseAddress->EVENTS_STOPPED = 0;
|
twiBaseAddress->EVENTS_STOPPED = 0;
|
||||||
twiBaseAddress->EVENTS_LASTTX = 0;
|
twiBaseAddress->EVENTS_LASTTX = 0;
|
||||||
|
@ -57,19 +51,15 @@ void TwiMaster::Init() {
|
||||||
|
|
||||||
twiBaseAddress->ENABLE = (TWIM_ENABLE_ENABLE_Enabled << TWIM_ENABLE_ENABLE_Pos);
|
twiBaseAddress->ENABLE = (TWIM_ENABLE_ENABLE_Enabled << TWIM_ENABLE_ENABLE_Pos);
|
||||||
|
|
||||||
/* // IRQ
|
|
||||||
NVIC_ClearPendingIRQ(_IRQn);
|
|
||||||
NVIC_SetPriority(_IRQn, 2);
|
|
||||||
NVIC_EnableIRQ(_IRQn);
|
|
||||||
*/
|
|
||||||
|
|
||||||
xSemaphoreGive(mutex);
|
xSemaphoreGive(mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
TwiMaster::ErrorCodes TwiMaster::Read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* data, size_t size) {
|
TwiMaster::ErrorCodes TwiMaster::Read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* data, size_t size) {
|
||||||
xSemaphoreTake(mutex, portMAX_DELAY);
|
xSemaphoreTake(mutex, portMAX_DELAY);
|
||||||
|
Wakeup();
|
||||||
auto ret = Write(deviceAddress, ®isterAddress, 1, false);
|
auto ret = Write(deviceAddress, ®isterAddress, 1, false);
|
||||||
ret = Read(deviceAddress, data, size, true);
|
ret = Read(deviceAddress, data, size, true);
|
||||||
|
Sleep();
|
||||||
xSemaphoreGive(mutex);
|
xSemaphoreGive(mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -77,9 +67,11 @@ TwiMaster::ErrorCodes TwiMaster::Read(uint8_t deviceAddress, uint8_t registerAdd
|
||||||
TwiMaster::ErrorCodes TwiMaster::Write(uint8_t deviceAddress, uint8_t registerAddress, const uint8_t* data, size_t size) {
|
TwiMaster::ErrorCodes TwiMaster::Write(uint8_t deviceAddress, uint8_t registerAddress, const uint8_t* data, size_t size) {
|
||||||
ASSERT(size <= maxDataSize);
|
ASSERT(size <= maxDataSize);
|
||||||
xSemaphoreTake(mutex, portMAX_DELAY);
|
xSemaphoreTake(mutex, portMAX_DELAY);
|
||||||
|
Wakeup();
|
||||||
internalBuffer[0] = registerAddress;
|
internalBuffer[0] = registerAddress;
|
||||||
std::memcpy(internalBuffer + 1, data, size);
|
std::memcpy(internalBuffer + 1, data, size);
|
||||||
auto ret = Write(deviceAddress, internalBuffer, size + 1, true);
|
auto ret = Write(deviceAddress, internalBuffer, size + 1, true);
|
||||||
|
Sleep();
|
||||||
xSemaphoreGive(mutex);
|
xSemaphoreGive(mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -170,17 +162,11 @@ TwiMaster::ErrorCodes TwiMaster::Write(uint8_t deviceAddress, const uint8_t* dat
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwiMaster::Sleep() {
|
void TwiMaster::Sleep() {
|
||||||
while (twiBaseAddress->ENABLE != 0) {
|
twiBaseAddress->ENABLE = (TWIM_ENABLE_ENABLE_Disabled << TWIM_ENABLE_ENABLE_Pos);
|
||||||
twiBaseAddress->ENABLE = (TWIM_ENABLE_ENABLE_Disabled << TWIM_ENABLE_ENABLE_Pos);
|
|
||||||
}
|
|
||||||
nrf_gpio_cfg_default(6);
|
|
||||||
nrf_gpio_cfg_default(7);
|
|
||||||
NRF_LOG_INFO("[TWIMASTER] Sleep");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwiMaster::Wakeup() {
|
void TwiMaster::Wakeup() {
|
||||||
Init();
|
twiBaseAddress->ENABLE = (TWIM_ENABLE_ENABLE_Enabled << TWIM_ENABLE_ENABLE_Pos);
|
||||||
NRF_LOG_INFO("[TWIMASTER] Wakeup");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sometimes, the TWIM device just freeze and never set the event EVENTS_LASTTX.
|
/* Sometimes, the TWIM device just freeze and never set the event EVENTS_LASTTX.
|
||||||
|
@ -190,20 +176,10 @@ void TwiMaster::Wakeup() {
|
||||||
* */
|
* */
|
||||||
void TwiMaster::FixHwFreezed() {
|
void TwiMaster::FixHwFreezed() {
|
||||||
NRF_LOG_INFO("I2C device frozen, reinitializing it!");
|
NRF_LOG_INFO("I2C device frozen, reinitializing it!");
|
||||||
// Disable I²C
|
|
||||||
uint32_t twi_state = NRF_TWI1->ENABLE;
|
uint32_t twi_state = NRF_TWI1->ENABLE;
|
||||||
twiBaseAddress->ENABLE = TWIM_ENABLE_ENABLE_Disabled << TWI_ENABLE_ENABLE_Pos;
|
|
||||||
|
|
||||||
NRF_GPIO->PIN_CNF[params.pinScl] =
|
Sleep();
|
||||||
((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
|
|
||||||
((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) |
|
|
||||||
((uint32_t) GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
|
|
||||||
|
|
||||||
NRF_GPIO->PIN_CNF[params.pinSda] =
|
|
||||||
((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
|
|
||||||
((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) |
|
|
||||||
((uint32_t) GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
|
|
||||||
|
|
||||||
// Re-enable I²C
|
|
||||||
twiBaseAddress->ENABLE = twi_state;
|
twiBaseAddress->ENABLE = twi_state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,16 +8,9 @@ namespace Pinetime {
|
||||||
namespace Drivers {
|
namespace Drivers {
|
||||||
class TwiMaster {
|
class TwiMaster {
|
||||||
public:
|
public:
|
||||||
enum class Modules { TWIM1 };
|
|
||||||
enum class Frequencies { Khz100, Khz250, Khz400 };
|
|
||||||
enum class ErrorCodes { NoError, TransactionFailed };
|
enum class ErrorCodes { NoError, TransactionFailed };
|
||||||
struct Parameters {
|
|
||||||
uint32_t frequency;
|
|
||||||
uint8_t pinSda;
|
|
||||||
uint8_t pinScl;
|
|
||||||
};
|
|
||||||
|
|
||||||
TwiMaster(const Modules module, const Parameters& params);
|
TwiMaster(NRF_TWIM_Type* module, uint32_t frequency, uint8_t pinSda, uint8_t pinScl);
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
ErrorCodes Read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, size_t size);
|
ErrorCodes Read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, size_t size);
|
||||||
|
@ -30,10 +23,14 @@ namespace Pinetime {
|
||||||
ErrorCodes Read(uint8_t deviceAddress, uint8_t* buffer, size_t size, bool stop);
|
ErrorCodes Read(uint8_t deviceAddress, uint8_t* buffer, size_t size, bool stop);
|
||||||
ErrorCodes Write(uint8_t deviceAddress, const uint8_t* data, size_t size, bool stop);
|
ErrorCodes Write(uint8_t deviceAddress, const uint8_t* data, size_t size, bool stop);
|
||||||
void FixHwFreezed();
|
void FixHwFreezed();
|
||||||
|
void ConfigurePins() const;
|
||||||
|
|
||||||
NRF_TWIM_Type* twiBaseAddress;
|
NRF_TWIM_Type* twiBaseAddress;
|
||||||
SemaphoreHandle_t mutex = nullptr;
|
SemaphoreHandle_t mutex = nullptr;
|
||||||
const Modules module;
|
NRF_TWIM_Type* module;
|
||||||
const Parameters params;
|
uint32_t frequency;
|
||||||
|
uint8_t pinSda;
|
||||||
|
uint8_t pinScl;
|
||||||
static constexpr uint8_t maxDataSize {16};
|
static constexpr uint8_t maxDataSize {16};
|
||||||
static constexpr uint8_t registerSize {1};
|
static constexpr uint8_t registerSize {1};
|
||||||
uint8_t internalBuffer[maxDataSize + registerSize];
|
uint8_t internalBuffer[maxDataSize + registerSize];
|
||||||
|
@ -41,4 +38,4 @@ namespace Pinetime {
|
||||||
static constexpr uint32_t HwFreezedDelay {161000};
|
static constexpr uint32_t HwFreezedDelay {161000};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -46,6 +46,7 @@
|
||||||
#include "drivers/PinMap.h"
|
#include "drivers/PinMap.h"
|
||||||
#include "systemtask/SystemTask.h"
|
#include "systemtask/SystemTask.h"
|
||||||
#include "drivers/PinMap.h"
|
#include "drivers/PinMap.h"
|
||||||
|
#include "touchhandler/TouchHandler.h"
|
||||||
|
|
||||||
#if NRF_LOG_ENABLED
|
#if NRF_LOG_ENABLED
|
||||||
#include "logging/NrfLogger.h"
|
#include "logging/NrfLogger.h"
|
||||||
|
@ -77,8 +78,7 @@ Pinetime::Drivers::SpiNorFlash spiNorFlash {flashSpi};
|
||||||
// respecting correct timings. According to erratas heet, this magic value makes it run
|
// respecting correct timings. According to erratas heet, this magic value makes it run
|
||||||
// at ~390Khz with correct timings.
|
// at ~390Khz with correct timings.
|
||||||
static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000};
|
static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000};
|
||||||
Pinetime::Drivers::TwiMaster twiMaster {Pinetime::Drivers::TwiMaster::Modules::TWIM1,
|
Pinetime::Drivers::TwiMaster twiMaster {NRF_TWIM1, MaxTwiFrequencyWithoutHardwareBug, Pinetime::PinMap::TwiSda, Pinetime::PinMap::TwiScl};
|
||||||
Pinetime::Drivers::TwiMaster::Parameters {MaxTwiFrequencyWithoutHardwareBug, Pinetime::PinMap::TwiSda, Pinetime::PinMap::TwiScl}};
|
|
||||||
Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress};
|
Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress};
|
||||||
#ifdef PINETIME_IS_RECOVERY
|
#ifdef PINETIME_IS_RECOVERY
|
||||||
static constexpr bool isFactory = true;
|
static constexpr bool isFactory = true;
|
||||||
|
@ -111,6 +111,7 @@ Pinetime::Drivers::WatchdogView watchdogView(watchdog);
|
||||||
Pinetime::Controllers::NotificationManager notificationManager;
|
Pinetime::Controllers::NotificationManager notificationManager;
|
||||||
Pinetime::Controllers::MotionController motionController;
|
Pinetime::Controllers::MotionController motionController;
|
||||||
Pinetime::Controllers::TimerController timerController;
|
Pinetime::Controllers::TimerController timerController;
|
||||||
|
Pinetime::Controllers::TouchHandler touchHandler(touchPanel, lvgl);
|
||||||
|
|
||||||
Pinetime::Controllers::FS fs {spiNorFlash};
|
Pinetime::Controllers::FS fs {spiNorFlash};
|
||||||
Pinetime::Controllers::Settings settingsController {fs};
|
Pinetime::Controllers::Settings settingsController {fs};
|
||||||
|
@ -129,7 +130,8 @@ Pinetime::Applications::DisplayApp displayApp(lcd,
|
||||||
settingsController,
|
settingsController,
|
||||||
motorController,
|
motorController,
|
||||||
motionController,
|
motionController,
|
||||||
timerController);
|
timerController,
|
||||||
|
touchHandler);
|
||||||
|
|
||||||
Pinetime::System::SystemTask systemTask(spi,
|
Pinetime::System::SystemTask systemTask(spi,
|
||||||
lcd,
|
lcd,
|
||||||
|
@ -151,7 +153,8 @@ Pinetime::System::SystemTask systemTask(spi,
|
||||||
heartRateController,
|
heartRateController,
|
||||||
displayApp,
|
displayApp,
|
||||||
heartRateApp,
|
heartRateApp,
|
||||||
fs);
|
fs,
|
||||||
|
touchHandler);
|
||||||
|
|
||||||
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
|
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
|
||||||
if (pin == Pinetime::PinMap::Cst816sIrq) {
|
if (pin == Pinetime::PinMap::Cst816sIrq) {
|
||||||
|
@ -316,6 +319,7 @@ int main(void) {
|
||||||
lvgl.Init();
|
lvgl.Init();
|
||||||
|
|
||||||
systemTask.Start();
|
systemTask.Start();
|
||||||
|
|
||||||
nimble_port_init();
|
nimble_port_init();
|
||||||
|
|
||||||
vTaskStartScheduler();
|
vTaskStartScheduler();
|
||||||
|
|
|
@ -69,7 +69,8 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi,
|
||||||
Pinetime::Controllers::HeartRateController& heartRateController,
|
Pinetime::Controllers::HeartRateController& heartRateController,
|
||||||
Pinetime::Applications::DisplayApp& displayApp,
|
Pinetime::Applications::DisplayApp& displayApp,
|
||||||
Pinetime::Applications::HeartRateTask& heartRateApp,
|
Pinetime::Applications::HeartRateTask& heartRateApp,
|
||||||
Pinetime::Controllers::FS& fs)
|
Pinetime::Controllers::FS& fs,
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler)
|
||||||
: spi {spi},
|
: spi {spi},
|
||||||
lcd {lcd},
|
lcd {lcd},
|
||||||
spiNorFlash {spiNorFlash},
|
spiNorFlash {spiNorFlash},
|
||||||
|
@ -81,18 +82,18 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi,
|
||||||
dateTimeController {dateTimeController},
|
dateTimeController {dateTimeController},
|
||||||
timerController {timerController},
|
timerController {timerController},
|
||||||
watchdog {watchdog},
|
watchdog {watchdog},
|
||||||
notificationManager{notificationManager},
|
notificationManager {notificationManager},
|
||||||
motorController {motorController},
|
motorController {motorController},
|
||||||
heartRateSensor {heartRateSensor},
|
heartRateSensor {heartRateSensor},
|
||||||
motionSensor {motionSensor},
|
motionSensor {motionSensor},
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
heartRateController{heartRateController},
|
heartRateController {heartRateController},
|
||||||
motionController{motionController},
|
motionController {motionController},
|
||||||
displayApp{displayApp},
|
displayApp {displayApp},
|
||||||
heartRateApp(heartRateApp),
|
heartRateApp(heartRateApp),
|
||||||
fs{fs},
|
fs {fs},
|
||||||
|
touchHandler {touchHandler},
|
||||||
nimbleController(*this, bleController, dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController) {
|
nimbleController(*this, bleController, dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTask::Start() {
|
void SystemTask::Start() {
|
||||||
|
@ -118,7 +119,7 @@ void SystemTask::Work() {
|
||||||
spi.Init();
|
spi.Init();
|
||||||
spiNorFlash.Init();
|
spiNorFlash.Init();
|
||||||
spiNorFlash.Wakeup();
|
spiNorFlash.Wakeup();
|
||||||
|
|
||||||
fs.Init();
|
fs.Init();
|
||||||
|
|
||||||
nimbleController.Init();
|
nimbleController.Init();
|
||||||
|
@ -221,7 +222,6 @@ void SystemTask::Work() {
|
||||||
break;
|
break;
|
||||||
case Messages::GoToRunning:
|
case Messages::GoToRunning:
|
||||||
spi.Wakeup();
|
spi.Wakeup();
|
||||||
twiMaster.Wakeup();
|
|
||||||
|
|
||||||
// Double Tap needs the touch screen to be in normal mode
|
// Double Tap needs the touch screen to be in normal mode
|
||||||
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
||||||
|
@ -242,14 +242,14 @@ void SystemTask::Work() {
|
||||||
isDimmed = false;
|
isDimmed = false;
|
||||||
break;
|
break;
|
||||||
case Messages::TouchWakeUp: {
|
case Messages::TouchWakeUp: {
|
||||||
twiMaster.Wakeup();
|
if(touchHandler.GetNewTouchInfo()) {
|
||||||
auto touchInfo = touchPanel.GetTouchInfo();
|
auto gesture = touchHandler.GestureGet();
|
||||||
twiMaster.Sleep();
|
if (gesture != Pinetime::Drivers::Cst816S::Gestures::None and ((gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap and
|
||||||
if (touchInfo.isTouch and ((touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap and
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) or
|
||||||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) or
|
(gesture == Pinetime::Drivers::Cst816S::Gestures::SingleTap and
|
||||||
(touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::SingleTap and
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
|
||||||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
|
GoToRunning();
|
||||||
GoToRunning();
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case Messages::GoToSleep:
|
case Messages::GoToSleep:
|
||||||
|
@ -296,6 +296,9 @@ void SystemTask::Work() {
|
||||||
xTimerStart(dimTimer, 0);
|
xTimerStart(dimTimer, 0);
|
||||||
break;
|
break;
|
||||||
case Messages::OnTouchEvent:
|
case Messages::OnTouchEvent:
|
||||||
|
if (touchHandler.GetNewTouchInfo()) {
|
||||||
|
touchHandler.UpdateLvglTouchPoint();
|
||||||
|
}
|
||||||
ReloadIdleTimer();
|
ReloadIdleTimer();
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
|
||||||
break;
|
break;
|
||||||
|
@ -316,7 +319,6 @@ void SystemTask::Work() {
|
||||||
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
||||||
touchPanel.Sleep();
|
touchPanel.Sleep();
|
||||||
}
|
}
|
||||||
twiMaster.Sleep();
|
|
||||||
|
|
||||||
isSleeping = true;
|
isSleeping = true;
|
||||||
isGoingToSleep = false;
|
isGoingToSleep = false;
|
||||||
|
@ -328,7 +330,7 @@ void SystemTask::Work() {
|
||||||
break;
|
break;
|
||||||
case Messages::OnChargingEvent:
|
case Messages::OnChargingEvent:
|
||||||
motorController.RunForDuration(15);
|
motorController.RunForDuration(15);
|
||||||
// Battery level is updated on every message - there's no need to do anything
|
// Battery level is updated on every message - there's no need to do anything
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -368,17 +370,12 @@ void SystemTask::UpdateMotion() {
|
||||||
if (isSleeping && !settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist))
|
if (isSleeping && !settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isSleeping)
|
|
||||||
twiMaster.Wakeup();
|
|
||||||
|
|
||||||
if (stepCounterMustBeReset) {
|
if (stepCounterMustBeReset) {
|
||||||
motionSensor.ResetStepCounter();
|
motionSensor.ResetStepCounter();
|
||||||
stepCounterMustBeReset = false;
|
stepCounterMustBeReset = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto motionValues = motionSensor.Process();
|
auto motionValues = motionSensor.Process();
|
||||||
if (isSleeping)
|
|
||||||
twiMaster.Sleep();
|
|
||||||
|
|
||||||
motionController.IsSensorOk(motionSensor.IsOk());
|
motionController.IsSensorOk(motionSensor.IsOk());
|
||||||
motionController.Update(motionValues.x, motionValues.y, motionValues.z, motionValues.steps);
|
motionController.Update(motionValues.x, motionValues.y, motionValues.z, motionValues.steps);
|
||||||
|
@ -426,14 +423,13 @@ void SystemTask::PushMessage(System::Messages msg) {
|
||||||
isGoingToSleep = true;
|
isGoingToSleep = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(in_isr()) {
|
if (in_isr()) {
|
||||||
BaseType_t xHigherPriorityTaskWoken;
|
BaseType_t xHigherPriorityTaskWoken;
|
||||||
xHigherPriorityTaskWoken = pdFALSE;
|
xHigherPriorityTaskWoken = pdFALSE;
|
||||||
xQueueSendFromISR(systemTasksMsgQueue, &msg, &xHigherPriorityTaskWoken);
|
xQueueSendFromISR(systemTasksMsgQueue, &msg, &xHigherPriorityTaskWoken);
|
||||||
if (xHigherPriorityTaskWoken) {
|
if (xHigherPriorityTaskWoken) {
|
||||||
/* Actual macro used here is port specific. */
|
/* Actual macro used here is port specific. */
|
||||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
xQueueSend(systemTasksMsgQueue, &msg, portMAX_DELAY);
|
xQueueSend(systemTasksMsgQueue, &msg, portMAX_DELAY);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "components/motor/MotorController.h"
|
#include "components/motor/MotorController.h"
|
||||||
#include "components/timer/TimerController.h"
|
#include "components/timer/TimerController.h"
|
||||||
#include "components/fs/FS.h"
|
#include "components/fs/FS.h"
|
||||||
|
#include "touchhandler/TouchHandler.h"
|
||||||
|
|
||||||
#ifdef PINETIME_IS_RECOVERY
|
#ifdef PINETIME_IS_RECOVERY
|
||||||
#include "displayapp/DisplayAppRecovery.h"
|
#include "displayapp/DisplayAppRecovery.h"
|
||||||
|
@ -25,7 +26,7 @@
|
||||||
#else
|
#else
|
||||||
#include "components/settings/Settings.h"
|
#include "components/settings/Settings.h"
|
||||||
#include "displayapp/DisplayApp.h"
|
#include "displayapp/DisplayApp.h"
|
||||||
#include "displayapp/LittleVgl.h"
|
#include "displayapp/LittleVgl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "drivers/Watchdog.h"
|
#include "drivers/Watchdog.h"
|
||||||
|
@ -40,6 +41,9 @@ namespace Pinetime {
|
||||||
class TwiMaster;
|
class TwiMaster;
|
||||||
class Hrs3300;
|
class Hrs3300;
|
||||||
}
|
}
|
||||||
|
namespace Controllers {
|
||||||
|
class TouchHandler;
|
||||||
|
}
|
||||||
namespace System {
|
namespace System {
|
||||||
class SystemTask {
|
class SystemTask {
|
||||||
public:
|
public:
|
||||||
|
@ -63,7 +67,8 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::HeartRateController& heartRateController,
|
Pinetime::Controllers::HeartRateController& heartRateController,
|
||||||
Pinetime::Applications::DisplayApp& displayApp,
|
Pinetime::Applications::DisplayApp& displayApp,
|
||||||
Pinetime::Applications::HeartRateTask& heartRateApp,
|
Pinetime::Applications::HeartRateTask& heartRateApp,
|
||||||
Pinetime::Controllers::FS& fs);
|
Pinetime::Controllers::FS& fs,
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler);
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
void PushMessage(Messages msg);
|
void PushMessage(Messages msg);
|
||||||
|
@ -93,7 +98,6 @@ namespace Pinetime {
|
||||||
Pinetime::Components::LittleVgl& lvgl;
|
Pinetime::Components::LittleVgl& lvgl;
|
||||||
Pinetime::Controllers::Battery& batteryController;
|
Pinetime::Controllers::Battery& batteryController;
|
||||||
|
|
||||||
|
|
||||||
Pinetime::Controllers::Ble& bleController;
|
Pinetime::Controllers::Ble& bleController;
|
||||||
Pinetime::Controllers::DateTime& dateTimeController;
|
Pinetime::Controllers::DateTime& dateTimeController;
|
||||||
Pinetime::Controllers::TimerController& timerController;
|
Pinetime::Controllers::TimerController& timerController;
|
||||||
|
@ -114,6 +118,7 @@ namespace Pinetime {
|
||||||
Pinetime::Applications::DisplayApp& displayApp;
|
Pinetime::Applications::DisplayApp& displayApp;
|
||||||
Pinetime::Applications::HeartRateTask& heartRateApp;
|
Pinetime::Applications::HeartRateTask& heartRateApp;
|
||||||
Pinetime::Controllers::FS& fs;
|
Pinetime::Controllers::FS& fs;
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler;
|
||||||
Pinetime::Controllers::NimbleController nimbleController;
|
Pinetime::Controllers::NimbleController nimbleController;
|
||||||
|
|
||||||
static void Process(void* instance);
|
static void Process(void* instance);
|
||||||
|
|
65
src/touchhandler/TouchHandler.cpp
Normal file
65
src/touchhandler/TouchHandler.cpp
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
#include "TouchHandler.h"
|
||||||
|
|
||||||
|
using namespace Pinetime::Controllers;
|
||||||
|
|
||||||
|
TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel, Components::LittleVgl& lvgl) : touchPanel {touchPanel}, lvgl {lvgl} {
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchHandler::CancelTap() {
|
||||||
|
if (info.touching) {
|
||||||
|
isCancelled = true;
|
||||||
|
lvgl.SetNewTouchPoint(-1, -1, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Pinetime::Drivers::Cst816S::Gestures TouchHandler::GestureGet() {
|
||||||
|
auto returnGesture = gesture;
|
||||||
|
gesture = Drivers::Cst816S::Gestures::None;
|
||||||
|
return returnGesture;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TouchHandler::GetNewTouchInfo() {
|
||||||
|
info = touchPanel.GetTouchInfo();
|
||||||
|
|
||||||
|
if (!info.isValid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) {
|
||||||
|
if (gestureReleased) {
|
||||||
|
if (info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideDown ||
|
||||||
|
info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideLeft ||
|
||||||
|
info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideUp ||
|
||||||
|
info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideRight ||
|
||||||
|
info.gesture == Pinetime::Drivers::Cst816S::Gestures::LongPress) {
|
||||||
|
if (info.touching) {
|
||||||
|
gesture = info.gesture;
|
||||||
|
gestureReleased = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
gesture = info.gesture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!info.touching) {
|
||||||
|
gestureReleased = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchHandler::UpdateLvglTouchPoint() {
|
||||||
|
if (info.touching) {
|
||||||
|
if (!isCancelled) {
|
||||||
|
lvgl.SetNewTouchPoint(info.x, info.y, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isCancelled) {
|
||||||
|
lvgl.SetNewTouchPoint(-1, -1, false);
|
||||||
|
isCancelled = false;
|
||||||
|
} else {
|
||||||
|
lvgl.SetNewTouchPoint(info.x, info.y, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
45
src/touchhandler/TouchHandler.h
Normal file
45
src/touchhandler/TouchHandler.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#pragma once
|
||||||
|
#include "drivers/Cst816s.h"
|
||||||
|
#include "systemtask/SystemTask.h"
|
||||||
|
#include <FreeRTOS.h>
|
||||||
|
#include <task.h>
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
namespace Components {
|
||||||
|
class LittleVgl;
|
||||||
|
}
|
||||||
|
namespace Drivers {
|
||||||
|
class Cst816S;
|
||||||
|
}
|
||||||
|
namespace System {
|
||||||
|
class SystemTask;
|
||||||
|
}
|
||||||
|
namespace Controllers {
|
||||||
|
class TouchHandler {
|
||||||
|
public:
|
||||||
|
explicit TouchHandler(Drivers::Cst816S&, Components::LittleVgl&);
|
||||||
|
void CancelTap();
|
||||||
|
bool GetNewTouchInfo();
|
||||||
|
void UpdateLvglTouchPoint();
|
||||||
|
|
||||||
|
bool IsTouching() const {
|
||||||
|
return info.touching;
|
||||||
|
}
|
||||||
|
uint8_t GetX() const {
|
||||||
|
return info.x;
|
||||||
|
}
|
||||||
|
uint8_t GetY() const {
|
||||||
|
return info.y;
|
||||||
|
}
|
||||||
|
Drivers::Cst816S::Gestures GestureGet();
|
||||||
|
private:
|
||||||
|
|
||||||
|
Pinetime::Drivers::Cst816S::TouchInfos info;
|
||||||
|
Pinetime::Drivers::Cst816S& touchPanel;
|
||||||
|
Pinetime::Components::LittleVgl& lvgl;
|
||||||
|
Pinetime::Drivers::Cst816S::Gestures gesture;
|
||||||
|
bool isCancelled = false;
|
||||||
|
bool gestureReleased = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user