mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 15:11:51 +02:00
Compare commits
37 commits
404c42d508
...
42a8a32928
Author | SHA1 | Date | |
---|---|---|---|
42a8a32928 | |||
3a0d673df4 | |||
53dc9dafe7 | |||
a407902b06 | |||
3e8accde69 | |||
2bb611db8e | |||
ef88e8165c | |||
da9ab4a7b4 | |||
0bcd7e0009 | |||
bf69e0dcc5 | |||
947c4f5067 | |||
0960d67001 | |||
5385f7e275 | |||
e884b053d3 | |||
85a2181b64 | |||
3dca742b65 | |||
20ac7e8df3 | |||
35cc022db4 | |||
872fc6f6c6 | |||
50929d915c | |||
0eb9bd6758 | |||
a812f6830e | |||
ae90cb2db0 | |||
a4dd1cdb13 | |||
49e97621d7 | |||
664ea79c5c | |||
8a978f0037 | |||
c532e13bae | |||
2405657333 | |||
99d16861a8 | |||
79a329fb71 | |||
cf1d28758f | |||
f9e9a4f4cf | |||
afa339313f | |||
0037b8e543 | |||
1da33443fc | |||
6f6d870167 |
|
@ -402,6 +402,7 @@ list(APPEND SOURCE_FILES
|
|||
displayapp/widgets/PageIndicator.cpp
|
||||
displayapp/widgets/DotIndicator.cpp
|
||||
displayapp/widgets/StatusIcons.cpp
|
||||
displayapp/widgets/PopupMessage.cpp
|
||||
|
||||
## Settings
|
||||
displayapp/screens/settings/QuickSettings.cpp
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
#define configTICK_RATE_HZ 1024
|
||||
#define configMAX_PRIORITIES (3)
|
||||
#define configMINIMAL_STACK_SIZE (120)
|
||||
#define configTOTAL_HEAP_SIZE (1024 * 40)
|
||||
#define configTOTAL_HEAP_SIZE (1024 * 35)
|
||||
#define configMAX_TASK_NAME_LEN (4)
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
|
|
|
@ -2,38 +2,138 @@
|
|||
#include <hal/nrf_gpio.h>
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
#include "drivers/PinMap.h"
|
||||
#include <libraries/delay/nrf_delay.h>
|
||||
using namespace Pinetime::Controllers;
|
||||
|
||||
namespace {
|
||||
// reinterpret_cast is not constexpr so this is the best we can do
|
||||
static NRF_RTC_Type* const RTC = reinterpret_cast<NRF_RTC_Type*>(NRF_RTC2_BASE);
|
||||
}
|
||||
|
||||
void BrightnessController::Init() {
|
||||
nrf_gpio_cfg_output(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_cfg_output(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_cfg_output(PinMap::LcdBacklightHigh);
|
||||
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightHigh);
|
||||
|
||||
static_assert(timerFrequency == 32768, "Change the prescaler below");
|
||||
RTC->PRESCALER = 0;
|
||||
// CC1 switches the backlight on (pin transitions from high to low) and resets the counter to 0
|
||||
RTC->CC[1] = timerPeriod;
|
||||
// Enable compare events for CC0,CC1
|
||||
RTC->EVTEN = 0b0000'0000'0000'0011'0000'0000'0000'0000;
|
||||
// Disable all interrupts
|
||||
RTC->INTENCLR = 0b0000'0000'0000'1111'0000'0000'0000'0011;
|
||||
Set(level);
|
||||
}
|
||||
|
||||
void BrightnessController::ApplyBrightness(uint16_t rawBrightness) {
|
||||
// The classic off, low, medium, high brightnesses are at {0, timerPeriod, timerPeriod*2, timerPeriod*3}
|
||||
// These brightness levels do not use PWM: they only set/clear the corresponding pins
|
||||
// Any brightness level between the above levels is achieved with efficient RTC based PWM on the next pin up
|
||||
// E.g 2.5*timerPeriod corresponds to medium brightness with 50% PWM on the high pin
|
||||
// Note: Raw brightness does not necessarily correspond to a linear perceived brightness
|
||||
|
||||
uint8_t pin;
|
||||
if (rawBrightness > 2 * timerPeriod) {
|
||||
rawBrightness -= 2 * timerPeriod;
|
||||
pin = PinMap::LcdBacklightHigh;
|
||||
} else if (rawBrightness > timerPeriod) {
|
||||
rawBrightness -= timerPeriod;
|
||||
pin = PinMap::LcdBacklightMedium;
|
||||
} else {
|
||||
pin = PinMap::LcdBacklightLow;
|
||||
}
|
||||
if (rawBrightness == timerPeriod || rawBrightness == 0) {
|
||||
if (lastPin != UNSET) {
|
||||
RTC->TASKS_STOP = 1;
|
||||
nrf_delay_us(rtcStopTime);
|
||||
nrf_ppi_channel_disable(ppiBacklightOff);
|
||||
nrf_ppi_channel_disable(ppiBacklightOn);
|
||||
nrfx_gpiote_out_uninit(lastPin);
|
||||
nrf_gpio_cfg_output(lastPin);
|
||||
}
|
||||
lastPin = UNSET;
|
||||
if (rawBrightness == 0) {
|
||||
nrf_gpio_pin_set(pin);
|
||||
} else {
|
||||
nrf_gpio_pin_clear(pin);
|
||||
}
|
||||
} else {
|
||||
// If the pin on which we are doing PWM is changing
|
||||
// Disable old PWM channel (if exists) and set up new one
|
||||
if (lastPin != pin) {
|
||||
if (lastPin != UNSET) {
|
||||
RTC->TASKS_STOP = 1;
|
||||
nrf_delay_us(rtcStopTime);
|
||||
nrf_ppi_channel_disable(ppiBacklightOff);
|
||||
nrf_ppi_channel_disable(ppiBacklightOn);
|
||||
nrfx_gpiote_out_uninit(lastPin);
|
||||
nrf_gpio_cfg_output(lastPin);
|
||||
}
|
||||
nrfx_gpiote_out_config_t gpioteCfg = {.action = NRF_GPIOTE_POLARITY_TOGGLE,
|
||||
.init_state = NRF_GPIOTE_INITIAL_VALUE_LOW,
|
||||
.task_pin = true};
|
||||
APP_ERROR_CHECK(nrfx_gpiote_out_init(pin, &gpioteCfg));
|
||||
nrfx_gpiote_out_task_enable(pin);
|
||||
nrf_ppi_channel_endpoint_setup(ppiBacklightOff,
|
||||
reinterpret_cast<uint32_t>(&RTC->EVENTS_COMPARE[0]),
|
||||
nrfx_gpiote_out_task_addr_get(pin));
|
||||
nrf_ppi_channel_endpoint_setup(ppiBacklightOn,
|
||||
reinterpret_cast<uint32_t>(&RTC->EVENTS_COMPARE[1]),
|
||||
nrfx_gpiote_out_task_addr_get(pin));
|
||||
nrf_ppi_fork_endpoint_setup(ppiBacklightOn, reinterpret_cast<uint32_t>(&RTC->TASKS_CLEAR));
|
||||
nrf_ppi_channel_enable(ppiBacklightOff);
|
||||
nrf_ppi_channel_enable(ppiBacklightOn);
|
||||
} else {
|
||||
// If the pin used for PWM isn't changing, we only need to set the pin state to the initial value (low)
|
||||
RTC->TASKS_STOP = 1;
|
||||
nrf_delay_us(rtcStopTime);
|
||||
// Due to errata 20,179 and the intricacies of RTC timing, keep it simple: override the pin state
|
||||
nrfx_gpiote_out_task_force(pin, false);
|
||||
}
|
||||
// CC0 switches the backlight off (pin transitions from low to high)
|
||||
RTC->CC[0] = rawBrightness;
|
||||
RTC->TASKS_CLEAR = 1;
|
||||
RTC->TASKS_START = 1;
|
||||
lastPin = pin;
|
||||
}
|
||||
switch (pin) {
|
||||
case PinMap::LcdBacklightHigh:
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
|
||||
break;
|
||||
case PinMap::LcdBacklightMedium:
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
||||
break;
|
||||
case PinMap::LcdBacklightLow:
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
||||
}
|
||||
}
|
||||
|
||||
void BrightnessController::Set(BrightnessController::Levels level) {
|
||||
this->level = level;
|
||||
switch (level) {
|
||||
default:
|
||||
case Levels::High:
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightHigh);
|
||||
ApplyBrightness(3 * timerPeriod);
|
||||
break;
|
||||
case Levels::Medium:
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
||||
ApplyBrightness(2 * timerPeriod);
|
||||
break;
|
||||
case Levels::Low:
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
||||
ApplyBrightness(timerPeriod);
|
||||
break;
|
||||
case Levels::AlwaysOn:
|
||||
ApplyBrightness(timerPeriod / 10);
|
||||
break;
|
||||
case Levels::Off:
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
||||
ApplyBrightness(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "nrf_ppi.h"
|
||||
#include "nrfx_gpiote.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
class BrightnessController {
|
||||
public:
|
||||
enum class Levels { Off, Low, Medium, High };
|
||||
enum class Levels { Off, AlwaysOn, Low, Medium, High };
|
||||
void Init();
|
||||
|
||||
void Set(Levels level);
|
||||
|
@ -20,6 +23,25 @@ namespace Pinetime {
|
|||
|
||||
private:
|
||||
Levels level = Levels::High;
|
||||
static constexpr uint8_t UNSET = UINT8_MAX;
|
||||
uint8_t lastPin = UNSET;
|
||||
// Maximum time (μs) it takes for the RTC to fully stop
|
||||
static constexpr uint8_t rtcStopTime = 46;
|
||||
// Frequency of timer used for PWM (Hz)
|
||||
static constexpr uint16_t timerFrequency = 32768;
|
||||
// Backlight PWM frequency (Hz)
|
||||
static constexpr uint16_t pwmFreq = 1000;
|
||||
// Wraparound point in timer ticks
|
||||
// Defines the number of brightness levels between each pin
|
||||
static constexpr uint16_t timerPeriod = timerFrequency / pwmFreq;
|
||||
// Warning: nimble reserves some PPIs
|
||||
// https://github.com/InfiniTimeOrg/InfiniTime/blob/034d83fe6baf1ab3875a34f8cee387e24410a824/src/libs/mynewt-nimble/nimble/drivers/nrf52/src/ble_phy.c#L53
|
||||
// SpiMaster uses PPI 0 for an erratum workaround
|
||||
// Channel 1, 2 should be free to use
|
||||
static constexpr nrf_ppi_channel_t ppiBacklightOn = NRF_PPI_CHANNEL1;
|
||||
static constexpr nrf_ppi_channel_t ppiBacklightOff = NRF_PPI_CHANNEL2;
|
||||
|
||||
void ApplyBrightness(uint16_t val);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,14 @@ namespace Pinetime {
|
|||
enum class WeatherFormat : uint8_t { Metric, Imperial };
|
||||
enum class Notification : uint8_t { On, Off, Sleep };
|
||||
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 {
|
||||
White,
|
||||
Silver,
|
||||
|
@ -214,6 +221,21 @@ namespace Pinetime {
|
|||
return settings.screenTimeOut;
|
||||
};
|
||||
|
||||
bool GetAlwaysOnDisplay() const {
|
||||
return settings.alwaysOnDisplay && GetNotificationStatus() != Notification::Sleep;
|
||||
};
|
||||
|
||||
void SetAlwaysOnDisplaySetting(bool state) {
|
||||
if (state != settings.alwaysOnDisplay) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.alwaysOnDisplay = state;
|
||||
}
|
||||
|
||||
bool GetAlwaysOnDisplaySetting() const {
|
||||
return settings.alwaysOnDisplay;
|
||||
}
|
||||
|
||||
void SetShakeThreshold(uint16_t thresh) {
|
||||
if (settings.shakeWakeThreshold != thresh) {
|
||||
settings.shakeWakeThreshold = thresh;
|
||||
|
@ -245,7 +267,7 @@ namespace Pinetime {
|
|||
}
|
||||
};
|
||||
|
||||
std::bitset<5> getWakeUpModes() const {
|
||||
std::bitset<6> getWakeUpModes() const {
|
||||
return settings.wakeUpMode;
|
||||
}
|
||||
|
||||
|
@ -286,13 +308,15 @@ namespace Pinetime {
|
|||
private:
|
||||
Pinetime::Controllers::FS& fs;
|
||||
|
||||
static constexpr uint32_t settingsVersion = 0x0007;
|
||||
static constexpr uint32_t settingsVersion = 0x0008;
|
||||
|
||||
struct SettingsData {
|
||||
uint32_t version = settingsVersion;
|
||||
uint32_t stepsGoal = 10000;
|
||||
uint32_t screenTimeOut = 15000;
|
||||
|
||||
bool alwaysOnDisplay = false;
|
||||
|
||||
ClockType clockType = ClockType::H24;
|
||||
WeatherFormat weatherFormat = WeatherFormat::Metric;
|
||||
Notification notificationStatus = Notification::On;
|
||||
|
@ -304,7 +328,7 @@ namespace Pinetime {
|
|||
|
||||
WatchFaceInfineat watchFaceInfineat;
|
||||
|
||||
std::bitset<5> wakeUpMode {0};
|
||||
std::bitset<6> wakeUpMode {0};
|
||||
uint16_t shakeWakeThreshold = 150;
|
||||
|
||||
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "displayapp/screens/Weather.h"
|
||||
#include "displayapp/screens/PassKey.h"
|
||||
#include "displayapp/screens/Error.h"
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
|
||||
#include "drivers/Cst816s.h"
|
||||
#include "drivers/St7789.h"
|
||||
|
@ -81,7 +82,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
|||
Pinetime::Controllers::AlarmController& alarmController,
|
||||
Pinetime::Controllers::BrightnessController& brightnessController,
|
||||
Pinetime::Controllers::TouchHandler& touchHandler,
|
||||
Pinetime::Controllers::FS& filesystem)
|
||||
Pinetime::Controllers::FS& filesystem,
|
||||
Pinetime::Drivers::SpiNorFlash& spiNorFlash)
|
||||
: lcd {lcd},
|
||||
touchPanel {touchPanel},
|
||||
batteryController {batteryController},
|
||||
|
@ -97,8 +99,10 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
|||
brightnessController {brightnessController},
|
||||
touchHandler {touchHandler},
|
||||
filesystem {filesystem},
|
||||
spiNorFlash {spiNorFlash},
|
||||
lvgl {lcd, filesystem},
|
||||
timer(this, TimerCallback),
|
||||
popupMessage {Screens::Symbols::lock, 90, 90},
|
||||
controllers {batteryController,
|
||||
bleController,
|
||||
dateTimeController,
|
||||
|
@ -154,6 +158,36 @@ void DisplayApp::InitHw() {
|
|||
lcd.Init();
|
||||
}
|
||||
|
||||
TickType_t DisplayApp::CalculateSleepTime() {
|
||||
TickType_t ticksElapsed = xTaskGetTickCount() - alwaysOnStartTime;
|
||||
// Divide both the numerator and denominator by 8 to increase the number of ticks (frames) before the overflow tick is reached
|
||||
TickType_t elapsedTarget = ROUNDED_DIV((configTICK_RATE_HZ / 8) * alwaysOnTickCount * alwaysOnRefreshPeriod, 1000 / 8);
|
||||
// ROUNDED_DIV overflows when numerator + (denominator floordiv 2) > uint32 max
|
||||
// in this case around 9 hours
|
||||
constexpr TickType_t overflowTick = (UINT32_MAX - (1000 / 16)) / ((configTICK_RATE_HZ / 8) * alwaysOnRefreshPeriod);
|
||||
|
||||
// Assumptions
|
||||
|
||||
// Tick rate is multiple of 8
|
||||
// Needed for division trick above
|
||||
static_assert(configTICK_RATE_HZ % 8 == 0);
|
||||
|
||||
// Local tick count must always wraparound before the system tick count does
|
||||
// As a static assert we can use 64 bit ints and therefore dodge overflows
|
||||
// Always on overflow time (ms) < system tick overflow time (ms)
|
||||
static_assert((uint64_t) overflowTick * (uint64_t) alwaysOnRefreshPeriod < (uint64_t) UINT32_MAX * 1000ULL / configTICK_RATE_HZ);
|
||||
|
||||
if (alwaysOnTickCount == overflowTick) {
|
||||
alwaysOnTickCount = 0;
|
||||
alwaysOnStartTime = xTaskGetTickCount();
|
||||
}
|
||||
if (elapsedTarget > ticksElapsed) {
|
||||
return elapsedTarget - ticksElapsed;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayApp::Refresh() {
|
||||
auto LoadPreviousScreen = [this]() {
|
||||
FullRefreshDirections returnDirection;
|
||||
|
@ -203,7 +237,29 @@ void DisplayApp::Refresh() {
|
|||
TickType_t queueTimeout;
|
||||
switch (state) {
|
||||
case States::Idle:
|
||||
queueTimeout = portMAX_DELAY;
|
||||
if (settingsController.GetAlwaysOnDisplay()) {
|
||||
if (!currentScreen->IsRunning()) {
|
||||
LoadPreviousScreen();
|
||||
}
|
||||
// Check we've slept long enough
|
||||
// Might not be true if the loop received an event
|
||||
// If not true, then wait that amount of time
|
||||
queueTimeout = CalculateSleepTime();
|
||||
if (queueTimeout == 0) {
|
||||
// Only advance the tick count when LVGL is done
|
||||
// Otherwise keep running the task handler while it still has things to draw
|
||||
// Note: under high graphics load, LVGL will always have more work to do
|
||||
if (lv_task_handler() > 0) {
|
||||
// Drop frames that we've missed if drawing/event handling took way longer than expected
|
||||
while (queueTimeout == 0) {
|
||||
alwaysOnTickCount += 1;
|
||||
queueTimeout = CalculateSleepTime();
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
queueTimeout = portMAX_DELAY;
|
||||
}
|
||||
break;
|
||||
case States::Running:
|
||||
if (!currentScreen->IsRunning()) {
|
||||
|
@ -234,20 +290,34 @@ void DisplayApp::Refresh() {
|
|||
case Messages::DimScreen:
|
||||
DimScreen();
|
||||
break;
|
||||
case Messages::RestoreBrightness:
|
||||
RestoreBrightness();
|
||||
break;
|
||||
case Messages::GoToSleep:
|
||||
while (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) {
|
||||
while (brightnessController.Level() != Controllers::BrightnessController::Levels::Low) {
|
||||
brightnessController.Lower();
|
||||
vTaskDelay(100);
|
||||
}
|
||||
lcd.Sleep();
|
||||
// Don't actually turn off the display for AlwaysOn mode
|
||||
if (settingsController.GetAlwaysOnDisplay()) {
|
||||
brightnessController.Set(Controllers::BrightnessController::Levels::AlwaysOn);
|
||||
lcd.LowPowerOn();
|
||||
// Record idle entry time
|
||||
alwaysOnTickCount = 0;
|
||||
alwaysOnStartTime = xTaskGetTickCount();
|
||||
} else {
|
||||
brightnessController.Set(Controllers::BrightnessController::Levels::Off);
|
||||
lcd.Sleep();
|
||||
}
|
||||
PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping);
|
||||
state = States::Idle;
|
||||
break;
|
||||
case Messages::NotifyDeviceActivity:
|
||||
lv_disp_trig_activity(nullptr);
|
||||
break;
|
||||
case Messages::GoToRunning:
|
||||
lcd.Wakeup();
|
||||
if (settingsController.GetAlwaysOnDisplay()) {
|
||||
lcd.LowPowerOff();
|
||||
} else {
|
||||
lcd.Wakeup();
|
||||
}
|
||||
lv_disp_trig_activity(nullptr);
|
||||
ApplyBrightness();
|
||||
state = States::Running;
|
||||
|
@ -381,6 +451,12 @@ void DisplayApp::Refresh() {
|
|||
RestoreBrightness();
|
||||
motorController.RunForDuration(15);
|
||||
break;
|
||||
case Messages::ShowIgnoreTouchPopup:
|
||||
popupMessage.SetHidden(false);
|
||||
break;
|
||||
case Messages::HideIgnoreTouchPopup:
|
||||
popupMessage.SetHidden(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -504,7 +580,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
|||
currentScreen = std::make_unique<Screens::SettingWeatherFormat>(settingsController);
|
||||
break;
|
||||
case Apps::SettingWakeUp:
|
||||
currentScreen = std::make_unique<Screens::SettingWakeUp>(settingsController);
|
||||
currentScreen = std::make_unique<Screens::SettingWakeUp>(this, settingsController);
|
||||
break;
|
||||
case Apps::SettingDisplay:
|
||||
currentScreen = std::make_unique<Screens::SettingDisplay>(this, settingsController);
|
||||
|
@ -535,7 +611,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
|||
bleController,
|
||||
watchdog,
|
||||
motionController,
|
||||
touchPanel);
|
||||
touchPanel,
|
||||
spiNorFlash);
|
||||
break;
|
||||
case Apps::FlashLight:
|
||||
currentScreen = std::make_unique<Screens::FlashLight>(*systemTask, brightnessController);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "components/timer/Timer.h"
|
||||
#include "components/alarm/AlarmController.h"
|
||||
#include "touchhandler/TouchHandler.h"
|
||||
#include "displayapp/widgets/PopupMessage.h"
|
||||
|
||||
#include "displayapp/Messages.h"
|
||||
#include "BootErrors.h"
|
||||
|
@ -66,7 +67,8 @@ namespace Pinetime {
|
|||
Pinetime::Controllers::AlarmController& alarmController,
|
||||
Pinetime::Controllers::BrightnessController& brightnessController,
|
||||
Pinetime::Controllers::TouchHandler& touchHandler,
|
||||
Pinetime::Controllers::FS& filesystem);
|
||||
Pinetime::Controllers::FS& filesystem,
|
||||
Pinetime::Drivers::SpiNorFlash& spiNorFlash);
|
||||
void Start(System::BootErrors error);
|
||||
void PushMessage(Display::Messages msg);
|
||||
|
||||
|
@ -96,11 +98,14 @@ namespace Pinetime {
|
|||
Pinetime::Controllers::BrightnessController& brightnessController;
|
||||
Pinetime::Controllers::TouchHandler& touchHandler;
|
||||
Pinetime::Controllers::FS& filesystem;
|
||||
Pinetime::Drivers::SpiNorFlash& spiNorFlash;
|
||||
|
||||
Pinetime::Controllers::FirmwareValidator validator;
|
||||
Pinetime::Components::LittleVgl lvgl;
|
||||
Pinetime::Controllers::Timer timer;
|
||||
|
||||
Pinetime::Applications::Widgets::PopupMessage popupMessage;
|
||||
|
||||
AppControllers controllers;
|
||||
TaskHandle_t taskHandle;
|
||||
|
||||
|
@ -135,6 +140,13 @@ namespace Pinetime {
|
|||
Utility::StaticStack<FullRefreshDirections, returnAppStackSize> appStackDirections;
|
||||
|
||||
bool isDimmed = false;
|
||||
|
||||
TickType_t CalculateSleepTime();
|
||||
TickType_t alwaysOnTickCount;
|
||||
TickType_t alwaysOnStartTime;
|
||||
// If this is to be changed, make sure the actual always on refresh rate is changed
|
||||
// by configuring the LCD refresh timings
|
||||
static constexpr uint32_t alwaysOnRefreshPeriod = 500;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
|||
Pinetime::Controllers::AlarmController& /*alarmController*/,
|
||||
Pinetime::Controllers::BrightnessController& /*brightnessController*/,
|
||||
Pinetime::Controllers::TouchHandler& /*touchHandler*/,
|
||||
Pinetime::Controllers::FS& /*filesystem*/)
|
||||
Pinetime::Controllers::FS& /*filesystem*/,
|
||||
Pinetime::Drivers::SpiNorFlash& /*spiNorFlash*/)
|
||||
: lcd {lcd}, bleController {bleController} {
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Pinetime {
|
|||
class St7789;
|
||||
class Cst816S;
|
||||
class Watchdog;
|
||||
class SpiNorFlash;
|
||||
}
|
||||
|
||||
namespace Controllers {
|
||||
|
@ -59,7 +60,8 @@ namespace Pinetime {
|
|||
Pinetime::Controllers::AlarmController& alarmController,
|
||||
Pinetime::Controllers::BrightnessController& brightnessController,
|
||||
Pinetime::Controllers::TouchHandler& touchHandler,
|
||||
Pinetime::Controllers::FS& filesystem);
|
||||
Pinetime::Controllers::FS& filesystem,
|
||||
Pinetime::Drivers::SpiNorFlash& spiNorFlash);
|
||||
void Start();
|
||||
|
||||
void Start(Pinetime::System::BootErrors) {
|
||||
|
|
|
@ -18,12 +18,14 @@ namespace Pinetime {
|
|||
TimerDone,
|
||||
BleFirmwareUpdateStarted,
|
||||
DimScreen,
|
||||
RestoreBrightness,
|
||||
NotifyDeviceActivity,
|
||||
ShowPairingKey,
|
||||
AlarmTriggered,
|
||||
Chime,
|
||||
BleRadioEnableToggle,
|
||||
OnChargingEvent,
|
||||
ShowIgnoreTouchPopup,
|
||||
HideIgnoreTouchPopup
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set(FONTS jetbrains_mono_42 jetbrains_mono_76 jetbrains_mono_bold_20
|
||||
jetbrains_mono_extrabold_compressed lv_font_sys_48
|
||||
jetbrains_mono_extrabold_compressed lv_font_sys_48 lv_font_sys_80
|
||||
open_sans_light fontawesome_weathericons)
|
||||
find_program(LV_FONT_CONV "lv_font_conv" NO_CACHE REQUIRED
|
||||
HINTS "${CMAKE_SOURCE_DIR}/node_modules/.bin")
|
||||
|
|
|
@ -64,6 +64,16 @@
|
|||
"bpp": 1,
|
||||
"size": 48
|
||||
},
|
||||
"lv_font_sys_80": {
|
||||
"sources": [
|
||||
{
|
||||
"file": "material-design-icons/MaterialIcons-Regular.ttf",
|
||||
"range": "0xe897"
|
||||
}
|
||||
],
|
||||
"bpp": 1,
|
||||
"size": 80
|
||||
},
|
||||
"fontawesome_weathericons": {
|
||||
"sources": [
|
||||
{
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace {
|
|||
FlashLight::FlashLight(System::SystemTask& systemTask, Controllers::BrightnessController& brightnessController)
|
||||
: systemTask {systemTask}, brightnessController {brightnessController} {
|
||||
|
||||
previousBrightnessLevel = brightnessController.Level();
|
||||
brightnessController.Set(Controllers::BrightnessController::Levels::Low);
|
||||
|
||||
flashLight = lv_label_create(lv_scr_act(), nullptr);
|
||||
|
@ -52,6 +53,7 @@ FlashLight::FlashLight(System::SystemTask& systemTask, Controllers::BrightnessCo
|
|||
FlashLight::~FlashLight() {
|
||||
lv_obj_clean(lv_scr_act());
|
||||
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
brightnessController.Set(previousBrightnessLevel);
|
||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace Pinetime {
|
|||
Controllers::BrightnessController& brightnessController;
|
||||
|
||||
Controllers::BrightnessController::Levels brightnessLevel = Controllers::BrightnessController::Levels::High;
|
||||
Controllers::BrightnessController::Levels previousBrightnessLevel;
|
||||
|
||||
lv_obj_t* flashLight;
|
||||
lv_obj_t* backgroundAction;
|
||||
|
|
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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -64,6 +64,9 @@ namespace Pinetime {
|
|||
|
||||
static constexpr const char* flashlight = "\xEF\x80\x8B";
|
||||
static constexpr const char* paintbrushLg = "\xEE\x90\x8A";
|
||||
|
||||
// wake-up screenlock icon, from material icons
|
||||
static constexpr const char* lock = "\xEE\xA2\x97";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
|
|||
const Pinetime::Controllers::Ble& bleController,
|
||||
const Pinetime::Drivers::Watchdog& watchdog,
|
||||
Pinetime::Controllers::MotionController& motionController,
|
||||
const Pinetime::Drivers::Cst816S& touchPanel)
|
||||
const Pinetime::Drivers::Cst816S& touchPanel,
|
||||
const Pinetime::Drivers::SpiNorFlash& spiNorFlash)
|
||||
: app {app},
|
||||
dateTimeController {dateTimeController},
|
||||
batteryController {batteryController},
|
||||
|
@ -47,6 +48,7 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
|
|||
watchdog {watchdog},
|
||||
motionController {motionController},
|
||||
touchPanel {touchPanel},
|
||||
spiNorFlash {spiNorFlash},
|
||||
screens {app,
|
||||
0,
|
||||
{[this]() -> std::unique_ptr<Screen> {
|
||||
|
@ -186,10 +188,12 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
|
|||
lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_recolor(label, true);
|
||||
const auto& bleAddr = bleController.Address();
|
||||
auto spiFlashId = spiNorFlash.GetIdentification();
|
||||
lv_label_set_text_fmt(label,
|
||||
"#808080 BLE MAC#\n"
|
||||
" %02x:%02x:%02x:%02x:%02x:%02x"
|
||||
" %02x:%02x:%02x:%02x:%02x:%02x\n"
|
||||
"\n"
|
||||
"#808080 SPI Flash# %02x-%02x-%02x\n"
|
||||
"\n"
|
||||
"#808080 Memory heap#\n"
|
||||
" #808080 Free# %d\n"
|
||||
|
@ -202,6 +206,9 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
|
|||
bleAddr[2],
|
||||
bleAddr[1],
|
||||
bleAddr[0],
|
||||
spiFlashId.manufacturer,
|
||||
spiFlashId.type,
|
||||
spiFlashId.density,
|
||||
xPortGetFreeHeapSize(),
|
||||
xPortGetMinimumEverFreeHeapSize(),
|
||||
mallocFailedCount,
|
||||
|
|
|
@ -29,7 +29,8 @@ namespace Pinetime {
|
|||
const Pinetime::Controllers::Ble& bleController,
|
||||
const Pinetime::Drivers::Watchdog& watchdog,
|
||||
Pinetime::Controllers::MotionController& motionController,
|
||||
const Pinetime::Drivers::Cst816S& touchPanel);
|
||||
const Pinetime::Drivers::Cst816S& touchPanel,
|
||||
const Pinetime::Drivers::SpiNorFlash& spiNorFlash);
|
||||
~SystemInfo() override;
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
|
||||
|
@ -42,6 +43,7 @@ namespace Pinetime {
|
|||
const Pinetime::Drivers::Watchdog& watchdog;
|
||||
Pinetime::Controllers::MotionController& motionController;
|
||||
const Pinetime::Drivers::Cst816S& touchPanel;
|
||||
const Pinetime::Drivers::SpiNorFlash& spiNorFlash;
|
||||
|
||||
ScreenList<5> screens;
|
||||
|
||||
|
|
|
@ -9,10 +9,17 @@
|
|||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
namespace {
|
||||
void event_handler(lv_obj_t* obj, lv_event_t event) {
|
||||
void TimeoutEventHandler(lv_obj_t* obj, lv_event_t event) {
|
||||
auto* screen = static_cast<SettingDisplay*>(obj->user_data);
|
||||
screen->UpdateSelected(obj, event);
|
||||
}
|
||||
|
||||
void AlwaysOnEventHandler(lv_obj_t* obj, lv_event_t event) {
|
||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
||||
auto* screen = static_cast<SettingDisplay*>(obj->user_data);
|
||||
screen->ToggleAlwaysOn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constexpr std::array<uint16_t, 6> SettingDisplay::options;
|
||||
|
@ -49,13 +56,20 @@ SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime
|
|||
snprintf(buffer, sizeof(buffer), "%2" PRIu16 "s", options[i] / 1000);
|
||||
lv_checkbox_set_text(cbOption[i], buffer);
|
||||
cbOption[i]->user_data = this;
|
||||
lv_obj_set_event_cb(cbOption[i], event_handler);
|
||||
lv_obj_set_event_cb(cbOption[i], TimeoutEventHandler);
|
||||
SetRadioButtonStyle(cbOption[i]);
|
||||
|
||||
if (settingsController.GetScreenTimeOut() == options[i]) {
|
||||
lv_checkbox_set_checked(cbOption[i], true);
|
||||
}
|
||||
}
|
||||
|
||||
alwaysOnCheckbox = lv_checkbox_create(container1, nullptr);
|
||||
lv_checkbox_set_text(alwaysOnCheckbox, "Always On");
|
||||
lv_checkbox_set_checked(alwaysOnCheckbox, settingsController.GetAlwaysOnDisplaySetting());
|
||||
lv_obj_add_state(alwaysOnCheckbox, LV_STATE_DEFAULT);
|
||||
alwaysOnCheckbox->user_data = this;
|
||||
lv_obj_set_event_cb(alwaysOnCheckbox, AlwaysOnEventHandler);
|
||||
}
|
||||
|
||||
SettingDisplay::~SettingDisplay() {
|
||||
|
@ -63,6 +77,11 @@ SettingDisplay::~SettingDisplay() {
|
|||
settingsController.SaveSettings();
|
||||
}
|
||||
|
||||
void SettingDisplay::ToggleAlwaysOn() {
|
||||
settingsController.SetAlwaysOnDisplaySetting(!settingsController.GetAlwaysOnDisplaySetting());
|
||||
lv_checkbox_set_checked(alwaysOnCheckbox, settingsController.GetAlwaysOnDisplaySetting());
|
||||
}
|
||||
|
||||
void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||
if (event == LV_EVENT_CLICKED) {
|
||||
for (unsigned int i = 0; i < options.size(); i++) {
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Pinetime {
|
|||
~SettingDisplay() override;
|
||||
|
||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||
void ToggleAlwaysOn();
|
||||
|
||||
private:
|
||||
DisplayApp* app;
|
||||
|
@ -25,6 +26,7 @@ namespace Pinetime {
|
|||
|
||||
Controllers::Settings& settingsController;
|
||||
lv_obj_t* cbOption[options.size()];
|
||||
lv_obj_t* alwaysOnCheckbox;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,17 @@
|
|||
|
||||
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 {
|
||||
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_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_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);
|
||||
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);
|
||||
}
|
||||
cbOption[i]->user_data = this;
|
||||
lv_obj_set_event_cb(cbOption[i], event_handler);
|
||||
}
|
||||
return std::make_unique<Screens::Page>(screenNum, nScreens, container1);
|
||||
}
|
||||
|
||||
SettingWakeUp::~SettingWakeUp() {
|
||||
lv_obj_clean(lv_scr_act());
|
||||
settingsController.SaveSettings();
|
||||
bool SettingWakeUp::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
return screens.OnTouchEvent(event);
|
||||
}
|
||||
|
||||
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.
|
||||
auto modes = settingsController.getWakeUpModes();
|
||||
for (size_t i = 0; i < options.size(); ++i) {
|
||||
lv_checkbox_set_checked(cbOption[i], modes[i]);
|
||||
if (cbOption[i]) {
|
||||
lv_checkbox_set_checked(cbOption[i], modes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
#include <cstdint>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include "components/settings/Settings.h"
|
||||
#include "displayapp/screens/Page.h"
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "displayapp/screens/ScreenList.h"
|
||||
#include "displayapp/widgets/PageIndicator.h"
|
||||
|
||||
namespace Pinetime {
|
||||
|
||||
|
@ -13,27 +16,40 @@ namespace Pinetime {
|
|||
|
||||
class SettingWakeUp : public Screen {
|
||||
public:
|
||||
SettingWakeUp(Pinetime::Controllers::Settings& settingsController);
|
||||
SettingWakeUp(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||
~SettingWakeUp() override;
|
||||
|
||||
void UpdateSelected(lv_obj_t* object);
|
||||
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
|
||||
private:
|
||||
auto CreateScreenList();
|
||||
std::unique_ptr<Screen> CreateScreen(size_t screenNum);
|
||||
|
||||
struct Option {
|
||||
Controllers::Settings::WakeUpMode wakeUpMode;
|
||||
const char* name;
|
||||
};
|
||||
|
||||
static constexpr size_t numOptions = 6;
|
||||
static constexpr size_t optionsPerScreen = 4;
|
||||
static constexpr size_t nScreens = 2;
|
||||
|
||||
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::DoubleTap, "Double Tap"},
|
||||
{Controllers::Settings::WakeUpMode::RaiseWrist, "Raise Wrist"},
|
||||
{Controllers::Settings::WakeUpMode::Shake, "Shake Wake"},
|
||||
{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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
37
src/displayapp/widgets/PopupMessage.cpp
Normal file
37
src/displayapp/widgets/PopupMessage.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include "displayapp/widgets/PopupMessage.h"
|
||||
#include <libraries/log/nrf_log.h>
|
||||
|
||||
using namespace Pinetime::Applications::Widgets;
|
||||
|
||||
PopupMessage::PopupMessage(const char* msg, int16_t h, int16_t w) : message {msg}, height {h}, width {w} {
|
||||
}
|
||||
|
||||
void PopupMessage::Create() {
|
||||
btnPopup = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnPopup->user_data = this;
|
||||
lv_obj_set_size(btnPopup, height, width);
|
||||
lv_obj_align(btnPopup, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_local_bg_opa(btnPopup, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_60);
|
||||
lv_obj_set_style_local_text_font(btnPopup, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_80);
|
||||
lv_obj_t* lblMessage = lv_label_create(btnPopup, nullptr);
|
||||
lv_label_set_text_static(lblMessage, message);
|
||||
lv_obj_set_hidden(btnPopup, isHidden);
|
||||
}
|
||||
|
||||
void PopupMessage::SetHidden(bool hidden) {
|
||||
if (isHidden == hidden) {
|
||||
return;
|
||||
}
|
||||
isHidden = hidden;
|
||||
// create/delete on demand
|
||||
if (btnPopup == nullptr && !isHidden) {
|
||||
Create();
|
||||
} else if (btnPopup != nullptr) {
|
||||
lv_obj_del(btnPopup);
|
||||
btnPopup = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool PopupMessage::IsHidden() {
|
||||
return isHidden;
|
||||
}
|
24
src/displayapp/widgets/PopupMessage.h
Normal file
24
src/displayapp/widgets/PopupMessage.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Applications {
|
||||
namespace Widgets {
|
||||
class PopupMessage {
|
||||
public:
|
||||
// The caller owns the message string, it is not copied.
|
||||
PopupMessage(const char* msg, int16_t h, int16_t w);
|
||||
void Create();
|
||||
void SetHidden(bool hidden);
|
||||
bool IsHidden();
|
||||
|
||||
private:
|
||||
const char* message;
|
||||
lv_obj_t* btnPopup = nullptr;
|
||||
bool isHidden = true;
|
||||
int16_t height;
|
||||
int16_t width;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ SpiNorFlash::SpiNorFlash(Spi& spi) : spi {spi} {
|
|||
}
|
||||
|
||||
void SpiNorFlash::Init() {
|
||||
device_id = ReadIdentificaion();
|
||||
device_id = ReadIdentification();
|
||||
NRF_LOG_INFO("[SpiNorFlash] Manufacturer : %d, Memory type : %d, memory density : %d",
|
||||
device_id.manufacturer,
|
||||
device_id.type,
|
||||
|
@ -32,7 +32,7 @@ void SpiNorFlash::Wakeup() {
|
|||
uint8_t cmd[cmdSize] = {static_cast<uint8_t>(Commands::ReleaseFromDeepPowerDown), 0x01, 0x02, 0x03};
|
||||
uint8_t id = 0;
|
||||
spi.Read(reinterpret_cast<uint8_t*>(&cmd), cmdSize, &id, 1);
|
||||
auto devId = device_id = ReadIdentificaion();
|
||||
auto devId = device_id = ReadIdentification();
|
||||
if (devId.type != device_id.type) {
|
||||
NRF_LOG_INFO("[SpiNorFlash] ID on Wakeup: Failed");
|
||||
} else {
|
||||
|
@ -41,7 +41,7 @@ void SpiNorFlash::Wakeup() {
|
|||
NRF_LOG_INFO("[SpiNorFlash] Wakeup")
|
||||
}
|
||||
|
||||
SpiNorFlash::Identification SpiNorFlash::ReadIdentificaion() {
|
||||
SpiNorFlash::Identification SpiNorFlash::ReadIdentification() {
|
||||
auto cmd = static_cast<uint8_t>(Commands::ReadIdentification);
|
||||
Identification identification;
|
||||
spi.Read(&cmd, 1, reinterpret_cast<uint8_t*>(&identification), sizeof(Identification));
|
||||
|
@ -145,3 +145,7 @@ void SpiNorFlash::Write(uint32_t address, const uint8_t* buffer, size_t size) {
|
|||
len -= toWrite;
|
||||
}
|
||||
}
|
||||
|
||||
SpiNorFlash::Identification SpiNorFlash::GetIdentification() const {
|
||||
return device_id;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ namespace Pinetime {
|
|||
uint8_t density = 0;
|
||||
};
|
||||
|
||||
Identification ReadIdentificaion();
|
||||
uint8_t ReadStatusRegister();
|
||||
bool WriteInProgress();
|
||||
bool WriteEnabled();
|
||||
|
@ -33,6 +32,8 @@ namespace Pinetime {
|
|||
bool ProgramFailed();
|
||||
bool EraseFailed();
|
||||
|
||||
Identification GetIdentification() const;
|
||||
|
||||
void Init();
|
||||
void Uninit();
|
||||
|
||||
|
@ -40,6 +41,8 @@ namespace Pinetime {
|
|||
void Wakeup();
|
||||
|
||||
private:
|
||||
Identification ReadIdentification();
|
||||
|
||||
enum class Commands : uint8_t {
|
||||
PageProgram = 0x02,
|
||||
Read = 0x03,
|
||||
|
|
|
@ -16,6 +16,7 @@ void St7789::Init() {
|
|||
nrf_gpio_pin_set(pinReset);
|
||||
HardwareReset();
|
||||
SoftwareReset();
|
||||
Command2Enable();
|
||||
SleepOut();
|
||||
PixelFormat();
|
||||
MemoryDataAccessControl();
|
||||
|
@ -24,8 +25,13 @@ void St7789::Init() {
|
|||
#ifndef DRIVER_DISPLAY_MIRROR
|
||||
DisplayInversionOn();
|
||||
#endif
|
||||
PorchSet();
|
||||
FrameRateNormalSet();
|
||||
IdleFrameRateOff();
|
||||
NormalModeOn();
|
||||
SetVdv();
|
||||
PowerControl();
|
||||
GateControl();
|
||||
DisplayOn();
|
||||
}
|
||||
|
||||
|
@ -63,6 +69,17 @@ void St7789::SoftwareReset() {
|
|||
vTaskDelay(pdMS_TO_TICKS(125));
|
||||
}
|
||||
|
||||
void St7789::Command2Enable() {
|
||||
WriteCommand(static_cast<uint8_t>(Commands::Command2Enable));
|
||||
constexpr uint8_t args[] = {
|
||||
0x5a, // Constant
|
||||
0x69, // Constant
|
||||
0x02, // Constant
|
||||
0x01, // Enable
|
||||
};
|
||||
WriteData(args, sizeof(args));
|
||||
}
|
||||
|
||||
void St7789::SleepOut() {
|
||||
if (!sleepIn) {
|
||||
return;
|
||||
|
@ -127,10 +144,79 @@ void St7789::NormalModeOn() {
|
|||
WriteCommand(static_cast<uint8_t>(Commands::NormalModeOn));
|
||||
}
|
||||
|
||||
void St7789::IdleModeOn() {
|
||||
WriteCommand(static_cast<uint8_t>(Commands::IdleModeOn));
|
||||
}
|
||||
|
||||
void St7789::IdleModeOff() {
|
||||
WriteCommand(static_cast<uint8_t>(Commands::IdleModeOff));
|
||||
}
|
||||
|
||||
void St7789::PorchSet() {
|
||||
WriteCommand(static_cast<uint8_t>(Commands::Porch));
|
||||
constexpr uint8_t args[] = {
|
||||
0x02, // Normal mode front porch
|
||||
0x03, // Normal mode back porch
|
||||
0x01, // Porch control enable
|
||||
0xed, // Idle mode front:back porch
|
||||
0xed, // Partial mode front:back porch (partial mode unused but set anyway)
|
||||
};
|
||||
WriteData(args, sizeof(args));
|
||||
}
|
||||
|
||||
void St7789::FrameRateNormalSet() {
|
||||
WriteCommand(static_cast<uint8_t>(Commands::FrameRateNormal));
|
||||
// Note that the datasheet table is imprecise - see formula below table
|
||||
WriteData(0x0a);
|
||||
}
|
||||
|
||||
void St7789::IdleFrameRateOn() {
|
||||
WriteCommand(static_cast<uint8_t>(Commands::FrameRateIdle));
|
||||
// According to the datasheet, these controls should apply only to partial/idle mode
|
||||
// However they appear to apply to normal mode, so we have to enable/disable
|
||||
// every time we enter/exit always on
|
||||
// In testing this divider appears to actually be 16x?
|
||||
constexpr uint8_t args[] = {
|
||||
0x13, // Enable frame rate control for partial/idle mode, 8x frame divider
|
||||
0x1e, // Idle mode frame rate
|
||||
0x1e, // Partial mode frame rate (unused)
|
||||
};
|
||||
WriteData(args, sizeof(args));
|
||||
}
|
||||
|
||||
void St7789::IdleFrameRateOff() {
|
||||
WriteCommand(static_cast<uint8_t>(Commands::FrameRateIdle));
|
||||
constexpr uint8_t args[] = {
|
||||
0x00, // Disable frame rate control and divider
|
||||
0x0a, // Idle mode frame rate (normal)
|
||||
0x0a, // Partial mode frame rate (normal, unused)
|
||||
};
|
||||
WriteData(args, sizeof(args));
|
||||
}
|
||||
|
||||
void St7789::DisplayOn() {
|
||||
WriteCommand(static_cast<uint8_t>(Commands::DisplayOn));
|
||||
}
|
||||
|
||||
void St7789::PowerControl() {
|
||||
WriteCommand(static_cast<uint8_t>(Commands::PowerControl1));
|
||||
constexpr uint8_t args[] = {
|
||||
0xa4, // Constant
|
||||
0x00, // Lowest possible voltages
|
||||
};
|
||||
WriteData(args, sizeof(args));
|
||||
|
||||
WriteCommand(static_cast<uint8_t>(Commands::PowerControl2));
|
||||
// Lowest possible boost circuit clocks
|
||||
WriteData(0xb3);
|
||||
}
|
||||
|
||||
void St7789::GateControl() {
|
||||
WriteCommand(static_cast<uint8_t>(Commands::GateControl));
|
||||
// Lowest possible VGL/VGH
|
||||
WriteData(0x00);
|
||||
}
|
||||
|
||||
void St7789::SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||
WriteCommand(static_cast<uint8_t>(Commands::ColumnAddressSet));
|
||||
uint8_t colArgs[] = {
|
||||
|
@ -198,6 +284,18 @@ void St7789::HardwareReset() {
|
|||
vTaskDelay(pdMS_TO_TICKS(125));
|
||||
}
|
||||
|
||||
void St7789::LowPowerOn() {
|
||||
IdleModeOn();
|
||||
IdleFrameRateOn();
|
||||
NRF_LOG_INFO("[LCD] Low power mode");
|
||||
}
|
||||
|
||||
void St7789::LowPowerOff() {
|
||||
IdleModeOff();
|
||||
IdleFrameRateOff();
|
||||
NRF_LOG_INFO("[LCD] Normal power mode");
|
||||
}
|
||||
|
||||
void St7789::Sleep() {
|
||||
SleepIn();
|
||||
nrf_gpio_cfg_default(pinDataCommand);
|
||||
|
|
|
@ -24,6 +24,8 @@ namespace Pinetime {
|
|||
|
||||
void DrawBuffer(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint8_t* data, size_t size);
|
||||
|
||||
void LowPowerOn();
|
||||
void LowPowerOff();
|
||||
void Sleep();
|
||||
void Wakeup();
|
||||
|
||||
|
@ -37,6 +39,7 @@ namespace Pinetime {
|
|||
|
||||
void HardwareReset();
|
||||
void SoftwareReset();
|
||||
void Command2Enable();
|
||||
void SleepOut();
|
||||
void EnsureSleepOutPostDelay();
|
||||
void SleepIn();
|
||||
|
@ -45,8 +48,16 @@ namespace Pinetime {
|
|||
void DisplayInversionOn();
|
||||
void NormalModeOn();
|
||||
void WriteToRam(const uint8_t* data, size_t size);
|
||||
void IdleModeOn();
|
||||
void IdleModeOff();
|
||||
void FrameRateNormalSet();
|
||||
void IdleFrameRateOff();
|
||||
void IdleFrameRateOn();
|
||||
void DisplayOn();
|
||||
void DisplayOff();
|
||||
void PowerControl();
|
||||
void GateControl();
|
||||
void PorchSet();
|
||||
|
||||
void SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||
void SetVdv();
|
||||
|
@ -68,8 +79,17 @@ namespace Pinetime {
|
|||
MemoryDataAccessControl = 0x36,
|
||||
VerticalScrollDefinition = 0x33,
|
||||
VerticalScrollStartAddress = 0x37,
|
||||
IdleModeOff = 0x38,
|
||||
IdleModeOn = 0x39,
|
||||
PixelFormat = 0x3a,
|
||||
FrameRateIdle = 0xb3,
|
||||
FrameRateNormal = 0xc6,
|
||||
VdvSet = 0xc4,
|
||||
Command2Enable = 0xdf,
|
||||
PowerControl1 = 0xd0,
|
||||
PowerControl2 = 0xe8,
|
||||
GateControl = 0xb7,
|
||||
Porch = 0xb2,
|
||||
};
|
||||
void WriteData(uint8_t data);
|
||||
void WriteData(const uint8_t* data, size_t size);
|
||||
|
|
|
@ -419,7 +419,8 @@ typedef void* lv_indev_drv_user_data_t; /*Type of user data in the in
|
|||
LV_FONT_DECLARE(jetbrains_mono_76) \
|
||||
LV_FONT_DECLARE(open_sans_light) \
|
||||
LV_FONT_DECLARE(fontawesome_weathericons) \
|
||||
LV_FONT_DECLARE(lv_font_sys_48)
|
||||
LV_FONT_DECLARE(lv_font_sys_48) \
|
||||
LV_FONT_DECLARE(lv_font_sys_80)
|
||||
|
||||
/* Enable it if you have fonts with a lot of characters.
|
||||
* The limit depends on the font size, font face and bpp
|
||||
|
|
|
@ -123,7 +123,8 @@ Pinetime::Applications::DisplayApp displayApp(lcd,
|
|||
alarmController,
|
||||
brightnessController,
|
||||
touchHandler,
|
||||
fs);
|
||||
fs,
|
||||
spiNorFlash);
|
||||
|
||||
Pinetime::System::SystemTask systemTask(spi,
|
||||
spiNorFlash,
|
||||
|
|
|
@ -102,7 +102,9 @@ void SystemTask::Work() {
|
|||
watchdog.Setup(7, Drivers::Watchdog::SleepBehaviour::Run, Drivers::Watchdog::HaltBehaviour::Pause);
|
||||
watchdog.Start();
|
||||
NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::ResetReasonToString(watchdog.GetResetReason()));
|
||||
APP_GPIOTE_INIT(2);
|
||||
if (!nrfx_gpiote_is_init()) {
|
||||
nrfx_gpiote_init();
|
||||
}
|
||||
|
||||
spi.Init();
|
||||
spiNorFlash.Init();
|
||||
|
@ -192,13 +194,16 @@ void SystemTask::Work() {
|
|||
if (!bleController.IsFirmwareUpdating()) {
|
||||
doNotGoToSleep = false;
|
||||
}
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
|
||||
break;
|
||||
case Messages::DisableSleeping:
|
||||
doNotGoToSleep = true;
|
||||
break;
|
||||
case Messages::GoToRunning:
|
||||
spi.Wakeup();
|
||||
// SPI doesn't go to sleep for always on mode
|
||||
if (!settingsController.GetAlwaysOnDisplay()) {
|
||||
spi.Wakeup();
|
||||
}
|
||||
|
||||
// Double Tap needs the touch screen to be in normal mode
|
||||
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
||||
|
@ -217,7 +222,11 @@ void SystemTask::Work() {
|
|||
state = SystemTaskState::Running;
|
||||
break;
|
||||
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();
|
||||
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
|
||||
gesture != Pinetime::Applications::TouchEvents::None &&
|
||||
|
@ -225,12 +234,15 @@ void SystemTask::Work() {
|
|||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) ||
|
||||
(gesture == Pinetime::Applications::TouchEvents::Tap &&
|
||||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
|
||||
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::WakeUpAction, true);
|
||||
GoToRunning();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Messages::GoToSleep:
|
||||
touchHandler.SetIgnoreTouchPopupHidden(true);
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::HideIgnoreTouchPopup);
|
||||
if (doNotGoToSleep) {
|
||||
break;
|
||||
}
|
||||
|
@ -240,7 +252,7 @@ void SystemTask::Work() {
|
|||
heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep);
|
||||
break;
|
||||
case Messages::OnNewTime:
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
|
||||
if (alarmController.State() == Controllers::AlarmController::AlarmState::Set) {
|
||||
alarmController.ScheduleAlarm();
|
||||
|
@ -249,27 +261,30 @@ void SystemTask::Work() {
|
|||
case Messages::OnNewNotification:
|
||||
if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::On) {
|
||||
if (state == SystemTaskState::Sleeping) {
|
||||
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||
GoToRunning();
|
||||
} else {
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
|
||||
}
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
|
||||
}
|
||||
break;
|
||||
case Messages::SetOffAlarm:
|
||||
if (state == SystemTaskState::Sleeping) {
|
||||
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||
GoToRunning();
|
||||
}
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::AlarmTriggered);
|
||||
break;
|
||||
case Messages::BleConnected:
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
|
||||
isBleDiscoveryTimerRunning = true;
|
||||
bleDiscoveryTimer = 5;
|
||||
break;
|
||||
case Messages::BleFirmwareUpdateStarted:
|
||||
doNotGoToSleep = true;
|
||||
if (state == SystemTaskState::Sleeping) {
|
||||
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||
GoToRunning();
|
||||
}
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::BleFirmwareUpdateStarted);
|
||||
|
@ -284,6 +299,7 @@ void SystemTask::Work() {
|
|||
NRF_LOG_INFO("[systemtask] FS Started");
|
||||
doNotGoToSleep = true;
|
||||
if (state == SystemTaskState::Sleeping) {
|
||||
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||
GoToRunning();
|
||||
}
|
||||
// TODO add intent of fs access icon or something
|
||||
|
@ -294,24 +310,39 @@ void SystemTask::Work() {
|
|||
// TODO add intent of fs access icon or something
|
||||
break;
|
||||
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);
|
||||
} else if (reply == Pinetime::Controllers::TouchHandler::TouchProcessReply::IgnoreTouchPopup) {
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::ShowIgnoreTouchPopup);
|
||||
touchHandler.SetIgnoreTouchPopupHidden(false);
|
||||
}
|
||||
break;
|
||||
case Messages::HandleButtonEvent: {
|
||||
Controllers::ButtonActions action = Controllers::ButtonActions::None;
|
||||
if (nrf_gpio_pin_read(Pinetime::PinMap::Button) == 0) {
|
||||
action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Release);
|
||||
// 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 {
|
||||
action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Press);
|
||||
// This is for faster wakeup, sacrificing special longpress and doubleclick handling while sleeping
|
||||
if (IsSleeping()) {
|
||||
fastWakeUpDone = true;
|
||||
GoToRunning();
|
||||
break;
|
||||
Controllers::ButtonActions action = Controllers::ButtonActions::None;
|
||||
if (nrf_gpio_pin_read(Pinetime::PinMap::Button) == 0) {
|
||||
action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Release);
|
||||
} else {
|
||||
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
|
||||
if (IsSleeping()) {
|
||||
fastWakeUpDone = true;
|
||||
GoToRunning();
|
||||
break;
|
||||
}
|
||||
}
|
||||
HandleButtonAction(action);
|
||||
}
|
||||
HandleButtonAction(action);
|
||||
} break;
|
||||
case Messages::HandleButtonTimerEvent: {
|
||||
auto action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Timer);
|
||||
|
@ -323,7 +354,11 @@ void SystemTask::Work() {
|
|||
// if it's in sleep mode. Avoid bricked device by disabling sleep mode on these versions.
|
||||
spiNorFlash.Sleep();
|
||||
}
|
||||
spi.Sleep();
|
||||
|
||||
// Must keep SPI awake when still updating the display for always on
|
||||
if (!settingsController.GetAlwaysOnDisplay()) {
|
||||
spi.Sleep();
|
||||
}
|
||||
|
||||
// Double Tap needs the touch screen to be in normal mode
|
||||
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
||||
|
@ -331,6 +366,8 @@ void SystemTask::Work() {
|
|||
}
|
||||
|
||||
state = SystemTaskState::Sleeping;
|
||||
// reset touch restrictions when going to sleep
|
||||
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||
break;
|
||||
case Messages::OnNewDay:
|
||||
// We might be sleeping (with TWI device disabled.
|
||||
|
@ -345,6 +382,7 @@ void SystemTask::Work() {
|
|||
// if sleeping, we can't send a chime to displayApp yet (SPI flash switched off)
|
||||
// request running first and repush the chime message
|
||||
if (state == SystemTaskState::Sleeping) {
|
||||
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||
GoToRunning();
|
||||
PushMessage(msg);
|
||||
} else {
|
||||
|
@ -360,6 +398,7 @@ void SystemTask::Work() {
|
|||
// if sleeping, we can't send a chime to displayApp yet (SPI flash switched off)
|
||||
// request running first and repush the chime message
|
||||
if (state == SystemTaskState::Sleeping) {
|
||||
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||
GoToRunning();
|
||||
PushMessage(msg);
|
||||
} else {
|
||||
|
@ -371,6 +410,7 @@ void SystemTask::Work() {
|
|||
batteryController.ReadPowerState();
|
||||
displayApp.PushMessage(Applications::Display::Messages::OnChargingEvent);
|
||||
if (state == SystemTaskState::Sleeping) {
|
||||
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||
GoToRunning();
|
||||
}
|
||||
break;
|
||||
|
@ -382,6 +422,7 @@ void SystemTask::Work() {
|
|||
break;
|
||||
case Messages::OnPairing:
|
||||
if (state == SystemTaskState::Sleeping) {
|
||||
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::Other, false);
|
||||
GoToRunning();
|
||||
}
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::ShowPairingKey);
|
||||
|
@ -443,6 +484,9 @@ void SystemTask::UpdateMotion() {
|
|||
motionController.ShouldRaiseWake()) ||
|
||||
(settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake) &&
|
||||
motionController.ShouldShakeWake(settingsController.GetShakeThreshold()))) {
|
||||
if (state == SystemTaskState::Sleeping) {
|
||||
touchHandler.SetWokenBy(Pinetime::Controllers::TouchHandler::WokenBy::WakeUpAction, true);
|
||||
}
|
||||
GoToRunning();
|
||||
}
|
||||
}
|
||||
|
@ -457,7 +501,7 @@ void SystemTask::HandleButtonAction(Controllers::ButtonActions action) {
|
|||
return;
|
||||
}
|
||||
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
|
||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
|
||||
|
||||
using Actions = Controllers::ButtonActions;
|
||||
|
||||
|
|
|
@ -53,6 +53,11 @@ namespace Pinetime {
|
|||
class SystemTask {
|
||||
public:
|
||||
enum class SystemTaskState { Sleeping, Running, GoingToSleep, WakingUp };
|
||||
// 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,
|
||||
Pinetime::Drivers::SpiNorFlash& spiNorFlash,
|
||||
Drivers::TwiMaster& twiMaster,
|
||||
|
|
|
@ -33,9 +33,9 @@ Pinetime::Applications::TouchEvents TouchHandler::GestureGet() {
|
|||
return returnGesture;
|
||||
}
|
||||
|
||||
bool TouchHandler::ProcessTouchInfo(Drivers::Cst816S::TouchInfos info) {
|
||||
TouchHandler::TouchProcessReply TouchHandler::ProcessTouchInfo(Drivers::Cst816S::TouchInfos info, bool buttonUnlocksOn) {
|
||||
if (!info.isValid) {
|
||||
return false;
|
||||
return TouchHandler::TouchProcessReply::NoAction;
|
||||
}
|
||||
|
||||
// Only a single gesture per touch
|
||||
|
@ -62,5 +62,19 @@ bool TouchHandler::ProcessTouchInfo(Drivers::Cst816S::TouchInfos info) {
|
|||
|
||||
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 {
|
||||
class TouchHandler {
|
||||
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 {
|
||||
int x;
|
||||
int y;
|
||||
bool touching;
|
||||
};
|
||||
|
||||
bool ProcessTouchInfo(Drivers::Cst816S::TouchInfos info);
|
||||
TouchProcessReply ProcessTouchInfo(Drivers::Cst816S::TouchInfos info, bool buttonUnlocksOn);
|
||||
|
||||
bool IsTouching() const {
|
||||
return currentTouchPoint.touching;
|
||||
|
@ -26,12 +38,29 @@ namespace Pinetime {
|
|||
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();
|
||||
|
||||
private:
|
||||
Pinetime::Applications::TouchEvents gesture;
|
||||
TouchPoint currentTouchPoint = {};
|
||||
bool gestureReleased = true;
|
||||
|
||||
WokenBy wokenBy;
|
||||
bool ignoreNextTouchEvent = false;
|
||||
bool ignoreTouchPopupHidden = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue