mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 23:21:53 +02:00
Merge 42bcd56545
into 8598142c27
This commit is contained in:
commit
61fb05409a
|
@ -402,6 +402,7 @@ list(APPEND SOURCE_FILES
|
||||||
displayapp/widgets/PageIndicator.cpp
|
displayapp/widgets/PageIndicator.cpp
|
||||||
displayapp/widgets/DotIndicator.cpp
|
displayapp/widgets/DotIndicator.cpp
|
||||||
displayapp/widgets/StatusIcons.cpp
|
displayapp/widgets/StatusIcons.cpp
|
||||||
|
displayapp/widgets/PopupMessage.cpp
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
displayapp/screens/settings/QuickSettings.cpp
|
displayapp/screens/settings/QuickSettings.cpp
|
||||||
|
|
|
@ -13,7 +13,14 @@ namespace Pinetime {
|
||||||
enum class WeatherFormat : uint8_t { Metric, Imperial };
|
enum class WeatherFormat : uint8_t { Metric, Imperial };
|
||||||
enum class Notification : uint8_t { On, Off, Sleep };
|
enum class Notification : uint8_t { On, Off, Sleep };
|
||||||
enum class ChimesOption : uint8_t { None, Hours, HalfHours };
|
enum class ChimesOption : uint8_t { None, Hours, HalfHours };
|
||||||
enum class WakeUpMode : uint8_t { SingleTap = 0, DoubleTap = 1, RaiseWrist = 2, Shake = 3, LowerWrist = 4 };
|
enum class WakeUpMode : uint8_t {
|
||||||
|
SingleTap = 0,
|
||||||
|
DoubleTap = 1,
|
||||||
|
RaiseWrist = 2,
|
||||||
|
Shake = 3,
|
||||||
|
LowerWrist = 4,
|
||||||
|
ButtonUnlocks = 5,
|
||||||
|
};
|
||||||
enum class Colors : uint8_t {
|
enum class Colors : uint8_t {
|
||||||
White,
|
White,
|
||||||
Silver,
|
Silver,
|
||||||
|
@ -260,7 +267,7 @@ namespace Pinetime {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::bitset<5> getWakeUpModes() const {
|
std::bitset<6> getWakeUpModes() const {
|
||||||
return settings.wakeUpMode;
|
return settings.wakeUpMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +328,7 @@ namespace Pinetime {
|
||||||
|
|
||||||
WatchFaceInfineat watchFaceInfineat;
|
WatchFaceInfineat watchFaceInfineat;
|
||||||
|
|
||||||
std::bitset<5> wakeUpMode {0};
|
std::bitset<6> wakeUpMode {0};
|
||||||
uint16_t shakeWakeThreshold = 150;
|
uint16_t shakeWakeThreshold = 150;
|
||||||
|
|
||||||
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
|
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
|
||||||
|
|
|
@ -456,6 +456,12 @@ void DisplayApp::Refresh() {
|
||||||
case Messages::OnChargingEvent:
|
case Messages::OnChargingEvent:
|
||||||
motorController.RunForDuration(15);
|
motorController.RunForDuration(15);
|
||||||
break;
|
break;
|
||||||
|
case Messages::ShowIgnoreTouchPopup:
|
||||||
|
popupMessage.SetHidden(false);
|
||||||
|
break;
|
||||||
|
case Messages::HideIgnoreTouchPopup:
|
||||||
|
popupMessage.SetHidden(true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +585,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
||||||
currentScreen = std::make_unique<Screens::SettingWeatherFormat>(settingsController);
|
currentScreen = std::make_unique<Screens::SettingWeatherFormat>(settingsController);
|
||||||
break;
|
break;
|
||||||
case Apps::SettingWakeUp:
|
case Apps::SettingWakeUp:
|
||||||
currentScreen = std::make_unique<Screens::SettingWakeUp>(settingsController);
|
currentScreen = std::make_unique<Screens::SettingWakeUp>(this, settingsController);
|
||||||
break;
|
break;
|
||||||
case Apps::SettingDisplay:
|
case Apps::SettingDisplay:
|
||||||
currentScreen = std::make_unique<Screens::SettingDisplay>(settingsController);
|
currentScreen = std::make_unique<Screens::SettingDisplay>(settingsController);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "components/timer/Timer.h"
|
#include "components/timer/Timer.h"
|
||||||
#include "components/alarm/AlarmController.h"
|
#include "components/alarm/AlarmController.h"
|
||||||
#include "touchhandler/TouchHandler.h"
|
#include "touchhandler/TouchHandler.h"
|
||||||
|
#include "displayapp/widgets/PopupMessage.h"
|
||||||
|
|
||||||
#include "displayapp/Messages.h"
|
#include "displayapp/Messages.h"
|
||||||
#include "BootErrors.h"
|
#include "BootErrors.h"
|
||||||
|
@ -102,8 +103,10 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::FirmwareValidator validator;
|
Pinetime::Controllers::FirmwareValidator validator;
|
||||||
Pinetime::Components::LittleVgl lvgl;
|
Pinetime::Components::LittleVgl lvgl;
|
||||||
Pinetime::Controllers::Timer timer;
|
Pinetime::Controllers::Timer timer;
|
||||||
|
Pinetime::Applications::Widgets::PopupMessage popupMessage;
|
||||||
|
|
||||||
AppControllers controllers;
|
AppControllers controllers;
|
||||||
|
|
||||||
TaskHandle_t taskHandle;
|
TaskHandle_t taskHandle;
|
||||||
|
|
||||||
States state = States::Running;
|
States state = States::Running;
|
||||||
|
|
|
@ -24,6 +24,8 @@ namespace Pinetime {
|
||||||
Chime,
|
Chime,
|
||||||
BleRadioEnableToggle,
|
BleRadioEnableToggle,
|
||||||
OnChargingEvent,
|
OnChargingEvent,
|
||||||
|
ShowIgnoreTouchPopup,
|
||||||
|
HideIgnoreTouchPopup
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
29
src/displayapp/screens/Page.h
Normal file
29
src/displayapp/screens/Page.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
#include "displayapp/screens/Screen.h"
|
||||||
|
#include "displayapp/widgets/PageIndicator.h"
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
|
||||||
|
namespace Applications {
|
||||||
|
namespace Screens {
|
||||||
|
|
||||||
|
class Page : public Screen {
|
||||||
|
public:
|
||||||
|
Page(uint8_t screenID, uint8_t numScreens, lv_obj_t* contentObj) : contentObj {contentObj}, pageIndicator(screenID, numScreens) {
|
||||||
|
pageIndicator.Create();
|
||||||
|
}
|
||||||
|
|
||||||
|
~Page() override {
|
||||||
|
lv_obj_clean(lv_scr_act());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
lv_obj_t* contentObj = nullptr;
|
||||||
|
Widgets::PageIndicator pageIndicator;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,17 @@
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
constexpr std::array<SettingWakeUp::Option, 5> SettingWakeUp::options;
|
constexpr std::array<SettingWakeUp::Option, SettingWakeUp::numOptions> SettingWakeUp::options;
|
||||||
|
|
||||||
|
auto SettingWakeUp::CreateScreenList() {
|
||||||
|
std::array<std::function<std::unique_ptr<Screen>()>, nScreens> screens;
|
||||||
|
for (size_t i = 0; i < screens.size(); i++) {
|
||||||
|
screens[i] = [this, i]() -> std::unique_ptr<Screen> {
|
||||||
|
return CreateScreen(i);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return screens;
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void event_handler(lv_obj_t* obj, lv_event_t event) {
|
void event_handler(lv_obj_t* obj, lv_event_t event) {
|
||||||
|
@ -19,7 +29,16 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingWakeUp::SettingWakeUp(Pinetime::Controllers::Settings& settingsController) : settingsController {settingsController} {
|
SettingWakeUp::SettingWakeUp(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
|
||||||
|
: settingsController {settingsController}, screens {app, 0, CreateScreenList(), Screens::ScreenListModes::UpDown} {
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingWakeUp::~SettingWakeUp() {
|
||||||
|
lv_obj_clean(lv_scr_act());
|
||||||
|
settingsController.SaveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Screen> SettingWakeUp::CreateScreen(size_t screenNum) {
|
||||||
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
|
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
|
||||||
|
|
||||||
lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||||
|
@ -43,20 +62,29 @@ SettingWakeUp::SettingWakeUp(Pinetime::Controllers::Settings& settingsController
|
||||||
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
|
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
|
||||||
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
|
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < options.size(); i++) {
|
// cleanup any old pointers
|
||||||
|
cbOption.fill(nullptr);
|
||||||
|
|
||||||
|
// only loop as far as the list size aĺlows
|
||||||
|
unsigned int loopMax = screenNum * optionsPerScreen + optionsPerScreen;
|
||||||
|
if (loopMax > options.size()) {
|
||||||
|
loopMax = options.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = screenNum * optionsPerScreen; i < loopMax; i++) {
|
||||||
cbOption[i] = lv_checkbox_create(container1, nullptr);
|
cbOption[i] = lv_checkbox_create(container1, nullptr);
|
||||||
lv_checkbox_set_text(cbOption[i], options[i].name);
|
lv_checkbox_set_text(cbOption[i], options[i].name);
|
||||||
if (settingsController.isWakeUpModeOn(static_cast<Controllers::Settings::WakeUpMode>(i))) {
|
if (settingsController.isWakeUpModeOn(options[i].wakeUpMode)) {
|
||||||
lv_checkbox_set_checked(cbOption[i], true);
|
lv_checkbox_set_checked(cbOption[i], true);
|
||||||
}
|
}
|
||||||
cbOption[i]->user_data = this;
|
cbOption[i]->user_data = this;
|
||||||
lv_obj_set_event_cb(cbOption[i], event_handler);
|
lv_obj_set_event_cb(cbOption[i], event_handler);
|
||||||
}
|
}
|
||||||
|
return std::make_unique<Screens::Page>(screenNum, nScreens, container1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingWakeUp::~SettingWakeUp() {
|
bool SettingWakeUp::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
lv_obj_clean(lv_scr_act());
|
return screens.OnTouchEvent(event);
|
||||||
settingsController.SaveSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingWakeUp::UpdateSelected(lv_obj_t* object) {
|
void SettingWakeUp::UpdateSelected(lv_obj_t* object) {
|
||||||
|
@ -74,6 +102,8 @@ void SettingWakeUp::UpdateSelected(lv_obj_t* object) {
|
||||||
// for example, when setting SingleTap, DoubleTap is unset and vice versa.
|
// for example, when setting SingleTap, DoubleTap is unset and vice versa.
|
||||||
auto modes = settingsController.getWakeUpModes();
|
auto modes = settingsController.getWakeUpModes();
|
||||||
for (size_t i = 0; i < options.size(); ++i) {
|
for (size_t i = 0; i < options.size(); ++i) {
|
||||||
|
if (cbOption[i]) {
|
||||||
lv_checkbox_set_checked(cbOption[i], modes[i]);
|
lv_checkbox_set_checked(cbOption[i], modes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
#include "components/settings/Settings.h"
|
#include "components/settings/Settings.h"
|
||||||
|
#include "displayapp/screens/Page.h"
|
||||||
#include "displayapp/screens/Screen.h"
|
#include "displayapp/screens/Screen.h"
|
||||||
|
#include "displayapp/screens/ScreenList.h"
|
||||||
|
#include "displayapp/widgets/PageIndicator.h"
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
|
|
||||||
|
@ -13,27 +16,40 @@ namespace Pinetime {
|
||||||
|
|
||||||
class SettingWakeUp : public Screen {
|
class SettingWakeUp : public Screen {
|
||||||
public:
|
public:
|
||||||
SettingWakeUp(Pinetime::Controllers::Settings& settingsController);
|
SettingWakeUp(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||||
~SettingWakeUp() override;
|
~SettingWakeUp() override;
|
||||||
|
|
||||||
void UpdateSelected(lv_obj_t* object);
|
void UpdateSelected(lv_obj_t* object);
|
||||||
|
|
||||||
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
auto CreateScreenList();
|
||||||
|
std::unique_ptr<Screen> CreateScreen(size_t screenNum);
|
||||||
|
|
||||||
struct Option {
|
struct Option {
|
||||||
Controllers::Settings::WakeUpMode wakeUpMode;
|
Controllers::Settings::WakeUpMode wakeUpMode;
|
||||||
const char* name;
|
const char* name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static constexpr size_t numOptions = 6;
|
||||||
|
static constexpr size_t optionsPerScreen = 4;
|
||||||
|
static constexpr size_t nScreens = 2;
|
||||||
|
|
||||||
Controllers::Settings& settingsController;
|
Controllers::Settings& settingsController;
|
||||||
static constexpr std::array<Option, 5> options = {{
|
|
||||||
|
ScreenList<nScreens> screens;
|
||||||
|
|
||||||
|
static constexpr std::array<Option, numOptions> options = {{
|
||||||
{Controllers::Settings::WakeUpMode::SingleTap, "Single Tap"},
|
{Controllers::Settings::WakeUpMode::SingleTap, "Single Tap"},
|
||||||
{Controllers::Settings::WakeUpMode::DoubleTap, "Double Tap"},
|
{Controllers::Settings::WakeUpMode::DoubleTap, "Double Tap"},
|
||||||
{Controllers::Settings::WakeUpMode::RaiseWrist, "Raise Wrist"},
|
{Controllers::Settings::WakeUpMode::RaiseWrist, "Raise Wrist"},
|
||||||
{Controllers::Settings::WakeUpMode::Shake, "Shake Wake"},
|
{Controllers::Settings::WakeUpMode::Shake, "Shake Wake"},
|
||||||
{Controllers::Settings::WakeUpMode::LowerWrist, "Lower Wrist"},
|
{Controllers::Settings::WakeUpMode::LowerWrist, "Lower Wrist"},
|
||||||
|
{Controllers::Settings::WakeUpMode::ButtonUnlocks, "Button Unlock"},
|
||||||
}};
|
}};
|
||||||
|
|
||||||
lv_obj_t* cbOption[options.size()];
|
std::array<lv_obj_t*, numOptions> cbOption;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
56
src/displayapp/widgets/PopupMessage.cpp
Normal file
56
src/displayapp/widgets/PopupMessage.cpp
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#include "displayapp/widgets/PopupMessage.h"
|
||||||
|
#include "displayapp/InfiniTimeTheme.h"
|
||||||
|
#include <libraries/log/nrf_log.h>
|
||||||
|
|
||||||
|
using namespace Pinetime::Applications::Widgets;
|
||||||
|
|
||||||
|
PopupMessage::PopupMessage() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupMessage::Create() {
|
||||||
|
popup = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_size(popup, 90, 90);
|
||||||
|
lv_obj_align(popup, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||||
|
lv_obj_set_style_local_bg_color(popup, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, Colors::bg);
|
||||||
|
lv_obj_set_style_local_bg_opa(popup, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_60);
|
||||||
|
lv_obj_t* lockBody = lv_obj_create(popup, nullptr);
|
||||||
|
lv_obj_set_size(lockBody, 55, 50);
|
||||||
|
lv_obj_align(lockBody, popup, LV_ALIGN_CENTER, 0, 10);
|
||||||
|
|
||||||
|
lv_obj_set_style_local_bg_color(lockBody, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
|
lv_obj_set_style_local_bg_opa(lockBody, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
|
||||||
|
lv_obj_set_style_local_border_color(lockBody, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
|
lv_obj_set_style_local_border_width(lockBody, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 22);
|
||||||
|
lv_obj_set_style_local_border_side(lockBody, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_BORDER_SIDE_FULL);
|
||||||
|
lv_obj_set_style_local_border_opa(lockBody, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_100);
|
||||||
|
|
||||||
|
lv_obj_t* lockTop = lv_obj_create(popup, nullptr);
|
||||||
|
lv_obj_set_size(lockTop, 30, 35);
|
||||||
|
lv_obj_align(lockTop, popup, LV_ALIGN_CENTER, 0, -20);
|
||||||
|
lv_obj_set_style_local_bg_color(lockTop, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
|
lv_obj_set_style_local_bg_opa(lockTop, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
|
||||||
|
lv_obj_set_style_local_border_color(lockTop, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
|
lv_obj_set_style_local_border_width(lockTop, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 6);
|
||||||
|
lv_obj_set_style_local_border_side(lockTop, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_BORDER_SIDE_FULL);
|
||||||
|
lv_obj_set_style_local_border_opa(lockTop, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_100);
|
||||||
|
|
||||||
|
lv_obj_set_hidden(popup, isHidden);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupMessage::SetHidden(bool hidden) {
|
||||||
|
if (isHidden == hidden) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isHidden = hidden;
|
||||||
|
// create/delete on demand
|
||||||
|
if (popup == nullptr && !isHidden) {
|
||||||
|
Create();
|
||||||
|
} else if (popup != nullptr) {
|
||||||
|
lv_obj_del(popup);
|
||||||
|
popup = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PopupMessage::IsHidden() {
|
||||||
|
return isHidden;
|
||||||
|
}
|
20
src/displayapp/widgets/PopupMessage.h
Normal file
20
src/displayapp/widgets/PopupMessage.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
namespace Applications {
|
||||||
|
namespace Widgets {
|
||||||
|
class PopupMessage {
|
||||||
|
public:
|
||||||
|
PopupMessage();
|
||||||
|
void Create();
|
||||||
|
void SetHidden(bool hidden);
|
||||||
|
bool IsHidden();
|
||||||
|
|
||||||
|
private:
|
||||||
|
lv_obj_t* popup = nullptr;
|
||||||
|
bool isHidden = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -199,7 +199,11 @@ void SystemTask::Work() {
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
break;
|
break;
|
||||||
case Messages::TouchWakeUp: {
|
case Messages::TouchWakeUp: {
|
||||||
if (touchHandler.ProcessTouchInfo(touchPanel.GetTouchInfo())) {
|
Pinetime::Controllers::TouchHandler::TouchProcessReply reply;
|
||||||
|
reply =
|
||||||
|
touchHandler.ProcessTouchInfo(touchPanel.GetTouchInfo(),
|
||||||
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::ButtonUnlocks));
|
||||||
|
if (reply == Pinetime::Controllers::TouchHandler::TouchProcessReply::TouchEvent) {
|
||||||
auto gesture = touchHandler.GestureGet();
|
auto gesture = touchHandler.GestureGet();
|
||||||
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
|
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
|
||||||
gesture != Pinetime::Applications::TouchEvents::None &&
|
gesture != Pinetime::Applications::TouchEvents::None &&
|
||||||
|
@ -207,6 +211,7 @@ void SystemTask::Work() {
|
||||||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) ||
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) ||
|
||||||
(gesture == Pinetime::Applications::TouchEvents::Tap &&
|
(gesture == Pinetime::Applications::TouchEvents::Tap &&
|
||||||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
|
||||||
|
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::WakeUpAction, true);
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,11 +230,13 @@ void SystemTask::Work() {
|
||||||
if (IsSleeping()) {
|
if (IsSleeping()) {
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
}
|
}
|
||||||
|
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Messages::SetOffAlarm:
|
case Messages::SetOffAlarm:
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
|
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::AlarmTriggered);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::AlarmTriggered);
|
||||||
break;
|
break;
|
||||||
case Messages::BleConnected:
|
case Messages::BleConnected:
|
||||||
|
@ -240,6 +247,7 @@ void SystemTask::Work() {
|
||||||
case Messages::BleFirmwareUpdateStarted:
|
case Messages::BleFirmwareUpdateStarted:
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
wakeLocksHeld++;
|
wakeLocksHeld++;
|
||||||
|
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::BleFirmwareUpdateStarted);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::BleFirmwareUpdateStarted);
|
||||||
break;
|
break;
|
||||||
case Messages::BleFirmwareUpdateFinished:
|
case Messages::BleFirmwareUpdateFinished:
|
||||||
|
@ -252,6 +260,7 @@ void SystemTask::Work() {
|
||||||
NRF_LOG_INFO("[systemtask] FS Started");
|
NRF_LOG_INFO("[systemtask] FS Started");
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
wakeLocksHeld++;
|
wakeLocksHeld++;
|
||||||
|
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||||
// TODO add intent of fs access icon or something
|
// TODO add intent of fs access icon or something
|
||||||
break;
|
break;
|
||||||
case Messages::StopFileTransfer:
|
case Messages::StopFileTransfer:
|
||||||
|
@ -260,16 +269,30 @@ void SystemTask::Work() {
|
||||||
// TODO add intent of fs access icon or something
|
// TODO add intent of fs access icon or something
|
||||||
break;
|
break;
|
||||||
case Messages::OnTouchEvent:
|
case Messages::OnTouchEvent:
|
||||||
if (touchHandler.ProcessTouchInfo(touchPanel.GetTouchInfo())) {
|
Pinetime::Controllers::TouchHandler::TouchProcessReply reply;
|
||||||
|
reply =
|
||||||
|
touchHandler.ProcessTouchInfo(touchPanel.GetTouchInfo(),
|
||||||
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::ButtonUnlocks));
|
||||||
|
if (reply == Pinetime::Controllers::TouchHandler::TouchProcessReply::TouchEvent) {
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
|
||||||
|
} else if (reply == Pinetime::Controllers::TouchHandler::TouchProcessReply::IgnoreTouchPopup) {
|
||||||
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::ShowIgnoreTouchPopup);
|
||||||
|
touchHandler.SetIgnoreTouchPopupHidden(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Messages::HandleButtonEvent: {
|
case Messages::HandleButtonEvent: {
|
||||||
|
// if the IgnoreTouchPopup is active the first button event unlocks the device
|
||||||
|
if (!touchHandler.IsIgnoreTouchPopupHidden()) {
|
||||||
|
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Button, false);
|
||||||
|
touchHandler.SetIgnoreTouchPopupHidden(true);
|
||||||
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::HideIgnoreTouchPopup);
|
||||||
|
} else {
|
||||||
Controllers::ButtonActions action = Controllers::ButtonActions::None;
|
Controllers::ButtonActions action = Controllers::ButtonActions::None;
|
||||||
if (nrf_gpio_pin_read(Pinetime::PinMap::Button) == 0) {
|
if (nrf_gpio_pin_read(Pinetime::PinMap::Button) == 0) {
|
||||||
action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Release);
|
action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Release);
|
||||||
} else {
|
} else {
|
||||||
action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Press);
|
action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Press);
|
||||||
|
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Button, false);
|
||||||
// This is for faster wakeup, sacrificing special longpress and doubleclick handling while sleeping
|
// This is for faster wakeup, sacrificing special longpress and doubleclick handling while sleeping
|
||||||
if (IsSleeping()) {
|
if (IsSleeping()) {
|
||||||
fastWakeUpDone = true;
|
fastWakeUpDone = true;
|
||||||
|
@ -278,6 +301,7 @@ void SystemTask::Work() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HandleButtonAction(action);
|
HandleButtonAction(action);
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case Messages::HandleButtonTimerEvent: {
|
case Messages::HandleButtonTimerEvent: {
|
||||||
auto action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Timer);
|
auto action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Timer);
|
||||||
|
@ -308,6 +332,8 @@ void SystemTask::Work() {
|
||||||
}
|
}
|
||||||
|
|
||||||
state = SystemTaskState::Sleeping;
|
state = SystemTaskState::Sleeping;
|
||||||
|
// reset touch restrictions when going to sleep
|
||||||
|
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||||
break;
|
break;
|
||||||
case Messages::OnNewDay:
|
case Messages::OnNewDay:
|
||||||
// We might be sleeping (with TWI device disabled.
|
// We might be sleeping (with TWI device disabled.
|
||||||
|
@ -319,6 +345,7 @@ void SystemTask::Work() {
|
||||||
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
|
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
|
||||||
settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::Hours && !alarmController.IsAlerting()) {
|
settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::Hours && !alarmController.IsAlerting()) {
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
|
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Chime);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Chime);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -327,12 +354,14 @@ void SystemTask::Work() {
|
||||||
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
|
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
|
||||||
settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours && !alarmController.IsAlerting()) {
|
settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours && !alarmController.IsAlerting()) {
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
|
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Chime);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Chime);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Messages::OnChargingEvent:
|
case Messages::OnChargingEvent:
|
||||||
batteryController.ReadPowerState();
|
batteryController.ReadPowerState();
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
|
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||||
displayApp.PushMessage(Applications::Display::Messages::OnChargingEvent);
|
displayApp.PushMessage(Applications::Display::Messages::OnChargingEvent);
|
||||||
break;
|
break;
|
||||||
case Messages::MeasureBatteryTimerExpired:
|
case Messages::MeasureBatteryTimerExpired:
|
||||||
|
@ -343,6 +372,7 @@ void SystemTask::Work() {
|
||||||
break;
|
break;
|
||||||
case Messages::OnPairing:
|
case Messages::OnPairing:
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
|
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::ShowPairingKey);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::ShowPairingKey);
|
||||||
break;
|
break;
|
||||||
case Messages::BleRadioEnableToggle:
|
case Messages::BleRadioEnableToggle:
|
||||||
|
@ -413,6 +443,8 @@ void SystemTask::GoToSleep() {
|
||||||
NRF_LOG_INFO("[systemtask] Going to sleep");
|
NRF_LOG_INFO("[systemtask] Going to sleep");
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToSleep);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToSleep);
|
||||||
heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep);
|
heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep);
|
||||||
|
touchHandler.SetIgnoreTouchPopupHidden(true);
|
||||||
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::HideIgnoreTouchPopup);
|
||||||
|
|
||||||
state = SystemTaskState::GoingToSleep;
|
state = SystemTaskState::GoingToSleep;
|
||||||
};
|
};
|
||||||
|
@ -438,6 +470,9 @@ void SystemTask::UpdateMotion() {
|
||||||
motionController.ShouldRaiseWake()) ||
|
motionController.ShouldRaiseWake()) ||
|
||||||
(settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake) &&
|
(settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake) &&
|
||||||
motionController.ShouldShakeWake(settingsController.GetShakeThreshold()))) {
|
motionController.ShouldShakeWake(settingsController.GetShakeThreshold()))) {
|
||||||
|
if (state == SystemTaskState::Sleeping) {
|
||||||
|
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::WakeUpAction, true);
|
||||||
|
}
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,11 @@ namespace Pinetime {
|
||||||
class SystemTask {
|
class SystemTask {
|
||||||
public:
|
public:
|
||||||
enum class SystemTaskState { Sleeping, Running, GoingToSleep };
|
enum class SystemTaskState { Sleeping, Running, GoingToSleep };
|
||||||
|
// Enum describes how the watch was woken:
|
||||||
|
// * WakeUpAction: The actions selected in the wakeup settings, single/double tap, raise, shake
|
||||||
|
// * Button: The hardware button
|
||||||
|
// * Other: Other things that can wake the watch up, eg. apps and notifications.
|
||||||
|
enum class WokenBy { WakeUpAction, Button, Other };
|
||||||
SystemTask(Drivers::SpiMaster& spi,
|
SystemTask(Drivers::SpiMaster& spi,
|
||||||
Pinetime::Drivers::SpiNorFlash& spiNorFlash,
|
Pinetime::Drivers::SpiNorFlash& spiNorFlash,
|
||||||
Drivers::TwiMaster& twiMaster,
|
Drivers::TwiMaster& twiMaster,
|
||||||
|
|
|
@ -33,9 +33,9 @@ Pinetime::Applications::TouchEvents TouchHandler::GestureGet() {
|
||||||
return returnGesture;
|
return returnGesture;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TouchHandler::ProcessTouchInfo(Drivers::Cst816S::TouchInfos info) {
|
TouchHandler::TouchProcessReply TouchHandler::ProcessTouchInfo(Drivers::Cst816S::TouchInfos info, bool buttonUnlocksOn) {
|
||||||
if (!info.isValid) {
|
if (!info.isValid) {
|
||||||
return false;
|
return TouchHandler::TouchProcessReply::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only a single gesture per touch
|
// Only a single gesture per touch
|
||||||
|
@ -62,5 +62,19 @@ bool TouchHandler::ProcessTouchInfo(Drivers::Cst816S::TouchInfos info) {
|
||||||
|
|
||||||
currentTouchPoint = {info.x, info.y, info.touching};
|
currentTouchPoint = {info.x, info.y, info.touching};
|
||||||
|
|
||||||
return true;
|
// if the watch was just woken by touch and button must be used to unlock, ignore the first touch event which
|
||||||
|
// is the touch event that woke the watch. Otherwise the lock-popup will be displayed
|
||||||
|
if (buttonUnlocksOn && ignoreNextTouchEvent) {
|
||||||
|
ignoreNextTouchEvent = false;
|
||||||
|
return TouchHandler::TouchProcessReply::NoAction;
|
||||||
|
|
||||||
|
} else if (!buttonUnlocksOn || wokenBy != WokenBy::WakeUpAction) {
|
||||||
|
|
||||||
|
// if we get to here TouchEvents is allowed and the "ButtonUnlocks" requirement can be overridden
|
||||||
|
wokenBy = WokenBy::Other;
|
||||||
|
|
||||||
|
return TouchHandler::TouchProcessReply::TouchEvent;
|
||||||
|
} else {
|
||||||
|
return TouchHandler::TouchProcessReply::IgnoreTouchPopup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,25 @@ namespace Pinetime {
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
class TouchHandler {
|
class TouchHandler {
|
||||||
public:
|
public:
|
||||||
|
// Enum describes how the watch was woken:
|
||||||
|
// * WakeUpAction: The actions selected in the wakeup settings, single/double tap, raise, shake
|
||||||
|
// * Button: The hardware button
|
||||||
|
// * Other: Other things that can wake the watch up, eg. apps and notifications.
|
||||||
|
enum class WokenBy { WakeUpAction, Button, Other };
|
||||||
|
|
||||||
|
// Enum describes how the reply from ProcessTouchInfo should be interpreted:
|
||||||
|
// * NoAction: Do nothing, ignore input.
|
||||||
|
// * TouchEvent: The input should be treated as a normal touch event.
|
||||||
|
// * IgnoreTouchPopup: Show the popup when ignoring touch input.
|
||||||
|
enum class TouchProcessReply { NoAction, TouchEvent, IgnoreTouchPopup };
|
||||||
|
|
||||||
struct TouchPoint {
|
struct TouchPoint {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
bool touching;
|
bool touching;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ProcessTouchInfo(Drivers::Cst816S::TouchInfos info);
|
TouchProcessReply ProcessTouchInfo(Drivers::Cst816S::TouchInfos info, bool buttonUnlocksOn = false);
|
||||||
|
|
||||||
bool IsTouching() const {
|
bool IsTouching() const {
|
||||||
return currentTouchPoint.touching;
|
return currentTouchPoint.touching;
|
||||||
|
@ -26,12 +38,29 @@ namespace Pinetime {
|
||||||
return currentTouchPoint.y;
|
return currentTouchPoint.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetIgnoreTouchPopupHidden(bool hidden) {
|
||||||
|
ignoreTouchPopupHidden = hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsIgnoreTouchPopupHidden() {
|
||||||
|
return ignoreTouchPopupHidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetWokenBy(WokenBy woken, bool ifButtonUnlocksIgnoreTouch) {
|
||||||
|
wokenBy = woken;
|
||||||
|
ignoreNextTouchEvent = ifButtonUnlocksIgnoreTouch;
|
||||||
|
}
|
||||||
|
|
||||||
Pinetime::Applications::TouchEvents GestureGet();
|
Pinetime::Applications::TouchEvents GestureGet();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Pinetime::Applications::TouchEvents gesture;
|
Pinetime::Applications::TouchEvents gesture;
|
||||||
TouchPoint currentTouchPoint = {};
|
TouchPoint currentTouchPoint = {};
|
||||||
bool gestureReleased = true;
|
bool gestureReleased = true;
|
||||||
|
|
||||||
|
WokenBy wokenBy;
|
||||||
|
bool ignoreNextTouchEvent = false;
|
||||||
|
bool ignoreTouchPopupHidden = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue