summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/ISSUE_TEMPLATE/config.yml8
-rw-r--r--.github/workflows/main.yml11
-rw-r--r--.gitignore4
-rw-r--r--CMakeLists.txt4
-rw-r--r--doc/MemoryAnalysis.md22
-rw-r--r--doc/NavigationService.md4
-rw-r--r--doc/PinetimeStubWithNrf52DK.md12
-rw-r--r--doc/SPI-LCD-driver.md2
-rw-r--r--doc/SWD.md4
-rw-r--r--doc/ble.md4
-rw-r--r--doc/branches.md4
-rw-r--r--doc/buildAndProgram.md4
-rw-r--r--doc/code/Apps.md6
-rw-r--r--doc/code/Intro.md4
-rw-r--r--doc/contribute.md2
-rw-r--r--doc/gettingStarted/about-software.md10
-rw-r--r--doc/gettingStarted/gettingStarted-1.0.md2
-rw-r--r--doc/gettingStarted/ota-gadgetbridge.md2
-rw-r--r--doc/openOCD.md10
-rw-r--r--doc/ui_guidelines.md1
-rw-r--r--src/CMakeLists.txt7
-rw-r--r--src/buttonhandler/ButtonHandler.cpp2
-rw-r--r--src/buttonhandler/ButtonHandler.h2
-rw-r--r--src/components/ble/NimbleController.cpp23
-rw-r--r--src/components/datetime/DateTimeController.cpp43
-rw-r--r--src/components/datetime/DateTimeController.h7
-rw-r--r--src/components/heartrate/Ppg.h2
-rw-r--r--src/components/motion/MotionController.cpp47
-rw-r--r--src/components/motion/MotionController.h20
-rw-r--r--src/components/motor/MotorController.h2
-rw-r--r--src/components/settings/Settings.h37
-rw-r--r--src/displayapp/Apps.h3
-rw-r--r--src/displayapp/DisplayApp.cpp32
-rw-r--r--src/displayapp/DisplayApp.h3
-rw-r--r--src/displayapp/DisplayAppRecovery.cpp1
-rw-r--r--src/displayapp/DisplayAppRecovery.h2
-rw-r--r--src/displayapp/Messages.h1
-rw-r--r--src/displayapp/lv_pinetime_theme.c8
-rw-r--r--src/displayapp/lv_pinetime_theme.h2
-rw-r--r--src/displayapp/screens/Alarm.cpp138
-rw-r--r--src/displayapp/screens/Alarm.h17
-rw-r--r--src/displayapp/screens/Clock.cpp28
-rw-r--r--src/displayapp/screens/Clock.h2
-rw-r--r--src/displayapp/screens/DropDownDemo.cpp57
-rw-r--r--src/displayapp/screens/DropDownDemo.h27
-rw-r--r--src/displayapp/screens/InfiniPaint.cpp2
-rw-r--r--src/displayapp/screens/Metronome.cpp15
-rw-r--r--src/displayapp/screens/Metronome.h2
-rw-r--r--src/displayapp/screens/Music.cpp14
-rw-r--r--src/displayapp/screens/Music.h2
-rw-r--r--src/displayapp/screens/Notifications.cpp74
-rw-r--r--src/displayapp/screens/Notifications.h15
-rw-r--r--src/displayapp/screens/PineTimeStyle.cpp403
-rw-r--r--src/displayapp/screens/PineTimeStyle.h25
-rw-r--r--src/displayapp/screens/Steps.cpp49
-rw-r--r--src/displayapp/screens/Steps.h6
-rw-r--r--src/displayapp/screens/StopWatch.cpp9
-rw-r--r--src/displayapp/screens/StopWatch.h2
-rw-r--r--src/displayapp/screens/Tile.cpp4
-rw-r--r--src/displayapp/screens/WatchFaceDigital.cpp105
-rw-r--r--src/displayapp/screens/WatchFaceDigital.h3
-rw-r--r--src/displayapp/screens/WatchFaceTerminal.cpp198
-rw-r--r--src/displayapp/screens/WatchFaceTerminal.h82
-rw-r--r--src/displayapp/screens/settings/QuickSettings.cpp4
-rw-r--r--src/displayapp/screens/settings/SettingChimes.cpp100
-rw-r--r--src/displayapp/screens/settings/SettingChimes.h27
-rw-r--r--src/displayapp/screens/settings/SettingPineTimeStyle.cpp318
-rw-r--r--src/displayapp/screens/settings/SettingPineTimeStyle.h56
-rw-r--r--src/displayapp/screens/settings/SettingSetTime.cpp75
-rw-r--r--src/displayapp/screens/settings/SettingSetTime.h41
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.cpp137
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.h37
-rw-r--r--src/displayapp/screens/settings/SettingWakeUp.cpp8
-rw-r--r--src/displayapp/screens/settings/SettingWakeUp.h2
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.cpp2
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.h2
-rw-r--r--src/displayapp/screens/settings/Settings.cpp26
-rw-r--r--src/drivers/Hrs3300.cpp12
-rw-r--r--src/drivers/Hrs3300.h4
-rw-r--r--src/heartratetask/HeartRateTask.cpp3
-rw-r--r--src/main.cpp13
-rw-r--r--src/systemtask/Messages.h2
-rw-r--r--src/systemtask/SystemTask.cpp58
-rw-r--r--src/systemtask/SystemTask.h3
84 files changed, 1710 insertions, 863 deletions
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 00000000..e5a555fd
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,8 @@
+blank_issues_enabled: true
+contact_links:
+ - name: PineTime community chat (Matrix)
+ url: https://app.element.io/#/room/#pinetime:matrix.org
+ about: Please ask questions about PineTime here.
+ - name: PineTime developers chat (Matrix)
+ url: https://app.element.io/#/room/#pinetime-dev:matrix.org
+ about: Please ask questions about PineTime development here.
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 3b753a37..58a63931 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -113,7 +113,7 @@ jobs:
run: |
mkdir -p build
cd build
- cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=${{ runner.temp }}/arm-none-eabi -DNRF5_SDK_PATH=${{ runner.temp }}/nrf5_sdk -DUSE_OPENOCD=1 -DBUILD_DFU=1 ../
+ cmake -G Ninja -DARM_NONE_EABI_TOOLCHAIN_PATH=${{ runner.temp }}/arm-none-eabi -DNRF5_SDK_PATH=${{ runner.temp }}/nrf5_sdk -DUSE_OPENOCD=1 -DBUILD_DFU=1 ../
#########################################################################################
# Make and Upload DFU Package
@@ -125,8 +125,7 @@ jobs:
- name: Make pinetime-mcuboot-app
run: |
- cd build
- make pinetime-mcuboot-app
+ cmake --build build --target pinetime-mcuboot-app
- name: Unzip DFU package
run: |
@@ -144,8 +143,7 @@ jobs:
- name: Make pinetime-app
run: |
- cd build
- make pinetime-app
+ cmake --build build --target pinetime-app
- name: Upload standalone firmware
uses: actions/upload-artifact@v2
@@ -158,8 +156,7 @@ jobs:
- name: Make pinetime-recovery
run: |
- cd build
- make pinetime-recovery
+ cmake --build build --target pinetime-recovery
#########################################################################################
# Finish
diff --git a/.gitignore b/.gitignore
index 39fb672b..0474017b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,3 +43,7 @@ Testing/Temporary/
#VSCODE
.vscode/.cortex-debug.registers.state.json
.vscode/.cortex-debug.peripherals.state.json
+
+#build files
+src/nRF5_SDK_15.3.0_59ac345
+src/arm-none-eabi
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b5880666..8846531e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
-project(pinetime VERSION 1.7.1 LANGUAGES C CXX ASM)
+project(pinetime VERSION 1.8.0 LANGUAGES C CXX ASM)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 14)
@@ -100,7 +100,7 @@ else()
endif()
set(VERSION_EDIT_WARNING "// Do not edit this file, it is automatically generated by CMAKE!")
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/Version.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docker/post_build.sh.in ${CMAKE_CURRENT_BINARY_DIR}/post_build.sh)
diff --git a/doc/MemoryAnalysis.md b/doc/MemoryAnalysis.md
index 7304e3f3..376f98f6 100644
--- a/doc/MemoryAnalysis.md
+++ b/doc/MemoryAnalysis.md
@@ -32,13 +32,13 @@ In this analysis, I used [Linkermapviz](https://github.com/PromyLOPh/linkermapvi
### Linkermapviz
-[Linkermapviz](https://github.com/PromyLOPh/linkermapviz) parses the MAP file and displays its content in a graphical way into an HTML page:
+[Linkermapviz](https://github.com/PromyLOPh/linkermapviz) parses the MAP file and displays its content on an HTML page as a graphic:
![linkermapviz](./memoryAnalysis/linkermapviz.png)
-Using this tool, you can easily see the size of each symbol relative to the other one, and check what is using most of the space,...
+Using this tool, you can compare the relative size of symbols. This can be helpful for checking memory usage at a glance.
-Also, as Linkermapviz is written in Python, you can easily modify it to adapt it to your firmware, export data in another format,... For example, [I modified it to parse the contents of the MAP file and export it in a CSV file](https://github.com/InfiniTimeOrg/InfiniTime/issues/313#issuecomment-842338620). I could later on open this file in LibreOffice Calc and use sort/filter functionality to search for specific symbols in specific files...
+Also, as Linkermapviz is written in Python, you can easily modify and adapt it to your firmware or export data in another format. For example, [here it is modified to parse the contents of the MAP file and export it in a CSV file](https://github.com/InfiniTimeOrg/InfiniTime/issues/313#issuecomment-842338620). This file could later be opened in LibreOffice Calc where sort/filter functionality could be used to search for specific symbols in specific files...
### Puncover
[Puncover](https://github.com/HBehrens/puncover) is another useful tools that analyses the binary file generated by the compiler (the .out file that contains all debug information). It provides valuable information about the symbols (data and code): name, position, size, max stack of each functions, callers, callees...
@@ -46,8 +46,8 @@ Also, as Linkermapviz is written in Python, you can easily modify it to adapt it
Puncover is really easy to install:
- - clone the repo and cd into the cloned directory
- - setup a venv
+ - Clone the repo and cd into the cloned directory
+ - Setup a venv
- `python -m virtualenv venv`
- `source venv/bin/activate`
- Install : `pip install .`
@@ -60,13 +60,13 @@ Puncover is really easy to install:
- Launch a browser at http://localhost:5000/
### Analysis
-Using the MAP file and tools, we can easily see what symbols are using most of the FLASH memory space. In this case, with no surprise, fonts and graphics are the biggest flash space consumer.
+Using the MAP file and tools, we can easily see what symbols are using most of the flash memory. In this case, unsuprisingly, fonts and graphics are the largest use of flash memory.
![Puncover](./memoryAnalysis/puncover-all-symbols.png)
-This way, you can easily check what needs to be optimized : we should find a way to store big static data (like fonts and graphics) in the external flash memory, for example.
+This way, you can easily check what needs to be optimized. We should find a way to store big static data (like fonts and graphics) in the external flash memory, for example.
-It's always a good idea to check the flash memory space when working on the project : this way, you can easily check that your developments are using a reasonable amount of space.
+It's always a good idea to check the flash memory space when working on the project. This way, you can easily check that your developments are using a reasonable amount of space.
### Links
- Analysis with linkermapviz : https://github.com/InfiniTimeOrg/InfiniTime/issues/313#issuecomment-842338620
@@ -210,7 +210,7 @@ NRF_LOG_INFO("heap : %d", m.uordblks);
```
#### Analysis
-According to my experimentation, InfiniTime uses ~6000bytes of heap most of the time. Except when the Navigation app is launched, where the heap usage increases to... more than 9500 bytes (meaning that the heap overflows and could potentially corrupt the stack!!!). This is a bug that should be fixed in #362.
+According to my experimentation, InfiniTime uses ~6000bytes of heap most of the time. Except when the Navigation app is launched, where the heap usage exceeds 9500 bytes (meaning that the heap overflows and could potentially corrupt the stack). This is a bug that should be fixed in #362.
To know exactly what's consuming heap memory, you can `wrap` functions like `malloc()` into your own functions. In this wrapper, you can add logging code or put breakpoints:
@@ -245,7 +245,7 @@ Using this technique, I was able to trace all malloc calls at boot (boot -> digi
- https://www.embedded.com/mastering-stack-and-heap-for-system-reliability-part-3-avoiding-heap-errors/
## LVGL
-I did a deep analysis of the usage of the buffer dedicated for lvgl (managed by lv_mem).
+I did a deep analysis of the usage of the buffer dedicated to lvgl (managed by lv_mem).
This buffer is used by lvgl to allocated memory for drivers (display/touch), screens, themes, and all widgets created by the apps.
The usage of this buffer can be monitored using this code :
@@ -256,7 +256,7 @@ lv_mem_monitor(&mon);
NRF_LOG_INFO("\t Free %d / %d -- max %d", mon.free_size, mon.total_size, mon.max_used);
```
-The most interesting metric is `mon.max_used` which specifies the maximum number of bytes that were used from this buffer since the initialization of lvgl.
+The most interesting metric is `mon.max_used` which specifies the maximum number of bytes used from this buffer since the initialization of lvgl.
According to my measurements, initializing the theme, display/touch driver and screens cost **4752** bytes!
Then, initializing the digital clock face costs **1541 bytes**.
For example a simple lv_label needs **~140 bytes** of memory.
diff --git a/doc/NavigationService.md b/doc/NavigationService.md
index fd81d0bf..5a4f69e0 100644
--- a/doc/NavigationService.md
+++ b/doc/NavigationService.md
@@ -1,6 +1,6 @@
# Navigation Service
## Introduction
-The navigation ble service provides 4 characteristics to allow the the watch to display navigation instructions from a companion application. The intended purpose is when performing some outdoor activities, for example running or cycling.
+The navigation ble service provides 4 characteristics to allow the watch to display navigation instructions from a companion application. This service is intended to be used when performing some outdoor activities, for example running or cycling.
The 4 characteristics are:
flag (string) - Upcoming icon name
@@ -22,7 +22,7 @@ This is a client supplied string describing the upcoming instruction such as "At
This is a short string describing the distance to the upcoming instruction such as "50 m".
## Progress (UUID 00010004-78fc-48fe-8e23-433b3a1942d0)
-The percent complete in a uint8. The watch displays this as an overall progress in a progress bar.
+The percent complete in a uint8. The watch displays this as an overall progress in a progress bar.
## Full icon list
* arrive
diff --git a/doc/PinetimeStubWithNrf52DK.md b/doc/PinetimeStubWithNrf52DK.md
index c4857921..dcaad69b 100644
--- a/doc/PinetimeStubWithNrf52DK.md
+++ b/doc/PinetimeStubWithNrf52DK.md
@@ -1,11 +1,11 @@
# Build a stub for PineTime using NRF52-DK
-[NRF52-DK](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52-DK) is the official developpment kit for NRF52832 SoC from Nordic Semiconductor.
+[NRF52-DK](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52-DK) is the official developpment kit for the NRF52832 SoC from Nordic Semiconductor used in the PineTime.
-It can be very useful for PineTime development:
- * You can use it embedded JLink SWD programmer/debugger to program and debug you code on the PineTime
- * As it's based on the same SoC than the PineTime, you can program it to actually run the same code than the PineTime.
+This development kit can be very useful for PineTime development:
+ * You can use its embedded JLink SWD programmer/debugger to program and debug your code on the PineTime
+ * As it's based on the same SoC than the PineTime, you can program it to actually run the same code as the PineTime.
-This page is about the 2nd point : we will build a stub that will allow us to run the same code than the one you could run on the PineTime. This will allow you to work more easily if you don't have a PineTime dev kit around, if you don't want to modify your dev kit for SWD programming, or if you want to use some feature from the DK (like power measurement).
+This page is about the 2nd point. We will build a stub that will allow us to run the same code you can run on the PineTime. This will allow you to work more easily if you don't have a PineTime dev kit around, if you don't want to modify your dev kit for SWD programming, or if you want to use some feature from the NRF52-DK (like power measurement).
This stub only implements the display, the button and the BLE radio. The other features from the pintime are missing:
* heart rate sensor
@@ -41,7 +41,7 @@ You just need to make the following connections:
| P0.13 | Button IN (D3 in my case) |
| GND | GND |
-You also need to enable the I/O expander to disconnect pins from buttons and led on the NRF52-DK and leave them available on the pin headers:
+You also need to enable the I/O expander to disconnect pins from the buttons and LED on the NRF52-DK and leave them available on the pin headers:
| NRF52 -DK | NRF52- DK |
| --------- | --------- |
diff --git a/doc/SPI-LCD-driver.md b/doc/SPI-LCD-driver.md
index f787aab7..29f3bbfa 100644
--- a/doc/SPI-LCD-driver.md
+++ b/doc/SPI-LCD-driver.md
@@ -1,6 +1,6 @@
# The SPI LCD driver
## Introduction
-The LCD controller that drive the display of the Pinetime is the Sitronix ST7789V. This controller is easy to integrate with an MCU thanks to its SPI interface, and has some interesting features like:
+The LCD controller that drives the display of the Pinetime is the [Sitronix ST7789V](https://wiki.pine64.org/images/5/54/ST7789V_v1.6.pdf). This controller is easy to integrate with an MCU thanks to its SPI interface, and has some interesting features like:
- an on-chip display data RAM that can store the whole framebuffer
- partial screen update
- hardware assisted vertical scrolling
diff --git a/doc/SWD.md b/doc/SWD.md
index 4146e6ae..155983b3 100644
--- a/doc/SWD.md
+++ b/doc/SWD.md
@@ -4,9 +4,9 @@ Download the files **bootloader.bin**, **image-x.y.z.bin** and **pinetime-graphi
![Image file](imageFile.png)
The bootloader reads a boot logo from the external SPI flash memory. The first step consists of flashing a tool in the MCU that will flash the boot logo into this SPI flash memory. This first step is optional but recommended (the bootloader will display garbage on screen for a few second if you don't do it).
-Using your SWD tool, flash **pinetime-graphics-x.y.z.bin** at offset **0x0000**. Reset the MCU and wait for a few second, until the logo is completely drawn on the display.
+Using your SWD tool, flash **pinetime-graphics-x.y.z.bin** at offset **0x0000**. Reset the MCU and wait for a few seconds until the logo is completely drawn on the display.
-Then, using your SWD tool, flash those file at specific offset:
+Then, using your SWD tool, flash these file at the following offsets:
- bootloader.bin : **0x0000**
- image-x.y.z.bin : **0x8000**
diff --git a/doc/ble.md b/doc/ble.md
index 314097d7..d2502636 100644
--- a/doc/ble.md
+++ b/doc/ble.md
@@ -120,11 +120,11 @@ Reading a value from the firmware version characteristic will yield a UTF-8 enco
#### Battery Level
-Reading from the battery level characteristic yields a single byte of data. This byte can be converted to an unsigned 8-bit integer which will be the battery percentage. This characteristic allows notify for updates as the value changes.
+Reading from the battery level characteristic yields a single byte of data. This byte can be converted to an unsigned 8-bit integer which will be the battery percentage. This characteristic allows notifications for updates as the value changes.
#### Heart Rate
-Reading from the heart rate characteristic yields two bytes of data. I am not sure of the function of the first byte. It appears to always be zero. The second byte can be converted to an unsigned 8-bit integer which is the current heart rate. This characteristic also allows notify for updates as the value changes.
+Reading from the heart rate characteristic yields two bytes of data. I am not sure of the function of the first byte. It appears to always be zero. The second byte can be converted to an unsigned 8-bit integer which is the current heart rate. This characteristic also allows notifications for updates as the value changes.
---
diff --git a/doc/branches.md b/doc/branches.md
index ef280f40..3c86375f 100644
--- a/doc/branches.md
+++ b/doc/branches.md
@@ -1,7 +1,7 @@
# Branches
The branching model of this project is based on the workflow named [Git flow](https://nvie.com/posts/a-successful-git-branching-model/).
-It is based on 2 main branches:
+The project is based on 2 main branches:
- **master** : this branch is always ready to be deployed. It means that at any time, we should be able to build the branch and release a new version of the application.
- **develop** : this branch contains the latest development that will be integrated in the next release once it's considered as stable.
@@ -9,4 +9,4 @@ New features should be implemented in **feature branches** created from **develo
To release a new version of the application, when develop is considered stable, a **release** branch is created from **develop**. This can be considered as a *release candidate* branch. When everything is OK, this release branch is merged into **master** and the release is generated (a tag is applied to git, the release note is finalized, binaries are built,...) from **master**.
-Git flow also supports the creation of **hotfix** branches when a bug is discovered in a released version. The **hotfix** branch is created from **master** and will be used only to implement a fix to this bug. Multiple hotfix branches can be created for the same release if more than one bugs are discovered. \ No newline at end of file
+Git flow also supports the creation of **hotfix** branches when a bug is discovered in a released version. The **hotfix** branch is created from **master** and will be used only to implement a fix to this bug. Multiple hotfix branches can be created for the same release if multiple bugs are discovered. \ No newline at end of file
diff --git a/doc/buildAndProgram.md b/doc/buildAndProgram.md
index 3686871a..feef9f6d 100644
--- a/doc/buildAndProgram.md
+++ b/doc/buildAndProgram.md
@@ -4,7 +4,7 @@ To build this project, you'll need:
- A cross-compiler : [ARM-GCC (9-2020-q2-update)](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads/9-2020-q2-update)
- The NRF52 SDK 15.3.0 : [nRF-SDK v15.3.0](https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip)
- The Python 3 modules `cbor`, `intelhex`, `click` and `cryptography` modules for the `mcuboot` tool (see [requirements.txt](../tools/mcuboot/requirements.txt))
- - To to keep the system clean a python virtual environment (`venv`) can be used to install the python modules into
+ - To keep the system clean, you can install python modules into a python virtual environment (`venv`)
```sh
python -m venv .venv
source .venv/bin/activate
@@ -260,4 +260,4 @@ Finally, merge them together with **mergehex**:
This file must be flashed at offset **0x00** of the internal memory of the NRF52832.
#### spinor.bin
-This file is the MCUBoot image of the last stable version of the recovery firmware. It must be flashed at offset **0x00** of the external SPINOR flash memory. \ No newline at end of file
+This file is the MCUBoot image of the last stable version of the recovery firmware. It must be flashed at offset **0x00** of the external SPINOR flash memory.
diff --git a/doc/code/Apps.md b/doc/code/Apps.md
index b1c7d20e..f067b58b 100644
--- a/doc/code/Apps.md
+++ b/doc/code/Apps.md
@@ -8,8 +8,8 @@ This page will teach you:
The user interface of InfiniTime is made up of **screens**.
Screens that are opened from the app launcher are considered **apps**.
Every app in InfiniTime is it's own class.
-An instance of the class is created when the app is launched and destroyed when the user exits the app.
-They run inside the "displayapp" task (briefly discussed [here](./Intro.md)).
+An instance of the class is created when the app is launched, and destroyed when the user exits the app.
+Apps run inside the "displayapp" task (briefly discussed [here](./Intro.md)).
Apps are responsible for everything drawn on the screen when they are running.
By default, apps only do something (as in a function is executed) when they are created or when a touch event is detected.
@@ -21,7 +21,7 @@ A destructor is needed to clean up LVGL and restore any changes (for example re-
App classes can override `bool OnButtonPushed()`, `bool OnTouchEvent(TouchEvents event)` and `bool OnTouchEvent(uint16_t x, uint16_t y)` to implement their own functionality for those events.
If an app only needs to display some text and do something upon a touch screen button press,
it does not need to override any of these functions, as LVGL can also handle touch events for you.
-If you have any doubts, you can always look at how the other apps are doing things.
+If you have any doubts, you can always look at how the other apps function for reference.
### Continuous updating
If your app needs to be updated continuously, you can do so by overriding the `Refresh()` function in your class
diff --git a/doc/code/Intro.md b/doc/code/Intro.md
index bf68c7a5..23b3ade1 100644
--- a/doc/code/Intro.md
+++ b/doc/code/Intro.md
@@ -24,9 +24,9 @@ There are also other tasks that are responsible for Bluetooth ("ll" and "ble" in
and periodic tasks like heartrate measurements ([heartratetask/HeartRateTask.cpp](/src/heartratetask/HeartRateTask.cpp)).
While it is possible for you to create your own task when you need it, it is recommended to just add functionality to `SystemTask::Work()` if possible.
-If you absolutely need to create another task, try to guess how much [stack space](https://www.freertos.org/FAQMem.html#StackSize) (in words/4-byte packets)
+If you absolutely need to create another task, try to estimate how much [stack space](https://www.freertos.org/FAQMem.html#StackSize) (in words/4-byte packets)
it will need instead of just typing in a large-ish number.
-You can use the define `configMINIMAL_STACK_SIZE` which is currently set to 120 words.
+You can use `configMINIMAL_STACK_SIZE` which is currently set to 120 words.
## Controllers
Controllers in InfiniTime are singleton objects that can provide access to certain resources to apps.
diff --git a/doc/contribute.md b/doc/contribute.md
index b1be84a4..f2a4aeaa 100644
--- a/doc/contribute.md
+++ b/doc/contribute.md
@@ -46,7 +46,7 @@ Other contributors can post comments about the pull request, maybe ask for more
Once the pull request is reviewed and accepted, it'll be merged into **develop** and will be released in the next version of the firmware.
-## Why all these rules?
+## Why all these rules?
Reviewing pull requests is a **very time consuming task**. Everything you do to make reviewing easier will **get your PR merged faster**.
diff --git a/doc/gettingStarted/about-software.md b/doc/gettingStarted/about-software.md
index b19a610f..e935d938 100644
--- a/doc/gettingStarted/about-software.md
+++ b/doc/gettingStarted/about-software.md
@@ -12,15 +12,15 @@ InfiniTime has three distinct firmwares:
**OTA** (**O**ver **T**he **A**ir) refers to updating of the firmware over BLE (**B**luetooth **L**ow **E**nergy). This is a functionality that allows the user to update the firmware on their device wirelessly.
-**DFU** (**D**evice **F**irmware **U**pdate) is the file format and protocol used to send the update of the firmware to the watch over-the-air. InfiniTime implement the (legacy) DFU protocol from Nordic Semiconductor (NRF).
+**DFU** (**D**evice **F**irmware **U**pdate) is the file format and protocol used to send the update of the firmware to the watch over-the-air. InfiniTime implements the (legacy) DFU protocol from Nordic Semiconductor (NRF).
## Bootloader
-Most of the time, the bootloader just runs without your intervention (update and load the firmware).
+Most of the time, the bootloader just runs without your intervention (updating and loading the firmware).
-However, you can enable 2 functionalities using the push button:
+However, you can use the bootloader to rollback to the previous firmware, or load the recovery firmware using the push button:
- - Push the button until the pine cone is drawn in **blue** to force the rollback of the previous version of the firmware, even if you've already validated the updated one
- - Push the button until the pine cone is drawn in **red** to load the recovery firmware. This recovery firmware only provides BLE connectivity and OTA functionality.
+ - Press and hold the button until the pine cone is drawn in **blue** to force the rollback of the previous version of the firmware, even if you've already validated the current one.
+ - Press and hold the button until the pine cone is drawn in **red** to load the recovery firmware. This recovery firmware only provides BLE connectivity and OTA functionality.
More info about the bootloader in [its project page](https://github.com/JF002/pinetime-mcuboot-bootloader/blob/master/README.md).
diff --git a/doc/gettingStarted/gettingStarted-1.0.md b/doc/gettingStarted/gettingStarted-1.0.md
index 30b8bdb0..890164fe 100644
--- a/doc/gettingStarted/gettingStarted-1.0.md
+++ b/doc/gettingStarted/gettingStarted-1.0.md
@@ -18,7 +18,7 @@ You can sync the time using companion apps.
You can also set the time in the settings without a companion app. (version >1.7.0)
-InfiniTime doesn't handle daylight savings automatically, so make sure to set the correct the time or sync it with a companion app
+InfiniTime doesn't handle daylight savings automatically, so make sure to set the correct the time or sync it with a companion app.
### Digital watch face
diff --git a/doc/gettingStarted/ota-gadgetbridge.md b/doc/gettingStarted/ota-gadgetbridge.md
index 022b5e4d..fe26c03b 100644
--- a/doc/gettingStarted/ota-gadgetbridge.md
+++ b/doc/gettingStarted/ota-gadgetbridge.md
@@ -18,7 +18,7 @@ Now that Gadgetbridge is connected to your PineTime, use a file browser applicat
![Gadgetbridge 3](gadgetbridge3.jpg)
-Read carefully the warning and tap **Install**:
+Read the warning carefully and tap **Install**:
![Gadgetbridge 4](gadgetbridge4.jpg)
diff --git a/doc/openOCD.md b/doc/openOCD.md
index b3661cee..df24b30b 100644
--- a/doc/openOCD.md
+++ b/doc/openOCD.md
@@ -1,12 +1,12 @@
# OpenOCD and STLink
OpenOCD (**Open O**n **C**hip **D**ebugger) is an open source tool that interfaces with many SWD/JTAG debugger to provide debugging and *in-system* programming for embedded target devices.
-It supports the **NRF52** (the CPU of the PineTime) and the **STLinkV2**, a cheap SWD debugger.
+OpenOCD supports the **NRF52** (the CPU of the PineTime) and the **STLinkV2**, a cheap SWD debugger.
-It works on X86 computers, as well as ARM/ARM64 computers and SBC (like the RaspberryPi and Pine64 Pinebook Pro) !
+OpenOCD works on X86 computers, ARM/ARM64 computers, and SBCs (like the RaspberryPi and Pine64 Pinebook Pro)!
## Installation
-We will build OpenOCD from sources, as packages from Linux distributions are most of the time outdated and do not support the NRF52 correctly.
+We will build OpenOCD from sources, as packages from Linux distributions are most of the time outdated and do not support the NRF52 properly.
- Fetch the sources from GIT, and build and install it:
@@ -27,7 +27,7 @@ sudo cp contrib/60-openocd.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
```
- - You can now plug your STLinkV2 in a USB port and run OpenOCD to see if it's working correctly:
+ - You can now plug your STLinkV2 into a USB port and run OpenOCD to see if it's working correctly:
```
$ openocd -f interface/stlink.cfg -f target/nrf52.cfg
@@ -63,7 +63,7 @@ gdb_breakpoint_override hard
source [find target/nrf52.cfg]
```
-This file specifies to OpenOCD which debugger and target it will be connected to..
+This file specifies to OpenOCD which debugger and target it will be connected to.
Then, we use various *user files* to use OpenOCD to flash InfiniTime binary files.
diff --git a/doc/ui_guidelines.md b/doc/ui_guidelines.md
index 0cbd39f5..296497af 100644
--- a/doc/ui_guidelines.md
+++ b/doc/ui_guidelines.md
@@ -9,5 +9,6 @@
- Top bar takes at least 20px + padding
- Top bar right icons move 8px to the left when using a page indicator
- A black background helps to hide the screen border, allowing the UI to look less cramped when utilizing the entire display area.
+- A switch should be twice as wide as it is tall.
![example layouts](./ui/example.png)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ae8eece8..025fc330 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -445,15 +445,17 @@ list(APPEND SOURCE_FILES
displayapp/screens/settings/SettingWakeUp.cpp
displayapp/screens/settings/SettingDisplay.cpp
displayapp/screens/settings/SettingSteps.cpp
- displayapp/screens/settings/SettingPineTimeStyle.cpp
displayapp/screens/settings/SettingSetDate.cpp
displayapp/screens/settings/SettingSetTime.cpp
+ displayapp/screens/settings/SettingChimes.cpp
+ displayapp/screens/settings/SettingShakeThreshold.cpp
displayapp/screens/settings/SettingAirplaneMode.cpp
## Watch faces
displayapp/icons/bg_clock.c
displayapp/screens/WatchFaceAnalog.cpp
displayapp/screens/WatchFaceDigital.cpp
+ displayapp/screens/WatchFaceTerminal.cpp
displayapp/screens/PineTimeStyle.cpp
##
@@ -612,6 +614,7 @@ list(APPEND RECOVERYLOADER_SOURCE_FILES
set(INCLUDE_FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/src/Version.h
BootloaderVersion.h
logging/Logger.h
logging/NrfLogger.h
@@ -625,7 +628,6 @@ set(INCLUDE_FILES
displayapp/screens/InfiniPaint.h
displayapp/screens/StopWatch.h
displayapp/screens/Paddle.h
- displayapp/screens/DropDownDemo.h
displayapp/screens/BatteryIcon.h
displayapp/screens/BleIcon.h
displayapp/screens/NotificationIcon.h
@@ -710,6 +712,7 @@ set(INCLUDE_FILES
)
include_directories(
+ ${CMAKE_BINARY_DIR}/src # include generated files like Version.h
.
../
libs/
diff --git a/src/buttonhandler/ButtonHandler.cpp b/src/buttonhandler/ButtonHandler.cpp
index 02ee22cf..3c2bc72c 100644
--- a/src/buttonhandler/ButtonHandler.cpp
+++ b/src/buttonhandler/ButtonHandler.cpp
@@ -1,4 +1,4 @@
-#include "ButtonHandler.h"
+#include "buttonhandler/ButtonHandler.h"
using namespace Pinetime::Controllers;
diff --git a/src/buttonhandler/ButtonHandler.h b/src/buttonhandler/ButtonHandler.h
index 44b20f19..5802b998 100644
--- a/src/buttonhandler/ButtonHandler.h
+++ b/src/buttonhandler/ButtonHandler.h
@@ -1,6 +1,6 @@
#pragma once
-#include "ButtonActions.h"
+#include "buttonhandler/ButtonActions.h"
#include "systemtask/SystemTask.h"
#include <FreeRTOS.h>
#include <timers.h>
diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp
index d85ec5dc..94d2d155 100644
--- a/src/components/ble/NimbleController.cpp
+++ b/src/components/ble/NimbleController.cpp
@@ -282,7 +282,28 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
if (event->passkey.params.action == BLE_SM_IOACT_DISP) {
struct ble_sm_io pkey = {0};
pkey.action = event->passkey.params.action;
- pkey.passkey = ble_ll_rand() % 1000000;
+
+ /*
+ * Passkey is a 6 digits code (1'000'000 possibilities).
+ * It is important every possible value has an equal probability
+ * of getting generated. Simply applying a modulo creates a bias
+ * since 2^32 is not a multiple of 1'000'000.
+ * To prevent that, we can reject values greater than 999'999.
+ *
+ * Rejecting values would happen a lot since 2^32-1 is way greater
+ * than 1'000'000. An optimisation is to use a multiple of 1'000'000.
+ * The greatest multiple of 1'000'000 lesser than 2^32-1 is
+ * 4'294'000'000.
+ *
+ * Great explanation at:
+ * https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/
+ */
+ uint32_t passkey_rand;
+ do {
+ passkey_rand = ble_ll_rand();
+ } while (passkey_rand > 4293999999);
+ pkey.passkey = passkey_rand % 1000000;
+
bleController.SetPairingKey(pkey.passkey);
systemTask.PushMessage(Pinetime::System::Messages::OnPairing);
ble_sm_inject_io(event->passkey.conn_handle, &pkey);
diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp
index 4ac9e1f1..e0d12431 100644
--- a/src/components/datetime/DateTimeController.cpp
+++ b/src/components/datetime/DateTimeController.cpp
@@ -11,6 +11,9 @@ namespace {
char const* MonthsStringLow[] = {"--", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
}
+DateTime::DateTime(Controllers::Settings& settingsController) : settingsController {settingsController} {
+}
+
void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> t) {
this->currentDateTime = t;
UpdateTime(previousSystickCounter); // Update internal state without updating the time
@@ -36,6 +39,8 @@ void DateTime::SetTime(
UpdateTime(systickCounter);
NRF_LOG_INFO("* %d %d %d ", this->hour, this->minute, this->second);
NRF_LOG_INFO("* %d %d %d ", this->day, this->month, this->year);
+
+ systemTask->PushMessage(System::Messages::OnNewTime);
}
void DateTime::UpdateTime(uint32_t systickCounter) {
@@ -75,6 +80,24 @@ void DateTime::UpdateTime(uint32_t systickCounter) {
minute = time.minutes().count();
second = time.seconds().count();
+ if (minute == 0 && !isHourAlreadyNotified) {
+ isHourAlreadyNotified = true;
+ if (systemTask != nullptr) {
+ systemTask->PushMessage(System::Messages::OnNewHour);
+ }
+ } else if (minute != 0) {
+ isHourAlreadyNotified = false;
+ }
+
+ if ((minute == 0 || minute == 30) && !isHalfHourAlreadyNotified) {
+ isHalfHourAlreadyNotified = true;
+ if (systemTask != nullptr) {
+ systemTask->PushMessage(System::Messages::OnNewHalfHour);
+ }
+ } else if (minute != 0 && minute != 30) {
+ isHalfHourAlreadyNotified = false;
+ }
+
// Notify new day to SystemTask
if (hour == 0 and not isMidnightAlreadyNotified) {
isMidnightAlreadyNotified = true;
@@ -101,3 +124,23 @@ void DateTime::Register(Pinetime::System::SystemTask* systemTask) {
this->systemTask = systemTask;
}
+using ClockType = Pinetime::Controllers::Settings::ClockType;
+std::string DateTime::FormattedTime() {
+ // Return time as a string in 12- or 24-hour format
+ char buff[9];
+ if (settingsController.GetClockType() == ClockType::H12) {
+ uint8_t hour12;
+ const char* amPmStr;
+ if (hour < 12) {
+ hour12 = (hour == 0) ? 12 : hour;
+ amPmStr = "AM";
+ } else {
+ hour12 = (hour == 12) ? 12 : hour - 12;
+ amPmStr = "PM";
+ }
+ sprintf(buff, "%i:%02i %s", hour12, minute, amPmStr);
+ } else {
+ sprintf(buff, "%02i:%02i", hour, minute);
+ }
+ return std::string(buff);
+}
diff --git a/src/components/datetime/DateTimeController.h b/src/components/datetime/DateTimeController.h
index 77ed68e8..6e5ee3ca 100644
--- a/src/components/datetime/DateTimeController.h
+++ b/src/components/datetime/DateTimeController.h
@@ -2,6 +2,8 @@
#include <cstdint>
#include <chrono>
+#include <string>
+#include "components/settings/Settings.h"
namespace Pinetime {
namespace System {
@@ -10,6 +12,7 @@ namespace Pinetime {
namespace Controllers {
class DateTime {
public:
+ DateTime(Controllers::Settings& settingsController);
enum class Days : uint8_t { Unknown, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday };
enum class Months : uint8_t {
Unknown,
@@ -71,6 +74,7 @@ namespace Pinetime {
void Register(System::SystemTask* systemTask);
void SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> t);
+ std::string FormattedTime();
private:
uint16_t year = 0;
@@ -86,7 +90,10 @@ namespace Pinetime {
std::chrono::seconds uptime {0};
bool isMidnightAlreadyNotified = false;
+ bool isHourAlreadyNotified = true;
+ bool isHalfHourAlreadyNotified = true;
System::SystemTask* systemTask = nullptr;
+ Controllers::Settings& settingsController;
};
}
}
diff --git a/src/components/heartrate/Ppg.h b/src/components/heartrate/Ppg.h
index ed79b082..7000c871 100644
--- a/src/components/heartrate/Ppg.h
+++ b/src/components/heartrate/Ppg.h
@@ -1,6 +1,8 @@
#pragma once
#include <array>
+#include <cstddef>
+#include <cstdint>
#include "components/heartrate/Biquad.h"
#include "components/heartrate/Ptagc.h"
diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp
index cae49105..7dd32127 100644
--- a/src/components/motion/MotionController.cpp
+++ b/src/components/motion/MotionController.cpp
@@ -1,5 +1,5 @@
#include "components/motion/MotionController.h"
-
+#include "os/os_cputime.h"
using namespace Pinetime::Controllers;
void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps) {
@@ -7,17 +7,21 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps)
service->OnNewStepCountValue(nbSteps);
}
- if(service != nullptr && (this->x != x || this->y != y || this->z != z)) {
+ if (service != nullptr && (this->x != x || this->y != y || this->z != z)) {
service->OnNewMotionValues(x, y, z);
}
this->x = x;
this->y = y;
this->z = z;
+ int32_t deltaSteps = nbSteps - this->nbSteps;
this->nbSteps = nbSteps;
+ if (deltaSteps > 0) {
+ currentTripSteps += deltaSteps;
+ }
}
-bool MotionController::ShouldWakeUp(bool isSleeping) {
+bool MotionController::Should_RaiseWake(bool isSleeping) {
if ((x + 335) <= 670 && z < 0) {
if (not isSleeping) {
if (y <= 0) {
@@ -39,14 +43,43 @@ bool MotionController::ShouldWakeUp(bool isSleeping) {
}
return false;
}
+
+bool MotionController::Should_ShakeWake(uint16_t thresh) {
+ bool wake = false;
+ auto diff = xTaskGetTickCount() - lastShakeTime;
+ lastShakeTime = xTaskGetTickCount();
+ /* Currently Polling at 10hz, If this ever goes faster scalar and EMA might need adjusting */
+ int32_t speed = std::abs(z + (y / 2) + (x / 4) - lastYForShake - lastZForShake) / diff * 100;
+ //(.2 * speed) + ((1 - .2) * accumulatedspeed);
+ // implemented without floats as .25Alpha
+ accumulatedspeed = (speed / 5) + ((accumulatedspeed / 5) * 4);
+
+ if (accumulatedspeed > thresh) {
+ wake = true;
+ }
+ lastXForShake = x / 4;
+ lastYForShake = y / 2;
+ lastZForShake = z;
+ return wake;
+}
+int32_t MotionController::currentShakeSpeed() {
+ return accumulatedspeed;
+}
+
void MotionController::IsSensorOk(bool isOk) {
isSensorOk = isOk;
}
void MotionController::Init(Pinetime::Drivers::Bma421::DeviceTypes types) {
- switch(types){
- case Drivers::Bma421::DeviceTypes::BMA421: this->deviceType = DeviceTypes::BMA421; break;
- case Drivers::Bma421::DeviceTypes::BMA425: this->deviceType = DeviceTypes::BMA425; break;
- default: this->deviceType = DeviceTypes::Unknown; break;
+ switch (types) {
+ case Drivers::Bma421::DeviceTypes::BMA421:
+ this->deviceType = DeviceTypes::BMA421;
+ break;
+ case Drivers::Bma421::DeviceTypes::BMA425:
+ this->deviceType = DeviceTypes::BMA425;
+ break;
+ default:
+ this->deviceType = DeviceTypes::Unknown;
+ break;
}
}
void MotionController::SetService(Pinetime::Controllers::MotionService* service) {
diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h
index c72d8a4a..f80b11b9 100644
--- a/src/components/motion/MotionController.h
+++ b/src/components/motion/MotionController.h
@@ -8,7 +8,7 @@ namespace Pinetime {
namespace Controllers {
class MotionController {
public:
- enum class DeviceTypes{
+ enum class DeviceTypes {
Unknown,
BMA421,
BMA425,
@@ -28,8 +28,17 @@ namespace Pinetime {
uint32_t NbSteps() const {
return nbSteps;
}
- bool ShouldWakeUp(bool isSleeping);
+ void ResetTrip() {
+ currentTripSteps = 0;
+ }
+ uint32_t GetTripSteps() const {
+ return currentTripSteps;
+ }
+
+ bool Should_ShakeWake(uint16_t thresh);
+ bool Should_RaiseWake(bool isSleeping);
+ int32_t currentShakeSpeed();
void IsSensorOk(bool isOk);
bool IsSensorOk() const {
return isSensorOk;
@@ -44,6 +53,7 @@ namespace Pinetime {
private:
uint32_t nbSteps;
+ uint32_t currentTripSteps = 0;
int16_t x;
int16_t y;
int16_t z;
@@ -51,6 +61,12 @@ namespace Pinetime {
bool isSensorOk = false;
DeviceTypes deviceType = DeviceTypes::Unknown;
Pinetime::Controllers::MotionService* service = nullptr;
+
+ int16_t lastXForShake = 0;
+ int16_t lastYForShake = 0;
+ int16_t lastZForShake = 0;
+ int32_t accumulatedspeed = 0;
+ uint32_t lastShakeTime = 0;
};
}
} \ No newline at end of file
diff --git a/src/components/motor/MotorController.h b/src/components/motor/MotorController.h
index c9326d57..b5a592b1 100644
--- a/src/components/motor/MotorController.h
+++ b/src/components/motor/MotorController.h
@@ -12,7 +12,7 @@ namespace Pinetime {
void Init();
void RunForDuration(uint8_t motorDuration);
void StartRinging();
- static void StopRinging();
+ void StopRinging();
private:
static void Ring(void* p_context);
diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h
index a1529fec..9878aac5 100644
--- a/src/components/settings/Settings.h
+++ b/src/components/settings/Settings.h
@@ -1,7 +1,6 @@
#pragma once
#include <cstdint>
#include <bitset>
-#include "components/datetime/DateTimeController.h"
#include "components/brightness/BrightnessController.h"
#include "components/fs/FS.h"
@@ -11,10 +10,12 @@ namespace Pinetime {
public:
enum class ClockType : uint8_t { H24, H12 };
enum class Notification : uint8_t { ON, OFF };
+ enum class ChimesOption : uint8_t { None, Hours, HalfHours };
enum class WakeUpMode : uint8_t {
SingleTap = 0,
DoubleTap = 1,
RaiseWrist = 2,
+ Shake = 3,
};
enum class Colors : uint8_t {
White,
@@ -56,6 +57,16 @@ namespace Pinetime {
return settings.clockFace;
};
+ void SetChimeOption(ChimesOption chimeOption) {
+ if (chimeOption != settings.chimesOption) {
+ settingsChanged = true;
+ }
+ settings.chimesOption = chimeOption;
+ };
+ ChimesOption GetChimeOption() const {
+ return settings.chimesOption;
+ };
+
void SetPTSColorTime(Colors colorTime) {
if (colorTime != settings.PTS.ColorTime)
settingsChanged = true;
@@ -124,10 +135,23 @@ namespace Pinetime {
}
settings.screenTimeOut = timeout;
};
+
uint32_t GetScreenTimeOut() const {
return settings.screenTimeOut;
};
+ void SetShakeThreshold(uint16_t thresh){
+ if(settings.shakeWakeThreshold != thresh){
+ settings.shakeWakeThreshold = thresh;
+ settingsChanged = true;
+ }
+
+ }
+
+ int16_t GetShakeThreshold() const{
+ return settings.shakeWakeThreshold;
+ }
+
void setWakeUpMode(WakeUpMode wakeUp, bool enabled) {
if (enabled != isWakeUpModeOn(wakeUp)) {
settingsChanged = true;
@@ -142,13 +166,13 @@ namespace Pinetime {
case WakeUpMode::DoubleTap:
settings.wakeUpMode.set(static_cast<size_t>(WakeUpMode::SingleTap), false);
break;
- case WakeUpMode::RaiseWrist:
+ default:
break;
}
}
};
- std::bitset<3> getWakeUpModes() const {
+ std::bitset<4> getWakeUpModes() const {
return settings.wakeUpMode;
}
@@ -189,7 +213,7 @@ namespace Pinetime {
private:
Pinetime::Controllers::FS& fs;
- static constexpr uint32_t settingsVersion = 0x0002;
+ static constexpr uint32_t settingsVersion = 0x0003;
struct SettingsData {
uint32_t version = settingsVersion;
uint32_t stepsGoal = 10000;
@@ -199,11 +223,12 @@ namespace Pinetime {
Notification notificationStatus = Notification::ON;
uint8_t clockFace = 0;
+ ChimesOption chimesOption = ChimesOption::None;
PineTimeStyle PTS;
- std::bitset<3> wakeUpMode {0};
-
+ std::bitset<4> wakeUpMode {0};
+ uint16_t shakeWakeThreshold = 150;
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
};
diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h
index 971c36b7..dc9e6253 100644
--- a/src/displayapp/Apps.h
+++ b/src/displayapp/Apps.h
@@ -34,9 +34,10 @@ namespace Pinetime {
SettingDisplay,
SettingWakeUp,
SettingSteps,
- SettingPineTimeStyle,
SettingSetDate,
SettingSetTime,
+ SettingChimes,
+ SettingShakeThreshold,
SettingAirplaneMode,
Error
};
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index d3896b18..25ae9ad6 100644
--- a/src/displayapp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -45,9 +45,10 @@
#include "displayapp/screens/settings/SettingWakeUp.h"
#include "displayapp/screens/settings/SettingDisplay.h"
#include "displayapp/screens/settings/SettingSteps.h"
-#include "displayapp/screens/settings/SettingPineTimeStyle.h"
#include "displayapp/screens/settings/SettingSetDate.h"
#include "displayapp/screens/settings/SettingSetTime.h"
+#include "displayapp/screens/settings/SettingChimes.h"
+#include "displayapp/screens/settings/SettingShakeThreshold.h"
#include "displayapp/screens/settings/SettingAirplaneMode.h"
#include "libs/lv_conf.h"
@@ -97,6 +98,7 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Pinetime::Controllers::MotionController& motionController,
Pinetime::Controllers::TimerController& timerController,
Pinetime::Controllers::AlarmController& alarmController,
+ Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::TouchHandler& touchHandler)
: lcd {lcd},
lvgl {lvgl},
@@ -112,6 +114,7 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
motionController {motionController},
timerController {timerController},
alarmController {alarmController},
+ brightnessController {brightnessController},
touchHandler {touchHandler} {
}
@@ -256,10 +259,10 @@ void DisplayApp::Refresh() {
}
} break;
case Messages::ButtonPushed:
- if (currentApp == Apps::Clock) {
- PushMessageToSystemTask(System::Messages::GoToSleep);
- } else {
- if (!currentScreen->OnButtonPushed()) {
+ if (!currentScreen->OnButtonPushed()) {
+ if (currentApp == Apps::Clock) {
+ PushMessageToSystemTask(System::Messages::GoToSleep);
+ } else {
LoadApp(returnToApp, returnDirection);
brightnessController.Set(settingsController.GetBrightness());
brightnessController.Backup();
@@ -297,6 +300,9 @@ void DisplayApp::Refresh() {
// Added to remove warning
// What should happen here?
break;
+ case Messages::Clock:
+ LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None);
+ break;
}
}
@@ -367,19 +373,19 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
case Apps::Notifications:
currentScreen = std::make_unique<Screens::Notifications>(
- this, notificationManager, systemTask->nimble().alertService(), motorController, Screens::Notifications::Modes::Normal);
+ this, notificationManager, systemTask->nimble().alertService(), motorController, *systemTask, Screens::Notifications::Modes::Normal);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break;
case Apps::NotificationsPreview:
currentScreen = std::make_unique<Screens::Notifications>(
- this, notificationManager, systemTask->nimble().alertService(), motorController, Screens::Notifications::Modes::Preview);
+ this, notificationManager, systemTask->nimble().alertService(), motorController, *systemTask, Screens::Notifications::Modes::Preview);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break;
case Apps::Timer:
currentScreen = std::make_unique<Screens::Timer>(this, timerController);
break;
case Apps::Alarm:
- currentScreen = std::make_unique<Screens::Alarm>(this, alarmController);
+ currentScreen = std::make_unique<Screens::Alarm>(this, alarmController, settingsController, *systemTask);
break;
// Settings
@@ -417,11 +423,15 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
case Apps::SettingSetTime:
- currentScreen = std::make_unique<Screens::SettingSetTime>(this, dateTimeController);
+ currentScreen = std::make_unique<Screens::SettingSetTime>(this, dateTimeController, settingsController);
+ ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
+ break;
+ case Apps::SettingChimes:
+ currentScreen = std::make_unique<Screens::SettingChimes>(this, settingsController);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
- case Apps::SettingPineTimeStyle:
- currentScreen = std::make_unique<Screens::SettingPineTimeStyle>(this, settingsController);
+ case Apps::SettingShakeThreshold:
+ currentScreen = std::make_unique<Screens::SettingShakeThreshold>(this, settingsController, motionController, *systemTask);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
case Apps::SettingAirplaneMode:
diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h
index 39fe6314..1eaefaa1 100644
--- a/src/displayapp/DisplayApp.h
+++ b/src/displayapp/DisplayApp.h
@@ -61,6 +61,7 @@ namespace Pinetime {
Pinetime::Controllers::MotionController& motionController,
Pinetime::Controllers::TimerController& timerController,
Pinetime::Controllers::AlarmController& alarmController,
+ Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::TouchHandler& touchHandler);
void Start(System::BootErrors error);
void PushMessage(Display::Messages msg);
@@ -87,10 +88,10 @@ namespace Pinetime {
Pinetime::Controllers::MotionController& motionController;
Pinetime::Controllers::TimerController& timerController;
Pinetime::Controllers::AlarmController& alarmController;
+ Pinetime::Controllers::BrightnessController &brightnessController;
Pinetime::Controllers::TouchHandler& touchHandler;
Pinetime::Controllers::FirmwareValidator validator;
- Controllers::BrightnessController brightnessController;
TaskHandle_t taskHandle;
diff --git a/src/displayapp/DisplayAppRecovery.cpp b/src/displayapp/DisplayAppRecovery.cpp
index fd7017a4..9d6eb22f 100644
--- a/src/displayapp/DisplayAppRecovery.cpp
+++ b/src/displayapp/DisplayAppRecovery.cpp
@@ -23,6 +23,7 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Pinetime::Controllers::MotionController& motionController,
Pinetime::Controllers::TimerController& timerController,
Pinetime::Controllers::AlarmController& alarmController,
+ Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::TouchHandler& touchHandler)
: lcd {lcd}, bleController {bleController} {
diff --git a/src/displayapp/DisplayAppRecovery.h b/src/displayapp/DisplayAppRecovery.h
index 86e956d1..61f1c9bf 100644
--- a/src/displayapp/DisplayAppRecovery.h
+++ b/src/displayapp/DisplayAppRecovery.h
@@ -34,6 +34,7 @@ namespace Pinetime {
class MotorController;
class TimerController;
class AlarmController;
+ class BrightnessController;
}
namespace System {
@@ -57,6 +58,7 @@ namespace Pinetime {
Pinetime::Controllers::MotionController& motionController,
Pinetime::Controllers::TimerController& timerController,
Pinetime::Controllers::AlarmController& alarmController,
+ Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::TouchHandler& touchHandler);
void Start();
void Start(Pinetime::System::BootErrors){ Start(); };
diff --git a/src/displayapp/Messages.h b/src/displayapp/Messages.h
index 4d52df20..62256b9e 100644
--- a/src/displayapp/Messages.h
+++ b/src/displayapp/Messages.h
@@ -21,6 +21,7 @@ namespace Pinetime {
RestoreBrightness,
ShowPairingKey,
AlarmTriggered,
+ Clock,
AirplaneModeToggle
};
}
diff --git a/src/displayapp/lv_pinetime_theme.c b/src/displayapp/lv_pinetime_theme.c
index b74b2fd7..4fce5d65 100644
--- a/src/displayapp/lv_pinetime_theme.c
+++ b/src/displayapp/lv_pinetime_theme.c
@@ -199,17 +199,17 @@ static void basic_init(void) {
style_init_reset(&style_sw_bg);
lv_style_set_bg_opa(&style_sw_bg, LV_STATE_DEFAULT, LV_OPA_COVER);
- lv_style_set_bg_color(&style_sw_bg, LV_STATE_DEFAULT, LV_PINETIME_LIGHT_GRAY);
+ lv_style_set_bg_color(&style_sw_bg, LV_STATE_DEFAULT, LV_PINETIME_BLUE);
lv_style_set_radius(&style_sw_bg, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
- lv_style_set_value_color(&style_sw_bg, LV_STATE_DEFAULT, LV_PINETIME_BLUE);
style_init_reset(&style_sw_indic);
lv_style_set_bg_opa(&style_sw_indic, LV_STATE_DEFAULT, LV_OPA_COVER);
- lv_style_set_bg_color(&style_sw_indic, LV_STATE_DEFAULT, LV_PINETIME_GREEN);
+ lv_style_set_bg_color(&style_sw_indic, LV_STATE_DEFAULT, LV_COLOR_GREEN);
style_init_reset(&style_sw_knob);
lv_style_set_bg_opa(&style_sw_knob, LV_STATE_DEFAULT, LV_OPA_COVER);
- lv_style_set_bg_color(&style_sw_knob, LV_STATE_DEFAULT, LV_PINETIME_WHITE);
+ lv_style_set_bg_color(&style_sw_knob, LV_STATE_DEFAULT, LV_COLOR_SILVER);
+ lv_style_set_bg_color(&style_sw_knob, LV_STATE_CHECKED, LV_COLOR_WHITE);
lv_style_set_radius(&style_sw_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_set_pad_top(&style_sw_knob, LV_STATE_DEFAULT, -4);
lv_style_set_pad_bottom(&style_sw_knob, LV_STATE_DEFAULT, -4);
diff --git a/src/displayapp/lv_pinetime_theme.h b/src/displayapp/lv_pinetime_theme.h
index f914516d..714c4242 100644
--- a/src/displayapp/lv_pinetime_theme.h
+++ b/src/displayapp/lv_pinetime_theme.h
@@ -23,7 +23,7 @@ extern "C" {
#define LV_PINETIME_LIGHT lv_color_hex(0xf3f8fe)
#define LV_PINETIME_GRAY lv_color_hex(0x8a8a8a)
#define LV_PINETIME_LIGHT_GRAY lv_color_hex(0xc4c4c4)
-#define LV_PINETIME_BLUE lv_color_hex(0x2f3243) // 006fb6
+#define LV_PINETIME_BLUE lv_color_hex(0x2f3540)
#define LV_PINETIME_GREEN lv_color_hex(0x4cb242)
#define LV_PINETIME_RED lv_color_hex(0xd51732)
diff --git a/src/displayapp/screens/Alarm.cpp b/src/displayapp/screens/Alarm.cpp
index 537ac0e0..879e50d8 100644
--- a/src/displayapp/screens/Alarm.cpp
+++ b/src/displayapp/screens/Alarm.cpp
@@ -23,12 +23,20 @@ using namespace Pinetime::Applications::Screens;
using Pinetime::Controllers::AlarmController;
static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
- Alarm* screen = static_cast<Alarm*>(obj->user_data);
+ auto* screen = static_cast<Alarm*>(obj->user_data);
screen->OnButtonEvent(obj, event);
}
-Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
- : Screen(app), running {true}, alarmController {alarmController} {
+static void StopAlarmTaskCallback(lv_task_t* task) {
+ auto* screen = static_cast<Alarm*>(task->user_data);
+ screen->StopAlerting();
+}
+
+Alarm::Alarm(DisplayApp* app,
+ Controllers::AlarmController& alarmController,
+ Pinetime::Controllers::Settings& settingsController,
+ System::SystemTask& systemTask)
+ : Screen(app), alarmController {alarmController}, settingsController {settingsController}, systemTask {systemTask} {
time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
@@ -40,6 +48,13 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -25);
+ lblampm = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_font(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20);
+ lv_obj_set_style_local_text_color(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_label_set_text_static(lblampm, " ");
+ lv_label_set_align(lblampm, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(lblampm, lv_scr_act(), LV_ALIGN_CENTER, 0, 30);
+
btnHoursUp = lv_btn_create(lv_scr_act(), nullptr);
btnHoursUp->user_data = this;
lv_obj_set_event_cb(btnHoursUp, btnEventHandler);
@@ -72,13 +87,15 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
txtMinDown = lv_label_create(btnMinutesDown, nullptr);
lv_label_set_text_static(txtMinDown, "-");
- btnEnable = lv_btn_create(lv_scr_act(), nullptr);
- btnEnable->user_data = this;
- lv_obj_set_event_cb(btnEnable, btnEventHandler);
- lv_obj_set_size(btnEnable, 115, 50);
- lv_obj_align(btnEnable, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
- txtEnable = lv_label_create(btnEnable, nullptr);
- SetEnableButtonState();
+ btnStop = lv_btn_create(lv_scr_act(), nullptr);
+ btnStop->user_data = this;
+ lv_obj_set_event_cb(btnStop, btnEventHandler);
+ lv_obj_set_size(btnStop, 115, 50);
+ lv_obj_align(btnStop, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
+ lv_obj_set_style_local_bg_color(btnStop, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
+ txtStop = lv_label_create(btnStop, nullptr);
+ lv_label_set_text_static(txtStop, Symbols::stop);
+ lv_obj_set_hidden(btnStop, true);
btnRecur = lv_btn_create(lv_scr_act(), nullptr);
btnRecur->user_data = this;
@@ -95,24 +112,35 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
lv_obj_align(btnInfo, lv_scr_act(), LV_ALIGN_CENTER, 0, -85);
txtInfo = lv_label_create(btnInfo, nullptr);
lv_label_set_text_static(txtInfo, "i");
+
+ enableSwitch = lv_switch_create(lv_scr_act(), nullptr);
+ enableSwitch->user_data = this;
+ lv_obj_set_event_cb(enableSwitch, btnEventHandler);
+ lv_obj_set_size(enableSwitch, 100, 50);
+ // Align to the center of 115px from edge
+ lv_obj_align(enableSwitch, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 7, 0);
+
+ UpdateAlarmTime();
+
+ if (alarmController.State() == Controllers::AlarmController::AlarmState::Alerting) {
+ SetAlerting();
+ } else {
+ SetSwitchState(LV_ANIM_OFF);
+ }
}
Alarm::~Alarm() {
+ if (alarmController.State() == AlarmController::AlarmState::Alerting) {
+ StopAlerting();
+ }
lv_obj_clean(lv_scr_act());
}
void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
using Pinetime::Controllers::AlarmController;
if (event == LV_EVENT_CLICKED) {
- if (obj == btnEnable) {
- if (alarmController.State() == AlarmController::AlarmState::Alerting) {
- alarmController.StopAlerting();
- } else if (alarmController.State() == AlarmController::AlarmState::Set) {
- alarmController.DisableAlarm();
- } else {
- alarmController.ScheduleAlarm();
- }
- SetEnableButtonState();
+ if (obj == btnStop) {
+ StopAlerting();
return;
}
if (obj == btnInfo) {
@@ -123,11 +151,19 @@ void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
HideInfo();
return;
}
+ if (obj == enableSwitch) {
+ if (lv_switch_get_state(enableSwitch)) {
+ alarmController.ScheduleAlarm();
+ } else {
+ alarmController.DisableAlarm();
+ }
+ return;
+ }
// If any other button was pressed, disable the alarm
// this is to make it clear that the alarm won't be set until it is turned back on
if (alarmController.State() == AlarmController::AlarmState::Set) {
alarmController.DisableAlarm();
- SetEnableButtonState();
+ lv_switch_off(enableSwitch, LV_ANIM_ON);
}
if (obj == btnMinutesUp) {
if (alarmMinutes >= 59) {
@@ -176,31 +212,73 @@ bool Alarm::OnButtonPushed() {
HideInfo();
return true;
}
+ if (alarmController.State() == AlarmController::AlarmState::Alerting) {
+ StopAlerting();
+ return true;
+ }
return false;
}
+bool Alarm::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
+ // Don't allow closing the screen by swiping while the alarm is alerting
+ return alarmController.State() == AlarmController::AlarmState::Alerting && event == TouchEvents::SwipeDown;
+}
+
void Alarm::UpdateAlarmTime() {
- lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes);
+ if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ switch (alarmHours) {
+ case 0:
+ lv_label_set_text_static(lblampm, "AM");
+ lv_label_set_text_fmt(time, "%02d:%02d", 12, alarmMinutes);
+ break;
+ case 1 ... 11:
+ lv_label_set_text_static(lblampm, "AM");
+ lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes);
+ break;
+ case 12:
+ lv_label_set_text_static(lblampm, "PM");
+ lv_label_set_text_fmt(time, "%02d:%02d", 12, alarmMinutes);
+ break;
+ case 13 ... 23:
+ lv_label_set_text_static(lblampm, "PM");
+ lv_label_set_text_fmt(time, "%02d:%02d", alarmHours - 12, alarmMinutes);
+ break;
+ }
+ } else {
+ lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes);
+ }
alarmController.SetAlarmTime(alarmHours, alarmMinutes);
}
void Alarm::SetAlerting() {
- SetEnableButtonState();
+ lv_obj_set_hidden(enableSwitch, true);
+ lv_obj_set_hidden(btnStop, false);
+ taskStopAlarm = lv_task_create(StopAlarmTaskCallback, pdMS_TO_TICKS(60 * 1000), LV_TASK_PRIO_MID, this);
+ systemTask.PushMessage(System::Messages::DisableSleeping);
}
-void Alarm::SetEnableButtonState() {
+void Alarm::StopAlerting() {
+ alarmController.StopAlerting();
+ SetSwitchState(LV_ANIM_OFF);
+ if (taskStopAlarm != nullptr) {
+ lv_task_del(taskStopAlarm);
+ taskStopAlarm = nullptr;
+ }
+ systemTask.PushMessage(System::Messages::EnableSleeping);
+ lv_obj_set_hidden(enableSwitch, false);
+ lv_obj_set_hidden(btnStop, true);
+}
+
+void Alarm::SetSwitchState(lv_anim_enable_t anim) {
switch (alarmController.State()) {
case AlarmController::AlarmState::Set:
- lv_label_set_text(txtEnable, "ON");
- lv_obj_set_style_local_bg_color(btnEnable, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
+ lv_switch_on(enableSwitch, anim);
break;
case AlarmController::AlarmState::Not_Set:
- lv_label_set_text(txtEnable, "OFF");
- lv_obj_set_style_local_bg_color(btnEnable, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_switch_off(enableSwitch, anim);
+ break;
+ default:
break;
- case AlarmController::AlarmState::Alerting:
- lv_label_set_text(txtEnable, Symbols::stop);
- lv_obj_set_style_local_bg_color(btnEnable, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
}
}
diff --git a/src/displayapp/screens/Alarm.h b/src/displayapp/screens/Alarm.h
index 4b301ce1..f74dd68e 100644
--- a/src/displayapp/screens/Alarm.h
+++ b/src/displayapp/screens/Alarm.h
@@ -27,26 +27,33 @@ namespace Pinetime {
namespace Screens {
class Alarm : public Screen {
public:
- Alarm(DisplayApp* app, Controllers::AlarmController& alarmController);
+ Alarm(DisplayApp* app,
+ Controllers::AlarmController& alarmController,
+ Pinetime::Controllers::Settings& settingsController,
+ System::SystemTask& systemTask);
~Alarm() override;
void SetAlerting();
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
bool OnButtonPushed() override;
+ bool OnTouchEvent(TouchEvents event) override;
+ void StopAlerting();
private:
- bool running;
uint8_t alarmHours;
uint8_t alarmMinutes;
Controllers::AlarmController& alarmController;
+ Controllers::Settings& settingsController;
+ System::SystemTask& systemTask;
- lv_obj_t *time, *btnEnable, *txtEnable, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp, *txtMinDown,
- *txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo;
+ lv_obj_t *time, *lblampm, *btnStop, *txtStop, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp,
+ *txtMinDown, *txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo, *enableSwitch;
lv_obj_t* txtMessage = nullptr;
lv_obj_t* btnMessage = nullptr;
+ lv_task_t* taskStopAlarm = nullptr;
enum class EnableButtonState { On, Off, Alerting };
- void SetEnableButtonState();
void SetRecurButtonState();
+ void SetSwitchState(lv_anim_enable_t anim);
void SetAlarm();
void ShowInfo();
void HideInfo();
diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp
index 96d8e5b0..fd74683a 100644
--- a/src/displayapp/screens/Clock.cpp
+++ b/src/displayapp/screens/Clock.cpp
@@ -9,6 +9,7 @@
#include "components/settings/Settings.h"
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/WatchFaceDigital.h"
+#include "displayapp/screens/WatchFaceTerminal.h"
#include "displayapp/screens/WatchFaceAnalog.h"
#include "displayapp/screens/PineTimeStyle.h"
@@ -41,6 +42,9 @@ Clock::Clock(DisplayApp* app,
case 2:
return PineTimeStyleScreen();
break;
+ case 3:
+ return WatchFaceTerminalScreen();
+ break;
}
return WatchFaceDigitalScreen();
}()} {
@@ -55,6 +59,10 @@ bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screen->OnTouchEvent(event);
}
+bool Clock::OnButtonPushed() {
+ return screen->OnButtonPushed();
+}
+
std::unique_ptr<Screen> Clock::WatchFaceDigitalScreen() {
return std::make_unique<Screens::WatchFaceDigital>(app,
dateTimeController,
@@ -72,11 +80,17 @@ std::unique_ptr<Screen> Clock::WatchFaceAnalogScreen() {
}
std::unique_ptr<Screen> Clock::PineTimeStyleScreen() {
- return std::make_unique<Screens::PineTimeStyle>(app,
- dateTimeController,
- batteryController,
- bleController,
- notificatioManager,
- settingsController,
- motionController);
+ return std::make_unique<Screens::PineTimeStyle>(
+ app, dateTimeController, batteryController, bleController, notificatioManager, settingsController, motionController);
+}
+
+std::unique_ptr<Screen> Clock::WatchFaceTerminalScreen() {
+ return std::make_unique<Screens::WatchFaceTerminal>(app,
+ dateTimeController,
+ batteryController,
+ bleController,
+ notificatioManager,
+ settingsController,
+ heartRateController,
+ motionController);
}
diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h
index 2fad1e21..50996a73 100644
--- a/src/displayapp/screens/Clock.h
+++ b/src/displayapp/screens/Clock.h
@@ -32,6 +32,7 @@ namespace Pinetime {
~Clock() override;
bool OnTouchEvent(TouchEvents event) override;
+ bool OnButtonPushed() override;
private:
Controllers::DateTime& dateTimeController;
@@ -46,6 +47,7 @@ namespace Pinetime {
std::unique_ptr<Screen> WatchFaceDigitalScreen();
std::unique_ptr<Screen> WatchFaceAnalogScreen();
std::unique_ptr<Screen> PineTimeStyleScreen();
+ std::unique_ptr<Screen> WatchFaceTerminalScreen();
};
}
}
diff --git a/src/displayapp/screens/DropDownDemo.cpp b/src/displayapp/screens/DropDownDemo.cpp
deleted file mode 100644
index cf239a2f..00000000
--- a/src/displayapp/screens/DropDownDemo.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "displayapp/screens/DropDownDemo.h"
-#include <lvgl/lvgl.h>
-#include <libraries/log/nrf_log.h>
-#include "displayapp/DisplayApp.h"
-
-using namespace Pinetime::Applications::Screens;
-
-DropDownDemo::DropDownDemo(Pinetime::Applications::DisplayApp* app) : Screen(app) {
- // Create the dropdown object, with many item, and fix its height
- ddlist = lv_ddlist_create(lv_scr_act(), nullptr);
- lv_ddlist_set_options(ddlist,
- "Apple\n"
- "Banana\n"
- "Orange\n"
- "Melon\n"
- "Grape\n"
- "Raspberry\n"
- "A\n"
- "B\n"
- "C\n"
- "D\n"
- "E");
- lv_ddlist_set_fix_width(ddlist, 150);
- lv_ddlist_set_draw_arrow(ddlist, true);
- lv_ddlist_set_fix_height(ddlist, 150);
- lv_obj_align(ddlist, nullptr, LV_ALIGN_IN_TOP_MID, 0, 20);
-}
-
-DropDownDemo::~DropDownDemo() {
- // Reset the touchmode
- app->SetTouchMode(DisplayApp::TouchModes::Gestures);
- lv_obj_clean(lv_scr_act());
-}
-
-bool DropDownDemo::Refresh() {
- auto* list = static_cast<lv_ddlist_ext_t*>(ddlist->ext_attr);
-
- // Switch touchmode to Polling if the dropdown is opened. This will allow to scroll inside the
- // dropdown while it is opened.
- // Disable the polling mode when the dropdown is closed to be able to handle the gestures.
- if (list->opened)
- app->SetTouchMode(DisplayApp::TouchModes::Polling);
- else
- app->SetTouchMode(DisplayApp::TouchModes::Gestures);
- return running;
-}
-
-bool DropDownDemo::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
- // If the dropdown is opened, notify Display app that it doesn't need to handle the event
- // (this will prevent displayApp from going back to the menu or clock scree).
- auto* list = static_cast<lv_ddlist_ext_t*>(ddlist->ext_attr);
- if (list->opened) {
- return true;
- } else {
- return false;
- }
-}
diff --git a/src/displayapp/screens/DropDownDemo.h b/src/displayapp/screens/DropDownDemo.h
deleted file mode 100644
index bcf0f45c..00000000
--- a/src/displayapp/screens/DropDownDemo.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#include <cstdint>
-#include "displayapp/screens/Screen.h"
-#include <lvgl/src/lv_core/lv_obj.h>
-
-namespace Pinetime {
- namespace Applications {
- namespace Screens {
-
- class DropDownDemo : public Screen {
- public:
- DropDownDemo(DisplayApp* app);
- ~DropDownDemo() override;
-
- bool Refresh() override;
-
- bool OnTouchEvent(TouchEvents event) override;
-
- private:
- lv_obj_t* ddlist;
-
- bool isDropDownOpened = false;
- };
- }
- }
-}
diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp
index 93c3c4a0..d279fafc 100644
--- a/src/displayapp/screens/InfiniPaint.cpp
+++ b/src/displayapp/screens/InfiniPaint.cpp
@@ -2,6 +2,8 @@
#include "displayapp/DisplayApp.h"
#include "displayapp/LittleVgl.h"
+#include <algorithm> // std::fill
+
using namespace Pinetime::Applications::Screens;
InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app,
diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp
index 8347e1bb..f6f269dc 100644
--- a/src/displayapp/screens/Metronome.cpp
+++ b/src/displayapp/screens/Metronome.cpp
@@ -113,9 +113,16 @@ void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
lv_label_set_text_fmt(bpmValue, "%03d", bpm);
}
tappedTime = xTaskGetTickCount();
+ allowExit = true;
}
break;
}
+ case LV_EVENT_RELEASED:
+ case LV_EVENT_PRESS_LOST:
+ if (obj == bpmTap) {
+ allowExit = false;
+ }
+ break;
case LV_EVENT_CLICKED: {
if (obj == playPause) {
metronomeStarted = !metronomeStarted;
@@ -135,3 +142,11 @@ void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
break;
}
}
+
+bool Metronome::OnTouchEvent(TouchEvents event) {
+ if (event == TouchEvents::SwipeDown && allowExit) {
+ running = false;
+ return true;
+ }
+ return false;
+}
diff --git a/src/displayapp/screens/Metronome.h b/src/displayapp/screens/Metronome.h
index 373c884c..6e6589fe 100644
--- a/src/displayapp/screens/Metronome.h
+++ b/src/displayapp/screens/Metronome.h
@@ -14,6 +14,7 @@ namespace Pinetime {
~Metronome() override;
void Refresh() override;
void OnEvent(lv_obj_t* obj, lv_event_t event);
+ bool OnTouchEvent(TouchEvents event) override;
private:
TickType_t startTime = 0;
@@ -25,6 +26,7 @@ namespace Pinetime {
uint8_t counter = 1;
bool metronomeStarted = false;
+ bool allowExit = false;
lv_obj_t *bpmArc, *bpmTap, *bpmValue;
lv_obj_t *bpbDropdown, *currentBpbText;
diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp
index 8a01a6fe..9f17b956 100644
--- a/src/displayapp/screens/Music.cpp
+++ b/src/displayapp/screens/Music.cpp
@@ -277,12 +277,14 @@ bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return true;
}
case TouchEvents::SwipeDown: {
- lv_obj_set_hidden(btnNext, false);
- lv_obj_set_hidden(btnPrev, false);
-
- lv_obj_set_hidden(btnVolDown, true);
- lv_obj_set_hidden(btnVolUp, true);
- return true;
+ if (lv_obj_get_hidden(btnNext)) {
+ lv_obj_set_hidden(btnNext, false);
+ lv_obj_set_hidden(btnPrev, false);
+ lv_obj_set_hidden(btnVolDown, true);
+ lv_obj_set_hidden(btnVolUp, true);
+ return true;
+ }
+ return false;
}
case TouchEvents::SwipeLeft: {
musicService.event(Controllers::MusicService::EVENT_MUSIC_NEXT);
diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h
index f9b4eaab..35f7bab5 100644
--- a/src/displayapp/screens/Music.h
+++ b/src/displayapp/screens/Music.h
@@ -69,7 +69,7 @@ namespace Pinetime {
std::string track;
/** Total length in seconds */
- int totalLength;
+ int totalLength = 0;
/** Current length in seconds */
int currentLength;
/** Last length */
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index 569c422b..3a39dacf 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -12,8 +12,14 @@ Notifications::Notifications(DisplayApp* app,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Pinetime::Controllers::MotorController& motorController,
+ System::SystemTask& systemTask,
Modes mode)
- : Screen(app), notificationManager {notificationManager}, alertNotificationService {alertNotificationService}, mode {mode} {
+ : Screen(app),
+ notificationManager {notificationManager},
+ alertNotificationService {alertNotificationService},
+ motorController {motorController},
+ systemTask {systemTask},
+ mode {mode} {
notificationManager.ClearNewNotificationFlag();
auto notification = notificationManager.GetLastNotification();
if (notification.valid) {
@@ -24,7 +30,8 @@ Notifications::Notifications(DisplayApp* app,
notification.category,
notificationManager.NbNotifications(),
mode,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
validDisplay = true;
} else {
currentItem = std::make_unique<NotificationItem>("Notification",
@@ -33,24 +40,27 @@ Notifications::Notifications(DisplayApp* app,
notification.category,
notificationManager.NbNotifications(),
Modes::Preview,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
}
if (mode == Modes::Preview) {
+ systemTask.PushMessage(System::Messages::DisableSleeping);
if (notification.category == Controllers::NotificationManager::Categories::IncomingCall) {
motorController.StartRinging();
} else {
motorController.RunForDuration(35);
- timeoutLine = lv_line_create(lv_scr_act(), nullptr);
+ }
- lv_obj_set_style_local_line_width(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_line_color(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
- lv_obj_set_style_local_line_rounded(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true);
+ timeoutLine = lv_line_create(lv_scr_act(), nullptr);
- lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
- timeoutTickCountStart = xTaskGetTickCount();
- timeoutTickCountEnd = timeoutTickCountStart + (5 * 1024);
- }
+ lv_obj_set_style_local_line_width(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
+ lv_obj_set_style_local_line_color(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
+ lv_obj_set_style_local_line_rounded(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true);
+
+ lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
+ timeoutTickCountStart = xTaskGetTickCount();
+ interacted = false;
}
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
@@ -59,24 +69,41 @@ Notifications::Notifications(DisplayApp* app,
Notifications::~Notifications() {
lv_task_del(taskRefresh);
// make sure we stop any vibrations before exiting
- Controllers::MotorController::StopRinging();
+ motorController.StopRinging();
+ systemTask.PushMessage(System::Messages::EnableSleeping);
lv_obj_clean(lv_scr_act());
}
void Notifications::Refresh() {
if (mode == Modes::Preview && timeoutLine != nullptr) {
- auto tick = xTaskGetTickCount();
- int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240));
- if (pos < 0)
+ TickType_t tick = xTaskGetTickCount();
+ int32_t pos = 240 - ((tick - timeoutTickCountStart) / (timeoutLength / 240));
+ if (pos <= 0) {
running = false;
+ } else {
+ timeoutLinePoints[1].x = pos;
+ lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
+ }
+ }
+ running = currentItem->IsRunning() && running;
+}
- timeoutLinePoints[1].x = pos;
- lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
+void Notifications::OnPreviewInteraction() {
+ systemTask.PushMessage(System::Messages::EnableSleeping);
+ motorController.StopRinging();
+ if (timeoutLine != nullptr) {
+ lv_obj_del(timeoutLine);
+ timeoutLine = nullptr;
}
}
bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
if (mode != Modes::Normal) {
+ if (!interacted && event == TouchEvents::Tap) {
+ interacted = true;
+ OnPreviewInteraction();
+ return true;
+ }
return false;
}
@@ -101,7 +128,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
previousNotification.category,
notificationManager.NbNotifications(),
mode,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
}
return true;
case Pinetime::Applications::TouchEvents::SwipeUp: {
@@ -126,7 +154,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
nextNotification.category,
notificationManager.NbNotifications(),
mode,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
}
return true;
default:
@@ -147,8 +176,9 @@ Notifications::NotificationItem::NotificationItem(const char* title,
Controllers::NotificationManager::Categories category,
uint8_t notifNb,
Modes mode,
- Pinetime::Controllers::AlertNotificationService& alertNotificationService)
- : mode {mode}, alertNotificationService {alertNotificationService} {
+ Pinetime::Controllers::AlertNotificationService& alertNotificationService,
+ Pinetime::Controllers::MotorController& motorController)
+ : mode {mode}, alertNotificationService {alertNotificationService}, motorController {motorController} {
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL);
lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222));
@@ -245,7 +275,7 @@ void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_
return;
}
- Controllers::MotorController::StopRinging();
+ motorController.StopRinging();
if (obj == bt_accept) {
alertNotificationService.AcceptIncomingCall();
diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h
index cbb7af6c..f49d3b3a 100644
--- a/src/displayapp/screens/Notifications.h
+++ b/src/displayapp/screens/Notifications.h
@@ -1,11 +1,13 @@
#pragma once
#include <lvgl/lvgl.h>
+#include <FreeRTOS.h>
#include <cstdint>
#include <memory>
#include "displayapp/screens/Screen.h"
#include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
+#include "systemtask/SystemTask.h"
namespace Pinetime {
namespace Controllers {
@@ -21,11 +23,13 @@ namespace Pinetime {
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Pinetime::Controllers::MotorController& motorController,
+ System::SystemTask& systemTask,
Modes mode);
~Notifications() override;
void Refresh() override;
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
+ void OnPreviewInteraction();
class NotificationItem {
public:
@@ -35,7 +39,8 @@ namespace Pinetime {
Controllers::NotificationManager::Categories,
uint8_t notifNb,
Modes mode,
- Pinetime::Controllers::AlertNotificationService& alertNotificationService);
+ Pinetime::Controllers::AlertNotificationService& alertNotificationService,
+ Pinetime::Controllers::MotorController& motorController);
~NotificationItem();
bool IsRunning() const {
return running;
@@ -52,6 +57,7 @@ namespace Pinetime {
lv_obj_t* label_reject;
Modes mode;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
+ Pinetime::Controllers::MotorController& motorController;
bool running = true;
};
@@ -62,6 +68,8 @@ namespace Pinetime {
};
Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
+ Pinetime::Controllers::MotorController& motorController;
+ System::SystemTask& systemTask;
Modes mode = Modes::Normal;
std::unique_ptr<NotificationItem> currentItem;
Controllers::NotificationManager::Notification::Id currentId;
@@ -69,8 +77,9 @@ namespace Pinetime {
lv_point_t timeoutLinePoints[2] {{0, 1}, {239, 1}};
lv_obj_t* timeoutLine = nullptr;
- uint32_t timeoutTickCountStart;
- uint32_t timeoutTickCountEnd;
+ TickType_t timeoutTickCountStart;
+ static const TickType_t timeoutLength = pdMS_TO_TICKS(7000);
+ bool interacted = true;
lv_task_t* taskRefresh;
};
diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp
index e7b1f393..f1f7f922 100644
--- a/src/displayapp/screens/PineTimeStyle.cpp
+++ b/src/displayapp/screens/PineTimeStyle.cpp
@@ -37,6 +37,13 @@
using namespace Pinetime::Applications::Screens;
+namespace {
+ void event_handler(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<PineTimeStyle*>(obj->user_data);
+ screen->UpdateSelected(obj, event);
+ }
+}
+
PineTimeStyle::PineTimeStyle(DisplayApp* app,
Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController,
@@ -53,16 +60,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
settingsController {settingsController},
motionController {motionController} {
- // This sets the watchface number to return to after leaving the menu
- settingsController.SetClockFace(2);
-
- displayedChar[0] = 0;
- displayedChar[1] = 0;
- displayedChar[2] = 0;
- displayedChar[3] = 0;
- displayedChar[4] = 0;
-
- //Create a 200px wide background rectangle
+ // Create a 200px wide background rectangle
timebar = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
@@ -73,19 +71,19 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
- lv_label_set_text(timeDD1, "00");
+ lv_label_set_text_static(timeDD1, "00");
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
- lv_label_set_text(timeDD2, "00");
+ lv_label_set_text_static(timeDD2, "00");
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
- lv_label_set_text(timeAMPM, "");
+ lv_label_set_text_static(timeAMPM, "");
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
// Create a 40px wide bar down the right side of the screen
@@ -97,74 +95,78 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
// Display icons
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(batteryIcon, Symbols::batteryFull);
+ lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+ lv_label_set_text_static(batteryIcon, Symbols::batteryFull);
lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
lv_obj_set_auto_realign(batteryIcon, true);
bleIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(bleIcon, "");
+ lv_label_set_text_static(bleIcon, "");
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(notificationIcon, "");
+ lv_label_set_text_static(notificationIcon, "");
// Calendar icon
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(calendarOuter, 34, 34);
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
calendarInner = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff));
+ lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(calendarInner, 27, 27);
lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0);
calendarBar1 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(calendarBar1, 3, 12);
lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3);
calendarBar2 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(calendarBar2, 3, 12);
lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3);
calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(calendarCrossBar1, 8, 3);
lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(calendarCrossBar2, 8, 3);
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
// Display date
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(dateDayOfWeek, "THU");
+ lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+ lv_label_set_text_static(dateDayOfWeek, "THU");
lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
dateDay = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(dateDay, "25");
+ lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+ lv_label_set_text_static(dateDay, "25");
lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
dateMonth = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(dateMonth, "MAR");
+ lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+ lv_label_set_text_static(dateMonth, "MAR");
lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
// Step count gauge
- needle_colors[0] = LV_COLOR_WHITE;
+ if (settingsController.GetPTSColorBar() == Pinetime::Controllers::Settings::Colors::White) {
+ needle_colors[0] = LV_COLOR_BLACK;
+ } else {
+ needle_colors[0] = LV_COLOR_WHITE;
+ }
stepGauge = lv_gauge_create(lv_scr_act(), nullptr);
lv_gauge_set_needle_count(stepGauge, 1, needle_colors);
lv_obj_set_size(stepGauge, 40, 40);
@@ -191,7 +193,101 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text(backgroundLabel, "");
+ lv_label_set_text_static(backgroundLabel, "");
+
+ btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
+ btnNextTime->user_data = this;
+ lv_obj_set_size(btnNextTime, 60, 60);
+ lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, -80);
+ lv_obj_set_style_local_bg_opa(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
+ lv_obj_set_event_cb(btnNextTime, event_handler);
+ lv_obj_set_hidden(btnNextTime, true);
+
+ btnPrevTime = lv_btn_create(lv_scr_act(), nullptr);
+ btnPrevTime->user_data = this;
+ lv_obj_set_size(btnPrevTime, 60, 60);
+ lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, -80);
+ lv_obj_set_style_local_bg_opa(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
+ lv_obj_set_event_cb(btnPrevTime, event_handler);
+ lv_obj_set_hidden(btnPrevTime, true);
+
+ btnNextBar = lv_btn_create(lv_scr_act(), nullptr);
+ btnNextBar->user_data = this;
+ lv_obj_set_size(btnNextBar, 60, 60);
+ lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0);
+ lv_obj_set_style_local_bg_opa(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
+ lv_obj_set_event_cb(btnNextBar, event_handler);
+ lv_obj_set_hidden(btnNextBar, true);
+
+ btnPrevBar = lv_btn_create(lv_scr_act(), nullptr);
+ btnPrevBar->user_data = this;
+ lv_obj_set_size(btnPrevBar, 60, 60);
+ lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0);
+ lv_obj_set_style_local_bg_opa(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
+ lv_obj_set_event_cb(btnPrevBar, event_handler);
+ lv_obj_set_hidden(btnPrevBar, true);
+
+ btnNextBG = lv_btn_create(lv_scr_act(), nullptr);
+ btnNextBG->user_data = this;
+ lv_obj_set_size(btnNextBG, 60, 60);
+ lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 80);
+ lv_obj_set_style_local_bg_opa(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
+ lv_obj_set_event_cb(btnNextBG, event_handler);
+ lv_obj_set_hidden(btnNextBG, true);
+
+ btnPrevBG = lv_btn_create(lv_scr_act(), nullptr);
+ btnPrevBG->user_data = this;
+ lv_obj_set_size(btnPrevBG, 60, 60);
+ lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 80);
+ lv_obj_set_style_local_bg_opa(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
+ lv_obj_set_event_cb(btnPrevBG, event_handler);
+ lv_obj_set_hidden(btnPrevBG, true);
+
+ btnReset = lv_btn_create(lv_scr_act(), nullptr);
+ btnReset->user_data = this;
+ lv_obj_set_size(btnReset, 60, 60);
+ lv_obj_align(btnReset, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
+ lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst");
+ lv_obj_set_event_cb(btnReset, event_handler);
+ lv_obj_set_hidden(btnReset, true);
+
+ btnRandom = lv_btn_create(lv_scr_act(), nullptr);
+ btnRandom->user_data = this;
+ lv_obj_set_size(btnRandom, 60, 60);
+ lv_obj_align(btnRandom, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
+ lv_obj_set_style_local_bg_opa(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rnd");
+ lv_obj_set_event_cb(btnRandom, event_handler);
+ lv_obj_set_hidden(btnRandom, true);
+
+ btnClose = lv_btn_create(lv_scr_act(), nullptr);
+ btnClose->user_data = this;
+ lv_obj_set_size(btnClose, 60, 60);
+ lv_obj_align(btnClose, lv_scr_act(), LV_ALIGN_CENTER, 0, -80);
+ lv_obj_set_style_local_bg_opa(btnClose, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnClose, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "X");
+ lv_obj_set_event_cb(btnClose, event_handler);
+ lv_obj_set_hidden(btnClose, true);
+
+ btnSet = lv_btn_create(lv_scr_act(), nullptr);
+ btnSet->user_data = this;
+ lv_obj_set_height(btnSet, 150);
+ lv_obj_set_width(btnSet, 150);
+ lv_obj_align(btnSet, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
+ lv_obj_set_style_local_radius(btnSet, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 30);
+ lv_obj_set_style_local_bg_opa(btnSet, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_event_cb(btnSet, event_handler);
+ lbl_btnSet = lv_label_create(btnSet, nullptr);
+ lv_obj_set_style_local_text_font(lbl_btnSet, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
+ lv_label_set_text_static(lbl_btnSet, Symbols::settings);
+ lv_obj_set_hidden(btnSet, true);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
Refresh();
@@ -202,9 +298,42 @@ PineTimeStyle::~PineTimeStyle() {
lv_obj_clean(lv_scr_act());
}
+bool PineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
+ if ((event == Pinetime::Applications::TouchEvents::LongTap) && lv_obj_get_hidden(btnRandom)) {
+ lv_obj_set_hidden(btnSet, false);
+ savedTick = lv_tick_get();
+ return true;
+ }
+ if ((event == Pinetime::Applications::TouchEvents::DoubleTap) && (lv_obj_get_hidden(btnRandom) == false)) {
+ return true;
+ }
+ return false;
+}
+
+void PineTimeStyle::CloseMenu() {
+ settingsController.SaveSettings();
+ lv_obj_set_hidden(btnNextTime, true);
+ lv_obj_set_hidden(btnPrevTime, true);
+ lv_obj_set_hidden(btnNextBar, true);
+ lv_obj_set_hidden(btnPrevBar, true);
+ lv_obj_set_hidden(btnNextBG, true);
+ lv_obj_set_hidden(btnPrevBG, true);
+ lv_obj_set_hidden(btnReset, true);
+ lv_obj_set_hidden(btnRandom, true);
+ lv_obj_set_hidden(btnClose, true);
+}
+
+bool PineTimeStyle::OnButtonPushed() {
+ if (!lv_obj_get_hidden(btnClose)) {
+ CloseMenu();
+ return true;
+ }
+ return false;
+}
+
void PineTimeStyle::SetBatteryIcon() {
auto batteryPercent = batteryPercentRemaining.Get();
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+ lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
}
void PineTimeStyle::AlignIcons() {
@@ -222,7 +351,7 @@ void PineTimeStyle::Refresh() {
isCharging = batteryController.IsCharging();
if (isCharging.IsUpdated()) {
if (isCharging.Get()) {
- lv_label_set_text(batteryIcon, Symbols::plug);
+ lv_label_set_text_static(batteryIcon, Symbols::plug);
} else {
SetBatteryIcon();
}
@@ -236,13 +365,13 @@ void PineTimeStyle::Refresh() {
bleState = bleController.GetConnectState();
if (bleState.IsUpdated()) {
- lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
+ lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
AlignIcons();
}
notificationState = notificatioManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
+ lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
AlignIcons();
}
@@ -259,45 +388,31 @@ void PineTimeStyle::Refresh() {
auto day = static_cast<unsigned>(yearMonthDay.day());
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
- int hour = time.hours().count();
- auto minute = time.minutes().count();
+ uint8_t hour = time.hours().count();
+ uint8_t minute = time.minutes().count();
- char minutesChar[3];
- sprintf(minutesChar, "%02d", static_cast<int>(minute));
-
- char hoursChar[3];
- char ampmChar[5];
- if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
- sprintf(hoursChar, "%02d", hour);
- } else {
- if (hour == 0 && hour != 12) {
- hour = 12;
- sprintf(ampmChar, "A\nM");
- } else if (hour == 12 && hour != 0) {
- hour = 12;
- sprintf(ampmChar, "P\nM");
- } else if (hour < 12 && hour != 0) {
- sprintf(ampmChar, "A\nM");
- } else if (hour > 12 && hour != 0) {
- hour = hour - 12;
- sprintf(ampmChar, "P\nM");
- }
- sprintf(hoursChar, "%02d", hour);
- }
-
- if (hoursChar[0] != displayedChar[0] or hoursChar[1] != displayedChar[1] or minutesChar[0] != displayedChar[2] or
- minutesChar[1] != displayedChar[3]) {
- displayedChar[0] = hoursChar[0];
- displayedChar[1] = hoursChar[1];
- displayedChar[2] = minutesChar[0];
- displayedChar[3] = minutesChar[1];
+ if (displayedHour != hour || displayedMinute != minute) {
+ displayedHour = hour;
+ displayedMinute = minute;
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ char ampmChar[4] = "A\nM";
+ if (hour == 0) {
+ hour = 12;
+ } else if (hour == 12) {
+ ampmChar[0] = 'P';
+ } else if (hour > 12) {
+ hour = hour - 12;
+ ampmChar[0] = 'P';
+ }
lv_label_set_text(timeAMPM, ampmChar);
+ // Should be padded with blank spaces, but the space character doesn't exist in the font
+ lv_label_set_text_fmt(timeDD1, "%02d", hour);
+ lv_label_set_text_fmt(timeDD2, "%02d", minute);
+ } else {
+ lv_label_set_text_fmt(timeDD1, "%02d", hour);
+ lv_label_set_text_fmt(timeDD2, "%02d", minute);
}
-
- lv_label_set_text_fmt(timeDD1, "%s", hoursChar);
- lv_label_set_text_fmt(timeDD2, "%s", minutesChar);
}
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
@@ -323,4 +438,154 @@ void PineTimeStyle::Refresh() {
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
}
}
+ if (!lv_obj_get_hidden(btnSet)) {
+ if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) {
+ lv_obj_set_hidden(btnSet, true);
+ savedTick = 0;
+ }
+ }
+}
+
+void PineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
+ auto valueTime = settingsController.GetPTSColorTime();
+ auto valueBar = settingsController.GetPTSColorBar();
+ auto valueBG = settingsController.GetPTSColorBG();
+
+ if (event == LV_EVENT_CLICKED) {
+ if (object == btnNextTime) {
+ valueTime = GetNext(valueTime);
+ if (valueTime == valueBG) {
+ valueTime = GetNext(valueTime);
+ }
+ settingsController.SetPTSColorTime(valueTime);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ }
+ if (object == btnPrevTime) {
+ valueTime = GetPrevious(valueTime);
+ if (valueTime == valueBG) {
+ valueTime = GetPrevious(valueTime);
+ }
+ settingsController.SetPTSColorTime(valueTime);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ }
+ if (object == btnNextBar) {
+ valueBar = GetNext(valueBar);
+ if (valueBar == Controllers::Settings::Colors::Black) {
+ valueBar = GetNext(valueBar);
+ }
+ if (valueBar == Controllers::Settings::Colors::White) {
+ needle_colors[0] = LV_COLOR_BLACK;
+ } else {
+ needle_colors[0] = LV_COLOR_WHITE;
+ }
+ settingsController.SetPTSColorBar(valueBar);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
+ }
+ if (object == btnPrevBar) {
+ valueBar = GetPrevious(valueBar);
+ if (valueBar == Controllers::Settings::Colors::Black) {
+ valueBar = GetPrevious(valueBar);
+ }
+ if (valueBar == Controllers::Settings::Colors::White) {
+ needle_colors[0] = LV_COLOR_BLACK;
+ } else {
+ needle_colors[0] = LV_COLOR_WHITE;
+ }
+ settingsController.SetPTSColorBar(valueBar);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
+ }
+ if (object == btnNextBG) {
+ valueBG = GetNext(valueBG);
+ if (valueBG == valueTime) {
+ valueBG = GetNext(valueBG);
+ }
+ settingsController.SetPTSColorBG(valueBG);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
+ }
+ if (object == btnPrevBG) {
+ valueBG = GetPrevious(valueBG);
+ if (valueBG == valueTime) {
+ valueBG = GetPrevious(valueBG);
+ }
+ settingsController.SetPTSColorBG(valueBG);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
+ }
+ if (object == btnReset) {
+ needle_colors[0] = LV_COLOR_WHITE;
+ settingsController.SetPTSColorTime(Controllers::Settings::Colors::Teal);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ settingsController.SetPTSColorBar(Controllers::Settings::Colors::Teal);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ settingsController.SetPTSColorBG(Controllers::Settings::Colors::Black);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black));
+ }
+ if (object == btnRandom) {
+ valueTime = static_cast<Controllers::Settings::Colors>(rand() % 17);
+ valueBar = static_cast<Controllers::Settings::Colors>(rand() % 17);
+ valueBG = static_cast<Controllers::Settings::Colors>(rand() % 17);
+ if (valueTime == valueBG) {
+ valueBG = GetNext(valueBG);
+ }
+ if (valueBar == Controllers::Settings::Colors::Black) {
+ valueBar = GetPrevious(valueBar);
+ }
+ if (valueBar == Controllers::Settings::Colors::White) {
+ needle_colors[0] = LV_COLOR_BLACK;
+ } else {
+ needle_colors[0] = LV_COLOR_WHITE;
+ }
+ settingsController.SetPTSColorTime(static_cast<Controllers::Settings::Colors>(valueTime));
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(valueBar));
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
+ settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(valueBG));
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
+ }
+ if (object == btnClose) {
+ CloseMenu();
+ }
+ if (object == btnSet) {
+ lv_obj_set_hidden(btnSet, true);
+ lv_obj_set_hidden(btnNextTime, false);
+ lv_obj_set_hidden(btnPrevTime, false);
+ lv_obj_set_hidden(btnNextBar, false);
+ lv_obj_set_hidden(btnPrevBar, false);
+ lv_obj_set_hidden(btnNextBG, false);
+ lv_obj_set_hidden(btnPrevBG, false);
+ lv_obj_set_hidden(btnReset, false);
+ lv_obj_set_hidden(btnRandom, false);
+ lv_obj_set_hidden(btnClose, false);
+ }
+ }
+}
+
+Pinetime::Controllers::Settings::Colors PineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
+ auto colorAsInt = static_cast<uint8_t>(color);
+ Pinetime::Controllers::Settings::Colors nextColor;
+ if (colorAsInt < 16) {
+ nextColor = static_cast<Controllers::Settings::Colors>(colorAsInt + 1);
+ } else {
+ nextColor = static_cast<Controllers::Settings::Colors>(0);
+ }
+ return nextColor;
+}
+
+Pinetime::Controllers::Settings::Colors PineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
+ auto colorAsInt = static_cast<uint8_t>(color);
+ Pinetime::Controllers::Settings::Colors prevColor;
+
+ if (colorAsInt > 0) {
+ prevColor = static_cast<Controllers::Settings::Colors>(colorAsInt - 1);
+ } else {
+ prevColor = static_cast<Controllers::Settings::Colors>(16);
+ }
+ return prevColor;
}
diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h
index c5136fc2..cb8f6804 100644
--- a/src/displayapp/screens/PineTimeStyle.h
+++ b/src/displayapp/screens/PineTimeStyle.h
@@ -5,6 +5,7 @@
#include <cstdint>
#include <memory>
#include "displayapp/screens/Screen.h"
+#include "displayapp/Colors.h"
#include "components/datetime/DateTimeController.h"
#include "components/ble/BleController.h"
@@ -31,15 +32,22 @@ namespace Pinetime {
Controllers::MotionController& motionController);
~PineTimeStyle() override;
+ bool OnTouchEvent(TouchEvents event) override;
+ bool OnButtonPushed() override;
+
void Refresh() override;
+ void UpdateSelected(lv_obj_t *object, lv_event_t event);
+
private:
- char displayedChar[5];
+ uint8_t displayedHour = -1;
+ uint8_t displayedMinute = -1;
uint16_t currentYear = 1970;
Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
uint8_t currentDay = 0;
+ uint32_t savedTick = 0;
DirtyValue<uint8_t> batteryPercentRemaining {};
DirtyValue<bool> isCharging {};
@@ -49,6 +57,18 @@ namespace Pinetime {
DirtyValue<uint32_t> stepCount {};
DirtyValue<bool> notificationState {};
+ static Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color);
+ static Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color);
+
+ lv_obj_t* btnNextTime;
+ lv_obj_t* btnPrevTime;
+ lv_obj_t* btnNextBar;
+ lv_obj_t* btnPrevBar;
+ lv_obj_t* btnNextBG;
+ lv_obj_t* btnPrevBG;
+ lv_obj_t* btnReset;
+ lv_obj_t* btnRandom;
+ lv_obj_t* btnClose;
lv_obj_t* timebar;
lv_obj_t* sidebar;
lv_obj_t* timeDD1;
@@ -68,6 +88,8 @@ namespace Pinetime {
lv_obj_t* calendarCrossBar2;
lv_obj_t* notificationIcon;
lv_obj_t* stepGauge;
+ lv_obj_t* btnSet;
+ lv_obj_t* lbl_btnSet;
lv_color_t needle_colors[1];
Controllers::DateTime& dateTimeController;
@@ -78,6 +100,7 @@ namespace Pinetime {
Controllers::MotionController& motionController;
void SetBatteryIcon();
+ void CloseMenu();
void AlignIcons();
lv_task_t* taskRefresh;
diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp
index 916138ed..3e7f8201 100644
--- a/src/displayapp/screens/Steps.cpp
+++ b/src/displayapp/screens/Steps.cpp
@@ -5,6 +5,11 @@
using namespace Pinetime::Applications::Screens;
+static void lap_event_handler(lv_obj_t* obj, lv_event_t event) {
+ auto* steps = static_cast<Steps*>(obj->user_data);
+ steps->lapBtnEventHandler(event);
+}
+
Steps::Steps(Pinetime::Applications::DisplayApp* app,
Controllers::MotionController& motionController,
Controllers::Settings& settingsController)
@@ -17,11 +22,12 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
lv_obj_set_style_local_radius(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);
lv_obj_set_style_local_line_color(stepsArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, lv_color_hex(0x0000FF));
lv_arc_set_end_angle(stepsArc, 200);
- lv_obj_set_size(stepsArc, 220, 220);
+ lv_obj_set_size(stepsArc, 240, 240);
lv_arc_set_range(stepsArc, 0, 500);
lv_obj_align(stepsArc, nullptr, LV_ALIGN_CENTER, 0, 0);
stepsCount = motionController.NbSteps();
+ currentTripSteps = stepsCount - motionController.GetTripSteps();
lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal()));
@@ -29,18 +35,18 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
lv_obj_set_style_local_text_color(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00));
lv_obj_set_style_local_text_font(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_fmt(lSteps, "%li", stepsCount);
- lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20);
+ lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40);
lv_obj_t* lstepsL = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lstepsL, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111));
lv_label_set_text_static(lstepsL, "Steps");
- lv_obj_align(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
+ lv_obj_align(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
lv_obj_t* lstepsGoal = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lstepsGoal, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN);
- lv_label_set_text_fmt(lstepsGoal, "Goal\n%lu", settingsController.GetStepsGoal());
+ lv_label_set_text_fmt(lstepsGoal, "Goal: %5lu", settingsController.GetStepsGoal());
lv_label_set_align(lstepsGoal, LV_LABEL_ALIGN_CENTER);
- lv_obj_align(lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 60);
+ lv_obj_align(lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
@@ -48,6 +54,22 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text_static(backgroundLabel, "");
+ resetBtn = lv_btn_create(lv_scr_act(), nullptr);
+ resetBtn->user_data = this;
+ lv_obj_set_event_cb(resetBtn, lap_event_handler);
+ lv_obj_set_height(resetBtn, 50);
+ lv_obj_set_width(resetBtn, 115);
+ lv_obj_align(resetBtn, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+ resetButtonLabel = lv_label_create(resetBtn, nullptr);
+ lv_label_set_text(resetButtonLabel, "Reset");
+
+ currentTripSteps = motionController.GetTripSteps();
+
+ tripLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(tripLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
+ lv_label_set_text_fmt(tripLabel, "Trip: %5li", currentTripSteps);
+ lv_obj_align(tripLabel, lstepsGoal, LV_ALIGN_IN_LEFT_MID, 0, 20);
+
taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
}
@@ -58,9 +80,24 @@ Steps::~Steps() {
void Steps::Refresh() {
stepsCount = motionController.NbSteps();
+ currentTripSteps = motionController.GetTripSteps();
lv_label_set_text_fmt(lSteps, "%li", stepsCount);
- lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20);
+ lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40);
+ if (currentTripSteps < 100000) {
+ lv_label_set_text_fmt(tripLabel, "Trip: %5li", currentTripSteps);
+ } else {
+ lv_label_set_text_fmt(tripLabel, "Trip: 99999+");
+ }
lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal()));
}
+
+void Steps::lapBtnEventHandler(lv_event_t event) {
+ if (event != LV_EVENT_CLICKED) {
+ return;
+ }
+ stepsCount = motionController.NbSteps();
+ motionController.ResetTrip();
+ Refresh();
+}
diff --git a/src/displayapp/screens/Steps.h b/src/displayapp/screens/Steps.h
index 68daf16d..f109e0f2 100644
--- a/src/displayapp/screens/Steps.h
+++ b/src/displayapp/screens/Steps.h
@@ -20,14 +20,20 @@ namespace Pinetime {
~Steps() override;
void Refresh() override;
+ void lapBtnEventHandler(lv_event_t event);
private:
Controllers::MotionController& motionController;
Controllers::Settings& settingsController;
+ uint32_t currentTripSteps = 0;
+
lv_obj_t* lSteps;
lv_obj_t* lStepsIcon;
lv_obj_t* stepsArc;
+ lv_obj_t* resetBtn;
+ lv_obj_t* resetButtonLabel;
+ lv_obj_t* tripLabel;
uint32_t stepsCount;
diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp
index a260d293..8749839f 100644
--- a/src/displayapp/screens/StopWatch.cpp
+++ b/src/displayapp/screens/StopWatch.cpp
@@ -1,13 +1,10 @@
-#include "StopWatch.h"
+#include "displayapp/screens/StopWatch.h"
#include "displayapp/screens/Screen.h"
#include "displayapp/screens/Symbols.h"
#include <lvgl/lvgl.h>
-#include "projdefs.h"
-#include "FreeRTOSConfig.h"
-#include "task.h"
-
-#include <tuple>
+#include <FreeRTOS.h>
+#include <task.h>
using namespace Pinetime::Applications::Screens;
diff --git a/src/displayapp/screens/StopWatch.h b/src/displayapp/screens/StopWatch.h
index 0720a586..06193f68 100644
--- a/src/displayapp/screens/StopWatch.h
+++ b/src/displayapp/screens/StopWatch.h
@@ -4,7 +4,7 @@
#include "components/datetime/DateTimeController.h"
#include "displayapp/LittleVgl.h"
-#include "FreeRTOS.h"
+#include <FreeRTOS.h>
#include "portmacro_cmsis.h"
#include <array>
diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp
index ba764a2e..23d9bca7 100644
--- a/src/displayapp/screens/Tile.cpp
+++ b/src/displayapp/screens/Tile.cpp
@@ -33,7 +33,7 @@ Tile::Tile(uint8_t screenID,
// Time
label_time = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes());
+ lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label_time, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
@@ -119,7 +119,7 @@ Tile::~Tile() {
}
void Tile::UpdateScreen() {
- lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes());
+ lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
}
diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp
index 8f06553f..fd36aa22 100644
--- a/src/displayapp/screens/WatchFaceDigital.cpp
+++ b/src/displayapp/screens/WatchFaceDigital.cpp
@@ -35,22 +35,22 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
settingsController.SetClockFace(0);
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(batteryIcon, Symbols::batteryFull);
+ lv_label_set_text_static(batteryIcon, Symbols::batteryFull);
lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
batteryPlug = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFF0000));
- lv_label_set_text(batteryPlug, Symbols::plug);
+ lv_label_set_text_static(batteryPlug, Symbols::plug);
lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
bleIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x0000FF));
- lv_label_set_text(bleIcon, Symbols::bluetooth);
+ lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x0082FC));
+ lv_label_set_text_static(bleIcon, Symbols::bluetooth);
lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00));
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
+ lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
label_date = lv_label_create(lv_scr_act(), nullptr);
@@ -71,26 +71,26 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text(backgroundLabel, "");
+ lv_label_set_text_static(backgroundLabel, "");
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(heartbeatIcon, Symbols::heartBeat);
+ lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
- lv_label_set_text(heartbeatValue, "");
+ lv_label_set_text_static(heartbeatValue, "");
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
stepValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
- lv_label_set_text(stepValue, "0");
+ lv_label_set_text_static(stepValue, "0");
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
stepIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
- lv_label_set_text(stepIcon, Symbols::shoe);
+ lv_label_set_text_static(stepIcon, Symbols::shoe);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
@@ -105,7 +105,7 @@ WatchFaceDigital::~WatchFaceDigital() {
void WatchFaceDigital::Refresh() {
powerPresent = batteryController.IsPowerPresent();
if (powerPresent.IsUpdated()) {
- lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get()));
+ lv_label_set_text_static(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get()));
}
batteryPercentRemaining = batteryController.PercentRemaining();
@@ -116,20 +116,20 @@ void WatchFaceDigital::Refresh() {
} else {
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
}
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+ lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
}
bleState = bleController.GetConnectState();
if (bleState.IsUpdated()) {
- lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
+ lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
}
- lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
- lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
- lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
+ lv_obj_realign(batteryIcon);
+ lv_obj_realign(batteryPlug);
+ lv_obj_realign(bleIcon);
notificationState = notificatioManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
+ lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
}
currentDateTime = dateTimeController.CurrentDateTime();
@@ -146,62 +146,41 @@ void WatchFaceDigital::Refresh() {
auto day = static_cast<unsigned>(yearMonthDay.day());
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
- int hour = time.hours().count();
- auto minute = time.minutes().count();
-
- char minutesChar[3];
- sprintf(minutesChar, "%02d", static_cast<int>(minute));
-
- char hoursChar[3];
- char ampmChar[3];
- if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
- sprintf(hoursChar, "%02d", hour);
- } else {
- if (hour == 0 && hour != 12) {
- hour = 12;
- sprintf(ampmChar, "AM");
- } else if (hour == 12 && hour != 0) {
- hour = 12;
- sprintf(ampmChar, "PM");
- } else if (hour < 12 && hour != 0) {
- sprintf(ampmChar, "AM");
- } else if (hour > 12 && hour != 0) {
- hour = hour - 12;
- sprintf(ampmChar, "PM");
- }
- sprintf(hoursChar, "%02d", hour);
- }
+ uint8_t hour = time.hours().count();
+ uint8_t minute = time.minutes().count();
- if ((hoursChar[0] != displayedChar[0]) or (hoursChar[1] != displayedChar[1]) or (minutesChar[0] != displayedChar[2]) or
- (minutesChar[1] != displayedChar[3])) {
- displayedChar[0] = hoursChar[0];
- displayedChar[1] = hoursChar[1];
- displayedChar[2] = minutesChar[0];
- displayedChar[3] = minutesChar[1];
+ if (displayedHour != hour || displayedMinute != minute) {
+ displayedHour = hour;
+ displayedMinute = minute;
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
- lv_label_set_text(label_time_ampm, ampmChar);
- if (hoursChar[0] == '0') {
- hoursChar[0] = ' ';
+ char ampmChar[3] = "AM";
+ if (hour == 0) {
+ hour = 12;
+ } else if (hour == 12) {
+ ampmChar[0] = 'P';
+ } else if (hour > 12) {
+ hour = hour - 12;
+ ampmChar[0] = 'P';
}
- }
-
- lv_label_set_text_fmt(label_time, "%s:%s", hoursChar, minutesChar);
-
- if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ lv_label_set_text(label_time_ampm, ampmChar);
+ lv_label_set_text_fmt(label_time, "%2d:%02d", hour, minute);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);
} else {
+ lv_label_set_text_fmt(label_time, "%02d:%02d", hour, minute);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
}
}
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
- lv_label_set_text_fmt(label_date, "%s %d %s %d", dateTimeController.DayOfWeekShortToString(), day, dateTimeController.MonthShortToString(), year);
+ lv_label_set_text_fmt(
+ label_date, "%s %d %s %d", dateTimeController.DayOfWeekShortToString(), day, dateTimeController.MonthShortToString(), year);
} else {
- lv_label_set_text_fmt(label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year);
+ lv_label_set_text_fmt(
+ label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year);
}
- lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
+ lv_obj_realign(label_date);
currentYear = year;
currentMonth = month;
@@ -221,15 +200,15 @@ void WatchFaceDigital::Refresh() {
lv_label_set_text_static(heartbeatValue, "");
}
- lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
- lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
+ lv_obj_realign(heartbeatIcon);
+ lv_obj_realign(heartbeatValue);
}
stepCount = motionController.NbSteps();
motionSensorOk = motionController.IsSensorOk();
if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
- lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
- lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
+ lv_obj_realign(stepValue);
+ lv_obj_realign(stepIcon);
}
}
diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h
index addb539a..6cf11310 100644
--- a/src/displayapp/screens/WatchFaceDigital.h
+++ b/src/displayapp/screens/WatchFaceDigital.h
@@ -36,7 +36,8 @@ namespace Pinetime {
void Refresh() override;
private:
- char displayedChar[5] {};
+ uint8_t displayedHour = -1;
+ uint8_t displayedMinute = -1;
uint16_t currentYear = 1970;
Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp
new file mode 100644
index 00000000..033aad88
--- /dev/null
+++ b/src/displayapp/screens/WatchFaceTerminal.cpp
@@ -0,0 +1,198 @@
+#include <date/date.h>
+#include <lvgl/lvgl.h>
+#include "displayapp/screens/WatchFaceTerminal.h"
+#include "displayapp/screens/BatteryIcon.h"
+#include "displayapp/screens/NotificationIcon.h"
+#include "displayapp/screens/Symbols.h"
+#include "components/battery/BatteryController.h"
+#include "components/ble/BleController.h"
+#include "components/ble/NotificationManager.h"
+#include "components/heartrate/HeartRateController.h"
+#include "components/motion/MotionController.h"
+#include "components/settings/Settings.h"
+
+using namespace Pinetime::Applications::Screens;
+
+WatchFaceTerminal::WatchFaceTerminal(DisplayApp* app,
+ Controllers::DateTime& dateTimeController,
+ Controllers::Battery& batteryController,
+ Controllers::Ble& bleController,
+ Controllers::NotificationManager& notificatioManager,
+ Controllers::Settings& settingsController,
+ Controllers::HeartRateController& heartRateController,
+ Controllers::MotionController& motionController)
+ : Screen(app),
+ currentDateTime {{}},
+ dateTimeController {dateTimeController},
+ batteryController {batteryController},
+ bleController {bleController},
+ notificatioManager {notificatioManager},
+ settingsController {settingsController},
+ heartRateController {heartRateController},
+ motionController {motionController} {
+ settingsController.SetClockFace(3);
+
+ batteryIcon = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text(batteryIcon, Symbols::batteryFull);
+ lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, 2);
+
+ batteryPlug = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text(batteryPlug, Symbols::plug);
+ lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
+
+ batteryValue = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(batteryValue, true);
+ lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
+
+ connectState = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(connectState, true);
+ lv_label_set_text(connectState, "[STAT]#387b54 Disconnected#");
+ lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40);
+
+ notificationIcon = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
+ lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 10, 0);
+
+ label_date = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(label_date, true);
+ lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -40);
+
+ label_prompt_1 = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -80);
+ lv_label_set_text(label_prompt_1, "user@watch:~ $ now");
+
+ label_prompt_2 = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
+ lv_label_set_text(label_prompt_2, "user@watch:~ $");
+
+ label_time = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(label_time, true);
+ lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -60);
+
+ backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_click(backgroundLabel, true);
+ lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
+ lv_obj_set_size(backgroundLabel, 240, 240);
+ lv_obj_set_pos(backgroundLabel, 0, 0);
+ lv_label_set_text(backgroundLabel, "");
+
+ heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(heartbeatValue, true);
+ lv_label_set_text(heartbeatValue, "[L_HR]#ee3311 0 bpm#");
+ lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 20);
+
+ stepValue = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(stepValue, true);
+ lv_label_set_text(stepValue, "[STEP]#ee3377 0 steps#");
+ lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
+ Refresh();
+}
+
+WatchFaceTerminal::~WatchFaceTerminal() {
+ lv_task_del(taskRefresh);
+ lv_obj_clean(lv_scr_act());
+}
+
+void WatchFaceTerminal::Refresh() {
+ powerPresent = batteryController.IsPowerPresent();
+ if (powerPresent.IsUpdated()) {
+ lv_label_set_text_static(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get()));
+ }
+
+ batteryPercentRemaining = batteryController.PercentRemaining();
+ if (batteryPercentRemaining.IsUpdated()) {
+ auto batteryPercent = batteryPercentRemaining.Get();
+ if (batteryPercent == 100) {
+ lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
+ } else {
+ lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
+ }
+ lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+ lv_label_set_text_fmt(batteryValue, "[BATT]#387b54 %d%\%#", batteryPercent);
+ }
+
+ bleState = bleController.IsConnected();
+ if (bleState.IsUpdated()) {
+ if (bleState.Get()) {
+ lv_label_set_text_static(connectState, "[STAT]#387b54 Connected#");
+ } else {
+ lv_label_set_text_static(connectState, "[STAT]#387b54 Disconnected#");
+ }
+ }
+
+ notificationState = notificatioManager.AreNewNotificationsAvailable();
+ if (notificationState.IsUpdated()) {
+ if (notificationState.Get()) {
+ lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(true));
+ } else {
+ lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
+ }
+ }
+
+ currentDateTime = dateTimeController.CurrentDateTime();
+
+ if (currentDateTime.IsUpdated()) {
+ auto newDateTime = currentDateTime.Get();
+
+ auto dp = date::floor<date::days>(newDateTime);
+ auto time = date::make_time(newDateTime - dp);
+ auto yearMonthDay = date::year_month_day(dp);
+
+ auto year = static_cast<int>(yearMonthDay.year());
+ auto month = static_cast<Pinetime::Controllers::DateTime::Months>(static_cast<unsigned>(yearMonthDay.month()));
+ auto day = static_cast<unsigned>(yearMonthDay.day());
+ auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
+
+ uint8_t hour = time.hours().count();
+ uint8_t minute = time.minutes().count();
+ uint8_t second = time.seconds().count();
+
+ if (displayedHour != hour || displayedMinute != minute || displayedSecond != second) {
+ displayedHour = hour;
+ displayedMinute = minute;
+ displayedSecond = second;
+
+ if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ char ampmChar[3] = "AM";
+ if (hour == 0) {
+ hour = 12;
+ } else if (hour == 12) {
+ ampmChar[0] = 'P';
+ } else if (hour > 12) {
+ hour = hour - 12;
+ ampmChar[0] = 'P';
+ }
+ lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
+ } else {
+ lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d", hour, minute, second);
+ }
+ }
+
+ if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
+ lv_label_set_text_fmt(label_date, "[DATE]#007fff %04d.%02d.%02d#", short(year), char(month), char(day));
+
+ currentYear = year;
+ currentMonth = month;
+ currentDayOfWeek = dayOfWeek;
+ currentDay = day;
+ }
+ }
+
+ heartbeat = heartRateController.HeartRate();
+ heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
+ if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
+ if (heartbeatRunning.Get()) {
+ lv_label_set_text_fmt(heartbeatValue, "[L_HR]#ee3311 %d bpm#", heartbeat.Get());
+ } else {
+ lv_label_set_text_static(heartbeatValue, "[L_HR]#ee3311 ---#");
+ }
+ }
+
+ stepCount = motionController.NbSteps();
+ motionSensorOk = motionController.IsSensorOk();
+ if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) {
+ lv_label_set_text_fmt(stepValue, "[STEP]#ee3377 %lu steps#", stepCount.Get());
+ }
+}
diff --git a/src/displayapp/screens/WatchFaceTerminal.h b/src/displayapp/screens/WatchFaceTerminal.h
new file mode 100644
index 00000000..c3df82b4
--- /dev/null
+++ b/src/displayapp/screens/WatchFaceTerminal.h
@@ -0,0 +1,82 @@
+#pragma once
+
+#include <lvgl/src/lv_core/lv_obj.h>
+#include <chrono>
+#include <cstdint>
+#include <memory>
+#include "displayapp/screens/Screen.h"
+#include "components/datetime/DateTimeController.h"
+
+namespace Pinetime {
+ namespace Controllers {
+ class Settings;
+ class Battery;
+ class Ble;
+ class NotificationManager;
+ class HeartRateController;
+ class MotionController;
+ }
+
+ namespace Applications {
+ namespace Screens {
+
+ class WatchFaceTerminal : public Screen {
+ public:
+ WatchFaceTerminal(DisplayApp* app,
+ Controllers::DateTime& dateTimeController,
+ Controllers::Battery& batteryController,
+ Controllers::Ble& bleController,
+ Controllers::NotificationManager& notificatioManager,
+ Controllers::Settings& settingsController,
+ Controllers::HeartRateController& heartRateController,
+ Controllers::MotionController& motionController);
+ ~WatchFaceTerminal() override;
+
+ void Refresh() override;
+
+ private:
+ uint8_t displayedHour = -1;
+ uint8_t displayedMinute = -1;
+ uint8_t displayedSecond = -1;
+
+ uint16_t currentYear = 1970;
+ Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
+ Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
+ uint8_t currentDay = 0;
+
+ DirtyValue<int> batteryPercentRemaining {};
+ DirtyValue<bool> powerPresent {};
+ DirtyValue<bool> bleState {};
+ DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
+ DirtyValue<bool> motionSensorOk {};
+ DirtyValue<uint32_t> stepCount {};
+ DirtyValue<uint8_t> heartbeat {};
+ DirtyValue<bool> heartbeatRunning {};
+ DirtyValue<bool> notificationState {};
+
+ lv_obj_t* label_time;
+ lv_obj_t* label_date;
+ lv_obj_t* label_prompt_1;
+ lv_obj_t* label_prompt_2;
+ lv_obj_t* backgroundLabel;
+ lv_obj_t* batteryIcon;
+ lv_obj_t* batteryPlug;
+ lv_obj_t* batteryValue;
+ lv_obj_t* heartbeatValue;
+ lv_obj_t* stepValue;
+ lv_obj_t* notificationIcon;
+ lv_obj_t* connectState;
+
+ Controllers::DateTime& dateTimeController;
+ Controllers::Battery& batteryController;
+ Controllers::Ble& bleController;
+ Controllers::NotificationManager& notificatioManager;
+ Controllers::Settings& settingsController;
+ Controllers::HeartRateController& heartRateController;
+ Controllers::MotionController& motionController;
+
+ lv_task_t* taskRefresh;
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp
index 5d3a9834..cd56c145 100644
--- a/src/displayapp/screens/settings/QuickSettings.cpp
+++ b/src/displayapp/screens/settings/QuickSettings.cpp
@@ -35,7 +35,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
// Time
label_time = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes());
+ lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 0);
@@ -123,7 +123,7 @@ QuickSettings::~QuickSettings() {
}
void QuickSettings::UpdateScreen() {
- lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes());
+ lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
}
diff --git a/src/displayapp/screens/settings/SettingChimes.cpp b/src/displayapp/screens/settings/SettingChimes.cpp
new file mode 100644
index 00000000..543b5e0e
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingChimes.cpp
@@ -0,0 +1,100 @@
+#include "displayapp/screens/settings/SettingChimes.h"
+#include <lvgl/lvgl.h>
+#include "displayapp/DisplayApp.h"
+#include "displayapp/screens/Styles.h"
+#include "displayapp/screens/Screen.h"
+#include "displayapp/screens/Symbols.h"
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ static void event_handler(lv_obj_t* obj, lv_event_t event) {
+ SettingChimes* screen = static_cast<SettingChimes*>(obj->user_data);
+ screen->UpdateSelected(obj, event);
+ }
+}
+
+SettingChimes::SettingChimes(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
+ : Screen(app), settingsController {settingsController} {
+
+ lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
+
+ lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
+ lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10);
+ lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5);
+ lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
+
+ lv_obj_set_pos(container1, 10, 60);
+ lv_obj_set_width(container1, LV_HOR_RES - 20);
+ lv_obj_set_height(container1, LV_VER_RES - 50);
+ lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT);
+
+ lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text_static(title, "Chimes");
+ lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 10, 15);
+
+ lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
+ lv_label_set_text_static(icon, Symbols::clock);
+ lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
+
+ optionsTotal = 0;
+ cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text_static(cbOption[optionsTotal], " Off");
+ cbOption[optionsTotal]->user_data = this;
+ lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
+ SetRadioButtonStyle(cbOption[optionsTotal]);
+ if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::None) {
+ lv_checkbox_set_checked(cbOption[optionsTotal], true);
+ }
+
+ optionsTotal++;
+ cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text_static(cbOption[optionsTotal], " Every hour");
+ cbOption[optionsTotal]->user_data = this;
+ lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
+ SetRadioButtonStyle(cbOption[optionsTotal]);
+ if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::Hours) {
+ lv_checkbox_set_checked(cbOption[optionsTotal], true);
+ }
+
+ optionsTotal++;
+ cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text_static(cbOption[optionsTotal], " Every 30 mins");
+ cbOption[optionsTotal]->user_data = this;
+ lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
+ SetRadioButtonStyle(cbOption[optionsTotal]);
+ if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours) {
+ lv_checkbox_set_checked(cbOption[optionsTotal], true);
+ }
+
+ optionsTotal++;
+}
+
+SettingChimes::~SettingChimes() {
+ lv_obj_clean(lv_scr_act());
+ settingsController.SaveSettings();
+}
+
+void SettingChimes::UpdateSelected(lv_obj_t* object, lv_event_t event) {
+ if (event == LV_EVENT_VALUE_CHANGED) {
+ for (uint8_t i = 0; i < optionsTotal; i++) {
+ if (object == cbOption[i]) {
+ lv_checkbox_set_checked(cbOption[i], true);
+ if (i == 0) {
+ settingsController.SetChimeOption(Controllers::Settings::ChimesOption::None);
+ }
+ if (i == 1) {
+ settingsController.SetChimeOption(Controllers::Settings::ChimesOption::Hours);
+ }
+ if (i == 2) {
+ settingsController.SetChimeOption(Controllers::Settings::ChimesOption::HalfHours);
+ }
+ } else {
+ lv_checkbox_set_checked(cbOption[i], false);
+ }
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingChimes.h b/src/displayapp/screens/settings/SettingChimes.h
new file mode 100644
index 00000000..653f87f7
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingChimes.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include <cstdint>
+#include <lvgl/lvgl.h>
+#include "components/settings/Settings.h"
+#include "displayapp/screens/Screen.h"
+
+namespace Pinetime {
+
+ namespace Applications {
+ namespace Screens {
+
+ class SettingChimes : public Screen {
+ public:
+ SettingChimes(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
+ ~SettingChimes() override;
+
+ void UpdateSelected(lv_obj_t* object, lv_event_t event);
+
+ private:
+ Controllers::Settings& settingsController;
+ uint8_t optionsTotal;
+ lv_obj_t* cbOption[2];
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp
deleted file mode 100644
index f38ec3bd..00000000
--- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-#include "displayapp/screens/settings/SettingPineTimeStyle.h"
-#include <lvgl/lvgl.h>
-#include <displayapp/Colors.h>
-#include "displayapp/DisplayApp.h"
-#include "displayapp/screens/Symbols.h"
-
-using namespace Pinetime::Applications::Screens;
-
-namespace {
- static void event_handler(lv_obj_t* obj, lv_event_t event) {
- SettingPineTimeStyle* screen = static_cast<SettingPineTimeStyle*>(obj->user_data);
- screen->UpdateSelected(obj, event);
- }
-}
-
-SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
- : Screen(app), settingsController {settingsController} {
- timebar = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
- lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(timebar, 200, 240);
- lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
-
- // Display the time
-
- timeDD1 = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
- lv_label_set_text(timeDD1, "12");
- lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
-
- timeDD2 = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
- lv_label_set_text(timeDD2, "34");
- lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
-
- timeAMPM = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
- lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
- lv_label_set_text(timeAMPM, "A\nM");
- lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
-
- // Create a 40px wide bar down the right side of the screen
-
- sidebar = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
- lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(sidebar, 40, 240);
- lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
-
- // Display icons
-
- batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(batteryIcon, Symbols::batteryFull);
- lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
-
- bleIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(bleIcon, Symbols::bluetooth);
- lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25);
-
- // Calendar icon
-
- calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(calendarOuter, 34, 34);
- lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
-
- calendarInner = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff));
- lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(calendarInner, 27, 27);
- lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0);
-
- calendarBar1 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(calendarBar1, 3, 12);
- lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3);
-
- calendarBar2 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(calendarBar2, 3, 12);
- lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3);
-
- calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(calendarCrossBar1, 8, 3);
- lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
-
- calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(calendarCrossBar2, 8, 3);
- lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
-
- // Display date
-
- dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(dateDayOfWeek, "THU");
- lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
-
- dateDay = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(dateDay, "25");
- lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
-
- dateMonth = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(dateMonth, "MAR");
- lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
-
- // Step count gauge
- needle_colors[0] = LV_COLOR_WHITE;
- stepGauge = lv_gauge_create(lv_scr_act(), nullptr);
- lv_gauge_set_needle_count(stepGauge, 1, needle_colors);
- lv_obj_set_size(stepGauge, 40, 40);
- lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
- lv_gauge_set_scale(stepGauge, 360, 11, 0);
- lv_gauge_set_angle_offset(stepGauge, 180);
- lv_gauge_set_critical_value(stepGauge, (100));
- lv_gauge_set_range(stepGauge, 0, (100));
- lv_gauge_set_value(stepGauge, 0, 0);
-
- lv_obj_set_style_local_pad_right(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_pad_left(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_pad_bottom(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
- lv_obj_set_style_local_scale_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
- lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
- lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
- lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
- lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
-
- backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_click(backgroundLabel, true);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text(backgroundLabel, "");
-
- btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
- btnNextTime->user_data = this;
- lv_obj_set_size(btnNextTime, 60, 60);
- lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, -80);
- lv_obj_set_style_local_bg_opa(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
- lv_obj_set_event_cb(btnNextTime, event_handler);
-
- btnPrevTime = lv_btn_create(lv_scr_act(), nullptr);
- btnPrevTime->user_data = this;
- lv_obj_set_size(btnPrevTime, 60, 60);
- lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, -80);
- lv_obj_set_style_local_bg_opa(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
- lv_obj_set_event_cb(btnPrevTime, event_handler);
-
- btnNextBar = lv_btn_create(lv_scr_act(), nullptr);
- btnNextBar->user_data = this;
- lv_obj_set_size(btnNextBar, 60, 60);
- lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0);
- lv_obj_set_style_local_bg_opa(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
- lv_obj_set_event_cb(btnNextBar, event_handler);
-
- btnPrevBar = lv_btn_create(lv_scr_act(), nullptr);
- btnPrevBar->user_data = this;
- lv_obj_set_size(btnPrevBar, 60, 60);
- lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0);
- lv_obj_set_style_local_bg_opa(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
- lv_obj_set_event_cb(btnPrevBar, event_handler);
-
- btnNextBG = lv_btn_create(lv_scr_act(), nullptr);
- btnNextBG->user_data = this;
- lv_obj_set_size(btnNextBG, 60, 60);
- lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 80);
- lv_obj_set_style_local_bg_opa(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
- lv_obj_set_event_cb(btnNextBG, event_handler);
-
- btnPrevBG = lv_btn_create(lv_scr_act(), nullptr);
- btnPrevBG->user_data = this;
- lv_obj_set_size(btnPrevBG, 60, 60);
- lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 80);
- lv_obj_set_style_local_bg_opa(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
- lv_obj_set_event_cb(btnPrevBG, event_handler);
-
- btnReset = lv_btn_create(lv_scr_act(), nullptr);
- btnReset->user_data = this;
- lv_obj_set_size(btnReset, 60, 60);
- lv_obj_align(btnReset, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
- lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst");
- lv_obj_set_event_cb(btnReset, event_handler);
-
- btnRandom = lv_btn_create(lv_scr_act(), nullptr);
- btnRandom->user_data = this;
- lv_obj_set_size(btnRandom, 60, 60);
- lv_obj_align(btnRandom, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
- lv_obj_set_style_local_bg_opa(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rnd");
- lv_obj_set_event_cb(btnRandom, event_handler);
-}
-
-SettingPineTimeStyle::~SettingPineTimeStyle() {
- lv_obj_clean(lv_scr_act());
- settingsController.SaveSettings();
-}
-
-void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
- auto valueTime = settingsController.GetPTSColorTime();
- auto valueBar = settingsController.GetPTSColorBar();
- auto valueBG = settingsController.GetPTSColorBG();
-
- if (event == LV_EVENT_CLICKED) {
- if (object == btnNextTime) {
- valueTime = GetNext(valueTime);
-
- settingsController.SetPTSColorTime(valueTime);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
- }
- if (object == btnPrevTime) {
- valueTime = GetPrevious(valueTime);
- settingsController.SetPTSColorTime(valueTime);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
- }
- if (object == btnNextBar) {
- valueBar = GetNext(valueBar);
- if(valueBar == Controllers::Settings::Colors::Black)
- valueBar = GetNext(valueBar);
- settingsController.SetPTSColorBar(valueBar);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
- }
- if (object == btnPrevBar) {
- valueBar = GetPrevious(valueBar);
- if(valueBar == Controllers::Settings::Colors::Black)
- valueBar = GetPrevious(valueBar);
- settingsController.SetPTSColorBar(valueBar);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
- }
- if (object == btnNextBG) {
- valueBG = GetNext(valueBG);
- settingsController.SetPTSColorBG(valueBG);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
- }
- if (object == btnPrevBG) {
- valueBG = GetPrevious(valueBG);
- settingsController.SetPTSColorBG(valueBG);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
- }
- if (object == btnReset) {
- settingsController.SetPTSColorTime(Controllers::Settings::Colors::Teal);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
- settingsController.SetPTSColorBar(Controllers::Settings::Colors::Teal);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
- settingsController.SetPTSColorBG(Controllers::Settings::Colors::Black);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black));
- }
- if (object == btnRandom) {
- uint8_t randTime = rand() % 17;
- uint8_t randBar = rand() % 17;
- uint8_t randBG = rand() % 17;
- // Check if the time color is the same as its background, or if the sidebar is black. If so, change them to more useful values.
- if (randTime == randBG) {
- randBG += 1;
- }
- if (randBar == 3) {
- randBar -= 1;
- }
- settingsController.SetPTSColorTime(static_cast<Controllers::Settings::Colors>(randTime));
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
- settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(randBar));
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBar)));
- settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(randBG));
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBG)));
- }
- }
-}
-
-Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
- auto colorAsInt = static_cast<uint8_t>(color);
- Pinetime::Controllers::Settings::Colors nextColor;
- if (colorAsInt < 16) {
- nextColor = static_cast<Controllers::Settings::Colors>(colorAsInt + 1);
- } else {
- nextColor = static_cast<Controllers::Settings::Colors>(0);
- }
- return nextColor;
-}
-
-Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
- auto colorAsInt = static_cast<uint8_t>(color);
- Pinetime::Controllers::Settings::Colors prevColor;
-
- if (colorAsInt > 0) {
- prevColor = static_cast<Controllers::Settings::Colors>(colorAsInt - 1);
- } else {
- prevColor = static_cast<Controllers::Settings::Colors>(16);
- }
- return prevColor;
-}
diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h
deleted file mode 100644
index 397bd86d..00000000
--- a/src/displayapp/screens/settings/SettingPineTimeStyle.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#pragma once
-
-#include <cstdint>
-#include <lvgl/lvgl.h>
-#include "components/settings/Settings.h"
-#include "displayapp/screens/Screen.h"
-
-namespace Pinetime {
-
- namespace Applications {
- namespace Screens {
-
- class SettingPineTimeStyle : public Screen{
- public:
- SettingPineTimeStyle(DisplayApp* app, Pinetime::Controllers::Settings &settingsController);
- ~SettingPineTimeStyle() override;
-
- void UpdateSelected(lv_obj_t *object, lv_event_t event);
-
- private:
- Controllers::Settings& settingsController;
-
- Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color);
- Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color);
-
- lv_obj_t * btnNextTime;
- lv_obj_t * btnPrevTime;
- lv_obj_t * btnNextBar;
- lv_obj_t * btnPrevBar;
- lv_obj_t * btnNextBG;
- lv_obj_t * btnPrevBG;
- lv_obj_t * btnReset;
- lv_obj_t * btnRandom;
- lv_obj_t * timebar;
- lv_obj_t * sidebar;
- lv_obj_t * timeDD1;
- lv_obj_t * timeDD2;
- lv_obj_t * timeAMPM;
- lv_obj_t * dateDayOfWeek;
- lv_obj_t * dateDay;
- lv_obj_t * dateMonth;
- lv_obj_t * backgroundLabel;
- lv_obj_t * batteryIcon;
- lv_obj_t * bleIcon;
- lv_obj_t * calendarOuter;
- lv_obj_t * calendarInner;
- lv_obj_t * calendarBar1;
- lv_obj_t * calendarBar2;
- lv_obj_t * calendarCrossBar1;
- lv_obj_t * calendarCrossBar2;
- lv_obj_t * stepGauge;
- lv_color_t needle_colors[1];
- };
- }
- }
-}
diff --git a/src/displayapp/screens/settings/SettingSetTime.cpp b/src/displayapp/screens/settings/SettingSetTime.cpp
index 5351adeb..037611f3 100644
--- a/src/displayapp/screens/settings/SettingSetTime.cpp
+++ b/src/displayapp/screens/settings/SettingSetTime.cpp
@@ -4,6 +4,7 @@
#include <nrf_log.h>
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/Symbols.h"
+#include "components/settings/Settings.h"
using namespace Pinetime::Applications::Screens;
@@ -16,23 +17,24 @@ namespace {
constexpr int16_t POS_Y_MINUS = 40;
constexpr int16_t OFS_Y_COLON = -2;
- void event_handler(lv_obj_t * obj, lv_event_t event) {
- auto* screen = static_cast<SettingSetTime *>(obj->user_data);
+ void event_handler(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingSetTime*>(obj->user_data);
screen->HandleButtonPress(obj, event);
}
}
-SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::DateTime &dateTimeController) :
- Screen(app),
- dateTimeController {dateTimeController} {
- lv_obj_t * title = lv_label_create(lv_scr_act(), nullptr);
+SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp* app,
+ Pinetime::Controllers::DateTime& dateTimeController,
+ Pinetime::Controllers::Settings& settingsController)
+ : Screen(app), dateTimeController {dateTimeController}, settingsController {settingsController} {
+ lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(title, "Set current time");
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15);
- lv_obj_t * icon = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
-
+
lv_label_set_text_static(icon, Symbols::clock);
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
@@ -45,7 +47,7 @@ SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp *app, Pinetime
lv_obj_align(lblHours, lv_scr_act(), LV_ALIGN_CENTER, POS_X_HOURS, POS_Y_TEXT);
lv_obj_set_auto_realign(lblHours, true);
- lv_obj_t * lblColon1 = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_t* lblColon1 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(lblColon1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_static(lblColon1, ":");
lv_label_set_align(lblColon1, LV_LABEL_ALIGN_CENTER);
@@ -59,18 +61,24 @@ SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp *app, Pinetime
lv_obj_align(lblMinutes, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MINUTES, POS_Y_TEXT);
lv_obj_set_auto_realign(lblMinutes, true);
- lv_obj_t * lblColon2 = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_t* lblColon2 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(lblColon2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_static(lblColon2, ":");
lv_label_set_align(lblColon2, LV_LABEL_ALIGN_CENTER);
lv_obj_align(lblColon2, lv_scr_act(), LV_ALIGN_CENTER, (POS_X_MINUTES + POS_X_SECONDS) / 2, POS_Y_TEXT + OFS_Y_COLON);
- lv_obj_t * lblSeconds = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_t* lblSeconds = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(lblSeconds, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_static(lblSeconds, "00");
lv_label_set_align(lblSeconds, LV_LABEL_ALIGN_CENTER);
lv_obj_align(lblSeconds, lv_scr_act(), LV_ALIGN_CENTER, POS_X_SECONDS, POS_Y_TEXT);
+ lblampm = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_font(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20);
+ lv_label_set_text_static(lblampm, " ");
+ lv_label_set_align(lblampm, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(lblampm, lv_scr_act(), LV_ALIGN_CENTER, POS_X_SECONDS, POS_Y_PLUS);
+
btnHoursPlus = lv_btn_create(lv_scr_act(), nullptr);
btnHoursPlus->user_data = this;
lv_obj_set_size(btnHoursPlus, 50, 40);
@@ -105,38 +113,69 @@ SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp *app, Pinetime
lv_obj_align(btnSetTime, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_obj_set_style_local_value_str(btnSetTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Set");
lv_obj_set_event_cb(btnSetTime, event_handler);
+
+ SetHourLabels();
}
SettingSetTime::~SettingSetTime() {
lv_obj_clean(lv_scr_act());
}
-void SettingSetTime::HandleButtonPress(lv_obj_t *object, lv_event_t event) {
+void SettingSetTime::SetHourLabels() {
+ if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ switch (hoursValue) {
+ case 0:
+ lv_label_set_text_static(lblHours, "12");
+ lv_label_set_text_static(lblampm, "AM");
+ break;
+ case 1 ... 11:
+ lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
+ lv_label_set_text_static(lblampm, "AM");
+ break;
+ case 12:
+ lv_label_set_text_static(lblHours, "12");
+ lv_label_set_text_static(lblampm, "PM");
+ break;
+ case 13 ... 23:
+ lv_label_set_text_fmt(lblHours, "%02d", hoursValue - 12);
+ lv_label_set_text_static(lblampm, "PM");
+ break;
+ }
+ } else {
+ lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
+ }
+}
+
+void SettingSetTime::HandleButtonPress(lv_obj_t* object, lv_event_t event) {
if (event != LV_EVENT_CLICKED)
return;
if (object == btnHoursPlus) {
hoursValue++;
- if (hoursValue > 23)
+ if (hoursValue > 23) {
hoursValue = 0;
- lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
+ }
+ SetHourLabels();
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
} else if (object == btnHoursMinus) {
hoursValue--;
- if (hoursValue < 0)
+ if (hoursValue < 0) {
hoursValue = 23;
- lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
+ }
+ SetHourLabels();
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
} else if (object == btnMinutesPlus) {
minutesValue++;
- if (minutesValue > 59)
+ if (minutesValue > 59) {
minutesValue = 0;
+ }
lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue);
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
} else if (object == btnMinutesMinus) {
minutesValue--;
- if (minutesValue < 0)
+ if (minutesValue < 0) {
minutesValue = 59;
+ }
lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue);
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
} else if (object == btnSetTime) {
diff --git a/src/displayapp/screens/settings/SettingSetTime.h b/src/displayapp/screens/settings/SettingSetTime.h
index 8ba41eae..d02c332e 100644
--- a/src/displayapp/screens/settings/SettingSetTime.h
+++ b/src/displayapp/screens/settings/SettingSetTime.h
@@ -3,30 +3,37 @@
#include <cstdint>
#include <lvgl/lvgl.h>
#include "components/datetime/DateTimeController.h"
+#include "components/settings/Settings.h"
#include "displayapp/screens/Screen.h"
namespace Pinetime {
namespace Applications {
namespace Screens {
- class SettingSetTime : public Screen{
- public:
- SettingSetTime(DisplayApp* app, Pinetime::Controllers::DateTime &dateTimeController);
- ~SettingSetTime() override;
+ class SettingSetTime : public Screen {
+ public:
+ SettingSetTime(DisplayApp* app,
+ Pinetime::Controllers::DateTime& dateTimeController,
+ Pinetime::Controllers::Settings& settingsController);
+ ~SettingSetTime() override;
- void HandleButtonPress(lv_obj_t *object, lv_event_t event);
-
- private:
- Controllers::DateTime& dateTimeController;
+ void HandleButtonPress(lv_obj_t* object, lv_event_t event);
- int hoursValue;
- int minutesValue;
- lv_obj_t * lblHours;
- lv_obj_t * lblMinutes;
- lv_obj_t * btnHoursPlus;
- lv_obj_t * btnHoursMinus;
- lv_obj_t * btnMinutesPlus;
- lv_obj_t * btnMinutesMinus;
- lv_obj_t * btnSetTime;
+ private:
+ Controllers::DateTime& dateTimeController;
+ Controllers::Settings& settingsController;
+
+ void SetHourLabels();
+
+ int hoursValue;
+ int minutesValue;
+ lv_obj_t* lblHours;
+ lv_obj_t* lblMinutes;
+ lv_obj_t* lblampm;
+ lv_obj_t* btnHoursPlus;
+ lv_obj_t* btnHoursMinus;
+ lv_obj_t* btnMinutesPlus;
+ lv_obj_t* btnMinutesMinus;
+ lv_obj_t* btnSetTime;
};
}
}
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.cpp b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
new file mode 100644
index 00000000..9d40fcf9
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
@@ -0,0 +1,137 @@
+#include "displayapp/screens/settings/SettingShakeThreshold.h"
+#include <lvgl/lvgl.h>
+#include "displayapp/DisplayApp.h"
+#include "displayapp/screens/Screen.h"
+#include "displayapp/screens/Symbols.h"
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ void event_handler(lv_obj_t* obj, lv_event_t event) {
+ SettingShakeThreshold* screen = static_cast<SettingShakeThreshold*>(obj->user_data);
+ screen->UpdateSelected(obj, event);
+ }
+}
+
+SettingShakeThreshold::SettingShakeThreshold(DisplayApp* app,
+ Controllers::Settings& settingsController,
+ Controllers::MotionController& motionController,
+ System::SystemTask& systemTask)
+ : Screen(app), settingsController {settingsController}, motionController {motionController}, systemTask {systemTask} {
+
+ lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text_static(title, "Wake Sensitivity");
+ lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0);
+
+ positionArc = lv_arc_create(lv_scr_act(), nullptr);
+ positionArc->user_data = this;
+
+ lv_obj_set_event_cb(positionArc, event_handler);
+ lv_arc_set_bg_angles(positionArc, 180, 360);
+ lv_arc_set_range(positionArc, 0, 4095);
+ lv_arc_set_adjustable(positionArc, true);
+ lv_obj_set_width(positionArc, lv_obj_get_width(lv_scr_act()) - 10);
+ lv_obj_set_height(positionArc, 240);
+ lv_obj_align(positionArc, title, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
+
+ animArc = lv_arc_create(positionArc, positionArc);
+ lv_arc_set_adjustable(animArc, false);
+ lv_obj_set_width(animArc, lv_obj_get_width(positionArc));
+ lv_obj_set_height(animArc, lv_obj_get_height(positionArc));
+ lv_obj_align_mid(animArc, positionArc, LV_ALIGN_CENTER, 0, 0);
+ lv_obj_set_style_local_line_opa(animArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);
+ lv_obj_set_style_local_line_opa(animArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_OPA_70);
+ lv_obj_set_style_local_line_opa(animArc, LV_ARC_PART_KNOB, LV_STATE_DEFAULT, LV_OPA_0);
+ lv_obj_set_style_local_line_color(animArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED);
+ lv_obj_set_style_local_bg_color(animArc, LV_ARC_PART_BG, LV_STATE_CHECKED, LV_COLOR_TRANSP);
+
+ animArc->user_data = this;
+ lv_obj_set_click(animArc, false);
+
+ calButton = lv_btn_create(lv_scr_act(), nullptr);
+ calButton->user_data = this;
+ lv_obj_set_event_cb(calButton, event_handler);
+ lv_obj_set_height(calButton, 80);
+ lv_obj_set_width(calButton, 200);
+ lv_obj_align(calButton, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+ lv_btn_set_checkable(calButton, true);
+ calLabel = lv_label_create(calButton, NULL);
+ lv_label_set_text(calLabel, "Calibrate");
+
+ lv_arc_set_value(positionArc, settingsController.GetShakeThreshold());
+
+ vDecay = xTaskGetTickCount();
+ calibrating = false;
+ EnableForCal = false;
+ if(!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake)){
+ EnableForCal = true;
+ settingsController.setWakeUpMode(Pinetime::Controllers::Settings::WakeUpMode::Shake,true);
+ }
+ refreshTask = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
+}
+
+SettingShakeThreshold::~SettingShakeThreshold() {
+ settingsController.SetShakeThreshold(lv_arc_get_value(positionArc));
+
+ if(EnableForCal){
+ settingsController.setWakeUpMode(Pinetime::Controllers::Settings::WakeUpMode::Shake,false);
+ EnableForCal = false;
+ }
+ lv_task_del(refreshTask);
+ settingsController.SaveSettings();
+ lv_obj_clean(lv_scr_act());
+}
+
+void SettingShakeThreshold::Refresh() {
+
+ if (calibrating == 1) {
+ if (xTaskGetTickCount() - vCalTime > pdMS_TO_TICKS(2000)) {
+ vCalTime = xTaskGetTickCount();
+ calibrating = 2;
+ lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_RED);
+ lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_RED);
+ lv_label_set_text(calLabel, "Shake!!");
+ }
+ }
+ if (calibrating == 2) {
+
+ if ((motionController.currentShakeSpeed() - 300) > lv_arc_get_value(positionArc)) {
+ lv_arc_set_value(positionArc, (int16_t) motionController.currentShakeSpeed() - 300);
+ }
+ if (xTaskGetTickCount() - vCalTime > pdMS_TO_TICKS(7500)) {
+ lv_btn_set_state(calButton, LV_STATE_DEFAULT);
+ lv_event_send(calButton, LV_EVENT_VALUE_CHANGED, NULL);
+ }
+ }
+ if (motionController.currentShakeSpeed() - 300 > lv_arc_get_value(animArc)) {
+ lv_arc_set_value(animArc, (uint16_t) motionController.currentShakeSpeed() - 300);
+ vDecay = xTaskGetTickCount();
+ } else if ((xTaskGetTickCount() - vDecay) > pdMS_TO_TICKS(1500)) {
+ lv_arc_set_value(animArc, lv_arc_get_value(animArc) - 25);
+ }
+}
+
+void SettingShakeThreshold::UpdateSelected(lv_obj_t* object, lv_event_t event) {
+
+ switch (event) {
+ case LV_EVENT_VALUE_CHANGED: {
+ if (object == calButton) {
+ if (lv_btn_get_state(calButton) == LV_BTN_STATE_CHECKED_RELEASED && calibrating == 0) {
+ lv_arc_set_value(positionArc, 0);
+ calibrating = 1;
+ vCalTime = xTaskGetTickCount();
+ lv_label_set_text(calLabel, "Ready!");
+ lv_obj_set_click(positionArc, false);
+ lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
+ lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
+ } else if (lv_btn_get_state(calButton) == LV_BTN_STATE_RELEASED) {
+ calibrating = 0;
+ lv_obj_set_click(positionArc, true);
+ lv_label_set_text(calLabel, "Calibrate");
+ }
+ break;
+ }
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.h b/src/displayapp/screens/settings/SettingShakeThreshold.h
new file mode 100644
index 00000000..37f4a65e
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include <cstdint>
+#include <lvgl/lvgl.h>
+#include "components/settings/Settings.h"
+#include "displayapp/screens/Screen.h"
+#include <components/motion/MotionController.h>
+#include "systemtask/SystemTask.h"
+namespace Pinetime {
+
+ namespace Applications {
+ namespace Screens {
+
+ class SettingShakeThreshold : public Screen {
+ public:
+ SettingShakeThreshold(DisplayApp* app,
+ Pinetime::Controllers::Settings& settingsController,
+ Controllers::MotionController& motionController,
+ System::SystemTask& systemTask);
+
+ ~SettingShakeThreshold() override;
+ void Refresh() override;
+ void UpdateSelected(lv_obj_t* object, lv_event_t event);
+
+ private:
+ Controllers::Settings& settingsController;
+ Controllers::MotionController& motionController;
+ System::SystemTask& systemTask;
+ uint8_t calibrating;
+ bool EnableForCal;
+ uint32_t vDecay,vCalTime;
+ lv_obj_t *positionArc, *animArc,*calButton, *calLabel;
+ lv_task_t* refreshTask;
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingWakeUp.cpp b/src/displayapp/screens/settings/SettingWakeUp.cpp
index 8339d9ad..e1b6e36e 100644
--- a/src/displayapp/screens/settings/SettingWakeUp.cpp
+++ b/src/displayapp/screens/settings/SettingWakeUp.cpp
@@ -65,6 +65,14 @@ SettingWakeUp::SettingWakeUp(Pinetime::Applications::DisplayApp* app, Pinetime::
lv_checkbox_set_checked(cbOption[optionsTotal], true);
}
optionsTotal++;
+ cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text_static(cbOption[optionsTotal], " Shake Wake");
+ cbOption[optionsTotal]->user_data = this;
+ lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
+ if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake)) {
+ lv_checkbox_set_checked(cbOption[optionsTotal], true);
+ }
+ optionsTotal++;
}
SettingWakeUp::~SettingWakeUp() {
diff --git a/src/displayapp/screens/settings/SettingWakeUp.h b/src/displayapp/screens/settings/SettingWakeUp.h
index b9a31dc9..cd244ae5 100644
--- a/src/displayapp/screens/settings/SettingWakeUp.h
+++ b/src/displayapp/screens/settings/SettingWakeUp.h
@@ -20,7 +20,7 @@ namespace Pinetime {
private:
Controllers::Settings& settingsController;
uint8_t optionsTotal;
- lv_obj_t* cbOption[4];
+ lv_obj_t* cbOption[5];
// When UpdateSelected is called, it uses lv_checkbox_set_checked,
// which can cause extra events to be fired,
// which might trigger UpdateSelected again, causing a loop.
diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp
index a24eaa15..50085925 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.cpp
+++ b/src/displayapp/screens/settings/SettingWatchFace.cpp
@@ -14,7 +14,7 @@ namespace {
}
}
-constexpr std::array<const char*, 3> SettingWatchFace::options;
+constexpr std::array<const char*, 4> SettingWatchFace::options;
SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
: Screen(app), settingsController {settingsController} {
diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h
index ccba7d13..62427b4f 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.h
+++ b/src/displayapp/screens/settings/SettingWatchFace.h
@@ -20,7 +20,7 @@ namespace Pinetime {
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
- static constexpr std::array<const char*, 3> options = {" Digital face", " Analog face", " PineTimeStyle"};
+ static constexpr std::array<const char*, 4> options = {" Digital face", " Analog face", " PineTimeStyle", " Terminal"};
Controllers::Settings& settingsController;
lv_obj_t* cbOption[options.size()];
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp
index 6be00f57..7bc90b47 100644
--- a/src/displayapp/screens/settings/Settings.cpp
+++ b/src/displayapp/screens/settings/Settings.cpp
@@ -36,10 +36,10 @@ bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
std::unique_ptr<Screen> Settings::CreateScreen1() {
std::array<Screens::List::Applications, 4> applications {{
- {Symbols::list, "About", Apps::SysInfo},
- {Symbols::airplane, "Airplane mode", Apps::SettingAirplaneMode},
- {Symbols::batteryHalf, "Battery", Apps::BatteryInfo},
- {Symbols::sun, "Display", Apps::SettingDisplay}
+ {Symbols::sun, "Display", Apps::SettingDisplay},
+ {Symbols::eye, "Wake Up", Apps::SettingWakeUp},
+ {Symbols::clock, "Time format", Apps::SettingTimeFormat},
+ {Symbols::home, "Watch face", Apps::SettingWatchFace},
}};
return std::make_unique<Screens::List>(0, 3, app, settingsController, applications);
@@ -47,12 +47,10 @@ std::unique_ptr<Screen> Settings::CreateScreen1() {
std::unique_ptr<Screen> Settings::CreateScreen2() {
- std::array<Screens::List::Applications, 4> applications {{
- {Symbols::check, "Firmware", Apps::FirmwareValidation},
- {Symbols::paintbrush, "PTS colors", Apps::SettingPineTimeStyle},
- {Symbols::clock, "Set date", Apps::SettingSetDate},
- {Symbols::clock, "Set time", Apps::SettingSetTime}
- }};
+ std::array<Screens::List::Applications, 4> applications {{{Symbols::shoe, "Steps", Apps::SettingSteps},
+ {Symbols::clock, "Set date", Apps::SettingSetDate},
+ {Symbols::clock, "Set time", Apps::SettingSetTime},
+ {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}}};
return std::make_unique<Screens::List>(1, 3, app, settingsController, applications);
}
@@ -60,10 +58,10 @@ std::unique_ptr<Screen> Settings::CreateScreen2() {
std::unique_ptr<Screen> Settings::CreateScreen3() {
std::array<Screens::List::Applications, 4> applications {{
- {Symbols::shoe, "Steps", Apps::SettingSteps},
- {Symbols::clock, "Time format", Apps::SettingTimeFormat},
- {Symbols::eye, "Wake up", Apps::SettingWakeUp},
- {Symbols::home, "Watch face", Apps::SettingWatchFace}
+ {Symbols::clock, "Chimes", Apps::SettingChimes},
+ {Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
+ {Symbols::check, "Firmware", Apps::FirmwareValidation},
+ {Symbols::list, "About", Apps::SysInfo}
}};
return std::make_unique<Screens::List>(2, 3, app, settingsController, applications);
diff --git a/src/drivers/Hrs3300.cpp b/src/drivers/Hrs3300.cpp
index c14fe7aa..ec620af2 100644
--- a/src/drivers/Hrs3300.cpp
+++ b/src/drivers/Hrs3300.cpp
@@ -36,8 +36,8 @@ void Hrs3300::Init() {
// HRS and ALS both in 16-bit mode
WriteRegister(static_cast<uint8_t>(Registers::Res), 0x88);
- // 64x gain
- WriteRegister(static_cast<uint8_t>(Registers::Hgain), 0x10);
+ // 8x gain, non default, reduced value for better readings
+ WriteRegister(static_cast<uint8_t>(Registers::Hgain), 0xc);
}
void Hrs3300::Enable() {
@@ -54,18 +54,18 @@ void Hrs3300::Disable() {
WriteRegister(static_cast<uint8_t>(Registers::Enable), value);
}
-uint16_t Hrs3300::ReadHrs() {
+uint32_t Hrs3300::ReadHrs() {
auto m = ReadRegister(static_cast<uint8_t>(Registers::C0DataM));
auto h = ReadRegister(static_cast<uint8_t>(Registers::C0DataH));
auto l = ReadRegister(static_cast<uint8_t>(Registers::C0dataL));
- return (m << 8) | ((h & 0x0f) << 4) | (l & 0x0f) | ((l & 0x30) << 12);
+ return ((l & 0x30) << 12) | (m << 8) | ((h & 0x0f) << 4) | (l & 0x0f);
}
-uint16_t Hrs3300::ReadAls() {
+uint32_t Hrs3300::ReadAls() {
auto m = ReadRegister(static_cast<uint8_t>(Registers::C1dataM));
auto h = ReadRegister(static_cast<uint8_t>(Registers::C1dataH));
auto l = ReadRegister(static_cast<uint8_t>(Registers::C1dataL));
- return (m << 3) | ((h & 0x3f) << 11) | (l & 0x07);
+ return ((h & 0x3f) << 11) | (m << 3) | (l & 0x07);
}
void Hrs3300::SetGain(uint8_t gain) {
diff --git a/src/drivers/Hrs3300.h b/src/drivers/Hrs3300.h
index 01310c62..8bbdc69a 100644
--- a/src/drivers/Hrs3300.h
+++ b/src/drivers/Hrs3300.h
@@ -30,8 +30,8 @@ namespace Pinetime {
void Init();
void Enable();
void Disable();
- uint16_t ReadHrs();
- uint16_t ReadAls();
+ uint32_t ReadHrs();
+ uint32_t ReadAls();
void SetGain(uint8_t gain);
void SetDrive(uint8_t drive);
diff --git a/src/heartratetask/HeartRateTask.cpp b/src/heartratetask/HeartRateTask.cpp
index 213ab4a7..2f689b9b 100644
--- a/src/heartratetask/HeartRateTask.cpp
+++ b/src/heartratetask/HeartRateTask.cpp
@@ -65,8 +65,7 @@ void HeartRateTask::Work() {
}
if (measurementStarted) {
- auto hrs = heartRateSensor.ReadHrs();
- ppg.Preprocess(hrs);
+ ppg.Preprocess(static_cast<float>(heartRateSensor.ReadHrs()));
auto bpm = ppg.HeartRate();
if (lastBpm == 0 && bpm == 0)
diff --git a/src/main.cpp b/src/main.cpp
index 53f78ce8..fa492d08 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -33,6 +33,7 @@
#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
#include "components/ble/NotificationManager.h"
+#include "components/brightness/BrightnessController.h"
#include "components/motor/MotorController.h"
#include "components/datetime/DateTimeController.h"
#include "components/heartrate/HeartRateController.h"
@@ -101,7 +102,11 @@ Pinetime::Controllers::Ble bleController;
Pinetime::Controllers::HeartRateController heartRateController;
Pinetime::Applications::HeartRateTask heartRateApp(heartRateSensor, heartRateController);
-Pinetime::Controllers::DateTime dateTimeController;
+Pinetime::Controllers::FS fs {spiNorFlash};
+Pinetime::Controllers::Settings settingsController {fs};
+Pinetime::Controllers::MotorController motorController {};
+
+Pinetime::Controllers::DateTime dateTimeController {settingsController};
Pinetime::Drivers::Watchdog watchdog;
Pinetime::Drivers::WatchdogView watchdogView(watchdog);
Pinetime::Controllers::NotificationManager notificationManager;
@@ -110,10 +115,7 @@ Pinetime::Controllers::TimerController timerController;
Pinetime::Controllers::AlarmController alarmController {dateTimeController};
Pinetime::Controllers::TouchHandler touchHandler(touchPanel, lvgl);
Pinetime::Controllers::ButtonHandler buttonHandler;
-
-Pinetime::Controllers::FS fs {spiNorFlash};
-Pinetime::Controllers::Settings settingsController {fs};
-Pinetime::Controllers::MotorController motorController {};
+Pinetime::Controllers::BrightnessController brightnessController {};
Pinetime::Applications::DisplayApp displayApp(lcd,
lvgl,
@@ -129,6 +131,7 @@ Pinetime::Applications::DisplayApp displayApp(lcd,
motionController,
timerController,
alarmController,
+ brightnessController,
touchHandler);
Pinetime::System::SystemTask systemTask(spi,
diff --git a/src/systemtask/Messages.h b/src/systemtask/Messages.h
index 886505b5..ad13244f 100644
--- a/src/systemtask/Messages.h
+++ b/src/systemtask/Messages.h
@@ -21,6 +21,8 @@ namespace Pinetime {
EnableSleeping,
DisableSleeping,
OnNewDay,
+ OnNewHour,
+ OnNewHalfHour,
OnChargingEvent,
OnPairing,
SetOffAlarm,
diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp
index 5ce223a6..75a71ecc 100644
--- a/src/systemtask/SystemTask.cpp
+++ b/src/systemtask/SystemTask.cpp
@@ -1,18 +1,10 @@
#include "systemtask/SystemTask.h"
-#define min // workaround: nimble's min/max macros conflict with libstdc++
-#define max
-#include <host/ble_gap.h>
-#include <host/ble_gatt.h>
-#include <host/ble_hs_adv.h>
-#include <host/util/util.h>
-#include <nimble/hci_common.h>
-#undef max
-#undef min
#include <hal/nrf_rtc.h>
#include <libraries/gpiote/app_gpiote.h>
#include <libraries/log/nrf_log.h>
#include "BootloaderVersion.h"
+#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
#include "drivers/Cst816s.h"
#include "drivers/St7789.h"
@@ -197,13 +189,13 @@ void SystemTask::Work() {
// Touchscreen
nrf_gpio_cfg_sense_input(PinMap::Cst816sIrq,
static_cast<nrf_gpio_pin_pull_t>(GPIO_PIN_CNF_PULL_Pullup),
- static_cast<nrf_gpio_pin_sense_t> GPIO_PIN_CNF_SENSE_Low);
+ static_cast<nrf_gpio_pin_sense_t>(GPIO_PIN_CNF_SENSE_Low));
pinConfig.skip_gpio_setup = true;
pinConfig.hi_accuracy = false;
pinConfig.is_watcher = false;
pinConfig.sense = static_cast<nrf_gpiote_polarity_t>(NRF_GPIOTE_POLARITY_HITOLO);
- pinConfig.pull = static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Pullup;
+ pinConfig.pull = static_cast<nrf_gpio_pin_pull_t>(GPIO_PIN_CNF_PULL_Pullup);
nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler);
@@ -239,6 +231,7 @@ void SystemTask::Work() {
if (!bleController.IsFirmwareUpdating()) {
doNotGoToSleep = false;
}
+ ReloadIdleTimer();
break;
case Messages::DisableSleeping:
doNotGoToSleep = true;
@@ -295,6 +288,9 @@ void SystemTask::Work() {
case Messages::OnNewTime:
ReloadIdleTimer();
displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
+ if (alarmController.State() == Controllers::AlarmController::AlarmState::Set) {
+ alarmController.ScheduleAlarm();
+ }
break;
case Messages::OnNewNotification:
if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::ON) {
@@ -343,18 +339,18 @@ void SystemTask::Work() {
xTimerStart(dimTimer, 0);
break;
case Messages::StartFileTransfer:
- NRF_LOG_INFO("[systemtask] FS Started");
+ NRF_LOG_INFO("[systemtask] FS Started");
doNotGoToSleep = true;
if (isSleeping && !isWakingUp)
GoToRunning();
- //TODO add intent of fs access icon or something
+ // TODO add intent of fs access icon or something
break;
case Messages::StopFileTransfer:
NRF_LOG_INFO("[systemtask] FS Stopped");
doNotGoToSleep = false;
xTimerStart(dimTimer, 0);
- //TODO add intent of fs access icon or something
- break;
+ // TODO add intent of fs access icon or something
+ break;
case Messages::OnTouchEvent:
if (touchHandler.GetNewTouchInfo()) {
touchHandler.UpdateLvglTouchPoint();
@@ -403,6 +399,26 @@ void SystemTask::Work() {
// Remember we'll have to reset the counter next time we're awake
stepCounterMustBeReset = true;
break;
+ case Messages::OnNewHour:
+ using Pinetime::Controllers::AlarmController;
+ if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::Hours && alarmController.State() != AlarmController::AlarmState::Alerting) {
+ if (isSleeping && !isWakingUp) {
+ GoToRunning();
+ displayApp.PushMessage(Pinetime::Applications::Display::Messages::Clock);
+ }
+ motorController.RunForDuration(35);
+ }
+ break;
+ case Messages::OnNewHalfHour:
+ using Pinetime::Controllers::AlarmController;
+ if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours && alarmController.State() != AlarmController::AlarmState::Alerting) {
+ if (isSleeping && !isWakingUp) {
+ GoToRunning();
+ displayApp.PushMessage(Pinetime::Applications::Display::Messages::Clock);
+ }
+ motorController.RunForDuration(35);
+ }
+ break;
case Messages::OnChargingEvent:
batteryController.ReadPowerState();
motorController.RunForDuration(15);
@@ -459,10 +475,10 @@ void SystemTask::UpdateMotion() {
return;
}
- if (isSleeping && !settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist)) {
+ if (isSleeping && !(settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist) ||
+ settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake))) {
return;
}
-
if (stepCounterMustBeReset) {
motionSensor.ResetStepCounter();
stepCounterMustBeReset = false;
@@ -472,7 +488,13 @@ void SystemTask::UpdateMotion() {
motionController.IsSensorOk(motionSensor.IsOk());
motionController.Update(motionValues.x, motionValues.y, motionValues.z, motionValues.steps);
- if (motionController.ShouldWakeUp(isSleeping)) {
+
+ if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist) &&
+ motionController.Should_RaiseWake(isSleeping)) {
+ GoToRunning();
+ }
+ if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake) &&
+ motionController.Should_ShakeWake(settingsController.GetShakeThreshold())) {
GoToRunning();
}
}
diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h
index e2e6de7f..517ed1ae 100644
--- a/src/systemtask/SystemTask.h
+++ b/src/systemtask/SystemTask.h
@@ -3,6 +3,7 @@
#include <memory>
#include <FreeRTOS.h>
+#include <queue.h>
#include <task.h>
#include <timers.h>
#include <heartratetask/HeartRateTask.h>
@@ -12,7 +13,6 @@
#include <components/motion/MotionController.h>
#include "systemtask/SystemMonitor.h"
-#include "components/battery/BatteryController.h"
#include "components/ble/NimbleController.h"
#include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
@@ -46,6 +46,7 @@ namespace Pinetime {
class Hrs3300;
}
namespace Controllers {
+ class Battery;
class TouchHandler;
class ButtonHandler;
}