mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 23:21:53 +02:00
Compare commits
18 commits
36acaaa3e0
...
c75a92ce15
Author | SHA1 | Date | |
---|---|---|---|
c75a92ce15 | |||
3a0d673df4 | |||
53dc9dafe7 | |||
a407902b06 | |||
3e8accde69 | |||
2bb611db8e | |||
ef88e8165c | |||
da9ab4a7b4 | |||
0bcd7e0009 | |||
bf69e0dcc5 | |||
947c4f5067 | |||
0960d67001 | |||
5385f7e275 | |||
e884b053d3 | |||
85a2181b64 | |||
3dca742b65 | |||
20ac7e8df3 | |||
8657f71d48 |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,6 +11,7 @@ cmake_install.cmake
|
||||||
Makefile
|
Makefile
|
||||||
build
|
build
|
||||||
tools
|
tools
|
||||||
|
node_modules
|
||||||
|
|
||||||
# Resulting binary files
|
# Resulting binary files
|
||||||
*.a
|
*.a
|
||||||
|
|
22
doc/alarmStatusOnInfineat/alarmStatusOnInfineat.md
Normal file
22
doc/alarmStatusOnInfineat/alarmStatusOnInfineat.md
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# [InfiniTime : show alarm status on infineat watchface](https://github.com/Eve1374/InfiniTime/tree/alarm-status-on-infineat)
|
||||||
|
- I forked from [InfiniTime](https://github.com/InfiniTimeOrg/InfiniTime) and added a branch alarm-status-on-infineat
|
||||||
|
- I modified the watchface settings to have the possibility to show alarm status on watchface
|
||||||
|
|
||||||
|
Here are pictures with alarm set in 12 and 24hrs format :
|
||||||
|
|
||||||
|
![alarm set and shown, 12hrs format](infineat_alarm_set_12hrs.png "alarm set and shown, 12hrs format")
|
||||||
|
![alarm set and shown, 24hrs format](infineat_alarm_set_24hrs.png "alarm set and shown, 24hrs format")
|
||||||
|
|
||||||
|
Alarm not set :
|
||||||
|
|
||||||
|
![alarm shown and not set](infineat_alarm_notset.png "alarm shown and not set")
|
||||||
|
|
||||||
|
Settings view :
|
||||||
|
|
||||||
|
![settings](infineat_settings.png "settings modified with a button to turn on or off alarm display")
|
||||||
|
|
||||||
|
|
||||||
|
## Possible further development :
|
||||||
|
- Move this setting to the Alarm app and include alarm display in all watchfaces ?
|
||||||
|
|
||||||
|
|
BIN
doc/alarmStatusOnInfineat/infineat_alarm_notset.png
Normal file
BIN
doc/alarmStatusOnInfineat/infineat_alarm_notset.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
BIN
doc/alarmStatusOnInfineat/infineat_alarm_set_12hrs.png
Normal file
BIN
doc/alarmStatusOnInfineat/infineat_alarm_set_12hrs.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
BIN
doc/alarmStatusOnInfineat/infineat_alarm_set_24hrs.png
Normal file
BIN
doc/alarmStatusOnInfineat/infineat_alarm_set_24hrs.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
BIN
doc/alarmStatusOnInfineat/infineat_settings.png
Normal file
BIN
doc/alarmStatusOnInfineat/infineat_settings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
183
package-lock.json
generated
Normal file
183
package-lock.json
generated
Normal file
|
@ -0,0 +1,183 @@
|
||||||
|
{
|
||||||
|
"name": "InfiniTime",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"dependencies": {
|
||||||
|
"lv_font_conv": "^1.5.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lv_font_conv": {
|
||||||
|
"version": "1.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/lv_font_conv/-/lv_font_conv-1.5.2.tgz",
|
||||||
|
"integrity": "sha512-0UapRSTkVP/pnB8Z4r2HDHx5p2dJx/xUG1+14u/WXo59mwuC7BahR+Bnx/66jKoDrG1wFQwn9ZzoyMxRHOD9bg==",
|
||||||
|
"bundleDependencies": [
|
||||||
|
"argparse",
|
||||||
|
"bit-buffer",
|
||||||
|
"debug",
|
||||||
|
"make-error",
|
||||||
|
"mkdirp",
|
||||||
|
"opentype.js",
|
||||||
|
"pngjs"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"argparse": "^2.0.0",
|
||||||
|
"bit-buffer": "^0.2.5",
|
||||||
|
"debug": "^4.1.1",
|
||||||
|
"make-error": "^1.3.5",
|
||||||
|
"mkdirp": "^1.0.4",
|
||||||
|
"opentype.js": "^1.1.0",
|
||||||
|
"pngjs": "^6.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"lv_font_conv": "lv_font_conv.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lv_font_conv/node_modules/argparse": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"inBundle": true,
|
||||||
|
"license": "Python-2.0"
|
||||||
|
},
|
||||||
|
"node_modules/lv_font_conv/node_modules/bit-buffer": {
|
||||||
|
"version": "0.2.5",
|
||||||
|
"inBundle": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/lv_font_conv/node_modules/debug": {
|
||||||
|
"version": "4.3.1",
|
||||||
|
"inBundle": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"ms": "2.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"supports-color": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lv_font_conv/node_modules/make-error": {
|
||||||
|
"version": "1.3.6",
|
||||||
|
"inBundle": true,
|
||||||
|
"license": "ISC"
|
||||||
|
},
|
||||||
|
"node_modules/lv_font_conv/node_modules/mkdirp": {
|
||||||
|
"version": "1.0.4",
|
||||||
|
"inBundle": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"mkdirp": "bin/cmd.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lv_font_conv/node_modules/ms": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"inBundle": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/lv_font_conv/node_modules/opentype.js": {
|
||||||
|
"version": "1.3.3",
|
||||||
|
"inBundle": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"string.prototype.codepointat": "^0.2.1",
|
||||||
|
"tiny-inflate": "^1.0.3"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"ot": "bin/ot"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lv_font_conv/node_modules/pngjs": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"inBundle": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.13.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lv_font_conv/node_modules/string.prototype.codepointat": {
|
||||||
|
"version": "0.2.1",
|
||||||
|
"inBundle": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/lv_font_conv/node_modules/tiny-inflate": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"inBundle": true,
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"lv_font_conv": {
|
||||||
|
"version": "1.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/lv_font_conv/-/lv_font_conv-1.5.2.tgz",
|
||||||
|
"integrity": "sha512-0UapRSTkVP/pnB8Z4r2HDHx5p2dJx/xUG1+14u/WXo59mwuC7BahR+Bnx/66jKoDrG1wFQwn9ZzoyMxRHOD9bg==",
|
||||||
|
"requires": {
|
||||||
|
"argparse": "^2.0.0",
|
||||||
|
"bit-buffer": "^0.2.5",
|
||||||
|
"debug": "^4.1.1",
|
||||||
|
"make-error": "^1.3.5",
|
||||||
|
"mkdirp": "^1.0.4",
|
||||||
|
"opentype.js": "^1.1.0",
|
||||||
|
"pngjs": "^6.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"argparse": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"bundled": true
|
||||||
|
},
|
||||||
|
"bit-buffer": {
|
||||||
|
"version": "0.2.5",
|
||||||
|
"bundled": true
|
||||||
|
},
|
||||||
|
"debug": {
|
||||||
|
"version": "4.3.1",
|
||||||
|
"bundled": true,
|
||||||
|
"requires": {
|
||||||
|
"ms": "2.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"make-error": {
|
||||||
|
"version": "1.3.6",
|
||||||
|
"bundled": true
|
||||||
|
},
|
||||||
|
"mkdirp": {
|
||||||
|
"version": "1.0.4",
|
||||||
|
"bundled": true
|
||||||
|
},
|
||||||
|
"ms": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"bundled": true
|
||||||
|
},
|
||||||
|
"opentype.js": {
|
||||||
|
"version": "1.3.3",
|
||||||
|
"bundled": true,
|
||||||
|
"requires": {
|
||||||
|
"string.prototype.codepointat": "^0.2.1",
|
||||||
|
"tiny-inflate": "^1.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pngjs": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"bundled": true
|
||||||
|
},
|
||||||
|
"string.prototype.codepointat": {
|
||||||
|
"version": "0.2.1",
|
||||||
|
"bundled": true
|
||||||
|
},
|
||||||
|
"tiny-inflate": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"bundled": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
package.json
Normal file
5
package.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"lv_font_conv": "^1.5.2"
|
||||||
|
}
|
||||||
|
}
|
|
@ -371,6 +371,7 @@ list(APPEND SOURCE_FILES
|
||||||
displayapp/screens/StopWatch.cpp
|
displayapp/screens/StopWatch.cpp
|
||||||
displayapp/screens/BatteryIcon.cpp
|
displayapp/screens/BatteryIcon.cpp
|
||||||
displayapp/screens/BleIcon.cpp
|
displayapp/screens/BleIcon.cpp
|
||||||
|
displayapp/screens/AlarmIcon.cpp
|
||||||
displayapp/screens/NotificationIcon.cpp
|
displayapp/screens/NotificationIcon.cpp
|
||||||
displayapp/screens/SystemInfo.cpp
|
displayapp/screens/SystemInfo.cpp
|
||||||
displayapp/screens/Label.cpp
|
displayapp/screens/Label.cpp
|
||||||
|
|
|
@ -2,38 +2,138 @@
|
||||||
#include <hal/nrf_gpio.h>
|
#include <hal/nrf_gpio.h>
|
||||||
#include "displayapp/screens/Symbols.h"
|
#include "displayapp/screens/Symbols.h"
|
||||||
#include "drivers/PinMap.h"
|
#include "drivers/PinMap.h"
|
||||||
|
#include <libraries/delay/nrf_delay.h>
|
||||||
using namespace Pinetime::Controllers;
|
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() {
|
void BrightnessController::Init() {
|
||||||
nrf_gpio_cfg_output(PinMap::LcdBacklightLow);
|
nrf_gpio_cfg_output(PinMap::LcdBacklightLow);
|
||||||
nrf_gpio_cfg_output(PinMap::LcdBacklightMedium);
|
nrf_gpio_cfg_output(PinMap::LcdBacklightMedium);
|
||||||
nrf_gpio_cfg_output(PinMap::LcdBacklightHigh);
|
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);
|
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) {
|
void BrightnessController::Set(BrightnessController::Levels level) {
|
||||||
this->level = level;
|
this->level = level;
|
||||||
switch (level) {
|
switch (level) {
|
||||||
default:
|
default:
|
||||||
case Levels::High:
|
case Levels::High:
|
||||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
ApplyBrightness(3 * timerPeriod);
|
||||||
nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
|
|
||||||
nrf_gpio_pin_clear(PinMap::LcdBacklightHigh);
|
|
||||||
break;
|
break;
|
||||||
case Levels::Medium:
|
case Levels::Medium:
|
||||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
ApplyBrightness(2 * timerPeriod);
|
||||||
nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
|
|
||||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
|
||||||
break;
|
break;
|
||||||
case Levels::Low:
|
case Levels::Low:
|
||||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
ApplyBrightness(timerPeriod);
|
||||||
nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
|
break;
|
||||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
case Levels::AlwaysOn:
|
||||||
|
ApplyBrightness(timerPeriod / 10);
|
||||||
break;
|
break;
|
||||||
case Levels::Off:
|
case Levels::Off:
|
||||||
nrf_gpio_pin_set(PinMap::LcdBacklightLow);
|
ApplyBrightness(0);
|
||||||
nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
|
|
||||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,14 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "nrf_ppi.h"
|
||||||
|
#include "nrfx_gpiote.h"
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
class BrightnessController {
|
class BrightnessController {
|
||||||
public:
|
public:
|
||||||
enum class Levels { Off, Low, Medium, High };
|
enum class Levels { Off, AlwaysOn, Low, Medium, High };
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
void Set(Levels level);
|
void Set(Levels level);
|
||||||
|
@ -20,6 +23,25 @@ namespace Pinetime {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Levels level = Levels::High;
|
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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,8 @@ namespace Pinetime {
|
||||||
|
|
||||||
struct WatchFaceInfineat {
|
struct WatchFaceInfineat {
|
||||||
bool showSideCover = true;
|
bool showSideCover = true;
|
||||||
int colorIndex = 0;
|
bool showAlarmStatus = true;
|
||||||
|
int colorIndex = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
Settings(Pinetime::Controllers::FS& fs);
|
Settings(Pinetime::Controllers::FS& fs);
|
||||||
|
@ -123,6 +124,17 @@ namespace Pinetime {
|
||||||
return settings.watchFaceInfineat.showSideCover;
|
return settings.watchFaceInfineat.showSideCover;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void SetInfineatShowAlarmStatus(bool show) {
|
||||||
|
if (show != settings.watchFaceInfineat.showAlarmStatus) {
|
||||||
|
settings.watchFaceInfineat.showAlarmStatus = show;
|
||||||
|
settingsChanged = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool GetInfineatShowAlarmStatus() const {
|
||||||
|
return settings.watchFaceInfineat.showAlarmStatus;
|
||||||
|
};
|
||||||
|
|
||||||
void SetInfineatColorIndex(int index) {
|
void SetInfineatColorIndex(int index) {
|
||||||
if (index != settings.watchFaceInfineat.colorIndex) {
|
if (index != settings.watchFaceInfineat.colorIndex) {
|
||||||
settings.watchFaceInfineat.colorIndex = index;
|
settings.watchFaceInfineat.colorIndex = index;
|
||||||
|
@ -214,6 +226,21 @@ namespace Pinetime {
|
||||||
return settings.screenTimeOut;
|
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) {
|
void SetShakeThreshold(uint16_t thresh) {
|
||||||
if (settings.shakeWakeThreshold != thresh) {
|
if (settings.shakeWakeThreshold != thresh) {
|
||||||
settings.shakeWakeThreshold = thresh;
|
settings.shakeWakeThreshold = thresh;
|
||||||
|
@ -286,13 +313,15 @@ namespace Pinetime {
|
||||||
private:
|
private:
|
||||||
Pinetime::Controllers::FS& fs;
|
Pinetime::Controllers::FS& fs;
|
||||||
|
|
||||||
static constexpr uint32_t settingsVersion = 0x0007;
|
static constexpr uint32_t settingsVersion = 0x0008;
|
||||||
|
|
||||||
struct SettingsData {
|
struct SettingsData {
|
||||||
uint32_t version = settingsVersion;
|
uint32_t version = settingsVersion;
|
||||||
uint32_t stepsGoal = 10000;
|
uint32_t stepsGoal = 10000;
|
||||||
uint32_t screenTimeOut = 15000;
|
uint32_t screenTimeOut = 15000;
|
||||||
|
|
||||||
|
bool alwaysOnDisplay = false;
|
||||||
|
|
||||||
ClockType clockType = ClockType::H24;
|
ClockType clockType = ClockType::H24;
|
||||||
WeatherFormat weatherFormat = WeatherFormat::Metric;
|
WeatherFormat weatherFormat = WeatherFormat::Metric;
|
||||||
Notification notificationStatus = Notification::On;
|
Notification notificationStatus = Notification::On;
|
||||||
|
|
|
@ -81,7 +81,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||||
Pinetime::Controllers::AlarmController& alarmController,
|
Pinetime::Controllers::AlarmController& alarmController,
|
||||||
Pinetime::Controllers::BrightnessController& brightnessController,
|
Pinetime::Controllers::BrightnessController& brightnessController,
|
||||||
Pinetime::Controllers::TouchHandler& touchHandler,
|
Pinetime::Controllers::TouchHandler& touchHandler,
|
||||||
Pinetime::Controllers::FS& filesystem)
|
Pinetime::Controllers::FS& filesystem,
|
||||||
|
Pinetime::Drivers::SpiNorFlash& spiNorFlash)
|
||||||
: lcd {lcd},
|
: lcd {lcd},
|
||||||
touchPanel {touchPanel},
|
touchPanel {touchPanel},
|
||||||
batteryController {batteryController},
|
batteryController {batteryController},
|
||||||
|
@ -97,6 +98,7 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||||
brightnessController {brightnessController},
|
brightnessController {brightnessController},
|
||||||
touchHandler {touchHandler},
|
touchHandler {touchHandler},
|
||||||
filesystem {filesystem},
|
filesystem {filesystem},
|
||||||
|
spiNorFlash {spiNorFlash},
|
||||||
lvgl {lcd, filesystem},
|
lvgl {lcd, filesystem},
|
||||||
timer(this, TimerCallback),
|
timer(this, TimerCallback),
|
||||||
controllers {batteryController,
|
controllers {batteryController,
|
||||||
|
@ -154,6 +156,36 @@ void DisplayApp::InitHw() {
|
||||||
lcd.Init();
|
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() {
|
void DisplayApp::Refresh() {
|
||||||
auto LoadPreviousScreen = [this]() {
|
auto LoadPreviousScreen = [this]() {
|
||||||
FullRefreshDirections returnDirection;
|
FullRefreshDirections returnDirection;
|
||||||
|
@ -203,7 +235,29 @@ void DisplayApp::Refresh() {
|
||||||
TickType_t queueTimeout;
|
TickType_t queueTimeout;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case States::Idle:
|
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;
|
break;
|
||||||
case States::Running:
|
case States::Running:
|
||||||
if (!currentScreen->IsRunning()) {
|
if (!currentScreen->IsRunning()) {
|
||||||
|
@ -234,20 +288,34 @@ void DisplayApp::Refresh() {
|
||||||
case Messages::DimScreen:
|
case Messages::DimScreen:
|
||||||
DimScreen();
|
DimScreen();
|
||||||
break;
|
break;
|
||||||
case Messages::RestoreBrightness:
|
|
||||||
RestoreBrightness();
|
|
||||||
break;
|
|
||||||
case Messages::GoToSleep:
|
case Messages::GoToSleep:
|
||||||
while (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) {
|
while (brightnessController.Level() != Controllers::BrightnessController::Levels::Low) {
|
||||||
brightnessController.Lower();
|
brightnessController.Lower();
|
||||||
vTaskDelay(100);
|
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);
|
PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping);
|
||||||
state = States::Idle;
|
state = States::Idle;
|
||||||
break;
|
break;
|
||||||
|
case Messages::NotifyDeviceActivity:
|
||||||
|
lv_disp_trig_activity(nullptr);
|
||||||
|
break;
|
||||||
case Messages::GoToRunning:
|
case Messages::GoToRunning:
|
||||||
lcd.Wakeup();
|
if (settingsController.GetAlwaysOnDisplay()) {
|
||||||
|
lcd.LowPowerOff();
|
||||||
|
} else {
|
||||||
|
lcd.Wakeup();
|
||||||
|
}
|
||||||
lv_disp_trig_activity(nullptr);
|
lv_disp_trig_activity(nullptr);
|
||||||
ApplyBrightness();
|
ApplyBrightness();
|
||||||
state = States::Running;
|
state = States::Running;
|
||||||
|
@ -535,7 +603,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
||||||
bleController,
|
bleController,
|
||||||
watchdog,
|
watchdog,
|
||||||
motionController,
|
motionController,
|
||||||
touchPanel);
|
touchPanel,
|
||||||
|
spiNorFlash);
|
||||||
break;
|
break;
|
||||||
case Apps::FlashLight:
|
case Apps::FlashLight:
|
||||||
currentScreen = std::make_unique<Screens::FlashLight>(*systemTask, brightnessController);
|
currentScreen = std::make_unique<Screens::FlashLight>(*systemTask, brightnessController);
|
||||||
|
|
|
@ -66,7 +66,8 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::AlarmController& alarmController,
|
Pinetime::Controllers::AlarmController& alarmController,
|
||||||
Pinetime::Controllers::BrightnessController& brightnessController,
|
Pinetime::Controllers::BrightnessController& brightnessController,
|
||||||
Pinetime::Controllers::TouchHandler& touchHandler,
|
Pinetime::Controllers::TouchHandler& touchHandler,
|
||||||
Pinetime::Controllers::FS& filesystem);
|
Pinetime::Controllers::FS& filesystem,
|
||||||
|
Pinetime::Drivers::SpiNorFlash& spiNorFlash);
|
||||||
void Start(System::BootErrors error);
|
void Start(System::BootErrors error);
|
||||||
void PushMessage(Display::Messages msg);
|
void PushMessage(Display::Messages msg);
|
||||||
|
|
||||||
|
@ -96,6 +97,7 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::BrightnessController& brightnessController;
|
Pinetime::Controllers::BrightnessController& brightnessController;
|
||||||
Pinetime::Controllers::TouchHandler& touchHandler;
|
Pinetime::Controllers::TouchHandler& touchHandler;
|
||||||
Pinetime::Controllers::FS& filesystem;
|
Pinetime::Controllers::FS& filesystem;
|
||||||
|
Pinetime::Drivers::SpiNorFlash& spiNorFlash;
|
||||||
|
|
||||||
Pinetime::Controllers::FirmwareValidator validator;
|
Pinetime::Controllers::FirmwareValidator validator;
|
||||||
Pinetime::Components::LittleVgl lvgl;
|
Pinetime::Components::LittleVgl lvgl;
|
||||||
|
@ -135,6 +137,13 @@ namespace Pinetime {
|
||||||
Utility::StaticStack<FullRefreshDirections, returnAppStackSize> appStackDirections;
|
Utility::StaticStack<FullRefreshDirections, returnAppStackSize> appStackDirections;
|
||||||
|
|
||||||
bool isDimmed = false;
|
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::AlarmController& /*alarmController*/,
|
||||||
Pinetime::Controllers::BrightnessController& /*brightnessController*/,
|
Pinetime::Controllers::BrightnessController& /*brightnessController*/,
|
||||||
Pinetime::Controllers::TouchHandler& /*touchHandler*/,
|
Pinetime::Controllers::TouchHandler& /*touchHandler*/,
|
||||||
Pinetime::Controllers::FS& /*filesystem*/)
|
Pinetime::Controllers::FS& /*filesystem*/,
|
||||||
|
Pinetime::Drivers::SpiNorFlash& /*spiNorFlash*/)
|
||||||
: lcd {lcd}, bleController {bleController} {
|
: lcd {lcd}, bleController {bleController} {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace Pinetime {
|
||||||
class St7789;
|
class St7789;
|
||||||
class Cst816S;
|
class Cst816S;
|
||||||
class Watchdog;
|
class Watchdog;
|
||||||
|
class SpiNorFlash;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
|
@ -59,7 +60,8 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::AlarmController& alarmController,
|
Pinetime::Controllers::AlarmController& alarmController,
|
||||||
Pinetime::Controllers::BrightnessController& brightnessController,
|
Pinetime::Controllers::BrightnessController& brightnessController,
|
||||||
Pinetime::Controllers::TouchHandler& touchHandler,
|
Pinetime::Controllers::TouchHandler& touchHandler,
|
||||||
Pinetime::Controllers::FS& filesystem);
|
Pinetime::Controllers::FS& filesystem,
|
||||||
|
Pinetime::Drivers::SpiNorFlash& spiNorFlash);
|
||||||
void Start();
|
void Start();
|
||||||
|
|
||||||
void Start(Pinetime::System::BootErrors) {
|
void Start(Pinetime::System::BootErrors) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Pinetime {
|
||||||
TimerDone,
|
TimerDone,
|
||||||
BleFirmwareUpdateStarted,
|
BleFirmwareUpdateStarted,
|
||||||
DimScreen,
|
DimScreen,
|
||||||
RestoreBrightness,
|
NotifyDeviceActivity,
|
||||||
ShowPairingKey,
|
ShowPairingKey,
|
||||||
AlarmTriggered,
|
AlarmTriggered,
|
||||||
Chime,
|
Chime,
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "FontAwesome5-Solid+Brands+Regular.woff",
|
"file": "FontAwesome5-Solid+Brands+Regular.woff",
|
||||||
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf0f3, 0xf522, 0xf743"
|
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf0f3, 0xf522, 0xf743, 0xf0f3, 0xf1f6"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bpp": 1,
|
"bpp": 1,
|
||||||
|
|
11
src/displayapp/screens/AlarmIcon.cpp
Normal file
11
src/displayapp/screens/AlarmIcon.cpp
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#include "displayapp/screens/AlarmIcon.h"
|
||||||
|
#include "displayapp/screens/Symbols.h"
|
||||||
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
const char* AlarmIcon::GetIcon(bool isSet) {
|
||||||
|
if (isSet) {
|
||||||
|
return Symbols::bell;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Symbols::notbell;
|
||||||
|
}
|
14
src/displayapp/screens/AlarmIcon.h
Normal file
14
src/displayapp/screens/AlarmIcon.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "components/alarm/AlarmController.h"
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
namespace Applications {
|
||||||
|
namespace Screens {
|
||||||
|
class AlarmIcon {
|
||||||
|
public:
|
||||||
|
static const char* GetIcon(bool isSet);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,7 @@ namespace {
|
||||||
FlashLight::FlashLight(System::SystemTask& systemTask, Controllers::BrightnessController& brightnessController)
|
FlashLight::FlashLight(System::SystemTask& systemTask, Controllers::BrightnessController& brightnessController)
|
||||||
: systemTask {systemTask}, brightnessController {brightnessController} {
|
: systemTask {systemTask}, brightnessController {brightnessController} {
|
||||||
|
|
||||||
|
previousBrightnessLevel = brightnessController.Level();
|
||||||
brightnessController.Set(Controllers::BrightnessController::Levels::Low);
|
brightnessController.Set(Controllers::BrightnessController::Levels::Low);
|
||||||
|
|
||||||
flashLight = lv_label_create(lv_scr_act(), nullptr);
|
flashLight = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
@ -52,6 +53,7 @@ FlashLight::FlashLight(System::SystemTask& systemTask, Controllers::BrightnessCo
|
||||||
FlashLight::~FlashLight() {
|
FlashLight::~FlashLight() {
|
||||||
lv_obj_clean(lv_scr_act());
|
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);
|
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);
|
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace Pinetime {
|
||||||
Controllers::BrightnessController& brightnessController;
|
Controllers::BrightnessController& brightnessController;
|
||||||
|
|
||||||
Controllers::BrightnessController::Levels brightnessLevel = Controllers::BrightnessController::Levels::High;
|
Controllers::BrightnessController::Levels brightnessLevel = Controllers::BrightnessController::Levels::High;
|
||||||
|
Controllers::BrightnessController::Levels previousBrightnessLevel;
|
||||||
|
|
||||||
lv_obj_t* flashLight;
|
lv_obj_t* flashLight;
|
||||||
lv_obj_t* backgroundAction;
|
lv_obj_t* backgroundAction;
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace Pinetime {
|
||||||
static constexpr const char* shoe = "\xEF\x95\x8B";
|
static constexpr const char* shoe = "\xEF\x95\x8B";
|
||||||
static constexpr const char* clock = "\xEF\x80\x97";
|
static constexpr const char* clock = "\xEF\x80\x97";
|
||||||
static constexpr const char* bell = "\xEF\x83\xB3";
|
static constexpr const char* bell = "\xEF\x83\xB3";
|
||||||
|
static constexpr const char* notbell = "\xEF\x87\xB6";
|
||||||
static constexpr const char* info = "\xEF\x84\xA9";
|
static constexpr const char* info = "\xEF\x84\xA9";
|
||||||
static constexpr const char* list = "\xEF\x80\xBA";
|
static constexpr const char* list = "\xEF\x80\xBA";
|
||||||
static constexpr const char* sun = "\xEF\x86\x85";
|
static constexpr const char* sun = "\xEF\x86\x85";
|
||||||
|
|
|
@ -38,7 +38,8 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
|
||||||
const Pinetime::Controllers::Ble& bleController,
|
const Pinetime::Controllers::Ble& bleController,
|
||||||
const Pinetime::Drivers::Watchdog& watchdog,
|
const Pinetime::Drivers::Watchdog& watchdog,
|
||||||
Pinetime::Controllers::MotionController& motionController,
|
Pinetime::Controllers::MotionController& motionController,
|
||||||
const Pinetime::Drivers::Cst816S& touchPanel)
|
const Pinetime::Drivers::Cst816S& touchPanel,
|
||||||
|
const Pinetime::Drivers::SpiNorFlash& spiNorFlash)
|
||||||
: app {app},
|
: app {app},
|
||||||
dateTimeController {dateTimeController},
|
dateTimeController {dateTimeController},
|
||||||
batteryController {batteryController},
|
batteryController {batteryController},
|
||||||
|
@ -47,6 +48,7 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
|
||||||
watchdog {watchdog},
|
watchdog {watchdog},
|
||||||
motionController {motionController},
|
motionController {motionController},
|
||||||
touchPanel {touchPanel},
|
touchPanel {touchPanel},
|
||||||
|
spiNorFlash {spiNorFlash},
|
||||||
screens {app,
|
screens {app,
|
||||||
0,
|
0,
|
||||||
{[this]() -> std::unique_ptr<Screen> {
|
{[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_obj_t* label = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_label_set_recolor(label, true);
|
lv_label_set_recolor(label, true);
|
||||||
const auto& bleAddr = bleController.Address();
|
const auto& bleAddr = bleController.Address();
|
||||||
|
auto spiFlashId = spiNorFlash.GetIdentification();
|
||||||
lv_label_set_text_fmt(label,
|
lv_label_set_text_fmt(label,
|
||||||
"#808080 BLE MAC#\n"
|
"#808080 BLE MAC#\n"
|
||||||
" %02x:%02x:%02x:%02x:%02x:%02x"
|
" %02x:%02x:%02x:%02x:%02x:%02x\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"#808080 SPI Flash# %02x-%02x-%02x\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#808080 Memory heap#\n"
|
"#808080 Memory heap#\n"
|
||||||
" #808080 Free# %d\n"
|
" #808080 Free# %d\n"
|
||||||
|
@ -202,6 +206,9 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
|
||||||
bleAddr[2],
|
bleAddr[2],
|
||||||
bleAddr[1],
|
bleAddr[1],
|
||||||
bleAddr[0],
|
bleAddr[0],
|
||||||
|
spiFlashId.manufacturer,
|
||||||
|
spiFlashId.type,
|
||||||
|
spiFlashId.density,
|
||||||
xPortGetFreeHeapSize(),
|
xPortGetFreeHeapSize(),
|
||||||
xPortGetMinimumEverFreeHeapSize(),
|
xPortGetMinimumEverFreeHeapSize(),
|
||||||
mallocFailedCount,
|
mallocFailedCount,
|
||||||
|
|
|
@ -29,7 +29,8 @@ namespace Pinetime {
|
||||||
const Pinetime::Controllers::Ble& bleController,
|
const Pinetime::Controllers::Ble& bleController,
|
||||||
const Pinetime::Drivers::Watchdog& watchdog,
|
const Pinetime::Drivers::Watchdog& watchdog,
|
||||||
Pinetime::Controllers::MotionController& motionController,
|
Pinetime::Controllers::MotionController& motionController,
|
||||||
const Pinetime::Drivers::Cst816S& touchPanel);
|
const Pinetime::Drivers::Cst816S& touchPanel,
|
||||||
|
const Pinetime::Drivers::SpiNorFlash& spiNorFlash);
|
||||||
~SystemInfo() override;
|
~SystemInfo() override;
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ namespace Pinetime {
|
||||||
const Pinetime::Drivers::Watchdog& watchdog;
|
const Pinetime::Drivers::Watchdog& watchdog;
|
||||||
Pinetime::Controllers::MotionController& motionController;
|
Pinetime::Controllers::MotionController& motionController;
|
||||||
const Pinetime::Drivers::Cst816S& touchPanel;
|
const Pinetime::Drivers::Cst816S& touchPanel;
|
||||||
|
const Pinetime::Drivers::SpiNorFlash& spiNorFlash;
|
||||||
|
|
||||||
ScreenList<5> screens;
|
ScreenList<5> screens;
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "displayapp/screens/Symbols.h"
|
#include "displayapp/screens/Symbols.h"
|
||||||
#include "displayapp/screens/BleIcon.h"
|
#include "displayapp/screens/BleIcon.h"
|
||||||
|
#include "displayapp/screens/AlarmIcon.h"
|
||||||
#include "components/settings/Settings.h"
|
#include "components/settings/Settings.h"
|
||||||
#include "components/battery/BatteryController.h"
|
#include "components/battery/BatteryController.h"
|
||||||
#include "components/ble/BleController.h"
|
#include "components/ble/BleController.h"
|
||||||
|
#include "components/alarm/AlarmController.h"
|
||||||
#include "components/ble/NotificationManager.h"
|
#include "components/ble/NotificationManager.h"
|
||||||
#include "components/motion/MotionController.h"
|
#include "components/motion/MotionController.h"
|
||||||
|
|
||||||
|
@ -122,6 +124,7 @@ namespace {
|
||||||
WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
||||||
const Controllers::Battery& batteryController,
|
const Controllers::Battery& batteryController,
|
||||||
const Controllers::Ble& bleController,
|
const Controllers::Ble& bleController,
|
||||||
|
Controllers::AlarmController& alarmController,
|
||||||
Controllers::NotificationManager& notificationManager,
|
Controllers::NotificationManager& notificationManager,
|
||||||
Controllers::Settings& settingsController,
|
Controllers::Settings& settingsController,
|
||||||
Controllers::MotionController& motionController,
|
Controllers::MotionController& motionController,
|
||||||
|
@ -130,6 +133,7 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
||||||
dateTimeController {dateTimeController},
|
dateTimeController {dateTimeController},
|
||||||
batteryController {batteryController},
|
batteryController {batteryController},
|
||||||
bleController {bleController},
|
bleController {bleController},
|
||||||
|
alarmController {alarmController},
|
||||||
notificationManager {notificationManager},
|
notificationManager {notificationManager},
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
motionController {motionController} {
|
motionController {motionController} {
|
||||||
|
@ -144,6 +148,7 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
||||||
font_bebas = lv_font_load("F:/fonts/bebas.bin");
|
font_bebas = lv_font_load("F:/fonts/bebas.bin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Side Cover
|
// Side Cover
|
||||||
static constexpr lv_point_t linePoints[nLines][2] = {{{30, 25}, {68, -8}},
|
static constexpr lv_point_t linePoints[nLines][2] = {{{30, 25}, {68, -8}},
|
||||||
{{26, 167}, {43, 216}},
|
{{26, 167}, {43, 216}},
|
||||||
|
@ -230,6 +235,31 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
||||||
lv_label_set_text_static(bleIcon, Symbols::bluetooth);
|
lv_label_set_text_static(bleIcon, Symbols::bluetooth);
|
||||||
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
|
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
|
||||||
|
|
||||||
|
labelAlarm = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(labelAlarm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
|
||||||
|
lv_obj_set_style_local_text_font(labelAlarm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||||
|
lv_obj_align(labelAlarm, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, -10, 0);
|
||||||
|
lv_obj_align(labelAlarm, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -3, 0);
|
||||||
|
lv_label_set_text_static(labelAlarm, "00:00");
|
||||||
|
|
||||||
|
labelTimeAmPmAlarm = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_font(labelTimeAmPmAlarm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||||
|
lv_label_set_text_static(labelTimeAmPmAlarm, "");
|
||||||
|
lv_obj_set_style_local_text_color(labelTimeAmPmAlarm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
|
||||||
|
lv_obj_align(labelTimeAmPmAlarm, labelAlarm, LV_ALIGN_OUT_TOP_RIGHT, 0, 0);
|
||||||
|
|
||||||
|
alarmIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(alarmIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
|
||||||
|
lv_label_set_text_static(alarmIcon, Symbols::notbell);
|
||||||
|
lv_obj_align(alarmIcon, labelAlarm, LV_ALIGN_OUT_LEFT_MID, -3, 0);
|
||||||
|
|
||||||
|
// don't show the icons jsut set if we don't show alarm status
|
||||||
|
if (!settingsController.GetInfineatShowAlarmStatus()) {
|
||||||
|
lv_obj_set_hidden(labelAlarm, true);
|
||||||
|
lv_obj_set_hidden(alarmIcon, true);
|
||||||
|
lv_obj_set_hidden(labelTimeAmPmAlarm, true);
|
||||||
|
}
|
||||||
|
|
||||||
stepValue = lv_label_create(lv_scr_act(), nullptr);
|
stepValue = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
|
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
|
||||||
lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||||
|
@ -275,7 +305,7 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
||||||
btnToggleCover = lv_btn_create(lv_scr_act(), nullptr);
|
btnToggleCover = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
btnToggleCover->user_data = this;
|
btnToggleCover->user_data = this;
|
||||||
lv_obj_set_size(btnToggleCover, 60, 60);
|
lv_obj_set_size(btnToggleCover, 60, 60);
|
||||||
lv_obj_align(btnToggleCover, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
|
lv_obj_align(btnToggleCover, lv_scr_act(), LV_ALIGN_CENTER, 0,0);
|
||||||
lv_obj_set_style_local_bg_opa(btnToggleCover, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
|
lv_obj_set_style_local_bg_opa(btnToggleCover, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
|
||||||
const char* labelToggle = settingsController.GetInfineatShowSideCover() ? "ON" : "OFF";
|
const char* labelToggle = settingsController.GetInfineatShowSideCover() ? "ON" : "OFF";
|
||||||
lblToggle = lv_label_create(btnToggleCover, nullptr);
|
lblToggle = lv_label_create(btnToggleCover, nullptr);
|
||||||
|
@ -283,6 +313,17 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
||||||
lv_obj_set_event_cb(btnToggleCover, event_handler);
|
lv_obj_set_event_cb(btnToggleCover, event_handler);
|
||||||
lv_obj_set_hidden(btnToggleCover, true);
|
lv_obj_set_hidden(btnToggleCover, true);
|
||||||
|
|
||||||
|
btnToggleAlarm = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnToggleAlarm->user_data = this;
|
||||||
|
lv_obj_set_size(btnToggleAlarm, 60, 60);
|
||||||
|
lv_obj_align(btnToggleAlarm, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnToggleAlarm, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
|
||||||
|
const char* labelToggleAlarm = settingsController.GetInfineatShowAlarmStatus() ? Symbols::bell : Symbols::notbell;
|
||||||
|
lblAlarm = lv_label_create(btnToggleAlarm, nullptr);
|
||||||
|
lv_label_set_text_static(lblAlarm, labelToggleAlarm);
|
||||||
|
lv_obj_set_event_cb(btnToggleAlarm, event_handler);
|
||||||
|
lv_obj_set_hidden(btnToggleAlarm, true);
|
||||||
|
|
||||||
// Button to access the settings
|
// Button to access the settings
|
||||||
btnSettings = lv_btn_create(lv_scr_act(), nullptr);
|
btnSettings = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
btnSettings->user_data = this;
|
btnSettings->user_data = this;
|
||||||
|
@ -332,6 +373,7 @@ void WatchFaceInfineat::CloseMenu() {
|
||||||
lv_obj_set_hidden(btnNextColor, true);
|
lv_obj_set_hidden(btnNextColor, true);
|
||||||
lv_obj_set_hidden(btnPrevColor, true);
|
lv_obj_set_hidden(btnPrevColor, true);
|
||||||
lv_obj_set_hidden(btnToggleCover, true);
|
lv_obj_set_hidden(btnToggleCover, true);
|
||||||
|
lv_obj_set_hidden(btnToggleAlarm, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WatchFaceInfineat::OnButtonPushed() {
|
bool WatchFaceInfineat::OnButtonPushed() {
|
||||||
|
@ -346,6 +388,7 @@ void WatchFaceInfineat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
if (event == LV_EVENT_CLICKED) {
|
if (event == LV_EVENT_CLICKED) {
|
||||||
bool showSideCover = settingsController.GetInfineatShowSideCover();
|
bool showSideCover = settingsController.GetInfineatShowSideCover();
|
||||||
int colorIndex = settingsController.GetInfineatColorIndex();
|
int colorIndex = settingsController.GetInfineatColorIndex();
|
||||||
|
bool showAlarmStatus = settingsController.GetInfineatShowAlarmStatus();
|
||||||
|
|
||||||
if (object == btnSettings) {
|
if (object == btnSettings) {
|
||||||
lv_obj_set_hidden(btnSettings, true);
|
lv_obj_set_hidden(btnSettings, true);
|
||||||
|
@ -353,6 +396,7 @@ void WatchFaceInfineat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
lv_obj_set_hidden(btnNextColor, !showSideCover);
|
lv_obj_set_hidden(btnNextColor, !showSideCover);
|
||||||
lv_obj_set_hidden(btnPrevColor, !showSideCover);
|
lv_obj_set_hidden(btnPrevColor, !showSideCover);
|
||||||
lv_obj_set_hidden(btnToggleCover, false);
|
lv_obj_set_hidden(btnToggleCover, false);
|
||||||
|
lv_obj_set_hidden(btnToggleAlarm, false);
|
||||||
}
|
}
|
||||||
if (object == btnClose) {
|
if (object == btnClose) {
|
||||||
CloseMenu();
|
CloseMenu();
|
||||||
|
@ -368,6 +412,18 @@ void WatchFaceInfineat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
const char* labelToggle = showSideCover ? "OFF" : "ON";
|
const char* labelToggle = showSideCover ? "OFF" : "ON";
|
||||||
lv_label_set_text_static(lblToggle, labelToggle);
|
lv_label_set_text_static(lblToggle, labelToggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (object == btnToggleAlarm) {
|
||||||
|
settingsController.SetInfineatShowAlarmStatus(!showAlarmStatus);
|
||||||
|
bool newShowAlarmStatus = settingsController.GetInfineatShowAlarmStatus();
|
||||||
|
lv_obj_set_hidden(labelAlarm, !newShowAlarmStatus);
|
||||||
|
lv_obj_set_hidden(alarmIcon, !newShowAlarmStatus);
|
||||||
|
lv_obj_set_hidden(labelTimeAmPmAlarm, !newShowAlarmStatus);
|
||||||
|
const char* labelToggleAlarm = newShowAlarmStatus ? Symbols::bell : Symbols::notbell;
|
||||||
|
lv_label_set_text_static(lblAlarm, labelToggleAlarm);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (object == btnNextColor) {
|
if (object == btnNextColor) {
|
||||||
colorIndex = (colorIndex + 1) % nColors;
|
colorIndex = (colorIndex + 1) % nColors;
|
||||||
settingsController.SetInfineatColorIndex(colorIndex);
|
settingsController.SetInfineatColorIndex(colorIndex);
|
||||||
|
@ -452,6 +508,43 @@ void WatchFaceInfineat::Refresh() {
|
||||||
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 3);
|
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settingsController.GetInfineatShowAlarmStatus()) {
|
||||||
|
alarmState = alarmController.State()==Pinetime::Controllers::AlarmController::AlarmState::Set;
|
||||||
|
// sets the icon as bell or barred bell
|
||||||
|
lv_label_set_text_static(alarmIcon, AlarmIcon::GetIcon(alarmState));
|
||||||
|
//displays the time of the alarm or nothing if the alarm is not set
|
||||||
|
if (alarmState) {
|
||||||
|
uint8_t alarmHours = alarmController.Hours();
|
||||||
|
uint8_t alarmMinutes = alarmController.Minutes();
|
||||||
|
//handles the am pm format.
|
||||||
|
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||||
|
char ampmChar[3] = "AM";
|
||||||
|
if (alarmHours == 0) {
|
||||||
|
alarmHours = 12;
|
||||||
|
} else if (alarmHours == 12) {
|
||||||
|
ampmChar[0]='P';
|
||||||
|
} else if (alarmHours > 12) {
|
||||||
|
alarmHours = alarmHours - 12;
|
||||||
|
ampmChar[0]='P';
|
||||||
|
}
|
||||||
|
lv_label_set_text(labelTimeAmPmAlarm, ampmChar);
|
||||||
|
lv_obj_set_style_local_text_font(labelTimeAmPmAlarm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||||
|
lv_obj_align(labelTimeAmPmAlarm, labelAlarm, LV_ALIGN_OUT_TOP_RIGHT, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_label_set_text_fmt(labelAlarm, "%02d:%02d", alarmHours, alarmMinutes);
|
||||||
|
|
||||||
|
lv_obj_align(alarmIcon, labelAlarm, LV_ALIGN_OUT_LEFT_MID, -3, 0);
|
||||||
|
lv_obj_align(labelAlarm, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, -10, 0);
|
||||||
|
lv_obj_align(labelAlarm, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -3, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lv_label_set_text_static(labelAlarm, Symbols::none);
|
||||||
|
lv_obj_align(alarmIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
|
||||||
|
lv_obj_align(alarmIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -3, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
stepCount = motionController.NbSteps();
|
stepCount = motionController.NbSteps();
|
||||||
if (stepCount.IsUpdated()) {
|
if (stepCount.IsUpdated()) {
|
||||||
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
|
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace Pinetime {
|
||||||
WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
||||||
const Controllers::Battery& batteryController,
|
const Controllers::Battery& batteryController,
|
||||||
const Controllers::Ble& bleController,
|
const Controllers::Ble& bleController,
|
||||||
|
Controllers::AlarmController& alarmController,
|
||||||
Controllers::NotificationManager& notificationManager,
|
Controllers::NotificationManager& notificationManager,
|
||||||
Controllers::Settings& settingsController,
|
Controllers::Settings& settingsController,
|
||||||
Controllers::MotionController& motionController,
|
Controllers::MotionController& motionController,
|
||||||
|
@ -52,6 +53,7 @@ namespace Pinetime {
|
||||||
Utility::DirtyValue<bool> isCharging {};
|
Utility::DirtyValue<bool> isCharging {};
|
||||||
Utility::DirtyValue<bool> bleState {};
|
Utility::DirtyValue<bool> bleState {};
|
||||||
Utility::DirtyValue<bool> bleRadioEnabled {};
|
Utility::DirtyValue<bool> bleRadioEnabled {};
|
||||||
|
bool alarmState {};
|
||||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::minutes>> currentDateTime {};
|
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::minutes>> currentDateTime {};
|
||||||
Utility::DirtyValue<uint32_t> stepCount {};
|
Utility::DirtyValue<uint32_t> stepCount {};
|
||||||
Utility::DirtyValue<bool> notificationState {};
|
Utility::DirtyValue<bool> notificationState {};
|
||||||
|
@ -71,22 +73,28 @@ namespace Pinetime {
|
||||||
lv_obj_t* dateContainer;
|
lv_obj_t* dateContainer;
|
||||||
lv_obj_t* labelDate;
|
lv_obj_t* labelDate;
|
||||||
lv_obj_t* bleIcon;
|
lv_obj_t* bleIcon;
|
||||||
|
lv_obj_t* labelAlarm;
|
||||||
|
lv_obj_t* labelTimeAmPmAlarm;
|
||||||
|
lv_obj_t* alarmIcon;
|
||||||
lv_obj_t* stepIcon;
|
lv_obj_t* stepIcon;
|
||||||
lv_obj_t* stepValue;
|
lv_obj_t* stepValue;
|
||||||
lv_obj_t* notificationIcon;
|
lv_obj_t* notificationIcon;
|
||||||
lv_obj_t* btnClose;
|
lv_obj_t* btnClose;
|
||||||
lv_obj_t* btnNextColor;
|
lv_obj_t* btnNextColor;
|
||||||
lv_obj_t* btnToggleCover;
|
lv_obj_t* btnToggleCover;
|
||||||
|
lv_obj_t* btnToggleAlarm;
|
||||||
lv_obj_t* btnPrevColor;
|
lv_obj_t* btnPrevColor;
|
||||||
lv_obj_t* btnSettings;
|
lv_obj_t* btnSettings;
|
||||||
lv_obj_t* labelBtnSettings;
|
lv_obj_t* labelBtnSettings;
|
||||||
lv_obj_t* lblToggle;
|
lv_obj_t* lblToggle;
|
||||||
|
lv_obj_t* lblAlarm;
|
||||||
|
|
||||||
lv_obj_t* lines[nLines];
|
lv_obj_t* lines[nLines];
|
||||||
|
|
||||||
Controllers::DateTime& dateTimeController;
|
Controllers::DateTime& dateTimeController;
|
||||||
const Controllers::Battery& batteryController;
|
const Controllers::Battery& batteryController;
|
||||||
const Controllers::Ble& bleController;
|
const Controllers::Ble& bleController;
|
||||||
|
Controllers::AlarmController& alarmController;
|
||||||
Controllers::NotificationManager& notificationManager;
|
Controllers::NotificationManager& notificationManager;
|
||||||
Controllers::Settings& settingsController;
|
Controllers::Settings& settingsController;
|
||||||
Controllers::MotionController& motionController;
|
Controllers::MotionController& motionController;
|
||||||
|
@ -94,6 +102,8 @@ namespace Pinetime {
|
||||||
void SetBatteryLevel(uint8_t batteryPercent);
|
void SetBatteryLevel(uint8_t batteryPercent);
|
||||||
void ToggleBatteryIndicatorColor(bool showSideCover);
|
void ToggleBatteryIndicatorColor(bool showSideCover);
|
||||||
|
|
||||||
|
void ToggleShowAlarmStatus(bool showAlarmStatus);
|
||||||
|
|
||||||
lv_task_t* taskRefresh;
|
lv_task_t* taskRefresh;
|
||||||
lv_font_t* font_teko = nullptr;
|
lv_font_t* font_teko = nullptr;
|
||||||
lv_font_t* font_bebas = nullptr;
|
lv_font_t* font_bebas = nullptr;
|
||||||
|
@ -109,6 +119,7 @@ namespace Pinetime {
|
||||||
return new Screens::WatchFaceInfineat(controllers.dateTimeController,
|
return new Screens::WatchFaceInfineat(controllers.dateTimeController,
|
||||||
controllers.batteryController,
|
controllers.batteryController,
|
||||||
controllers.bleController,
|
controllers.bleController,
|
||||||
|
controllers.alarmController,
|
||||||
controllers.notificationManager,
|
controllers.notificationManager,
|
||||||
controllers.settingsController,
|
controllers.settingsController,
|
||||||
controllers.motionController,
|
controllers.motionController,
|
||||||
|
|
|
@ -9,10 +9,17 @@
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
namespace {
|
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);
|
auto* screen = static_cast<SettingDisplay*>(obj->user_data);
|
||||||
screen->UpdateSelected(obj, event);
|
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;
|
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);
|
snprintf(buffer, sizeof(buffer), "%2" PRIu16 "s", options[i] / 1000);
|
||||||
lv_checkbox_set_text(cbOption[i], buffer);
|
lv_checkbox_set_text(cbOption[i], buffer);
|
||||||
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], TimeoutEventHandler);
|
||||||
SetRadioButtonStyle(cbOption[i]);
|
SetRadioButtonStyle(cbOption[i]);
|
||||||
|
|
||||||
if (settingsController.GetScreenTimeOut() == options[i]) {
|
if (settingsController.GetScreenTimeOut() == options[i]) {
|
||||||
lv_checkbox_set_checked(cbOption[i], true);
|
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() {
|
SettingDisplay::~SettingDisplay() {
|
||||||
|
@ -63,6 +77,11 @@ SettingDisplay::~SettingDisplay() {
|
||||||
settingsController.SaveSettings();
|
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) {
|
void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
if (event == LV_EVENT_CLICKED) {
|
if (event == LV_EVENT_CLICKED) {
|
||||||
for (unsigned int i = 0; i < options.size(); i++) {
|
for (unsigned int i = 0; i < options.size(); i++) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace Pinetime {
|
||||||
~SettingDisplay() override;
|
~SettingDisplay() override;
|
||||||
|
|
||||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||||
|
void ToggleAlwaysOn();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DisplayApp* app;
|
DisplayApp* app;
|
||||||
|
@ -25,6 +26,7 @@ namespace Pinetime {
|
||||||
|
|
||||||
Controllers::Settings& settingsController;
|
Controllers::Settings& settingsController;
|
||||||
lv_obj_t* cbOption[options.size()];
|
lv_obj_t* cbOption[options.size()];
|
||||||
|
lv_obj_t* alwaysOnCheckbox;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ SpiNorFlash::SpiNorFlash(Spi& spi) : spi {spi} {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpiNorFlash::Init() {
|
void SpiNorFlash::Init() {
|
||||||
device_id = ReadIdentificaion();
|
device_id = ReadIdentification();
|
||||||
NRF_LOG_INFO("[SpiNorFlash] Manufacturer : %d, Memory type : %d, memory density : %d",
|
NRF_LOG_INFO("[SpiNorFlash] Manufacturer : %d, Memory type : %d, memory density : %d",
|
||||||
device_id.manufacturer,
|
device_id.manufacturer,
|
||||||
device_id.type,
|
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 cmd[cmdSize] = {static_cast<uint8_t>(Commands::ReleaseFromDeepPowerDown), 0x01, 0x02, 0x03};
|
||||||
uint8_t id = 0;
|
uint8_t id = 0;
|
||||||
spi.Read(reinterpret_cast<uint8_t*>(&cmd), cmdSize, &id, 1);
|
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) {
|
if (devId.type != device_id.type) {
|
||||||
NRF_LOG_INFO("[SpiNorFlash] ID on Wakeup: Failed");
|
NRF_LOG_INFO("[SpiNorFlash] ID on Wakeup: Failed");
|
||||||
} else {
|
} else {
|
||||||
|
@ -41,7 +41,7 @@ void SpiNorFlash::Wakeup() {
|
||||||
NRF_LOG_INFO("[SpiNorFlash] Wakeup")
|
NRF_LOG_INFO("[SpiNorFlash] Wakeup")
|
||||||
}
|
}
|
||||||
|
|
||||||
SpiNorFlash::Identification SpiNorFlash::ReadIdentificaion() {
|
SpiNorFlash::Identification SpiNorFlash::ReadIdentification() {
|
||||||
auto cmd = static_cast<uint8_t>(Commands::ReadIdentification);
|
auto cmd = static_cast<uint8_t>(Commands::ReadIdentification);
|
||||||
Identification identification;
|
Identification identification;
|
||||||
spi.Read(&cmd, 1, reinterpret_cast<uint8_t*>(&identification), sizeof(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;
|
len -= toWrite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SpiNorFlash::Identification SpiNorFlash::GetIdentification() const {
|
||||||
|
return device_id;
|
||||||
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ namespace Pinetime {
|
||||||
uint8_t density = 0;
|
uint8_t density = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
Identification ReadIdentificaion();
|
|
||||||
uint8_t ReadStatusRegister();
|
uint8_t ReadStatusRegister();
|
||||||
bool WriteInProgress();
|
bool WriteInProgress();
|
||||||
bool WriteEnabled();
|
bool WriteEnabled();
|
||||||
|
@ -33,6 +32,8 @@ namespace Pinetime {
|
||||||
bool ProgramFailed();
|
bool ProgramFailed();
|
||||||
bool EraseFailed();
|
bool EraseFailed();
|
||||||
|
|
||||||
|
Identification GetIdentification() const;
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void Uninit();
|
void Uninit();
|
||||||
|
|
||||||
|
@ -40,6 +41,8 @@ namespace Pinetime {
|
||||||
void Wakeup();
|
void Wakeup();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Identification ReadIdentification();
|
||||||
|
|
||||||
enum class Commands : uint8_t {
|
enum class Commands : uint8_t {
|
||||||
PageProgram = 0x02,
|
PageProgram = 0x02,
|
||||||
Read = 0x03,
|
Read = 0x03,
|
||||||
|
|
|
@ -16,6 +16,7 @@ void St7789::Init() {
|
||||||
nrf_gpio_pin_set(pinReset);
|
nrf_gpio_pin_set(pinReset);
|
||||||
HardwareReset();
|
HardwareReset();
|
||||||
SoftwareReset();
|
SoftwareReset();
|
||||||
|
Command2Enable();
|
||||||
SleepOut();
|
SleepOut();
|
||||||
PixelFormat();
|
PixelFormat();
|
||||||
MemoryDataAccessControl();
|
MemoryDataAccessControl();
|
||||||
|
@ -24,8 +25,13 @@ void St7789::Init() {
|
||||||
#ifndef DRIVER_DISPLAY_MIRROR
|
#ifndef DRIVER_DISPLAY_MIRROR
|
||||||
DisplayInversionOn();
|
DisplayInversionOn();
|
||||||
#endif
|
#endif
|
||||||
|
PorchSet();
|
||||||
|
FrameRateNormalSet();
|
||||||
|
IdleFrameRateOff();
|
||||||
NormalModeOn();
|
NormalModeOn();
|
||||||
SetVdv();
|
SetVdv();
|
||||||
|
PowerControl();
|
||||||
|
GateControl();
|
||||||
DisplayOn();
|
DisplayOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +69,17 @@ void St7789::SoftwareReset() {
|
||||||
vTaskDelay(pdMS_TO_TICKS(125));
|
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() {
|
void St7789::SleepOut() {
|
||||||
if (!sleepIn) {
|
if (!sleepIn) {
|
||||||
return;
|
return;
|
||||||
|
@ -127,10 +144,79 @@ void St7789::NormalModeOn() {
|
||||||
WriteCommand(static_cast<uint8_t>(Commands::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() {
|
void St7789::DisplayOn() {
|
||||||
WriteCommand(static_cast<uint8_t>(Commands::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) {
|
void St7789::SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||||
WriteCommand(static_cast<uint8_t>(Commands::ColumnAddressSet));
|
WriteCommand(static_cast<uint8_t>(Commands::ColumnAddressSet));
|
||||||
uint8_t colArgs[] = {
|
uint8_t colArgs[] = {
|
||||||
|
@ -198,6 +284,18 @@ void St7789::HardwareReset() {
|
||||||
vTaskDelay(pdMS_TO_TICKS(125));
|
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() {
|
void St7789::Sleep() {
|
||||||
SleepIn();
|
SleepIn();
|
||||||
nrf_gpio_cfg_default(pinDataCommand);
|
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 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 Sleep();
|
||||||
void Wakeup();
|
void Wakeup();
|
||||||
|
|
||||||
|
@ -37,6 +39,7 @@ namespace Pinetime {
|
||||||
|
|
||||||
void HardwareReset();
|
void HardwareReset();
|
||||||
void SoftwareReset();
|
void SoftwareReset();
|
||||||
|
void Command2Enable();
|
||||||
void SleepOut();
|
void SleepOut();
|
||||||
void EnsureSleepOutPostDelay();
|
void EnsureSleepOutPostDelay();
|
||||||
void SleepIn();
|
void SleepIn();
|
||||||
|
@ -45,8 +48,16 @@ namespace Pinetime {
|
||||||
void DisplayInversionOn();
|
void DisplayInversionOn();
|
||||||
void NormalModeOn();
|
void NormalModeOn();
|
||||||
void WriteToRam(const uint8_t* data, size_t size);
|
void WriteToRam(const uint8_t* data, size_t size);
|
||||||
|
void IdleModeOn();
|
||||||
|
void IdleModeOff();
|
||||||
|
void FrameRateNormalSet();
|
||||||
|
void IdleFrameRateOff();
|
||||||
|
void IdleFrameRateOn();
|
||||||
void DisplayOn();
|
void DisplayOn();
|
||||||
void DisplayOff();
|
void DisplayOff();
|
||||||
|
void PowerControl();
|
||||||
|
void GateControl();
|
||||||
|
void PorchSet();
|
||||||
|
|
||||||
void SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
void SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||||
void SetVdv();
|
void SetVdv();
|
||||||
|
@ -68,8 +79,17 @@ namespace Pinetime {
|
||||||
MemoryDataAccessControl = 0x36,
|
MemoryDataAccessControl = 0x36,
|
||||||
VerticalScrollDefinition = 0x33,
|
VerticalScrollDefinition = 0x33,
|
||||||
VerticalScrollStartAddress = 0x37,
|
VerticalScrollStartAddress = 0x37,
|
||||||
|
IdleModeOff = 0x38,
|
||||||
|
IdleModeOn = 0x39,
|
||||||
PixelFormat = 0x3a,
|
PixelFormat = 0x3a,
|
||||||
|
FrameRateIdle = 0xb3,
|
||||||
|
FrameRateNormal = 0xc6,
|
||||||
VdvSet = 0xc4,
|
VdvSet = 0xc4,
|
||||||
|
Command2Enable = 0xdf,
|
||||||
|
PowerControl1 = 0xd0,
|
||||||
|
PowerControl2 = 0xe8,
|
||||||
|
GateControl = 0xb7,
|
||||||
|
Porch = 0xb2,
|
||||||
};
|
};
|
||||||
void WriteData(uint8_t data);
|
void WriteData(uint8_t data);
|
||||||
void WriteData(const uint8_t* data, size_t size);
|
void WriteData(const uint8_t* data, size_t size);
|
||||||
|
|
|
@ -123,7 +123,8 @@ Pinetime::Applications::DisplayApp displayApp(lcd,
|
||||||
alarmController,
|
alarmController,
|
||||||
brightnessController,
|
brightnessController,
|
||||||
touchHandler,
|
touchHandler,
|
||||||
fs);
|
fs,
|
||||||
|
spiNorFlash);
|
||||||
|
|
||||||
Pinetime::System::SystemTask systemTask(spi,
|
Pinetime::System::SystemTask systemTask(spi,
|
||||||
spiNorFlash,
|
spiNorFlash,
|
||||||
|
|
|
@ -102,7 +102,9 @@ void SystemTask::Work() {
|
||||||
watchdog.Setup(7, Drivers::Watchdog::SleepBehaviour::Run, Drivers::Watchdog::HaltBehaviour::Pause);
|
watchdog.Setup(7, Drivers::Watchdog::SleepBehaviour::Run, Drivers::Watchdog::HaltBehaviour::Pause);
|
||||||
watchdog.Start();
|
watchdog.Start();
|
||||||
NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::ResetReasonToString(watchdog.GetResetReason()));
|
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();
|
spi.Init();
|
||||||
spiNorFlash.Init();
|
spiNorFlash.Init();
|
||||||
|
@ -192,13 +194,16 @@ void SystemTask::Work() {
|
||||||
if (!bleController.IsFirmwareUpdating()) {
|
if (!bleController.IsFirmwareUpdating()) {
|
||||||
doNotGoToSleep = false;
|
doNotGoToSleep = false;
|
||||||
}
|
}
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
|
||||||
break;
|
break;
|
||||||
case Messages::DisableSleeping:
|
case Messages::DisableSleeping:
|
||||||
doNotGoToSleep = true;
|
doNotGoToSleep = true;
|
||||||
break;
|
break;
|
||||||
case Messages::GoToRunning:
|
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
|
// Double Tap needs the touch screen to be in normal mode
|
||||||
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
||||||
|
@ -240,7 +245,7 @@ void SystemTask::Work() {
|
||||||
heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep);
|
heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep);
|
||||||
break;
|
break;
|
||||||
case Messages::OnNewTime:
|
case Messages::OnNewTime:
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
|
||||||
if (alarmController.State() == Controllers::AlarmController::AlarmState::Set) {
|
if (alarmController.State() == Controllers::AlarmController::AlarmState::Set) {
|
||||||
alarmController.ScheduleAlarm();
|
alarmController.ScheduleAlarm();
|
||||||
|
@ -251,7 +256,7 @@ void SystemTask::Work() {
|
||||||
if (state == SystemTaskState::Sleeping) {
|
if (state == SystemTaskState::Sleeping) {
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
} else {
|
} else {
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
|
||||||
}
|
}
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
|
||||||
}
|
}
|
||||||
|
@ -263,7 +268,7 @@ void SystemTask::Work() {
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::AlarmTriggered);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::AlarmTriggered);
|
||||||
break;
|
break;
|
||||||
case Messages::BleConnected:
|
case Messages::BleConnected:
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
|
||||||
isBleDiscoveryTimerRunning = true;
|
isBleDiscoveryTimerRunning = true;
|
||||||
bleDiscoveryTimer = 5;
|
bleDiscoveryTimer = 5;
|
||||||
break;
|
break;
|
||||||
|
@ -323,7 +328,11 @@ void SystemTask::Work() {
|
||||||
// if it's in sleep mode. Avoid bricked device by disabling sleep mode on these versions.
|
// if it's in sleep mode. Avoid bricked device by disabling sleep mode on these versions.
|
||||||
spiNorFlash.Sleep();
|
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
|
// Double Tap needs the touch screen to be in normal mode
|
||||||
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
||||||
|
@ -457,7 +466,7 @@ void SystemTask::HandleButtonAction(Controllers::ButtonActions action) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NotifyDeviceActivity);
|
||||||
|
|
||||||
using Actions = Controllers::ButtonActions;
|
using Actions = Controllers::ButtonActions;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue