Compare commits
65 Commits
wadokei-0.
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2105a7b63d | ||
|
|
79ee886904 | ||
|
|
b1d70ae2ed | ||
|
|
a77a3dcb8b | ||
|
|
8aefa3b9a6 | ||
|
|
6c7eb6630e | ||
|
|
4dd0d60eeb | ||
|
|
a2ced5659d | ||
|
|
5ea9c5537e | ||
|
|
f7c87a700d | ||
|
|
e247bd7019 | ||
|
|
29ad09f4ef | ||
|
|
afeded0126 | ||
|
|
57b6db8b2a | ||
|
|
0076962588 | ||
|
|
e6ee548536 | ||
|
|
1808634f0e | ||
|
|
cfaad261dc | ||
|
|
f1651c8000 | ||
|
|
8a2ee437f5 | ||
|
|
06b721a71f | ||
|
|
771008495e | ||
|
|
f032847ae1 | ||
|
|
97ba39988b | ||
|
|
879bdccd92 | ||
|
|
8598142c27 | ||
|
|
a2356f2f4a | ||
|
|
3db4e012ce | ||
|
|
a0cd439efc | ||
|
|
997e4cee8c | ||
|
|
ad3bf49c7b | ||
|
|
7ca0418c82 | ||
|
|
c3d05901a0 | ||
|
|
b3756e45fa | ||
|
|
a266202831 | ||
|
|
c8236afbef | ||
|
|
5040733a97 | ||
|
|
fd019c7aad | ||
|
|
975bfc5420 | ||
|
|
2625ed39e5 | ||
|
|
a3dbcd62f6 | ||
|
|
4fddf93114 | ||
|
|
83922fb3de | ||
|
|
95917c65a5 | ||
|
|
3a0d673df4 | ||
|
|
53dc9dafe7 | ||
|
|
a407902b06 | ||
|
|
3e8accde69 | ||
|
|
2bb611db8e | ||
|
|
ef88e8165c | ||
|
|
da9ab4a7b4 | ||
|
|
0bcd7e0009 | ||
|
|
bf69e0dcc5 | ||
|
|
947c4f5067 | ||
|
|
0960d67001 | ||
|
|
5385f7e275 | ||
|
|
e884b053d3 | ||
|
|
85a2181b64 | ||
|
|
3dca742b65 | ||
|
|
20ac7e8df3 | ||
|
|
f8f8993fac | ||
|
|
fdc3b8badb | ||
|
|
f9a16feeaf | ||
|
|
4930c0cab7 | ||
|
|
a449b272f7 |
29
.github/workflows/main.yml
vendored
@@ -3,7 +3,7 @@ name: CI
|
||||
# Run this workflow whenever the build may be affected
|
||||
on:
|
||||
push:
|
||||
branches: [ main, 'wb/*' ]
|
||||
branches: [ main ]
|
||||
paths-ignore:
|
||||
- 'doc/**'
|
||||
- '**.md'
|
||||
@@ -46,20 +46,30 @@ jobs:
|
||||
# Unzip the package because Upload Artifact will zip up the files
|
||||
- name: Unzip DFU package
|
||||
run: unzip ./build/output/pinetime-mcuboot-app-dfu-*.zip -d ./build/output/pinetime-mcuboot-app-dfu
|
||||
- name: Set ref_name, but replace slashes with dashes.
|
||||
shell: bash
|
||||
env:
|
||||
ref_name: ${{ github.head_ref || github.ref_name }}
|
||||
run: echo "REF_NAME=${ref_name//\//-}" >> $GITHUB_ENV
|
||||
- name: Upload DFU artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: InfiniTime DFU ${{ github.head_ref }}
|
||||
name: InfiniTime DFU ${{ env.REF_NAME }}
|
||||
path: ./build/output/pinetime-mcuboot-app-dfu/*
|
||||
- name: Upload MCUBoot image artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: InfiniTime MCUBoot image ${{ github.head_ref }}
|
||||
name: InfiniTime MCUBoot image ${{ env.REF_NAME }}
|
||||
path: ./build/output/pinetime-mcuboot-app-image-*.bin
|
||||
- name: Upload standalone ELF artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: InfiniTime image ${{ env.REF_NAME }}
|
||||
path: ./build/output/src/pinetime-app-*.out
|
||||
- name: Upload resources artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: InfiniTime resources ${{ github.head_ref }}
|
||||
name: InfiniTime resources ${{ env.REF_NAME }}
|
||||
path: ./build/output/infinitime-resources-*.zip
|
||||
|
||||
build-simulator:
|
||||
@@ -88,15 +98,6 @@ jobs:
|
||||
git clone https://github.com/InfiniTimeOrg/InfiniSim.git --depth 1 --branch main
|
||||
git -C InfiniSim submodule update --init lv_drivers
|
||||
|
||||
- name: Add sunset lib to InfiniSim
|
||||
run: patch -i docker/infinisim-cmake.patch InfiniSim/CMakeLists.txt
|
||||
|
||||
- name: Remove Terminal from InfiniSim
|
||||
run: patch -i docker/infinisim-terminal.patch InfiniSim/littlefs-do-main.cpp
|
||||
|
||||
- name: Remove Digital from InfiniSim
|
||||
run: patch -i docker/infinisim-main.patch InfiniSim/main.cpp
|
||||
|
||||
- name: CMake
|
||||
# disable BUILD_RESOURCES as this is already done when building the firmware
|
||||
run: |
|
||||
@@ -109,7 +110,7 @@ jobs:
|
||||
- name: Upload simulator executable
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: infinisim-${{ github.head_ref }}
|
||||
name: infinisim-${{ env.REF_NAME }}
|
||||
path: build_lv_sim/infinisim
|
||||
|
||||
get-base-ref-size:
|
||||
|
||||
2
.gitignore
vendored
@@ -50,5 +50,3 @@ src/arm-none-eabi
|
||||
|
||||
# clangd
|
||||
.cache/
|
||||
|
||||
nRF5_SDK/
|
||||
|
||||
6
.gitmodules
vendored
@@ -4,12 +4,6 @@
|
||||
[submodule "src/libs/littlefs"]
|
||||
path = src/libs/littlefs
|
||||
url = https://github.com/littlefs-project/littlefs.git
|
||||
[submodule "src/libs/QCBOR"]
|
||||
path = src/libs/QCBOR
|
||||
url = https://github.com/laurencelundblade/QCBOR.git
|
||||
[submodule "src/libs/arduinoFFT"]
|
||||
path = src/libs/arduinoFFT
|
||||
url = https://github.com/kosme/arduinoFFT.git
|
||||
[submodule "src/libs/sunset"]
|
||||
path = src/libs/sunset
|
||||
url = https://github.com/buelowp/sunset.git
|
||||
|
||||
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose Debug or Release")
|
||||
|
||||
project(pinetime VERSION 1.14.0 LANGUAGES C CXX ASM)
|
||||
project(pinetime VERSION 1.15.0 LANGUAGES C CXX ASM)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
41
README.md
@@ -1,37 +1,50 @@
|
||||
# [InfiniTime](https://github.com/InfiniTimeOrg/InfiniTime)
|
||||
<div align="center">
|
||||
|
||||

|
||||

|
||||
|
||||
Fast open-source firmware for the [PineTime smartwatch](https://pine64.org/devices/pinetime/) with many features, written in modern C++.
|
||||
<br>
|
||||
|
||||
## Wadokei fork
|
||||
[](https://github.com/InfiniTimeOrg/InfiniTime/releases)
|
||||
[](https://github.com/InfiniTimeOrg/InfiniLink/blob/main/LICENSE)
|
||||
[](https://github.com/InfiniTimeOrg/InfiniTime/issues)
|
||||
[](https://github.com/InfiniTimeOrg/InfiniTime/pulls)
|
||||
[](https://github.com/InfiniTimeOrg/InfiniTime)
|
||||
[](https://github.com/InfiniTimeOrg/InfiniTime/stargazers)
|
||||
[](https://github.com/InfiniTimeOrg/InfiniTime/network/members)
|
||||
|
||||
Based on [Sudrien's Watchy Wadokei](https://github.com/Sudrien/watchy_wadokei) --
|
||||
displays an Edo-period Japanese clock face and a sunrise/sunset-based hour hand.
|
||||
# InfiniTime
|
||||
|
||||
Also chimes hours according to the number on the face (9,8,7,6,5,4) at the top
|
||||
of each modern hour (so noon and 1pm will be 9 chimes, 2pm and 3pm will be 8, etc).
|
||||
*Fast open-source firmware for the [PineTime smartwatch](https://pine64.org/devices/pinetime/) with many features, written in modern C++.*
|
||||
|
||||
See https://github.com/Sudrien/watchy_wadokei/blob/main/Reckoning.md for more ideas!
|
||||
<br>
|
||||
|
||||
</div>
|
||||
|
||||
## New to InfiniTime?
|
||||
|
||||
- [Getting started with InfiniTime](doc/gettingStarted/gettingStarted-1.0.md)
|
||||
- [Updating the software](doc/gettingStarted/updating-software.md)
|
||||
- [About the firmware and bootloader](doc/gettingStarted/about-software.md)
|
||||
- [PineTimeStyle Watch face](https://wiki.pine64.org/wiki/PineTimeStyle)
|
||||
- [Weather integration](https://wiki.pine64.org/wiki/Infinitime-Weather)
|
||||
- [Available apps](doc/gettingStarted/Applications.md)
|
||||
- [Available watch faces](/doc/gettingStarted/Watchfaces.md)
|
||||
- [PineTimeStyle Watch face](https://pine64.org/documentation/PineTime/Watchfaces/PineTimeStyle)
|
||||
- [Weather integration](https://pine64.org/documentation/PineTime/Software/InfiniTime_weather/)
|
||||
|
||||
### Companion apps
|
||||
|
||||
- [Gadgetbridge](https://gadgetbridge.org/) (Android)
|
||||
- [AmazFish](https://openrepos.net/content/piggz/amazfish/) (SailfishOS)
|
||||
- [Amazfish](https://github.com/piggz/harbour-amazfish/) ([SailfishOS](https://sailfishos-chum.github.io/apps/harbour-amazfish/), [Ubuntu Touch](https://open-store.io/app/uk.co.piggz.amazfish), [Flatpak](https://flathub.org/apps/uk.co.piggz.amazfish))
|
||||
- [Siglo](https://github.com/alexr4535/siglo) (Linux)
|
||||
- [InfiniLink](https://github.com/InfiniTimeOrg/InfiniLink) (iOS)
|
||||
- [ITD](https://gitea.elara.ws/Elara6331/itd) (Linux)
|
||||
- [WatchMate](https://github.com/azymohliad/watchmate) (Linux)
|
||||
- [InfiniTimeExplorer](https://infinitimeexplorer.netlify.app) (Web)
|
||||
|
||||
***Note**: We removed mentions to NRFConnect as this app is closed source and recent versions do not work anymore with InfiniTime (the last version known to work is 4.24.3). If you used NRFConnect in the past, we recommend you switch to [Gadgetbridge](https://gadgetbridge.org/).*
|
||||
<br>
|
||||
|
||||
> *InfiniTimeExplorer is only compatible with web browsers that support Web BLE. Current fully supported browsers include Chrome and Microsoft Edge.*
|
||||
>
|
||||
> *We removed mentions to NRFConnect as this app is closed source and recent versions do not work anymore with InfiniTime (the last version known to work is 4.24.3). If you used NRFConnect in the past, we recommend you switch to [Gadgetbridge](https://gadgetbridge.org/).*
|
||||
|
||||
## Development
|
||||
|
||||
@@ -45,7 +58,7 @@ See https://github.com/Sudrien/watchy_wadokei/blob/main/Reckoning.md for more id
|
||||
|
||||
### Contributing
|
||||
|
||||
- [How to contribute?](CONTRIBUTING.md)
|
||||
- [How to contribute](CONTRIBUTING.md)
|
||||
- [Coding conventions](doc/coding-convention.md)
|
||||
|
||||
### Build, flash and debug
|
||||
|
||||
99
doc/gettingStarted/Applications.md
Normal file
@@ -0,0 +1,99 @@
|
||||
# Applications
|
||||
|
||||
InfiniTime has 13 apps on the `main` branch at the time of writing.
|
||||
|
||||
## List of apps
|
||||
- Stopwatch
|
||||
- Alarm
|
||||
- Timer
|
||||
- Steps
|
||||
- Heartrate
|
||||
- Music
|
||||
- InfiniPaint
|
||||
- Paddle
|
||||
- 2
|
||||
- InfiniDice
|
||||
- Metronome
|
||||
- Maps
|
||||
- Weather
|
||||
|
||||
### Stopwatch
|
||||

|
||||
- Press the Start button (bottom right) to start or stop the timer.
|
||||
- You can also press the side button while the timer is running to pause the timer.
|
||||
- Press the Flag button (bottom left) to add a lap.
|
||||
- The stopwatch will not yet continue counting time while the app is closed.
|
||||
|
||||
### Alarm
|
||||

|
||||
- Ajust the time with the time picker.
|
||||
- Press the Info button in the top middle to see time remaning.
|
||||
- Use the toggle in the bottom left to turn the alarm on/off.
|
||||
- Use the button in the bottom right to change the alarm frequency.
|
||||
- You can choose between once, daily, or Monday - Friday.
|
||||
|
||||
### Timer
|
||||

|
||||
- Ajust how long the timer should go for with the time picker.
|
||||
- Press the Start button at the bottom to start/stop the timer.
|
||||
|
||||
### Steps
|
||||

|
||||
- The total count of steps for the current display will show in the middle of the screen.
|
||||
- The Reset button in the bottom middle resets the Trip counter. (Total of all steps taken.)
|
||||
- The progress circle shows the percentage of your daily goal completed.
|
||||
|
||||
### Heartrate
|
||||

|
||||
- Press Start to start measuring your heartrate.
|
||||
- It may take a bit to get the first measurement.
|
||||
|
||||
### Music
|
||||

|
||||
- This app shows currently playing music.
|
||||
- Please note that this app is not very useful without a device connected.
|
||||
- Press the button in the center to play/pause, and the buttons on the left and right to go to the previous and next tracks, respectively.
|
||||
- Swipe up to get to volume controls.
|
||||
|
||||
### InfiniPaint
|
||||

|
||||
- This app does not allow you to swipe from the top to exit, use the side button instead.
|
||||
- Draw on the screen to add lines.
|
||||
- Hold down in one spot to change paint colors.
|
||||
|
||||
### Paddle
|
||||

|
||||
- This app does not allow you to swipe from the top to exit, use the side button instead.
|
||||
- Drag your finger to move the paddle.
|
||||
- Goal: Don't let the ball go off the left side of the screen.
|
||||
|
||||
### 2
|
||||

|
||||
- This app does not allow you to swipe from the top to exit, use the side button instead.
|
||||
- Play a game of 2048.
|
||||
- Swipe up, down, left, or right tomove the tiles.
|
||||
- When two tiles with the same number run into each other, they will add together.
|
||||
- Goal: Don't let the screen fill up with tiles, and get to the 2048 tile to win.
|
||||
|
||||
### InfiniDice
|
||||

|
||||
- Ajust the count to change the number of dice.
|
||||
- Ajust the sides to change the number of sides.
|
||||
- Press the button at the bottom to roll.
|
||||
- The result will be on the right side of the screen.
|
||||
|
||||
### Metronome
|
||||

|
||||
- Ajust the BPM with the circular slider.
|
||||
- A bug currently makes it always snap to 98 BPM.
|
||||
- Use the button in the bottom left to start the metronome.
|
||||
|
||||
### Maps
|
||||

|
||||
- This app shows info from a navigation app.
|
||||
- Please note that this app is not very useful without a device connected.
|
||||
|
||||
### Weather
|
||||

|
||||
- This app shows weather info.
|
||||
- Please note that this app is not very useful without a device connected.
|
||||
BIN
doc/gettingStarted/AppsScreenshots/2048.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
doc/gettingStarted/AppsScreenshots/Dice.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
doc/gettingStarted/AppsScreenshots/Heartrate.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
doc/gettingStarted/AppsScreenshots/Maps.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
doc/gettingStarted/AppsScreenshots/Metronome.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
doc/gettingStarted/AppsScreenshots/Music.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
doc/gettingStarted/AppsScreenshots/Paint.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
doc/gettingStarted/AppsScreenshots/Pong.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
doc/gettingStarted/AppsScreenshots/Weather.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
doc/gettingStarted/AppsScreenshots/alarm.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
doc/gettingStarted/AppsScreenshots/steps.png
Normal file
|
After Width: | Height: | Size: 6.8 KiB |
BIN
doc/gettingStarted/AppsScreenshots/stopwatch.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
doc/gettingStarted/AppsScreenshots/timer.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
31
doc/gettingStarted/Watchfaces.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Watchfaces
|
||||
|
||||
InfiniTime has 6 apps on the `main` branch at the time of writing.
|
||||
|
||||
## List of apps
|
||||
- Digital
|
||||
- Analog
|
||||
- PineTimeStyle
|
||||
- Terminal
|
||||
- Infinineat
|
||||
- Casio G7710
|
||||
|
||||
### Digital
|
||||

|
||||
|
||||
### Analog
|
||||

|
||||
|
||||
### PineTimeStyle
|
||||

|
||||
- You can long-press on the display to change colors, step style, and weather.
|
||||
|
||||
### Terminal
|
||||

|
||||
|
||||
### Infinineat
|
||||

|
||||
- You can long-press on the display to change colors.
|
||||
|
||||
### Casio G7710
|
||||

|
||||
BIN
doc/gettingStarted/Watchfaces/Analog.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
doc/gettingStarted/Watchfaces/CasioG7710.png
Normal file
|
After Width: | Height: | Size: 6.4 KiB |
BIN
doc/gettingStarted/Watchfaces/Digital.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
doc/gettingStarted/Watchfaces/Infinineat.png
Normal file
|
After Width: | Height: | Size: 8.9 KiB |
BIN
doc/gettingStarted/Watchfaces/PineTimeStyle.png
Normal file
|
After Width: | Height: | Size: 6.4 KiB |
BIN
doc/gettingStarted/Watchfaces/Terminal.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 127 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 104 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 124 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 256 KiB |
@@ -14,7 +14,7 @@ You can sync the time using companion apps.
|
||||
|
||||
- Gadgetbridge automatically synchronizes the time when you connect it to your watch. More information on Gadgetbridge [here](/doc/gettingStarted/ota-gadgetbridge.md)
|
||||
- [Sync the time with NRFConnect](/doc/gettingStarted/time-nrfconnect.md)
|
||||
- Sync the time with your browser https://hubmartin.github.io/WebBLEWatch/
|
||||
- [Sync the time with your browser](https://hubmartin.github.io/WebBLEWatch/)
|
||||
|
||||
You can also set the time in the settings without a companion app. (version >1.7.0)
|
||||
|
||||
@@ -46,7 +46,7 @@ On the bottom right, you can see how many steps you have taken today.
|
||||

|
||||
|
||||
- Swipe **up** to display the application menus. Apps (stopwatch, music, step, games,...) can be started from this menu.
|
||||
- Swipe **down** to display the notification panel. Notification sent by your companion app will be displayed here.
|
||||
- Swipe **down** to display the notification panel. Notifications sent by your companion app will be displayed here.
|
||||
- Swipe **right** to display the Quick Actions menu. This menu allows you to
|
||||
- Set the brightness of the display
|
||||
- Start the **flashlight** app
|
||||
|
||||
@@ -1,29 +1,35 @@
|
||||
# Connecting to Gadgetbridge
|
||||
|
||||
Launch Gadgetbridge and tap on the **"+"** button on the bottom right to add a new device:
|
||||
Launch Gadgetbridge and tap on the menu button in the top left:
|
||||
|
||||

|
||||
|
||||
Wait for the scan to complete, your PineTime should be detected:
|
||||
Press the "Connect new device" button:
|
||||
|
||||

|
||||
|
||||
Your PineTime should appear on the list. Tap on it.
|
||||
|
||||
Tap on it. Gadgdetbridge will pair and connect to your device:
|
||||
|
||||

|
||||
|
||||
# Updating with Gadgetbridge
|
||||
|
||||
Now that Gadgetbridge is connected to your PineTime, use a file browser application and find the DFU file (`pinetime-mcuboot-app-dfu-x.x.x.zip`) you downloaded previously. Tap on it and open it using the Gadgetbridge application/firmware installer:
|
||||
Now that Gadgetbridge is connected to your PineTime, press the three dots on the device card:
|
||||
|
||||

|
||||
|
||||
Read the warning carefully and tap **Install**:
|
||||
Now press the "File Installer" button:
|
||||
|
||||

|
||||
|
||||
Wait for the transfer to finish. Your PineTime should reset and reboot with the new version of InfiniTime!
|
||||
|
||||
Don't forget to **validate** your firmware. In the InfiniTime go to the settings (swipe right, select gear icon) and Firmware option and click **validate**. Otherwise after reboot the previous firmware will be used.
|
||||
Select the firmware you downloaded (`pinetime-mcuboot-app-dfu-x.x.x.zip`) from the [Releases tab](https://github.com/InfiniTimeOrg/InfiniTime/releases/latest):
|
||||
|
||||

|
||||
|
||||
Wait for the transfer to finish. There will be a progress bar on both the watch and the phone. Your PineTime should reboot with the new version of InfiniTime!
|
||||
|
||||
Don't forget to **validate** your firmware. In the InfiniTime go to the settings (swipe right, select gear icon) and scroll to the Firmware option and click **validate**. Otherwise, after reboot the previous firmware will be used.
|
||||
|
||||

|
||||
|
||||
@@ -6,7 +6,7 @@ If you just want to flash or upgrade InfiniTime on your PineTime, this page is f
|
||||
|
||||
You can check the InfiniTime version by first swiping right on the watch face to open quick settings, tapping the cogwheel to open settings, swipe up until you find an entry named "About" and tap on it.
|
||||
|
||||

|
||||

|
||||
|
||||
PineTimes shipped after June 2021 will ship with the latest version of [the bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader/releases/tag/1.0.0) and [recovery firmware](https://github.com/InfiniTimeOrg/InfiniTime/releases/tag/0.14.1)
|
||||
|
||||
|
||||
BIN
doc/gettingStarted/validate.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
doc/gettingStarted/version.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
doc/logo/watchface_collage.png
Normal file
|
After Width: | Height: | Size: 846 KiB |
@@ -65,5 +65,8 @@ RUN bash -c "source /opt/build.sh; GetMcuBoot;"
|
||||
# Add the infinitime user for connecting devcontainer
|
||||
RUN adduser infinitime
|
||||
|
||||
# Configure Git to accept the /sources directory as safe
|
||||
RUN git config --global --add safe.directory /sources
|
||||
|
||||
ENV SOURCES_DIR /sources
|
||||
CMD ["/opt/build.sh"]
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index edd6748..641b74a 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -243,6 +243,14 @@ add_library(littlefs STATIC
|
||||
target_include_directories(littlefs PUBLIC "${InfiniTime_DIR}/src/libs/littlefs")
|
||||
target_link_libraries(infinisim PRIVATE littlefs)
|
||||
|
||||
+# sunset
|
||||
+add_library(sunset STATIC
|
||||
+ ${InfiniTime_DIR}/src/libs/sunset/src/sunset.h
|
||||
+ ${InfiniTime_DIR}/src/libs/sunset/src/sunset.cpp
|
||||
+)
|
||||
+target_include_directories(sunset PUBLIC "${InfiniTime_DIR}/src/libs/sunset")
|
||||
+target_link_libraries(infinisim PRIVATE sunset)
|
||||
+
|
||||
# QCBOR
|
||||
add_library(QCBOR STATIC
|
||||
${InfiniTime_DIR}/src/libs/QCBOR/src/ieee754.c
|
||||
@@ -1,20 +0,0 @@
|
||||
diff --git a/main.cpp b/main.cpp
|
||||
index 8070db7..530ff4b 100644
|
||||
--- a/main.cpp
|
||||
+++ b/main.cpp
|
||||
@@ -823,14 +823,10 @@ public:
|
||||
void switch_to_screen(uint8_t screen_idx)
|
||||
{
|
||||
if (screen_idx == 1) {
|
||||
- settingsController.SetWatchFace(Pinetime::Applications::WatchFace::Digital);
|
||||
- displayApp.StartApp(Pinetime::Applications::Apps::Clock, Pinetime::Applications::DisplayApp::FullRefreshDirections::None);
|
||||
- }
|
||||
- else if (screen_idx == 2) {
|
||||
settingsController.SetWatchFace(Pinetime::Applications::WatchFace::Analog);
|
||||
displayApp.StartApp(Pinetime::Applications::Apps::Clock, Pinetime::Applications::DisplayApp::FullRefreshDirections::None);
|
||||
}
|
||||
- else if (screen_idx == 3) {
|
||||
+ else if (screen_idx == 2) {
|
||||
settingsController.SetWatchFace(Pinetime::Applications::WatchFace::PineTimeStyle);
|
||||
displayApp.StartApp(Pinetime::Applications::Apps::Clock, Pinetime::Applications::DisplayApp::FullRefreshDirections::None);
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
diff --git a/littlefs-do-main.cpp b/littlefs-do-main.cpp
|
||||
index 0a5dfbd..3e818af 100644
|
||||
--- a/littlefs-do-main.cpp
|
||||
+++ b/littlefs-do-main.cpp
|
||||
@@ -537,10 +537,10 @@ int command_settings(const std::string &program_name, const std::vector<std::str
|
||||
{
|
||||
auto clockface = settingsController.GetWatchFace();
|
||||
auto clockface_str = [](auto val) {
|
||||
- if (val == Pinetime::Applications::WatchFace::Digital) return "Digital";
|
||||
+ //if (val == Pinetime::Applications::WatchFace::Digital) return "Digital";
|
||||
if (val == Pinetime::Applications::WatchFace::Analog) return "Analog";
|
||||
if (val == Pinetime::Applications::WatchFace::PineTimeStyle) return "PineTimeStyle";
|
||||
- if (val == Pinetime::Applications::WatchFace::Terminal) return "Terminal";
|
||||
+ //if (val == Pinetime::Applications::WatchFace::Terminal) return "Terminal";
|
||||
return "unknown";
|
||||
}(clockface);
|
||||
std::cout << "ClockFace: " << static_cast<uint32_t>(clockface) << " " << clockface_str << std::endl;
|
||||
50
shell.nix
@@ -1,50 +0,0 @@
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
with pkgs; let
|
||||
py4McuBoot = python3.withPackages (ps: with ps; [
|
||||
cbor
|
||||
intelhex
|
||||
click
|
||||
cryptography
|
||||
pillow
|
||||
]);
|
||||
lv_img_convWrapper = pkgs.writeScriptBin "lv_img_conv" ''
|
||||
npm install lv_img_conv
|
||||
nodejs node_modules/lv_img_conv/lv_img_conv.js
|
||||
'';
|
||||
buildInfinitime = pkgs.writeScriptBin "build-infinitime" ''
|
||||
mkdir -p build/
|
||||
cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=$ARM_NONE_EABI_TOOLCHAIN_PATH \
|
||||
-DNRF5_SDK_PATH=$NRF5_SDK_PATH \
|
||||
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
|
||||
-DBUILD_DFU=$BUILD_DFU \
|
||||
-DBUILD_RESOURCES=$BUILD_RESOURCES \
|
||||
-DTARGET_DEVICE=$TARGET_DEVICE \
|
||||
-S . -B build
|
||||
cmake --build build -j6
|
||||
'';
|
||||
in mkShell {
|
||||
packages = [
|
||||
gcc-arm-embedded-10
|
||||
nrf5-sdk
|
||||
cmake
|
||||
nodePackages.lv_font_conv
|
||||
lv_img_convWrapper
|
||||
# lv_img_conv
|
||||
nodejs
|
||||
py4McuBoot
|
||||
clang-tools
|
||||
SDL2
|
||||
libpng
|
||||
adafruit-nrfutil
|
||||
buildInfinitime
|
||||
# watchmate # wish this worked -- use flatpak run io.gitlab.azymohliad.WatchMate
|
||||
];
|
||||
|
||||
ARM_NONE_EABI_TOOLCHAIN_PATH="${gcc-arm-embedded-10}";
|
||||
NRF5_SDK_PATH="${nrf5-sdk}/share/nRF5_SDK";
|
||||
CMAKE_BUILD_TYPE="Release";
|
||||
BUILD_DFU=1;
|
||||
BUILD_RESOURCES=1;
|
||||
TARGET_DEVICE="PINETIME";
|
||||
}
|
||||
@@ -174,11 +174,6 @@ set(LITTLEFS_SRC
|
||||
libs/littlefs/lfs.c
|
||||
)
|
||||
|
||||
set(SUNSET_SRC
|
||||
libs/sunset/src/sunset.h
|
||||
libs/sunset/src/sunset.cpp
|
||||
)
|
||||
|
||||
set(LVGL_SRC
|
||||
libs/lv_conf.h
|
||||
libs/lvgl/lvgl.h
|
||||
@@ -371,6 +366,8 @@ list(APPEND SOURCE_FILES
|
||||
displayapp/DisplayApp.cpp
|
||||
displayapp/screens/Screen.cpp
|
||||
displayapp/screens/Tile.cpp
|
||||
displayapp/screens/InfiniPaint.cpp
|
||||
displayapp/screens/Paddle.cpp
|
||||
displayapp/screens/StopWatch.cpp
|
||||
displayapp/screens/BatteryIcon.cpp
|
||||
displayapp/screens/BleIcon.cpp
|
||||
@@ -379,9 +376,14 @@ list(APPEND SOURCE_FILES
|
||||
displayapp/screens/Label.cpp
|
||||
displayapp/screens/FirmwareUpdate.cpp
|
||||
displayapp/screens/Music.cpp
|
||||
displayapp/screens/Navigation.cpp
|
||||
displayapp/screens/Metronome.cpp
|
||||
displayapp/screens/Motion.cpp
|
||||
displayapp/screens/Weather.cpp
|
||||
displayapp/screens/FirmwareValidation.cpp
|
||||
displayapp/screens/ApplicationList.cpp
|
||||
displayapp/screens/Notifications.cpp
|
||||
displayapp/screens/Twos.cpp
|
||||
displayapp/screens/HeartRate.cpp
|
||||
displayapp/screens/FlashLight.cpp
|
||||
displayapp/screens/List.cpp
|
||||
@@ -413,21 +415,17 @@ list(APPEND SOURCE_FILES
|
||||
displayapp/screens/settings/SettingSetDateTime.cpp
|
||||
displayapp/screens/settings/SettingSetDate.cpp
|
||||
displayapp/screens/settings/SettingSetTime.cpp
|
||||
displayapp/screens/settings/SettingLocation.cpp
|
||||
displayapp/screens/settings/SettingChimes.cpp
|
||||
displayapp/screens/settings/SettingShakeThreshold.cpp
|
||||
displayapp/screens/settings/SettingBluetooth.cpp
|
||||
displayapp/screens/settings/SettingLocation.cpp
|
||||
|
||||
## Watch faces
|
||||
displayapp/screens/WatchFaceAnalog.cpp
|
||||
#displayapp/screens/WatchFaceDigital.cpp
|
||||
#displayapp/screens/WatchFaceInfineat.cpp
|
||||
#displayapp/screens/WatchFaceTerminal.cpp
|
||||
displayapp/screens/WatchFaceDigital.cpp
|
||||
displayapp/screens/WatchFaceInfineat.cpp
|
||||
displayapp/screens/WatchFaceTerminal.cpp
|
||||
displayapp/screens/WatchFacePineTimeStyle.cpp
|
||||
#displayapp/screens/WatchFaceCasioStyleG7710.cpp
|
||||
#displayapp/screens/WatchFaceFuzzy.cpp
|
||||
#displayapp/screens/WatchFaceSundial.cpp
|
||||
displayapp/screens/WatchFaceCasioStyleG7710.cpp
|
||||
|
||||
##
|
||||
|
||||
@@ -480,6 +478,7 @@ list(APPEND SOURCE_FILES
|
||||
|
||||
systemtask/SystemTask.cpp
|
||||
systemtask/SystemMonitor.cpp
|
||||
systemtask/WakeLock.cpp
|
||||
drivers/TwiMaster.cpp
|
||||
|
||||
heartratetask/HeartRateTask.cpp
|
||||
@@ -544,6 +543,7 @@ list(APPEND RECOVERY_SOURCE_FILES
|
||||
|
||||
systemtask/SystemTask.cpp
|
||||
systemtask/SystemMonitor.cpp
|
||||
systemtask/WakeLock.cpp
|
||||
drivers/TwiMaster.cpp
|
||||
components/rle/RleDecoder.cpp
|
||||
components/heartrate/HeartRateController.cpp
|
||||
@@ -592,7 +592,9 @@ set(INCLUDE_FILES
|
||||
displayapp/TouchEvents.h
|
||||
displayapp/screens/Screen.h
|
||||
displayapp/screens/Tile.h
|
||||
displayapp/screens/InfiniPaint.h
|
||||
displayapp/screens/StopWatch.h
|
||||
displayapp/screens/Paddle.h
|
||||
displayapp/screens/BatteryIcon.h
|
||||
displayapp/screens/BleIcon.h
|
||||
displayapp/screens/NotificationIcon.h
|
||||
@@ -606,7 +608,11 @@ set(INCLUDE_FILES
|
||||
displayapp/Apps.h
|
||||
displayapp/screens/Notifications.h
|
||||
displayapp/screens/HeartRate.h
|
||||
displayapp/screens/Metronome.h
|
||||
displayapp/screens/Motion.h
|
||||
displayapp/screens/Timer.h
|
||||
displayapp/screens/Dice.h
|
||||
displayapp/screens/Alarm.h
|
||||
displayapp/Colors.h
|
||||
displayapp/widgets/Counter.h
|
||||
displayapp/widgets/PageIndicator.h
|
||||
@@ -656,6 +662,7 @@ set(INCLUDE_FILES
|
||||
displayapp/InfiniTimeTheme.h
|
||||
systemtask/SystemTask.h
|
||||
systemtask/SystemMonitor.h
|
||||
systemtask/WakeLock.h
|
||||
displayapp/screens/Symbols.h
|
||||
drivers/TwiMaster.h
|
||||
heartratetask/HeartRateTask.h
|
||||
@@ -770,7 +777,7 @@ link_directories(
|
||||
set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -ftree-vrp -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin -fshort-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fstack-usage -fno-exceptions -fno-non-call-exceptions)
|
||||
set(WARNING_FLAGS -Wall -Wextra -Warray-bounds=2 -Wformat=2 -Wformat-overflow=2 -Wformat-truncation=2 -Wformat-nonliteral -Wno-missing-field-initializers -Wno-unknown-pragmas -Wno-expansion-to-defined -Wreturn-type -Werror=return-type -Werror)
|
||||
set(DEBUG_FLAGS -Og -g3)
|
||||
set(DEBUG_FLAGS -Os)
|
||||
set(RELEASE_FLAGS -Os)
|
||||
set(CXX_FLAGS -fno-rtti)
|
||||
set(ASM_FLAGS -x assembler-with-cpp)
|
||||
add_definitions(-DCONFIG_GPIO_AS_PINRESET)
|
||||
@@ -839,7 +846,7 @@ add_subdirectory(displayapp/fonts)
|
||||
target_compile_options(infinitime_fonts PUBLIC
|
||||
${COMMON_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${RELEASE_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CXX>: ${CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
)
|
||||
@@ -853,10 +860,9 @@ target_include_directories(nrf-sdk SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
|
||||
target_compile_options(nrf-sdk PRIVATE
|
||||
${COMMON_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${RELEASE_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CXX>: ${CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
-O3
|
||||
)
|
||||
|
||||
# NimBLE
|
||||
@@ -866,7 +872,7 @@ target_include_directories(nimble SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
|
||||
target_compile_options(nimble PRIVATE
|
||||
${COMMON_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${RELEASE_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CXX>: ${CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
)
|
||||
@@ -878,7 +884,7 @@ target_include_directories(lvgl SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
|
||||
target_compile_options(lvgl PRIVATE
|
||||
${COMMON_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${RELEASE_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CXX>: ${CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
)
|
||||
@@ -888,30 +894,6 @@ add_library(littlefs STATIC ${LITTLEFS_SRC})
|
||||
target_include_directories(littlefs SYSTEM PUBLIC . ../)
|
||||
target_include_directories(littlefs SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
|
||||
target_compile_options(littlefs PRIVATE
|
||||
${COMMON_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${DEBUG_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CXX>: ${CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
)
|
||||
|
||||
# SUNSET_SRC
|
||||
add_library(sunset STATIC ${SUNSET_SRC})
|
||||
target_include_directories(sunset SYSTEM PUBLIC . ../)
|
||||
target_include_directories(sunset SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
|
||||
target_compile_options(sunset PRIVATE
|
||||
${COMMON_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${DEBUG_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CXX>: ${CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
)
|
||||
|
||||
# SUNSET_SRC
|
||||
add_library(sunset STATIC ${SUNSET_SRC})
|
||||
target_include_directories(sunset SYSTEM PUBLIC . ../)
|
||||
target_include_directories(sunset SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
|
||||
target_compile_options(sunset PRIVATE
|
||||
${COMMON_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${RELEASE_FLAGS}>
|
||||
@@ -925,12 +907,12 @@ set(EXECUTABLE_FILE_NAME ${EXECUTABLE_NAME}-${pinetime_VERSION_MAJOR}.${pinetime
|
||||
set(NRF5_LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/gcc_nrf52.ld")
|
||||
add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES})
|
||||
set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FILE_NAME})
|
||||
target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl littlefs sunset infinitime_fonts infinitime_apps)
|
||||
target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl littlefs infinitime_fonts infinitime_apps)
|
||||
target_compile_options(${EXECUTABLE_NAME} PUBLIC
|
||||
${COMMON_FLAGS}
|
||||
${WARNING_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${RELEASE_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CXX>: ${CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
)
|
||||
@@ -959,13 +941,13 @@ set(IMAGE_MCUBOOT_FILE_NAME_BIN ${EXECUTABLE_MCUBOOT_NAME}-image-${pinetime_VERS
|
||||
set(DFU_MCUBOOT_FILE_NAME ${EXECUTABLE_MCUBOOT_NAME}-dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip)
|
||||
set(NRF5_LINKER_SCRIPT_MCUBOOT "${CMAKE_SOURCE_DIR}/gcc_nrf52-mcuboot.ld")
|
||||
add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES})
|
||||
target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl littlefs sunset infinitime_fonts infinitime_apps)
|
||||
target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl littlefs infinitime_fonts infinitime_apps)
|
||||
set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_FILE_NAME})
|
||||
target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC
|
||||
${COMMON_FLAGS}
|
||||
${WARNING_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${RELEASE_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CXX>: ${CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
)
|
||||
@@ -1001,14 +983,14 @@ endif()
|
||||
set(EXECUTABLE_RECOVERY_NAME "pinetime-recovery")
|
||||
set(EXECUTABLE_RECOVERY_FILE_NAME ${EXECUTABLE_RECOVERY_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH})
|
||||
add_executable(${EXECUTABLE_RECOVERY_NAME} ${RECOVERY_SOURCE_FILES})
|
||||
target_link_libraries(${EXECUTABLE_RECOVERY_NAME} nimble nrf-sdk littlefs sunset infinitime_fonts infinitime_apps)
|
||||
target_link_libraries(${EXECUTABLE_RECOVERY_NAME} nimble nrf-sdk littlefs infinitime_fonts infinitime_apps)
|
||||
set_target_properties(${EXECUTABLE_RECOVERY_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_FILE_NAME})
|
||||
target_compile_definitions(${EXECUTABLE_RECOVERY_NAME} PUBLIC "PINETIME_IS_RECOVERY")
|
||||
target_compile_options(${EXECUTABLE_RECOVERY_NAME} PUBLIC
|
||||
${COMMON_FLAGS}
|
||||
${WARNING_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${RELEASE_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CXX>: ${CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
)
|
||||
@@ -1033,14 +1015,14 @@ set(IMAGE_RECOVERY_MCUBOOT_FILE_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}-image-$
|
||||
set(IMAGE_RECOVERY_MCUBOOT_FILE_NAME_HEX ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME}.hex)
|
||||
set(DFU_RECOVERY_MCUBOOT_FILE_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}-dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip)
|
||||
add_executable(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} ${RECOVERY_SOURCE_FILES})
|
||||
target_link_libraries(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} nimble nrf-sdk littlefs sunset infinitime_fonts infinitime_apps)
|
||||
target_link_libraries(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} nimble nrf-sdk littlefs infinitime_fonts infinitime_apps)
|
||||
set_target_properties(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME})
|
||||
target_compile_definitions(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC "PINETIME_IS_RECOVERY")
|
||||
target_compile_options(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC
|
||||
${COMMON_FLAGS}
|
||||
${WARNING_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${RELEASE_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CXX>: ${CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
)
|
||||
@@ -1079,7 +1061,7 @@ target_compile_options(${EXECUTABLE_RECOVERYLOADER_NAME} PUBLIC
|
||||
${COMMON_FLAGS}
|
||||
${WARNING_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${RELEASE_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CXX>: ${CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
)
|
||||
@@ -1114,7 +1096,7 @@ target_compile_options(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PUBLIC
|
||||
${COMMON_FLAGS}
|
||||
${WARNING_FLAGS}
|
||||
$<$<CONFIG:DEBUG>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${DEBUG_FLAGS}>
|
||||
$<$<CONFIG:RELEASE>: ${RELEASE_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CXX>: ${CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: ${ASM_FLAGS}>
|
||||
)
|
||||
|
||||
@@ -62,8 +62,7 @@
|
||||
#define configTICK_RATE_HZ 1024
|
||||
#define configMAX_PRIORITIES (3)
|
||||
#define configMINIMAL_STACK_SIZE (120)
|
||||
// how much heap can one smartwatch need, michael, 40kb?
|
||||
#define configTOTAL_HEAP_SIZE (1024 * 39)
|
||||
#define configTOTAL_HEAP_SIZE (1024 * 40)
|
||||
#define configMAX_TASK_NAME_LEN (4)
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
#include "systemtask/SystemTask.h"
|
||||
#include "task.h"
|
||||
#include <chrono>
|
||||
#include <libraries/log/nrf_log.h>
|
||||
|
||||
using namespace Pinetime::Controllers;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
AlarmController::AlarmController(Controllers::DateTime& dateTimeController) : dateTimeController {dateTimeController} {
|
||||
AlarmController::AlarmController(Controllers::DateTime& dateTimeController, Controllers::FS& fs)
|
||||
: dateTimeController {dateTimeController}, fs {fs} {
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -36,11 +38,28 @@ namespace {
|
||||
void AlarmController::Init(System::SystemTask* systemTask) {
|
||||
this->systemTask = systemTask;
|
||||
alarmTimer = xTimerCreate("Alarm", 1, pdFALSE, this, SetOffAlarm);
|
||||
LoadSettingsFromFile();
|
||||
if (alarm.isEnabled) {
|
||||
NRF_LOG_INFO("[AlarmController] Loaded alarm was enabled, scheduling");
|
||||
ScheduleAlarm();
|
||||
}
|
||||
}
|
||||
|
||||
void AlarmController::SaveAlarm() {
|
||||
// verify if it is necessary to save
|
||||
if (alarmChanged) {
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
alarmChanged = false;
|
||||
}
|
||||
|
||||
void AlarmController::SetAlarmTime(uint8_t alarmHr, uint8_t alarmMin) {
|
||||
hours = alarmHr;
|
||||
minutes = alarmMin;
|
||||
if (alarm.hours == alarmHr && alarm.minutes == alarmMin) {
|
||||
return;
|
||||
}
|
||||
alarm.hours = alarmHr;
|
||||
alarm.minutes = alarmMin;
|
||||
alarmChanged = true;
|
||||
}
|
||||
|
||||
void AlarmController::ScheduleAlarm() {
|
||||
@@ -53,18 +72,19 @@ void AlarmController::ScheduleAlarm() {
|
||||
tm* tmAlarmTime = std::localtime(&ttAlarmTime);
|
||||
|
||||
// If the time being set has already passed today,the alarm should be set for tomorrow
|
||||
if (hours < dateTimeController.Hours() || (hours == dateTimeController.Hours() && minutes <= dateTimeController.Minutes())) {
|
||||
if (alarm.hours < dateTimeController.Hours() ||
|
||||
(alarm.hours == dateTimeController.Hours() && alarm.minutes <= dateTimeController.Minutes())) {
|
||||
tmAlarmTime->tm_mday += 1;
|
||||
// tm_wday doesn't update automatically
|
||||
tmAlarmTime->tm_wday = (tmAlarmTime->tm_wday + 1) % 7;
|
||||
}
|
||||
|
||||
tmAlarmTime->tm_hour = hours;
|
||||
tmAlarmTime->tm_min = minutes;
|
||||
tmAlarmTime->tm_hour = alarm.hours;
|
||||
tmAlarmTime->tm_min = alarm.minutes;
|
||||
tmAlarmTime->tm_sec = 0;
|
||||
|
||||
// if alarm is in weekday-only mode, make sure it shifts to the next weekday
|
||||
if (recurrence == RecurType::Weekdays) {
|
||||
if (alarm.recurrence == RecurType::Weekdays) {
|
||||
if (tmAlarmTime->tm_wday == 0) { // Sunday, shift 1 day
|
||||
tmAlarmTime->tm_mday += 1;
|
||||
} else if (tmAlarmTime->tm_wday == 6) { // Saturday, shift 2 days
|
||||
@@ -79,7 +99,10 @@ void AlarmController::ScheduleAlarm() {
|
||||
xTimerChangePeriod(alarmTimer, secondsToAlarm * configTICK_RATE_HZ, 0);
|
||||
xTimerStart(alarmTimer, 0);
|
||||
|
||||
state = AlarmState::Set;
|
||||
if (!alarm.isEnabled) {
|
||||
alarm.isEnabled = true;
|
||||
alarmChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t AlarmController::SecondsToAlarm() const {
|
||||
@@ -88,20 +111,72 @@ uint32_t AlarmController::SecondsToAlarm() const {
|
||||
|
||||
void AlarmController::DisableAlarm() {
|
||||
xTimerStop(alarmTimer, 0);
|
||||
state = AlarmState::Not_Set;
|
||||
isAlerting = false;
|
||||
if (alarm.isEnabled) {
|
||||
alarm.isEnabled = false;
|
||||
alarmChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
void AlarmController::SetOffAlarmNow() {
|
||||
state = AlarmState::Alerting;
|
||||
isAlerting = true;
|
||||
systemTask->PushMessage(System::Messages::SetOffAlarm);
|
||||
}
|
||||
|
||||
void AlarmController::StopAlerting() {
|
||||
// Alarm state is off unless this is a recurring alarm
|
||||
if (recurrence == RecurType::None) {
|
||||
state = AlarmState::Not_Set;
|
||||
isAlerting = false;
|
||||
// Disable alarm unless it is recurring
|
||||
if (alarm.recurrence == RecurType::None) {
|
||||
alarm.isEnabled = false;
|
||||
alarmChanged = true;
|
||||
} else {
|
||||
// set next instance
|
||||
ScheduleAlarm();
|
||||
}
|
||||
}
|
||||
|
||||
void AlarmController::SetRecurrence(RecurType recurrence) {
|
||||
if (alarm.recurrence != recurrence) {
|
||||
alarm.recurrence = recurrence;
|
||||
alarmChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
void AlarmController::LoadSettingsFromFile() {
|
||||
lfs_file_t alarmFile;
|
||||
AlarmSettings alarmBuffer;
|
||||
|
||||
if (fs.FileOpen(&alarmFile, "/.system/alarm.dat", LFS_O_RDONLY) != LFS_ERR_OK) {
|
||||
NRF_LOG_WARNING("[AlarmController] Failed to open alarm data file");
|
||||
return;
|
||||
}
|
||||
|
||||
fs.FileRead(&alarmFile, reinterpret_cast<uint8_t*>(&alarmBuffer), sizeof(alarmBuffer));
|
||||
fs.FileClose(&alarmFile);
|
||||
if (alarmBuffer.version != alarmFormatVersion) {
|
||||
NRF_LOG_WARNING("[AlarmController] Loaded alarm settings has version %u instead of %u, discarding",
|
||||
alarmBuffer.version,
|
||||
alarmFormatVersion);
|
||||
return;
|
||||
}
|
||||
|
||||
alarm = alarmBuffer;
|
||||
NRF_LOG_INFO("[AlarmController] Loaded alarm settings from file");
|
||||
}
|
||||
|
||||
void AlarmController::SaveSettingsToFile() const {
|
||||
lfs_dir systemDir;
|
||||
if (fs.DirOpen("/.system", &systemDir) != LFS_ERR_OK) {
|
||||
fs.DirCreate("/.system");
|
||||
}
|
||||
fs.DirClose(&systemDir);
|
||||
lfs_file_t alarmFile;
|
||||
if (fs.FileOpen(&alarmFile, "/.system/alarm.dat", LFS_O_WRONLY | LFS_O_CREAT) != LFS_ERR_OK) {
|
||||
NRF_LOG_WARNING("[AlarmController] Failed to open alarm data file for saving");
|
||||
return;
|
||||
}
|
||||
|
||||
fs.FileWrite(&alarmFile, reinterpret_cast<const uint8_t*>(&alarm), sizeof(alarm));
|
||||
fs.FileClose(&alarmFile);
|
||||
NRF_LOG_INFO("[AlarmController] Saved alarm settings with format version %u to file", alarm.version);
|
||||
}
|
||||
|
||||
@@ -30,47 +30,65 @@ namespace Pinetime {
|
||||
namespace Controllers {
|
||||
class AlarmController {
|
||||
public:
|
||||
AlarmController(Controllers::DateTime& dateTimeController);
|
||||
AlarmController(Controllers::DateTime& dateTimeController, Controllers::FS& fs);
|
||||
|
||||
void Init(System::SystemTask* systemTask);
|
||||
void SaveAlarm();
|
||||
void SetAlarmTime(uint8_t alarmHr, uint8_t alarmMin);
|
||||
void ScheduleAlarm();
|
||||
void DisableAlarm();
|
||||
void SetOffAlarmNow();
|
||||
uint32_t SecondsToAlarm() const;
|
||||
void StopAlerting();
|
||||
enum class AlarmState { Not_Set, Set, Alerting };
|
||||
enum class RecurType { None, Daily, Weekdays };
|
||||
|
||||
uint8_t Hours() const {
|
||||
return hours;
|
||||
return alarm.hours;
|
||||
}
|
||||
|
||||
uint8_t Minutes() const {
|
||||
return minutes;
|
||||
return alarm.minutes;
|
||||
}
|
||||
|
||||
AlarmState State() const {
|
||||
return state;
|
||||
bool IsAlerting() const {
|
||||
return isAlerting;
|
||||
}
|
||||
|
||||
bool IsEnabled() const {
|
||||
return alarm.isEnabled;
|
||||
}
|
||||
|
||||
RecurType Recurrence() const {
|
||||
return recurrence;
|
||||
return alarm.recurrence;
|
||||
}
|
||||
|
||||
void SetRecurrence(RecurType recurType) {
|
||||
recurrence = recurType;
|
||||
}
|
||||
void SetRecurrence(RecurType recurrence);
|
||||
|
||||
private:
|
||||
Controllers::DateTime& dateTimeController;
|
||||
System::SystemTask* systemTask = nullptr;
|
||||
TimerHandle_t alarmTimer;
|
||||
// Versions 255 is reserved for now, so the version field can be made
|
||||
// bigger, should it ever be needed.
|
||||
static constexpr uint8_t alarmFormatVersion = 1;
|
||||
|
||||
struct AlarmSettings {
|
||||
uint8_t version = alarmFormatVersion;
|
||||
uint8_t hours = 7;
|
||||
uint8_t minutes = 0;
|
||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> alarmTime;
|
||||
AlarmState state = AlarmState::Not_Set;
|
||||
RecurType recurrence = RecurType::None;
|
||||
bool isEnabled = false;
|
||||
};
|
||||
|
||||
bool isAlerting = false;
|
||||
bool alarmChanged = false;
|
||||
|
||||
Controllers::DateTime& dateTimeController;
|
||||
Controllers::FS& fs;
|
||||
System::SystemTask* systemTask = nullptr;
|
||||
TimerHandle_t alarmTimer;
|
||||
AlarmSettings alarm;
|
||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> alarmTime;
|
||||
|
||||
void LoadSettingsFromFile();
|
||||
void SaveSettingsToFile() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,9 +124,11 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) {
|
||||
bootloaderSize,
|
||||
applicationSize);
|
||||
|
||||
// wait until SystemTask has finished waking up all devices
|
||||
while (systemTask.IsSleeping()) {
|
||||
vTaskDelay(50); // 50ms
|
||||
// Wait until SystemTask has disabled sleeping
|
||||
// This isn't quite correct, as we don't actually know
|
||||
// if BleFirmwareUpdateStarted has been received yet
|
||||
while (!systemTask.IsSleepDisabled()) {
|
||||
vTaskDelay(pdMS_TO_TICKS(5));
|
||||
}
|
||||
|
||||
dfuImage.Erase();
|
||||
|
||||
@@ -77,6 +77,10 @@ namespace Pinetime {
|
||||
uint16_t ComputeCrc(uint8_t const* p_data, uint32_t size, uint16_t const* p_crc);
|
||||
};
|
||||
|
||||
static constexpr ble_uuid128_t serviceUuid {
|
||||
.u {.type = BLE_UUID_TYPE_128},
|
||||
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00}};
|
||||
|
||||
private:
|
||||
Pinetime::System::SystemTask& systemTask;
|
||||
Pinetime::Controllers::Ble& bleController;
|
||||
@@ -90,10 +94,6 @@ namespace Pinetime {
|
||||
|
||||
uint16_t revision {0x0008};
|
||||
|
||||
static constexpr ble_uuid128_t serviceUuid {
|
||||
.u {.type = BLE_UUID_TYPE_128},
|
||||
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00}};
|
||||
|
||||
static constexpr ble_uuid128_t packetCharacteristicUuid {
|
||||
.u {.type = BLE_UUID_TYPE_128},
|
||||
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x32, 0x15, 0x00, 0x00}};
|
||||
|
||||
@@ -21,14 +21,14 @@ namespace Pinetime {
|
||||
void SubscribeNotification(uint16_t attributeHandle);
|
||||
void UnsubscribeNotification(uint16_t attributeHandle);
|
||||
|
||||
static constexpr uint16_t heartRateServiceId {0x180D};
|
||||
static constexpr ble_uuid16_t heartRateServiceUuid {.u {.type = BLE_UUID_TYPE_16}, .value = heartRateServiceId};
|
||||
|
||||
private:
|
||||
NimbleController& nimble;
|
||||
Controllers::HeartRateController& heartRateController;
|
||||
static constexpr uint16_t heartRateServiceId {0x180D};
|
||||
static constexpr uint16_t heartRateMeasurementId {0x2A37};
|
||||
|
||||
static constexpr ble_uuid16_t heartRateServiceUuid {.u {.type = BLE_UUID_TYPE_16}, .value = heartRateServiceId};
|
||||
|
||||
static constexpr ble_uuid16_t heartRateMeasurementUuid {.u {.type = BLE_UUID_TYPE_16}, .value = heartRateMeasurementId};
|
||||
|
||||
struct ble_gatt_chr_def characteristicDefinition[2];
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "components/ble/MusicService.h"
|
||||
#include "components/ble/NimbleController.h"
|
||||
#include <cstring>
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
|
||||
namespace {
|
||||
// 0000yyxx-78fc-48fe-8e23-433b3a1942d0
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <host/ble_uuid.h>
|
||||
#undef max
|
||||
#undef min
|
||||
#include <FreeRTOS.h>
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
|
||||
@@ -158,7 +158,10 @@ void NimbleController::StartAdvertising() {
|
||||
}
|
||||
|
||||
fields.flags = BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP;
|
||||
fields.uuids128 = &dfuServiceUuid;
|
||||
fields.uuids16 = &HeartRateService::heartRateServiceUuid;
|
||||
fields.num_uuids16 = 1;
|
||||
fields.uuids16_is_complete = 1;
|
||||
fields.uuids128 = &DfuService::serviceUuid;
|
||||
fields.num_uuids128 = 1;
|
||||
fields.uuids128_is_complete = 1;
|
||||
fields.tx_pwr_lvl = BLE_HS_ADV_TX_PWR_LVL_AUTO;
|
||||
@@ -451,9 +454,15 @@ void NimbleController::PersistBond(struct ble_gap_conn_desc& desc) {
|
||||
/* Wakeup Spi and SpiNorFlash before accessing the file system
|
||||
* This should be fixed in the FS driver
|
||||
*/
|
||||
systemTask.PushMessage(Pinetime::System::Messages::GoToRunning);
|
||||
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
|
||||
vTaskDelay(10);
|
||||
|
||||
// This isn't quite correct
|
||||
// SystemTask could receive EnableSleeping right after passing this check
|
||||
// We need some guarantee that the SystemTask has processed the above message
|
||||
// before we can continue
|
||||
while (!systemTask.IsSleepDisabled()) {
|
||||
vTaskDelay(pdMS_TO_TICKS(5));
|
||||
}
|
||||
|
||||
lfs_file_t file_p;
|
||||
|
||||
|
||||
@@ -112,10 +112,6 @@ namespace Pinetime {
|
||||
uint16_t connectionHandle = BLE_HS_CONN_HANDLE_NONE;
|
||||
uint8_t fastAdvCount = 0;
|
||||
uint8_t bondId[16] = {0};
|
||||
|
||||
ble_uuid128_t dfuServiceUuid {
|
||||
.u {.type = BLE_UUID_TYPE_128},
|
||||
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00}};
|
||||
};
|
||||
|
||||
static NimbleController* nptr;
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace {
|
||||
std::memcpy(cityName.data(), &dataBuffer[16], 32);
|
||||
cityName[32] = '\0';
|
||||
return SimpleWeatherService::CurrentWeather(ToUInt64(&dataBuffer[2]),
|
||||
ToInt16(&dataBuffer[10]),
|
||||
ToInt16(&dataBuffer[12]),
|
||||
ToInt16(&dataBuffer[14]),
|
||||
SimpleWeatherService::Temperature(ToInt16(&dataBuffer[10])),
|
||||
SimpleWeatherService::Temperature(ToInt16(&dataBuffer[12])),
|
||||
SimpleWeatherService::Temperature(ToInt16(&dataBuffer[14])),
|
||||
SimpleWeatherService::Icons {dataBuffer[16 + 32]},
|
||||
std::move(cityName));
|
||||
}
|
||||
@@ -52,12 +52,12 @@ namespace {
|
||||
SimpleWeatherService::Forecast CreateForecast(const uint8_t* dataBuffer) {
|
||||
auto timestamp = static_cast<uint64_t>(ToUInt64(&dataBuffer[2]));
|
||||
|
||||
std::array<SimpleWeatherService::Forecast::Day, SimpleWeatherService::MaxNbForecastDays> days;
|
||||
std::array<std::optional<SimpleWeatherService::Forecast::Day>, SimpleWeatherService::MaxNbForecastDays> days;
|
||||
const uint8_t nbDaysInBuffer = dataBuffer[10];
|
||||
const uint8_t nbDays = std::min(SimpleWeatherService::MaxNbForecastDays, nbDaysInBuffer);
|
||||
for (int i = 0; i < nbDays; i++) {
|
||||
days[i] = SimpleWeatherService::Forecast::Day {ToInt16(&dataBuffer[11 + (i * 5)]),
|
||||
ToInt16(&dataBuffer[13 + (i * 5)]),
|
||||
days[i] = SimpleWeatherService::Forecast::Day {SimpleWeatherService::Temperature(ToInt16(&dataBuffer[11 + (i * 5)])),
|
||||
SimpleWeatherService::Temperature(ToInt16(&dataBuffer[13 + (i * 5)])),
|
||||
SimpleWeatherService::Icons {dataBuffer[15 + (i * 5)]}};
|
||||
}
|
||||
return SimpleWeatherService::Forecast {timestamp, nbDays, days};
|
||||
@@ -80,7 +80,7 @@ int WeatherCallback(uint16_t /*connHandle*/, uint16_t /*attrHandle*/, struct ble
|
||||
return static_cast<Pinetime::Controllers::SimpleWeatherService*>(arg)->OnCommand(ctxt);
|
||||
}
|
||||
|
||||
SimpleWeatherService::SimpleWeatherService(const DateTime& dateTimeController) : dateTimeController(dateTimeController) {
|
||||
SimpleWeatherService::SimpleWeatherService(DateTime& dateTimeController) : dateTimeController(dateTimeController) {
|
||||
}
|
||||
|
||||
void SimpleWeatherService::Init() {
|
||||
@@ -98,9 +98,9 @@ int SimpleWeatherService::OnCommand(struct ble_gatt_access_ctxt* ctxt) {
|
||||
currentWeather = CreateCurrentWeather(dataBuffer);
|
||||
NRF_LOG_INFO("Current weather :\n\tTimestamp : %d\n\tTemperature:%d\n\tMin:%d\n\tMax:%d\n\tIcon:%d\n\tLocation:%s",
|
||||
currentWeather->timestamp,
|
||||
currentWeather->temperature,
|
||||
currentWeather->minTemperature,
|
||||
currentWeather->maxTemperature,
|
||||
currentWeather->temperature.PreciseCelsius(),
|
||||
currentWeather->minTemperature.PreciseCelsius(),
|
||||
currentWeather->maxTemperature.PreciseCelsius(),
|
||||
currentWeather->iconId,
|
||||
currentWeather->location.data());
|
||||
}
|
||||
@@ -112,9 +112,9 @@ int SimpleWeatherService::OnCommand(struct ble_gatt_access_ctxt* ctxt) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
NRF_LOG_INFO("\t[%d] Min: %d - Max : %d - Icon : %d",
|
||||
i,
|
||||
forecast->days[i].minTemperature,
|
||||
forecast->days[i].maxTemperature,
|
||||
forecast->days[i].iconId);
|
||||
forecast->days[i]->minTemperature.PreciseCelsius(),
|
||||
forecast->days[i]->maxTemperature.PreciseCelsius(),
|
||||
forecast->days[i]->iconId);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
||||
#define min // workaround: nimble's min/max macros conflict with libstdc++
|
||||
@@ -40,7 +40,7 @@ namespace Pinetime {
|
||||
|
||||
class SimpleWeatherService {
|
||||
public:
|
||||
explicit SimpleWeatherService(const DateTime& dateTimeController);
|
||||
explicit SimpleWeatherService(DateTime& dateTimeController);
|
||||
|
||||
void Init();
|
||||
|
||||
@@ -61,13 +61,42 @@ namespace Pinetime {
|
||||
Unknown = 255
|
||||
};
|
||||
|
||||
class Temperature {
|
||||
public:
|
||||
explicit Temperature(int16_t raw) : raw {raw} {
|
||||
}
|
||||
|
||||
[[nodiscard]] int16_t PreciseCelsius() const {
|
||||
return raw;
|
||||
}
|
||||
|
||||
[[nodiscard]] int16_t PreciseFahrenheit() const {
|
||||
return raw * 9 / 5 + 3200;
|
||||
}
|
||||
|
||||
[[nodiscard]] int16_t Celsius() const {
|
||||
return (PreciseCelsius() + 50) / 100;
|
||||
}
|
||||
|
||||
[[nodiscard]] int16_t Fahrenheit() const {
|
||||
return (PreciseFahrenheit() + 50) / 100;
|
||||
}
|
||||
|
||||
bool operator==(const Temperature& other) const {
|
||||
return raw == other.raw;
|
||||
}
|
||||
|
||||
private:
|
||||
int16_t raw;
|
||||
};
|
||||
|
||||
using Location = std::array<char, 33>; // 32 char + \0 (end of string)
|
||||
|
||||
struct CurrentWeather {
|
||||
CurrentWeather(uint64_t timestamp,
|
||||
int16_t temperature,
|
||||
int16_t minTemperature,
|
||||
int16_t maxTemperature,
|
||||
Temperature temperature,
|
||||
Temperature minTemperature,
|
||||
Temperature maxTemperature,
|
||||
Icons iconId,
|
||||
Location&& location)
|
||||
: timestamp {timestamp},
|
||||
@@ -79,9 +108,9 @@ namespace Pinetime {
|
||||
}
|
||||
|
||||
uint64_t timestamp;
|
||||
int16_t temperature;
|
||||
int16_t minTemperature;
|
||||
int16_t maxTemperature;
|
||||
Temperature temperature;
|
||||
Temperature minTemperature;
|
||||
Temperature maxTemperature;
|
||||
Icons iconId;
|
||||
Location location;
|
||||
|
||||
@@ -93,14 +122,14 @@ namespace Pinetime {
|
||||
uint8_t nbDays;
|
||||
|
||||
struct Day {
|
||||
int16_t minTemperature;
|
||||
int16_t maxTemperature;
|
||||
Temperature minTemperature;
|
||||
Temperature maxTemperature;
|
||||
Icons iconId;
|
||||
|
||||
bool operator==(const Day& other) const;
|
||||
};
|
||||
|
||||
std::array<Day, MaxNbForecastDays> days;
|
||||
std::array<std::optional<Day>, MaxNbForecastDays> days;
|
||||
|
||||
bool operator==(const Forecast& other) const;
|
||||
};
|
||||
@@ -108,10 +137,6 @@ namespace Pinetime {
|
||||
std::optional<CurrentWeather> Current() const;
|
||||
std::optional<Forecast> GetForecast() const;
|
||||
|
||||
static int16_t CelsiusToFahrenheit(int16_t celsius) {
|
||||
return celsius * 9 / 5 + 3200;
|
||||
}
|
||||
|
||||
private:
|
||||
// 00050000-78fc-48fe-8e23-433b3a1942d0
|
||||
static constexpr ble_uuid128_t BaseUuid() {
|
||||
@@ -140,7 +165,7 @@ namespace Pinetime {
|
||||
|
||||
uint16_t eventHandle {};
|
||||
|
||||
const Pinetime::Controllers::DateTime& dateTimeController;
|
||||
Pinetime::Controllers::DateTime& dateTimeController;
|
||||
|
||||
std::optional<CurrentWeather> currentWeather;
|
||||
std::optional<Forecast> forecast;
|
||||
|
||||
@@ -2,38 +2,138 @@
|
||||
#include <hal/nrf_gpio.h>
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
#include "drivers/PinMap.h"
|
||||
#include <libraries/delay/nrf_delay.h>
|
||||
using namespace Pinetime::Controllers;
|
||||
|
||||
namespace {
|
||||
// reinterpret_cast is not constexpr so this is the best we can do
|
||||
static NRF_RTC_Type* const RTC = reinterpret_cast<NRF_RTC_Type*>(NRF_RTC2_BASE);
|
||||
}
|
||||
|
||||
void BrightnessController::Init() {
|
||||
nrf_gpio_cfg_output(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_cfg_output(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_cfg_output(PinMap::LcdBacklightHigh);
|
||||
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightHigh);
|
||||
|
||||
static_assert(timerFrequency == 32768, "Change the prescaler below");
|
||||
RTC->PRESCALER = 0;
|
||||
// CC1 switches the backlight on (pin transitions from high to low) and resets the counter to 0
|
||||
RTC->CC[1] = timerPeriod;
|
||||
// Enable compare events for CC0,CC1
|
||||
RTC->EVTEN = 0b0000'0000'0000'0011'0000'0000'0000'0000;
|
||||
// Disable all interrupts
|
||||
RTC->INTENCLR = 0b0000'0000'0000'1111'0000'0000'0000'0011;
|
||||
Set(level);
|
||||
}
|
||||
|
||||
void BrightnessController::ApplyBrightness(uint16_t rawBrightness) {
|
||||
// The classic off, low, medium, high brightnesses are at {0, timerPeriod, timerPeriod*2, timerPeriod*3}
|
||||
// These brightness levels do not use PWM: they only set/clear the corresponding pins
|
||||
// Any brightness level between the above levels is achieved with efficient RTC based PWM on the next pin up
|
||||
// E.g 2.5*timerPeriod corresponds to medium brightness with 50% PWM on the high pin
|
||||
// Note: Raw brightness does not necessarily correspond to a linear perceived brightness
|
||||
|
||||
uint8_t pin;
|
||||
if (rawBrightness > 2 * timerPeriod) {
|
||||
rawBrightness -= 2 * timerPeriod;
|
||||
pin = PinMap::LcdBacklightHigh;
|
||||
} else if (rawBrightness > timerPeriod) {
|
||||
rawBrightness -= timerPeriod;
|
||||
pin = PinMap::LcdBacklightMedium;
|
||||
} else {
|
||||
pin = PinMap::LcdBacklightLow;
|
||||
}
|
||||
if (rawBrightness == timerPeriod || rawBrightness == 0) {
|
||||
if (lastPin != UNSET) {
|
||||
RTC->TASKS_STOP = 1;
|
||||
nrf_delay_us(rtcStopTime);
|
||||
nrf_ppi_channel_disable(ppiBacklightOff);
|
||||
nrf_ppi_channel_disable(ppiBacklightOn);
|
||||
nrfx_gpiote_out_uninit(lastPin);
|
||||
nrf_gpio_cfg_output(lastPin);
|
||||
}
|
||||
lastPin = UNSET;
|
||||
if (rawBrightness == 0) {
|
||||
nrf_gpio_pin_set(pin);
|
||||
} else {
|
||||
nrf_gpio_pin_clear(pin);
|
||||
}
|
||||
} else {
|
||||
// If the pin on which we are doing PWM is changing
|
||||
// Disable old PWM channel (if exists) and set up new one
|
||||
if (lastPin != pin) {
|
||||
if (lastPin != UNSET) {
|
||||
RTC->TASKS_STOP = 1;
|
||||
nrf_delay_us(rtcStopTime);
|
||||
nrf_ppi_channel_disable(ppiBacklightOff);
|
||||
nrf_ppi_channel_disable(ppiBacklightOn);
|
||||
nrfx_gpiote_out_uninit(lastPin);
|
||||
nrf_gpio_cfg_output(lastPin);
|
||||
}
|
||||
nrfx_gpiote_out_config_t gpioteCfg = {.action = NRF_GPIOTE_POLARITY_TOGGLE,
|
||||
.init_state = NRF_GPIOTE_INITIAL_VALUE_LOW,
|
||||
.task_pin = true};
|
||||
APP_ERROR_CHECK(nrfx_gpiote_out_init(pin, &gpioteCfg));
|
||||
nrfx_gpiote_out_task_enable(pin);
|
||||
nrf_ppi_channel_endpoint_setup(ppiBacklightOff,
|
||||
reinterpret_cast<uint32_t>(&RTC->EVENTS_COMPARE[0]),
|
||||
nrfx_gpiote_out_task_addr_get(pin));
|
||||
nrf_ppi_channel_endpoint_setup(ppiBacklightOn,
|
||||
reinterpret_cast<uint32_t>(&RTC->EVENTS_COMPARE[1]),
|
||||
nrfx_gpiote_out_task_addr_get(pin));
|
||||
nrf_ppi_fork_endpoint_setup(ppiBacklightOn, reinterpret_cast<uint32_t>(&RTC->TASKS_CLEAR));
|
||||
nrf_ppi_channel_enable(ppiBacklightOff);
|
||||
nrf_ppi_channel_enable(ppiBacklightOn);
|
||||
} else {
|
||||
// If the pin used for PWM isn't changing, we only need to set the pin state to the initial value (low)
|
||||
RTC->TASKS_STOP = 1;
|
||||
nrf_delay_us(rtcStopTime);
|
||||
// Due to errata 20,179 and the intricacies of RTC timing, keep it simple: override the pin state
|
||||
nrfx_gpiote_out_task_force(pin, false);
|
||||
}
|
||||
// CC0 switches the backlight off (pin transitions from low to high)
|
||||
RTC->CC[0] = rawBrightness;
|
||||
RTC->TASKS_CLEAR = 1;
|
||||
RTC->TASKS_START = 1;
|
||||
lastPin = pin;
|
||||
}
|
||||
switch (pin) {
|
||||
case PinMap::LcdBacklightHigh:
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
|
||||
break;
|
||||
case PinMap::LcdBacklightMedium:
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
||||
break;
|
||||
case PinMap::LcdBacklightLow:
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
||||
}
|
||||
}
|
||||
|
||||
void BrightnessController::Set(BrightnessController::Levels level) {
|
||||
this->level = level;
|
||||
switch (level) {
|
||||
default:
|
||||
case Levels::High:
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightHigh);
|
||||
ApplyBrightness(3 * timerPeriod);
|
||||
break;
|
||||
case Levels::Medium:
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
||||
ApplyBrightness(2 * timerPeriod);
|
||||
break;
|
||||
case Levels::Low:
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
||||
ApplyBrightness(timerPeriod);
|
||||
break;
|
||||
case Levels::AlwaysOn:
|
||||
ApplyBrightness(timerPeriod / 10);
|
||||
break;
|
||||
case Levels::Off:
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
||||
ApplyBrightness(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "nrf_ppi.h"
|
||||
#include "nrfx_gpiote.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
class BrightnessController {
|
||||
public:
|
||||
enum class Levels { Off, Low, Medium, High };
|
||||
enum class Levels { Off, AlwaysOn, Low, Medium, High };
|
||||
void Init();
|
||||
|
||||
void Set(Levels level);
|
||||
@@ -20,6 +23,25 @@ namespace Pinetime {
|
||||
|
||||
private:
|
||||
Levels level = Levels::High;
|
||||
static constexpr uint8_t UNSET = UINT8_MAX;
|
||||
uint8_t lastPin = UNSET;
|
||||
// Maximum time (μs) it takes for the RTC to fully stop
|
||||
static constexpr uint8_t rtcStopTime = 46;
|
||||
// Frequency of timer used for PWM (Hz)
|
||||
static constexpr uint16_t timerFrequency = 32768;
|
||||
// Backlight PWM frequency (Hz)
|
||||
static constexpr uint16_t pwmFreq = 1000;
|
||||
// Wraparound point in timer ticks
|
||||
// Defines the number of brightness levels between each pin
|
||||
static constexpr uint16_t timerPeriod = timerFrequency / pwmFreq;
|
||||
// Warning: nimble reserves some PPIs
|
||||
// https://github.com/InfiniTimeOrg/InfiniTime/blob/034d83fe6baf1ab3875a34f8cee387e24410a824/src/libs/mynewt-nimble/nimble/drivers/nrf52/src/ble_phy.c#L53
|
||||
// SpiMaster uses PPI 0 for an erratum workaround
|
||||
// Channel 1, 2 should be free to use
|
||||
static constexpr nrf_ppi_channel_t ppiBacklightOn = NRF_PPI_CHANNEL1;
|
||||
static constexpr nrf_ppi_channel_t ppiBacklightOff = NRF_PPI_CHANNEL2;
|
||||
|
||||
void ApplyBrightness(uint16_t val);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,42 @@
|
||||
#include "components/datetime/DateTimeController.h"
|
||||
#include <libraries/log/nrf_log.h>
|
||||
#include <systemtask/SystemTask.h>
|
||||
#include <hal/nrf_rtc.h>
|
||||
#include "nrf_assert.h"
|
||||
|
||||
using namespace Pinetime::Controllers;
|
||||
|
||||
namespace {
|
||||
char const* DaysStringShort[] = {"--", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
|
||||
char const* DaysStringShortLow[] = {"--", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
|
||||
char const* MonthsString[] = {"--", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
|
||||
char const* MonthsStringLow[] = {"--", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
constexpr const char* const DaysStringShort[] = {"--", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
|
||||
constexpr const char* const DaysStringShortLow[] = {"--", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
|
||||
constexpr const char* const MonthsString[] = {"--", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
|
||||
constexpr const char* const MonthsStringLow[] =
|
||||
{"--", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
|
||||
constexpr int compileTimeAtoi(const char* str) {
|
||||
int result = 0;
|
||||
while (*str >= '0' && *str <= '9') {
|
||||
result = result * 10 + *str - '0';
|
||||
str++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
DateTime::DateTime(Controllers::Settings& settingsController) : settingsController {settingsController} {
|
||||
mutex = xSemaphoreCreateMutex();
|
||||
ASSERT(mutex != nullptr);
|
||||
xSemaphoreGive(mutex);
|
||||
|
||||
// __DATE__ is a string of the format "MMM DD YYYY", so an offset of 7 gives the start of the year
|
||||
SetTime(compileTimeAtoi(&__DATE__[7]), 1, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> t) {
|
||||
xSemaphoreTake(mutex, portMAX_DELAY);
|
||||
this->currentDateTime = t;
|
||||
UpdateTime(previousSystickCounter); // Update internal state without updating the time
|
||||
UpdateTime(previousSystickCounter, true); // Update internal state without updating the time
|
||||
xSemaphoreGive(mutex);
|
||||
}
|
||||
|
||||
void DateTime::SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) {
|
||||
@@ -29,41 +49,54 @@ void DateTime::SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour,
|
||||
/* .tm_year = */ year - 1900,
|
||||
};
|
||||
|
||||
tm.tm_isdst = -1; // Use DST value from local time zone
|
||||
currentDateTime = std::chrono::system_clock::from_time_t(std::mktime(&tm));
|
||||
|
||||
NRF_LOG_INFO("%d %d %d ", day, month, year);
|
||||
NRF_LOG_INFO("%d %d %d ", hour, minute, second);
|
||||
|
||||
UpdateTime(previousSystickCounter);
|
||||
tm.tm_isdst = -1; // Use DST value from local time zone
|
||||
|
||||
xSemaphoreTake(mutex, portMAX_DELAY);
|
||||
currentDateTime = std::chrono::system_clock::from_time_t(std::mktime(&tm));
|
||||
UpdateTime(previousSystickCounter, true);
|
||||
xSemaphoreGive(mutex);
|
||||
|
||||
if (systemTask != nullptr) {
|
||||
systemTask->PushMessage(System::Messages::OnNewTime);
|
||||
}
|
||||
}
|
||||
|
||||
void DateTime::SetTimeZone(int8_t timezone, int8_t dst) {
|
||||
tzOffset = timezone;
|
||||
dstOffset = dst;
|
||||
}
|
||||
|
||||
void DateTime::UpdateTime(uint32_t systickCounter) {
|
||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> DateTime::CurrentDateTime() {
|
||||
xSemaphoreTake(mutex, portMAX_DELAY);
|
||||
UpdateTime(nrf_rtc_counter_get(portNRF_RTC_REG), false);
|
||||
xSemaphoreGive(mutex);
|
||||
return currentDateTime;
|
||||
}
|
||||
|
||||
void DateTime::UpdateTime(uint32_t systickCounter, bool forceUpdate) {
|
||||
// Handle systick counter overflow
|
||||
uint32_t systickDelta = 0;
|
||||
if (systickCounter < previousSystickCounter) {
|
||||
systickDelta = 0xffffff - previousSystickCounter;
|
||||
systickDelta = static_cast<uint32_t>(portNRF_RTC_MAXTICKS) - previousSystickCounter;
|
||||
systickDelta += systickCounter + 1;
|
||||
} else {
|
||||
systickDelta = systickCounter - previousSystickCounter;
|
||||
}
|
||||
|
||||
/*
|
||||
* 1000 ms = 1024 ticks
|
||||
*/
|
||||
auto correctedDelta = systickDelta / 1024;
|
||||
auto rest = systickDelta % 1024;
|
||||
auto correctedDelta = systickDelta / configTICK_RATE_HZ;
|
||||
// If a second hasn't passed, there is nothing to do
|
||||
// If the time has been changed, set forceUpdate to trigger internal state updates
|
||||
if (correctedDelta == 0 && !forceUpdate) {
|
||||
return;
|
||||
}
|
||||
auto rest = systickDelta % configTICK_RATE_HZ;
|
||||
if (systickCounter >= rest) {
|
||||
previousSystickCounter = systickCounter - rest;
|
||||
} else {
|
||||
previousSystickCounter = 0xffffff - (rest - systickCounter);
|
||||
previousSystickCounter = static_cast<uint32_t>(portNRF_RTC_MAXTICKS) - (rest - systickCounter - 1);
|
||||
}
|
||||
|
||||
currentDateTime += std::chrono::seconds(correctedDelta);
|
||||
@@ -129,7 +162,7 @@ std::string DateTime::FormattedTime() {
|
||||
auto hour = Hours();
|
||||
auto minute = Minutes();
|
||||
// Return time as a string in 12- or 24-hour format
|
||||
char buff[11];
|
||||
char buff[9];
|
||||
if (settingsController.GetClockType() == ClockType::H12) {
|
||||
uint8_t hour12;
|
||||
const char* amPmStr;
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
#include "components/settings/Settings.h"
|
||||
#include <FreeRTOS.h>
|
||||
#include <semphr.h>
|
||||
|
||||
namespace Pinetime {
|
||||
namespace System {
|
||||
@@ -39,14 +41,12 @@ namespace Pinetime {
|
||||
*
|
||||
* used to update difference between utc and local time (see UtcOffset())
|
||||
*
|
||||
* parameters are in quarters of an our. Following the BLE CTS specification,
|
||||
* parameters are in quarters of an hour. Following the BLE CTS specification,
|
||||
* timezone is expected to be constant over DST which will be reported in
|
||||
* dst field.
|
||||
*/
|
||||
void SetTimeZone(int8_t timezone, int8_t dst);
|
||||
|
||||
void UpdateTime(uint32_t systickCounter);
|
||||
|
||||
uint16_t Year() const {
|
||||
return 1900 + localTime.tm_year;
|
||||
}
|
||||
@@ -124,12 +124,10 @@ namespace Pinetime {
|
||||
static const char* MonthShortToStringLow(Months month);
|
||||
static const char* DayOfWeekShortToStringLow(Days day);
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime() const {
|
||||
return currentDateTime;
|
||||
}
|
||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime();
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> UTCDateTime() const {
|
||||
return currentDateTime - std::chrono::seconds((tzOffset + dstOffset) * 15 * 60);
|
||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> UTCDateTime() {
|
||||
return CurrentDateTime() - std::chrono::seconds((tzOffset + dstOffset) * 15 * 60);
|
||||
}
|
||||
|
||||
std::chrono::seconds Uptime() const {
|
||||
@@ -141,10 +139,14 @@ namespace Pinetime {
|
||||
std::string FormattedTime();
|
||||
|
||||
private:
|
||||
void UpdateTime(uint32_t systickCounter, bool forceUpdate);
|
||||
|
||||
std::tm localTime;
|
||||
int8_t tzOffset = 0;
|
||||
int8_t dstOffset = 0;
|
||||
|
||||
SemaphoreHandle_t mutex = nullptr;
|
||||
|
||||
uint32_t previousSystickCounter = 0;
|
||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> currentDateTime;
|
||||
std::chrono::seconds uptime {0};
|
||||
|
||||
41
src/components/datetime/TODO.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Refactoring needed
|
||||
|
||||
## Context
|
||||
|
||||
The [PR #2041 - Continuous time updates](https://github.com/InfiniTimeOrg/InfiniTime/pull/2041) highlighted some
|
||||
limitations in the design of DateTimeController: the granularity of the time returned by `DateTime::CurrentDateTime()`
|
||||
is limited by the frequency at which SystemTask calls `DateTime::UpdateTime()`, which is currently set to 100ms.
|
||||
|
||||
@mark9064 provided more details
|
||||
in [this comment](https://github.com/InfiniTimeOrg/InfiniTime/pull/2041#issuecomment-2048528967).
|
||||
|
||||
The [PR #2041 - Continuous time updates](https://github.com/InfiniTimeOrg/InfiniTime/pull/2041) provided some changes
|
||||
to `DateTime` controller that improves the granularity of the time returned by `DateTime::CurrentDateTime()`.
|
||||
|
||||
However, the review showed that `DateTime` cannot be `const` anymore, even when it's only used to get the current time,
|
||||
since `DateTime::CurrentDateTime()` changes the internal state of the instance.
|
||||
|
||||
We tried to identify alternative implementation that would have maintained the "const correctness" but we eventually
|
||||
figured that this would lead to a re-design of `DateTime` which was out of scope of the initial PR (Continuous time
|
||||
updates and always on display).
|
||||
|
||||
So we decided to merge this PR #2041 and agree to fix/improve `DateTime` later on.
|
||||
|
||||
## What needs to be done?
|
||||
|
||||
Improve/redesign `DateTime` so that it
|
||||
|
||||
* provides a very granular (ideally down to the millisecond) date and time via `CurrentDateTime()`.
|
||||
* can be declared/passed as `const` when it's only used to **get** the time.
|
||||
* limits the use of mutex as much as possible (an ideal implementation would not use any mutex, but this might not be
|
||||
possible).
|
||||
* improves the design of `DateTime::Seconds()`, `DateTime::Minutes()`, `DateTime::Hours()`, etc as
|
||||
explained [in this comment](https://github.com/InfiniTimeOrg/InfiniTime/pull/2054#pullrequestreview-2037033105).
|
||||
|
||||
Once this redesign is implemented, all instances/references to `DateTime` should be reviewed and updated to use `const`
|
||||
where appropriate.
|
||||
|
||||
Please check the following PR to get more context about this redesign:
|
||||
|
||||
* [#2041 - Continuous time updates by @mark9064](https://github.com/InfiniTimeOrg/InfiniTime/pull/2041)
|
||||
* [#2054 - Continuous time update - Alternative implementation to #2041 by @JF002](https://github.com/InfiniTimeOrg/InfiniTime/pull/2054)
|
||||
@@ -142,7 +142,7 @@ Ppg::Ppg() {
|
||||
spectrum.fill(0.0f);
|
||||
}
|
||||
|
||||
int8_t Ppg::Preprocess(uint32_t hrs, uint32_t als) {
|
||||
int8_t Ppg::Preprocess(uint16_t hrs, uint16_t als) {
|
||||
if (dataIndex < dataLength) {
|
||||
dataHRS[dataIndex++] = hrs;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Pinetime {
|
||||
class Ppg {
|
||||
public:
|
||||
Ppg();
|
||||
int8_t Preprocess(uint32_t hrs, uint32_t als);
|
||||
int8_t Preprocess(uint16_t hrs, uint16_t als);
|
||||
int HeartRate();
|
||||
void Reset(bool resetDaqBuffer);
|
||||
static constexpr int deltaTms = 100;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Pinetime {
|
||||
namespace Controllers {
|
||||
class Settings {
|
||||
public:
|
||||
enum class ClockType : uint8_t { H24, H12, FUZZY };
|
||||
enum class ClockType : uint8_t { H24, H12 };
|
||||
enum class WeatherFormat : uint8_t { Metric, Imperial };
|
||||
enum class Notification : uint8_t { On, Off, Sleep };
|
||||
enum class ChimesOption : uint8_t { None, Hours, HalfHours };
|
||||
@@ -50,12 +50,6 @@ namespace Pinetime {
|
||||
int colorIndex = 0;
|
||||
};
|
||||
|
||||
struct Location {
|
||||
int16_t latitude;
|
||||
int16_t longitude;
|
||||
int8_t tzOffset;
|
||||
};
|
||||
|
||||
Settings(Pinetime::Controllers::FS& fs);
|
||||
|
||||
Settings(const Settings&) = delete;
|
||||
@@ -220,6 +214,21 @@ namespace Pinetime {
|
||||
return settings.screenTimeOut;
|
||||
};
|
||||
|
||||
bool GetAlwaysOnDisplay() const {
|
||||
return settings.alwaysOnDisplay && GetNotificationStatus() != Notification::Sleep;
|
||||
};
|
||||
|
||||
void SetAlwaysOnDisplaySetting(bool state) {
|
||||
if (state != settings.alwaysOnDisplay) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.alwaysOnDisplay = state;
|
||||
}
|
||||
|
||||
bool GetAlwaysOnDisplaySetting() const {
|
||||
return settings.alwaysOnDisplay;
|
||||
}
|
||||
|
||||
void SetShakeThreshold(uint16_t thresh) {
|
||||
if (settings.shakeWakeThreshold != thresh) {
|
||||
settings.shakeWakeThreshold = thresh;
|
||||
@@ -281,21 +290,6 @@ namespace Pinetime {
|
||||
return settings.stepsGoal;
|
||||
};
|
||||
|
||||
void SetLocation(Location loc) {
|
||||
if (
|
||||
loc.latitude != settings.location.latitude ||
|
||||
loc.longitude != settings.location.longitude ||
|
||||
loc.tzOffset != settings.location.tzOffset
|
||||
) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.location = loc;
|
||||
};
|
||||
|
||||
Location GetLocation() const {
|
||||
return settings.location;
|
||||
};
|
||||
|
||||
void SetBleRadioEnabled(bool enabled) {
|
||||
bleRadioEnabled = enabled;
|
||||
};
|
||||
@@ -307,18 +301,20 @@ namespace Pinetime {
|
||||
private:
|
||||
Pinetime::Controllers::FS& fs;
|
||||
|
||||
static constexpr uint32_t settingsVersion = 0x0007;
|
||||
static constexpr uint32_t settingsVersion = 0x0008;
|
||||
|
||||
struct SettingsData {
|
||||
uint32_t version = settingsVersion;
|
||||
uint32_t stepsGoal = 10000;
|
||||
uint32_t screenTimeOut = 15000;
|
||||
|
||||
ClockType clockType = ClockType::FUZZY;
|
||||
bool alwaysOnDisplay = false;
|
||||
|
||||
ClockType clockType = ClockType::H24;
|
||||
WeatherFormat weatherFormat = WeatherFormat::Metric;
|
||||
Notification notificationStatus = Notification::On;
|
||||
|
||||
Pinetime::Applications::WatchFace watchFace = Pinetime::Applications::WatchFace::Analog; //Digital
|
||||
Pinetime::Applications::WatchFace watchFace = Pinetime::Applications::WatchFace::Digital;
|
||||
ChimesOption chimesOption = ChimesOption::None;
|
||||
|
||||
PineTimeStyle PTS;
|
||||
@@ -329,7 +325,6 @@ namespace Pinetime {
|
||||
uint16_t shakeWakeThreshold = 150;
|
||||
|
||||
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
|
||||
Location location = {(int16_t)44,(int16_t)-123,(int8_t)-8};
|
||||
};
|
||||
|
||||
SettingsData settings;
|
||||
|
||||
@@ -46,11 +46,9 @@
|
||||
#include "displayapp/screens/settings/SettingDisplay.h"
|
||||
#include "displayapp/screens/settings/SettingSteps.h"
|
||||
#include "displayapp/screens/settings/SettingSetDateTime.h"
|
||||
#include "displayapp/screens/settings/SettingLocation.h"
|
||||
#include "displayapp/screens/settings/SettingChimes.h"
|
||||
#include "displayapp/screens/settings/SettingShakeThreshold.h"
|
||||
#include "displayapp/screens/settings/SettingBluetooth.h"
|
||||
#include "displayapp/screens/settings/SettingLocation.h"
|
||||
|
||||
#include "libs/lv_conf.h"
|
||||
#include "UserApps.h"
|
||||
@@ -83,7 +81,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||
Pinetime::Controllers::AlarmController& alarmController,
|
||||
Pinetime::Controllers::BrightnessController& brightnessController,
|
||||
Pinetime::Controllers::TouchHandler& touchHandler,
|
||||
Pinetime::Controllers::FS& filesystem)
|
||||
Pinetime::Controllers::FS& filesystem,
|
||||
Pinetime::Drivers::SpiNorFlash& spiNorFlash)
|
||||
: lcd {lcd},
|
||||
touchPanel {touchPanel},
|
||||
batteryController {batteryController},
|
||||
@@ -99,6 +98,7 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||
brightnessController {brightnessController},
|
||||
touchHandler {touchHandler},
|
||||
filesystem {filesystem},
|
||||
spiNorFlash {spiNorFlash},
|
||||
lvgl {lcd, filesystem},
|
||||
timer(this, TimerCallback),
|
||||
controllers {batteryController,
|
||||
@@ -156,6 +156,44 @@ void DisplayApp::InitHw() {
|
||||
lcd.Init();
|
||||
}
|
||||
|
||||
TickType_t DisplayApp::CalculateSleepTime() {
|
||||
// Calculates how many system ticks DisplayApp should sleep before rendering the next AOD frame
|
||||
// Next frame time is frame count * refresh period (ms) * tick rate
|
||||
|
||||
auto RoundedDiv = [](uint32_t a, uint32_t b) {
|
||||
return ((a + (b / 2)) / b);
|
||||
};
|
||||
// RoundedDiv overflows when numerator + (denominator floordiv 2) > uint32 max
|
||||
// in this case around 9 hours (=overflow frame count / always on refresh period)
|
||||
constexpr TickType_t overflowFrameCount = (UINT32_MAX - (1000 / 16)) / ((configTICK_RATE_HZ / 8) * alwaysOnRefreshPeriod);
|
||||
|
||||
TickType_t ticksElapsed = xTaskGetTickCount() - alwaysOnStartTime;
|
||||
// Divide both the numerator and denominator by 8 (=GCD(1000,1024))
|
||||
// to increase the number of ticks (frames) before the overflow tick is reached
|
||||
TickType_t targetRenderTick = RoundedDiv((configTICK_RATE_HZ / 8) * alwaysOnFrameCount * alwaysOnRefreshPeriod, 1000 / 8);
|
||||
|
||||
// Assumptions
|
||||
|
||||
// Tick rate is multiple of 8
|
||||
// Needed for division trick above
|
||||
static_assert(configTICK_RATE_HZ % 8 == 0);
|
||||
|
||||
// Frame count must always wraparound more often than the system tick count does
|
||||
// Always on overflow time (ms) < system tick overflow time (ms)
|
||||
// Using 64bit ints here to avoid overflow
|
||||
static_assert((uint64_t) overflowFrameCount * (uint64_t) alwaysOnRefreshPeriod < (uint64_t) UINT32_MAX * 1000ULL / configTICK_RATE_HZ);
|
||||
|
||||
if (alwaysOnFrameCount == overflowFrameCount) {
|
||||
alwaysOnFrameCount = 0;
|
||||
alwaysOnStartTime = xTaskGetTickCount();
|
||||
}
|
||||
if (targetRenderTick > ticksElapsed) {
|
||||
return targetRenderTick - ticksElapsed;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayApp::Refresh() {
|
||||
auto LoadPreviousScreen = [this]() {
|
||||
FullRefreshDirections returnDirection;
|
||||
@@ -179,21 +217,6 @@ void DisplayApp::Refresh() {
|
||||
LoadScreen(returnAppStack.Pop(), returnDirection);
|
||||
};
|
||||
|
||||
auto DimScreen = [this]() {
|
||||
if (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) {
|
||||
isDimmed = true;
|
||||
brightnessController.Set(Controllers::BrightnessController::Levels::Low);
|
||||
}
|
||||
};
|
||||
|
||||
auto RestoreBrightness = [this]() {
|
||||
if (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) {
|
||||
isDimmed = false;
|
||||
lv_disp_trig_activity(nullptr);
|
||||
ApplyBrightness();
|
||||
}
|
||||
};
|
||||
|
||||
auto IsPastDimTime = [this]() -> bool {
|
||||
return lv_disp_get_inactive_time(nullptr) >= pdMS_TO_TICKS(settingsController.GetScreenTimeOut() - 2000);
|
||||
};
|
||||
@@ -207,6 +230,27 @@ void DisplayApp::Refresh() {
|
||||
case States::Idle:
|
||||
queueTimeout = portMAX_DELAY;
|
||||
break;
|
||||
case States::AOD:
|
||||
if (!currentScreen->IsRunning()) {
|
||||
LoadPreviousScreen();
|
||||
}
|
||||
// Check we've slept long enough
|
||||
// Might not be true if the loop received an event
|
||||
// If not true, then wait that amount of time
|
||||
queueTimeout = CalculateSleepTime();
|
||||
if (queueTimeout == 0) {
|
||||
// Only advance the tick count when LVGL is done
|
||||
// Otherwise keep running the task handler while it still has things to draw
|
||||
// Note: under high graphics load, LVGL will always have more work to do
|
||||
if (lv_task_handler() > 0) {
|
||||
// Drop frames that we've missed if drawing/event handling took way longer than expected
|
||||
while (queueTimeout == 0) {
|
||||
alwaysOnFrameCount += 1;
|
||||
queueTimeout = CalculateSleepTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case States::Running:
|
||||
if (!currentScreen->IsRunning()) {
|
||||
LoadPreviousScreen();
|
||||
@@ -215,14 +259,27 @@ void DisplayApp::Refresh() {
|
||||
|
||||
if (!systemTask->IsSleepDisabled() && IsPastDimTime()) {
|
||||
if (!isDimmed) {
|
||||
DimScreen();
|
||||
isDimmed = true;
|
||||
brightnessController.Set(Controllers::BrightnessController::Levels::Low);
|
||||
}
|
||||
if (IsPastSleepTime()) {
|
||||
systemTask->PushMessage(System::Messages::GoToSleep);
|
||||
state = States::Idle;
|
||||
if (IsPastSleepTime() && uxQueueMessagesWaiting(msgQueue) == 0) {
|
||||
PushMessageToSystemTask(System::Messages::GoToSleep);
|
||||
// Can't set state to Idle here, something may send
|
||||
// DisableSleeping before this GoToSleep arrives
|
||||
// Instead we check we have no messages queued before sending GoToSleep
|
||||
// This works as the SystemTask is higher priority than DisplayApp
|
||||
// As soon as we send GoToSleep, SystemTask pre-empts DisplayApp
|
||||
// Whenever DisplayApp is running again, it is guaranteed that
|
||||
// SystemTask has handled the message
|
||||
// If it responded, we will have a GoToSleep waiting in the queue
|
||||
// By checking that there are no messages in the queue, we avoid
|
||||
// resending GoToSleep when we already have a response
|
||||
// SystemTask is resilient to duplicate messages, this is an
|
||||
// optimisation to reduce pressure on the message queues
|
||||
}
|
||||
} else if (isDimmed) {
|
||||
RestoreBrightness();
|
||||
isDimmed = false;
|
||||
ApplyBrightness();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -232,36 +289,74 @@ void DisplayApp::Refresh() {
|
||||
|
||||
Messages msg;
|
||||
if (xQueueReceive(msgQueue, &msg, queueTimeout) == pdTRUE) {
|
||||
|
||||
// let's do otaku chimes
|
||||
uint8_t myHour = dateTimeController.Hours();
|
||||
uint8_t myChimes = 9-(((int)floor(myHour/2))%6);
|
||||
|
||||
switch (msg) {
|
||||
case Messages::DimScreen:
|
||||
DimScreen();
|
||||
break;
|
||||
case Messages::RestoreBrightness:
|
||||
RestoreBrightness();
|
||||
break;
|
||||
case Messages::GoToSleep:
|
||||
while (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) {
|
||||
case Messages::GoToAOD:
|
||||
// Checking if SystemTask is sleeping is purely an optimisation.
|
||||
// If it's no longer sleeping since it sent GoToSleep, it has
|
||||
// cancelled the sleep and transitioned directly from
|
||||
// GoingToSleep->Running, so we are about to receive GoToRunning
|
||||
// and can ignore this message. If it wasn't ignored, DisplayApp
|
||||
// would go to sleep and then immediately re-wake
|
||||
if (state != States::Running || !systemTask->IsSleeping()) {
|
||||
break;
|
||||
}
|
||||
while (brightnessController.Level() != Controllers::BrightnessController::Levels::Low) {
|
||||
brightnessController.Lower();
|
||||
vTaskDelay(100);
|
||||
}
|
||||
// Turn brightness down (or set to AlwaysOn mode)
|
||||
if (msg == Messages::GoToAOD) {
|
||||
brightnessController.Set(Controllers::BrightnessController::Levels::AlwaysOn);
|
||||
} else {
|
||||
brightnessController.Set(Controllers::BrightnessController::Levels::Off);
|
||||
}
|
||||
// Since the active screen is not really an app, go back to Clock.
|
||||
if (currentApp == Apps::Launcher || currentApp == Apps::Notifications || currentApp == Apps::QuickSettings ||
|
||||
currentApp == Apps::Settings) {
|
||||
LoadScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None);
|
||||
// Wait for the clock app to load before moving on.
|
||||
while (!lv_task_handler()) {
|
||||
};
|
||||
}
|
||||
// Clear any ongoing touch pressed events
|
||||
// Without this LVGL gets stuck in the pressed state and will keep refreshing the
|
||||
// display activity timer causing the screen to never sleep after timeout
|
||||
lvgl.ClearTouchState();
|
||||
if (msg == Messages::GoToAOD) {
|
||||
lcd.LowPowerOn();
|
||||
// Record idle entry time
|
||||
alwaysOnFrameCount = 0;
|
||||
alwaysOnStartTime = xTaskGetTickCount();
|
||||
PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskAOD);
|
||||
state = States::AOD;
|
||||
} else {
|
||||
lcd.Sleep();
|
||||
PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping);
|
||||
state = States::Idle;
|
||||
}
|
||||
break;
|
||||
case Messages::NotifyDeviceActivity:
|
||||
lv_disp_trig_activity(nullptr);
|
||||
break;
|
||||
case Messages::GoToRunning:
|
||||
// If SystemTask is sleeping, the GoToRunning message is old
|
||||
// and must be ignored. Otherwise DisplayApp will use SPI
|
||||
// that is powered down and cause bad behaviour
|
||||
if (state == States::Running || systemTask->IsSleeping()) {
|
||||
break;
|
||||
}
|
||||
if (state == States::AOD) {
|
||||
lcd.LowPowerOff();
|
||||
} else {
|
||||
lcd.Wakeup();
|
||||
}
|
||||
lv_disp_trig_activity(nullptr);
|
||||
ApplyBrightness();
|
||||
state = States::Running;
|
||||
break;
|
||||
case Messages::UpdateBleConnection:
|
||||
// clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected :
|
||||
// Screens::Clock::BleConnectionStates::NotConnected);
|
||||
// Only used for recovery firmware
|
||||
break;
|
||||
case Messages::NewNotification:
|
||||
LoadNewScreen(Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down);
|
||||
@@ -376,54 +471,17 @@ void DisplayApp::Refresh() {
|
||||
case Messages::BleRadioEnableToggle:
|
||||
PushMessageToSystemTask(System::Messages::BleRadioEnableToggle);
|
||||
break;
|
||||
case Messages::UpdateDateTime:
|
||||
// Added to remove warning
|
||||
// What should happen here?
|
||||
break;
|
||||
case Messages::Chime:
|
||||
LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None);
|
||||
|
||||
// hour chime
|
||||
// 0 9
|
||||
// 1 9
|
||||
// 2 8
|
||||
// 3 8
|
||||
// 4 7
|
||||
// 5 7
|
||||
// 6 6
|
||||
// 7 6
|
||||
// 8 5
|
||||
// 9 5
|
||||
// 10 4
|
||||
// 11 4
|
||||
// 12 9
|
||||
// 13 9
|
||||
// 14 8
|
||||
// 15 8
|
||||
// 16 7
|
||||
// 17 7
|
||||
// 18 6
|
||||
// 19 6
|
||||
// 20 5
|
||||
// 21 5
|
||||
// 22 4
|
||||
// 23 4
|
||||
// NRF_LOG_INFO("buzzing %d times", myChimes);
|
||||
|
||||
for (uint8_t i=0; i<myChimes; i++){
|
||||
// NRF_LOG_INFO("buzz!");
|
||||
motorController.RunForDuration(15);
|
||||
vTaskDelay(1000);
|
||||
}
|
||||
motorController.RunForDuration(35);
|
||||
break;
|
||||
case Messages::OnChargingEvent:
|
||||
RestoreBrightness();
|
||||
motorController.RunForDuration(15);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (touchHandler.IsTouching()) {
|
||||
if (state == States::Running && touchHandler.IsTouching()) {
|
||||
currentScreen->OnTouchEvent(touchHandler.GetX(), touchHandler.GetY());
|
||||
}
|
||||
|
||||
@@ -546,7 +604,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
||||
currentScreen = std::make_unique<Screens::SettingWakeUp>(settingsController);
|
||||
break;
|
||||
case Apps::SettingDisplay:
|
||||
currentScreen = std::make_unique<Screens::SettingDisplay>(this, settingsController);
|
||||
currentScreen = std::make_unique<Screens::SettingDisplay>(settingsController);
|
||||
break;
|
||||
case Apps::SettingSteps:
|
||||
currentScreen = std::make_unique<Screens::SettingSteps>(settingsController);
|
||||
@@ -554,9 +612,6 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
||||
case Apps::SettingSetDateTime:
|
||||
currentScreen = std::make_unique<Screens::SettingSetDateTime>(this, dateTimeController, settingsController);
|
||||
break;
|
||||
case Apps::SettingLocation:
|
||||
currentScreen = std::make_unique<Screens::SettingLocation>(settingsController);
|
||||
break;
|
||||
case Apps::SettingChimes:
|
||||
currentScreen = std::make_unique<Screens::SettingChimes>(settingsController);
|
||||
break;
|
||||
@@ -577,7 +632,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
||||
bleController,
|
||||
watchdog,
|
||||
motionController,
|
||||
touchPanel);
|
||||
touchPanel,
|
||||
spiNorFlash);
|
||||
break;
|
||||
case Apps::FlashLight:
|
||||
currentScreen = std::make_unique<Screens::FlashLight>(*systemTask, brightnessController);
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Pinetime {
|
||||
namespace Applications {
|
||||
class DisplayApp {
|
||||
public:
|
||||
enum class States { Idle, Running };
|
||||
enum class States { Idle, Running, AOD };
|
||||
enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim };
|
||||
|
||||
DisplayApp(Drivers::St7789& lcd,
|
||||
@@ -66,7 +66,8 @@ namespace Pinetime {
|
||||
Pinetime::Controllers::AlarmController& alarmController,
|
||||
Pinetime::Controllers::BrightnessController& brightnessController,
|
||||
Pinetime::Controllers::TouchHandler& touchHandler,
|
||||
Pinetime::Controllers::FS& filesystem);
|
||||
Pinetime::Controllers::FS& filesystem,
|
||||
Pinetime::Drivers::SpiNorFlash& spiNorFlash);
|
||||
void Start(System::BootErrors error);
|
||||
void PushMessage(Display::Messages msg);
|
||||
|
||||
@@ -96,6 +97,7 @@ namespace Pinetime {
|
||||
Pinetime::Controllers::BrightnessController& brightnessController;
|
||||
Pinetime::Controllers::TouchHandler& touchHandler;
|
||||
Pinetime::Controllers::FS& filesystem;
|
||||
Pinetime::Drivers::SpiNorFlash& spiNorFlash;
|
||||
|
||||
Pinetime::Controllers::FirmwareValidator validator;
|
||||
Pinetime::Components::LittleVgl lvgl;
|
||||
@@ -135,6 +137,13 @@ namespace Pinetime {
|
||||
Utility::StaticStack<FullRefreshDirections, returnAppStackSize> appStackDirections;
|
||||
|
||||
bool isDimmed = false;
|
||||
|
||||
TickType_t CalculateSleepTime();
|
||||
TickType_t alwaysOnFrameCount;
|
||||
TickType_t alwaysOnStartTime;
|
||||
// If this is to be changed, make sure the actual always on refresh rate is changed
|
||||
// by configuring the LCD refresh timings
|
||||
static constexpr uint32_t alwaysOnRefreshPeriod = 500;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||
Pinetime::Controllers::AlarmController& /*alarmController*/,
|
||||
Pinetime::Controllers::BrightnessController& /*brightnessController*/,
|
||||
Pinetime::Controllers::TouchHandler& /*touchHandler*/,
|
||||
Pinetime::Controllers::FS& /*filesystem*/)
|
||||
Pinetime::Controllers::FS& /*filesystem*/,
|
||||
Pinetime::Drivers::SpiNorFlash& /*spiNorFlash*/)
|
||||
: lcd {lcd}, bleController {bleController} {
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Pinetime {
|
||||
class St7789;
|
||||
class Cst816S;
|
||||
class Watchdog;
|
||||
class SpiNorFlash;
|
||||
}
|
||||
|
||||
namespace Controllers {
|
||||
@@ -59,7 +60,8 @@ namespace Pinetime {
|
||||
Pinetime::Controllers::AlarmController& alarmController,
|
||||
Pinetime::Controllers::BrightnessController& brightnessController,
|
||||
Pinetime::Controllers::TouchHandler& touchHandler,
|
||||
Pinetime::Controllers::FS& filesystem);
|
||||
Pinetime::Controllers::FS& filesystem,
|
||||
Pinetime::Drivers::SpiNorFlash& spiNorFlash);
|
||||
void Start();
|
||||
|
||||
void Start(Pinetime::System::BootErrors) {
|
||||
|
||||
@@ -248,6 +248,8 @@ void LittleVgl::SetNewTouchPoint(int16_t x, int16_t y, bool contact) {
|
||||
}
|
||||
}
|
||||
|
||||
// Cancel an ongoing tap
|
||||
// Signifies that LVGL should not handle the current tap
|
||||
void LittleVgl::CancelTap() {
|
||||
if (tapped) {
|
||||
isCancelled = true;
|
||||
@@ -255,6 +257,13 @@ void LittleVgl::CancelTap() {
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the current tapped state
|
||||
// Signifies that touch input processing is suspended
|
||||
void LittleVgl::ClearTouchState() {
|
||||
touchPoint = {-1, -1};
|
||||
tapped = false;
|
||||
}
|
||||
|
||||
bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
|
||||
ptr->point.x = touchPoint.x;
|
||||
ptr->point.y = touchPoint.y;
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Pinetime {
|
||||
void SetFullRefresh(FullRefreshDirections direction);
|
||||
void SetNewTouchPoint(int16_t x, int16_t y, bool contact);
|
||||
void CancelTap();
|
||||
void ClearTouchState();
|
||||
|
||||
bool GetFullRefresh() {
|
||||
bool returnValue = fullRefresh;
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace Pinetime {
|
||||
namespace Display {
|
||||
enum class Messages : uint8_t {
|
||||
GoToSleep,
|
||||
GoToAOD,
|
||||
GoToRunning,
|
||||
UpdateDateTime,
|
||||
UpdateBleConnection,
|
||||
TouchEvent,
|
||||
ButtonPushed,
|
||||
@@ -17,8 +17,9 @@ namespace Pinetime {
|
||||
NewNotification,
|
||||
TimerDone,
|
||||
BleFirmwareUpdateStarted,
|
||||
DimScreen,
|
||||
RestoreBrightness,
|
||||
// Resets the screen timeout timer when awake
|
||||
// Does nothing when asleep
|
||||
NotifyDeviceActivity,
|
||||
ShowPairingKey,
|
||||
AlarmTriggered,
|
||||
Chime,
|
||||
|
||||
@@ -8,14 +8,12 @@
|
||||
#include "displayapp/screens/Twos.h"
|
||||
#include "displayapp/screens/Tile.h"
|
||||
#include "displayapp/screens/ApplicationList.h"
|
||||
//#include "displayapp/screens/WatchFaceDigital.h"
|
||||
#include "displayapp/screens/WatchFaceDigital.h"
|
||||
#include "displayapp/screens/WatchFaceAnalog.h"
|
||||
// #include "displayapp/screens/WatchFaceCasioStyleG7710.h"
|
||||
// #include "displayapp/screens/WatchFaceInfineat.h"
|
||||
#include "displayapp/screens/WatchFaceCasioStyleG7710.h"
|
||||
#include "displayapp/screens/WatchFaceInfineat.h"
|
||||
#include "displayapp/screens/WatchFacePineTimeStyle.h"
|
||||
// #include "displayapp/screens/WatchFaceTerminal.h"
|
||||
// #include "displayapp/screens/WatchFaceFuzzy.h"
|
||||
// #include "displayapp/screens/WatchFaceSundial.h"
|
||||
#include "displayapp/screens/WatchFaceTerminal.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Applications {
|
||||
|
||||
@@ -39,7 +39,6 @@ namespace Pinetime {
|
||||
SettingWakeUp,
|
||||
SettingSteps,
|
||||
SettingSetDateTime,
|
||||
SettingLocation,
|
||||
SettingChimes,
|
||||
SettingShakeThreshold,
|
||||
SettingBluetooth,
|
||||
@@ -47,14 +46,12 @@ namespace Pinetime {
|
||||
};
|
||||
|
||||
enum class WatchFace : uint8_t {
|
||||
Digital,
|
||||
Analog,
|
||||
PineTimeStyle,
|
||||
Digital,
|
||||
Terminal,
|
||||
Fuzzy,
|
||||
//Sundial,
|
||||
//Infineat,
|
||||
//CasioStyleG7710,
|
||||
Infineat,
|
||||
CasioStyleG7710,
|
||||
};
|
||||
|
||||
template <Apps>
|
||||
@@ -75,9 +72,7 @@ namespace Pinetime {
|
||||
static constexpr size_t Count = sizeof...(Ws);
|
||||
};
|
||||
|
||||
using UserWatchFaceTypes = WatchFaceTypeList<WatchFace::Analog,
|
||||
WatchFace::PineTimeStyle>;
|
||||
//using UserWatchFaceTypes = WatchFaceTypeList<@WATCHFACE_TYPES@>;
|
||||
using UserWatchFaceTypes = WatchFaceTypeList<@WATCHFACE_TYPES@>;
|
||||
|
||||
static_assert(UserWatchFaceTypes::Count >= 1);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
#"Apps::Navigation, Apps::StopWatch, Apps::Timer, Apps::Alarm, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Twos"
|
||||
#Apps::Paint, Apps::Metronome, Apps::Paddle
|
||||
if(DEFINED ENABLE_USERAPPS)
|
||||
set(USERAPP_TYPES ${ENABLE_USERAPPS} CACHE STRING "List of user apps to build into the firmware")
|
||||
else ()
|
||||
set(DEFAULT_USER_APP_TYPES "Apps::StopWatch")
|
||||
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Alarm")
|
||||
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Timer")
|
||||
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Steps")
|
||||
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::HeartRate")
|
||||
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Music")
|
||||
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Paint")
|
||||
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Paddle")
|
||||
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Twos")
|
||||
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Dice")
|
||||
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Metronome")
|
||||
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Navigation")
|
||||
set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Weather")
|
||||
#set(DEFAULT_USER_APP_TYPES "${DEFAULT_USER_APP_TYPES}, Apps::Motion")
|
||||
set(USERAPP_TYPES "${DEFAULT_USER_APP_TYPES}" CACHE STRING "List of user apps to build into the firmware")
|
||||
endif ()
|
||||
|
||||
@@ -16,7 +22,11 @@ if(DEFINED ENABLE_WATCHFACES)
|
||||
set(WATCHFACE_TYPES ${ENABLE_WATCHFACES} CACHE STRING "List of watch faces to build into the firmware")
|
||||
else()
|
||||
set(DEFAULT_WATCHFACE_TYPES "WatchFace::Digital")
|
||||
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Fuzzy")
|
||||
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Analog")
|
||||
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::PineTimeStyle")
|
||||
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Terminal")
|
||||
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Infineat")
|
||||
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::CasioStyleG7710")
|
||||
set(WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}" CACHE STRING "List of watch faces to build into the firmware")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
set(FONTS jetbrains_mono_42 noto_serif_cjk_20 noto_serif_cjk_15 jetbrains_mono_76 jetbrains_mono_bold_20 jetbrains_mono_bold_24
|
||||
set(FONTS jetbrains_mono_42 jetbrains_mono_76 jetbrains_mono_bold_20
|
||||
jetbrains_mono_extrabold_compressed lv_font_sys_48
|
||||
open_sans_light fontawesome_weathericons)
|
||||
find_program(LV_FONT_CONV "lv_font_conv" NO_CACHE REQUIRED
|
||||
@@ -11,6 +11,7 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/jetbrains_mono_bold_20.c_M.patch
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
|
||||
# FindPython3 module introduces with CMake 3.12
|
||||
# https://cmake.org/cmake/help/latest/module/FindPython3.html
|
||||
set(Python3_FIND_STRATEGY LOCATION) # https://discourse.cmake.org/t/find-package-python3-is-not-finding-the-correct-python/10563
|
||||
find_package(Python3 REQUIRED)
|
||||
else()
|
||||
set(Python3_EXECUTABLE "python")
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
"jetbrains_mono_bold_20": {
|
||||
"sources": [
|
||||
{
|
||||
"file": "Vulf_Mono-Italic.woff",
|
||||
"range": "0x20-0x7e, 0xB0"
|
||||
"file": "JetBrainsMono-Bold.ttf",
|
||||
"range": "0x20-0x7e, 0x410-0x44f, 0xB0"
|
||||
},
|
||||
{
|
||||
"file": "FontAwesome5-Solid+Brands+Regular.woff",
|
||||
@@ -11,53 +11,18 @@
|
||||
}
|
||||
],
|
||||
"bpp": 1,
|
||||
"size": 18
|
||||
},
|
||||
"jetbrains_mono_bold_24": {
|
||||
"sources": [
|
||||
{
|
||||
"file": "Vulf_Mono-Italic.woff",
|
||||
"range": "0x20-0x7e, 0xB0"
|
||||
},
|
||||
{
|
||||
"file": "FontAwesome5-Solid+Brands+Regular.woff",
|
||||
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf0f3, 0xf522, 0xf743"
|
||||
}
|
||||
],
|
||||
"bpp": 1,
|
||||
"size": 26
|
||||
},
|
||||
"noto_serif_cjk_20": {
|
||||
"sources": [
|
||||
{
|
||||
"file": "NotoSerifCJKjp-VF.ttf",
|
||||
"symbols": "丑寅卯辰巳午未申酉戌亥子四五六七八九"
|
||||
}
|
||||
],
|
||||
"bpp": 1,
|
||||
"size": 20
|
||||
},
|
||||
"noto_serif_cjk_15": {
|
||||
"sources": [
|
||||
{
|
||||
"file": "NotoSerifCJKjp-VF.ttf",
|
||||
"symbols": "四五六七八九"
|
||||
}
|
||||
],
|
||||
"bpp": 1,
|
||||
"size": 15
|
||||
"size": 20,
|
||||
"patches": ["jetbrains_mono_bold_20.c_zero.patch", "jetbrains_mono_bold_20.c_M.patch"]
|
||||
},
|
||||
"jetbrains_mono_42": {
|
||||
"sources": [
|
||||
{
|
||||
"file": "JetBrainsMono-Regular.ttf",
|
||||
"disabledfile": "Vulf Mono Light Italic.ttf",
|
||||
"range": "0x20, 0x25, 0x27, 0x2b, 0x2d, 0x30-0x3a, 0x4b-0x4d, 0x61-0x7a",
|
||||
"disabledrange": "0x25, 0x2b, 0x2d, 0x2e, 0x30-0x3a, 0x43, 0x46, 0x4b-0x4d, 0x66, 0x69, 0x6b, 0x6d, 0x74, 0xb0"
|
||||
"range": "0x25, 0x2b, 0x2d, 0x2e, 0x30-0x3a, 0x43, 0x46, 0x4b-0x4d, 0x66, 0x69, 0x6b, 0x6d, 0x74, 0xb0"
|
||||
}
|
||||
],
|
||||
"bpp": 1,
|
||||
"size": 30
|
||||
"size": 42
|
||||
},
|
||||
"jetbrains_mono_76": {
|
||||
"sources": [
|
||||
|
||||
@@ -48,7 +48,7 @@ Alarm::Alarm(Controllers::AlarmController& alarmController,
|
||||
Controllers::Settings::ClockType clockType,
|
||||
System::SystemTask& systemTask,
|
||||
Controllers::MotorController& motorController)
|
||||
: alarmController {alarmController}, systemTask {systemTask}, motorController {motorController} {
|
||||
: alarmController {alarmController}, wakeLock(systemTask), motorController {motorController} {
|
||||
|
||||
hourCounter.Create();
|
||||
lv_obj_align(hourCounter.GetObject(), nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
||||
@@ -117,7 +117,7 @@ Alarm::Alarm(Controllers::AlarmController& alarmController,
|
||||
|
||||
UpdateAlarmTime();
|
||||
|
||||
if (alarmController.State() == Controllers::AlarmController::AlarmState::Alerting) {
|
||||
if (alarmController.IsAlerting()) {
|
||||
SetAlerting();
|
||||
} else {
|
||||
SetSwitchState(LV_ANIM_OFF);
|
||||
@@ -125,14 +125,15 @@ Alarm::Alarm(Controllers::AlarmController& alarmController,
|
||||
}
|
||||
|
||||
Alarm::~Alarm() {
|
||||
if (alarmController.State() == AlarmController::AlarmState::Alerting) {
|
||||
if (alarmController.IsAlerting()) {
|
||||
StopAlerting();
|
||||
}
|
||||
lv_obj_clean(lv_scr_act());
|
||||
alarmController.SaveAlarm();
|
||||
}
|
||||
|
||||
void Alarm::DisableAlarm() {
|
||||
if (alarmController.State() == AlarmController::AlarmState::Set) {
|
||||
if (alarmController.IsEnabled()) {
|
||||
alarmController.DisableAlarm();
|
||||
lv_switch_off(enableSwitch, LV_ANIM_ON);
|
||||
}
|
||||
@@ -172,7 +173,7 @@ bool Alarm::OnButtonPushed() {
|
||||
HideInfo();
|
||||
return true;
|
||||
}
|
||||
if (alarmController.State() == AlarmController::AlarmState::Alerting) {
|
||||
if (alarmController.IsAlerting()) {
|
||||
StopAlerting();
|
||||
return true;
|
||||
}
|
||||
@@ -181,7 +182,7 @@ bool Alarm::OnButtonPushed() {
|
||||
|
||||
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;
|
||||
return alarmController.IsAlerting() && event == TouchEvents::SwipeDown;
|
||||
}
|
||||
|
||||
void Alarm::OnValueChanged() {
|
||||
@@ -205,7 +206,7 @@ void Alarm::SetAlerting() {
|
||||
lv_obj_set_hidden(btnStop, false);
|
||||
taskStopAlarm = lv_task_create(StopAlarmTaskCallback, pdMS_TO_TICKS(60 * 1000), LV_TASK_PRIO_MID, this);
|
||||
motorController.StartRinging();
|
||||
systemTask.PushMessage(System::Messages::DisableSleeping);
|
||||
wakeLock.Lock();
|
||||
}
|
||||
|
||||
void Alarm::StopAlerting() {
|
||||
@@ -216,21 +217,16 @@ void Alarm::StopAlerting() {
|
||||
lv_task_del(taskStopAlarm);
|
||||
taskStopAlarm = nullptr;
|
||||
}
|
||||
systemTask.PushMessage(System::Messages::EnableSleeping);
|
||||
wakeLock.Release();
|
||||
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:
|
||||
if (alarmController.IsEnabled()) {
|
||||
lv_switch_on(enableSwitch, anim);
|
||||
break;
|
||||
case AlarmController::AlarmState::Not_Set:
|
||||
} else {
|
||||
lv_switch_off(enableSwitch, anim);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +243,7 @@ void Alarm::ShowInfo() {
|
||||
txtMessage = lv_label_create(btnMessage, nullptr);
|
||||
lv_obj_set_style_local_bg_color(btnMessage, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_NAVY);
|
||||
|
||||
if (alarmController.State() == AlarmController::AlarmState::Set) {
|
||||
if (alarmController.IsEnabled()) {
|
||||
auto timeToAlarm = alarmController.SecondsToAlarm();
|
||||
|
||||
auto daysToAlarm = timeToAlarm / 86400;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "displayapp/widgets/Counter.h"
|
||||
#include "displayapp/Controllers.h"
|
||||
#include "systemtask/WakeLock.h"
|
||||
#include "Symbols.h"
|
||||
|
||||
namespace Pinetime {
|
||||
@@ -43,7 +44,7 @@ namespace Pinetime {
|
||||
|
||||
private:
|
||||
Controllers::AlarmController& alarmController;
|
||||
System::SystemTask& systemTask;
|
||||
System::WakeLock wakeLock;
|
||||
Controllers::MotorController& motorController;
|
||||
|
||||
lv_obj_t *btnStop, *txtStop, *btnRecur, *txtRecur, *btnInfo, *enableSwitch;
|
||||
|
||||
@@ -15,8 +15,9 @@ namespace {
|
||||
}
|
||||
|
||||
FlashLight::FlashLight(System::SystemTask& systemTask, Controllers::BrightnessController& brightnessController)
|
||||
: systemTask {systemTask}, brightnessController {brightnessController} {
|
||||
: wakeLock(systemTask), brightnessController {brightnessController} {
|
||||
|
||||
previousBrightnessLevel = brightnessController.Level();
|
||||
brightnessController.Set(Controllers::BrightnessController::Levels::Low);
|
||||
|
||||
flashLight = lv_label_create(lv_scr_act(), nullptr);
|
||||
@@ -46,13 +47,13 @@ FlashLight::FlashLight(System::SystemTask& systemTask, Controllers::BrightnessCo
|
||||
backgroundAction->user_data = this;
|
||||
lv_obj_set_event_cb(backgroundAction, EventHandler);
|
||||
|
||||
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
|
||||
wakeLock.Lock();
|
||||
}
|
||||
|
||||
FlashLight::~FlashLight() {
|
||||
lv_obj_clean(lv_scr_act());
|
||||
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||
brightnessController.Set(previousBrightnessLevel);
|
||||
}
|
||||
|
||||
void FlashLight::SetColors() {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "components/brightness/BrightnessController.h"
|
||||
#include "systemtask/SystemTask.h"
|
||||
#include "systemtask/WakeLock.h"
|
||||
#include <cstdint>
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
@@ -23,10 +24,11 @@ namespace Pinetime {
|
||||
void SetIndicators();
|
||||
void SetColors();
|
||||
|
||||
Pinetime::System::SystemTask& systemTask;
|
||||
Pinetime::System::WakeLock wakeLock;
|
||||
Controllers::BrightnessController& brightnessController;
|
||||
|
||||
Controllers::BrightnessController::Levels brightnessLevel = Controllers::BrightnessController::Levels::High;
|
||||
Controllers::BrightnessController::Levels previousBrightnessLevel;
|
||||
|
||||
lv_obj_t* flashLight;
|
||||
lv_obj_t* backgroundAction;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace {
|
||||
}
|
||||
|
||||
HeartRate::HeartRate(Controllers::HeartRateController& heartRateController, System::SystemTask& systemTask)
|
||||
: heartRateController {heartRateController}, systemTask {systemTask} {
|
||||
: heartRateController {heartRateController}, wakeLock(systemTask) {
|
||||
bool isHrRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
|
||||
label_hr = lv_label_create(lv_scr_act(), nullptr);
|
||||
|
||||
@@ -63,7 +63,7 @@ HeartRate::HeartRate(Controllers::HeartRateController& heartRateController, Syst
|
||||
label_startStop = lv_label_create(btn_startStop, nullptr);
|
||||
UpdateStartStopButton(isHrRunning);
|
||||
if (isHrRunning) {
|
||||
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
|
||||
wakeLock.Lock();
|
||||
}
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
|
||||
@@ -72,7 +72,6 @@ HeartRate::HeartRate(Controllers::HeartRateController& heartRateController, Syst
|
||||
HeartRate::~HeartRate() {
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||
}
|
||||
|
||||
void HeartRate::Refresh() {
|
||||
@@ -101,12 +100,12 @@ void HeartRate::OnStartStopEvent(lv_event_t event) {
|
||||
if (heartRateController.State() == Controllers::HeartRateController::States::Stopped) {
|
||||
heartRateController.Start();
|
||||
UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped);
|
||||
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
|
||||
wakeLock.Lock();
|
||||
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::highlight);
|
||||
} else {
|
||||
heartRateController.Stop();
|
||||
UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped);
|
||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||
wakeLock.Release();
|
||||
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <chrono>
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "systemtask/SystemTask.h"
|
||||
#include "systemtask/WakeLock.h"
|
||||
#include "Symbols.h"
|
||||
#include <lvgl/src/lv_core/lv_style.h>
|
||||
#include <lvgl/src/lv_core/lv_obj.h>
|
||||
@@ -27,7 +28,7 @@ namespace Pinetime {
|
||||
|
||||
private:
|
||||
Controllers::HeartRateController& heartRateController;
|
||||
Pinetime::System::SystemTask& systemTask;
|
||||
Pinetime::System::WakeLock wakeLock;
|
||||
void UpdateStartStopButton(bool isRunning);
|
||||
lv_obj_t* label_hr;
|
||||
lv_obj_t* label_bpm;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace {
|
||||
}
|
||||
|
||||
Metronome::Metronome(Controllers::MotorController& motorController, System::SystemTask& systemTask)
|
||||
: motorController {motorController}, systemTask {systemTask} {
|
||||
: motorController {motorController}, wakeLock(systemTask) {
|
||||
|
||||
bpmArc = lv_arc_create(lv_scr_act(), nullptr);
|
||||
bpmArc->user_data = this;
|
||||
@@ -72,7 +72,6 @@ Metronome::Metronome(Controllers::MotorController& motorController, System::Syst
|
||||
|
||||
Metronome::~Metronome() {
|
||||
lv_task_del(taskRefresh);
|
||||
systemTask.PushMessage(System::Messages::EnableSleeping);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
@@ -128,12 +127,12 @@ void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
|
||||
metronomeStarted = !metronomeStarted;
|
||||
if (metronomeStarted) {
|
||||
lv_label_set_text_static(lblPlayPause, Symbols::pause);
|
||||
systemTask.PushMessage(System::Messages::DisableSleeping);
|
||||
wakeLock.Lock();
|
||||
startTime = xTaskGetTickCount();
|
||||
counter = 1;
|
||||
} else {
|
||||
lv_label_set_text_static(lblPlayPause, Symbols::play);
|
||||
systemTask.PushMessage(System::Messages::EnableSleeping);
|
||||
wakeLock.Release();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "systemtask/SystemTask.h"
|
||||
#include "systemtask/WakeLock.h"
|
||||
#include "components/motor/MotorController.h"
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "Symbols.h"
|
||||
@@ -21,7 +22,7 @@ namespace Pinetime {
|
||||
TickType_t startTime = 0;
|
||||
TickType_t tappedTime = 0;
|
||||
Controllers::MotorController& motorController;
|
||||
System::SystemTask& systemTask;
|
||||
System::WakeLock wakeLock;
|
||||
int16_t bpm = 120;
|
||||
uint8_t bpb = 4;
|
||||
uint8_t counter = 1;
|
||||
|
||||
@@ -20,7 +20,7 @@ Notifications::Notifications(DisplayApp* app,
|
||||
notificationManager {notificationManager},
|
||||
alertNotificationService {alertNotificationService},
|
||||
motorController {motorController},
|
||||
systemTask {systemTask},
|
||||
wakeLock(systemTask),
|
||||
mode {mode} {
|
||||
|
||||
notificationManager.ClearNewNotificationFlag();
|
||||
@@ -40,7 +40,7 @@ Notifications::Notifications(DisplayApp* app,
|
||||
validDisplay = false;
|
||||
}
|
||||
if (mode == Modes::Preview) {
|
||||
systemTask.PushMessage(System::Messages::DisableSleeping);
|
||||
wakeLock.Lock();
|
||||
if (notification.category == Controllers::NotificationManager::Categories::IncomingCall) {
|
||||
motorController.StartRinging();
|
||||
} else {
|
||||
@@ -65,7 +65,6 @@ Notifications::~Notifications() {
|
||||
lv_task_del(taskRefresh);
|
||||
// make sure we stop any vibrations before exiting
|
||||
motorController.StopRinging();
|
||||
systemTask.PushMessage(System::Messages::EnableSleeping);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
@@ -82,7 +81,6 @@ void Notifications::Refresh() {
|
||||
|
||||
} else if (mode == Modes::Preview && dismissingNotification) {
|
||||
running = false;
|
||||
currentItem = std::make_unique<NotificationItem>(alertNotificationService, motorController);
|
||||
|
||||
} else if (dismissingNotification) {
|
||||
dismissingNotification = false;
|
||||
@@ -113,15 +111,15 @@ void Notifications::Refresh() {
|
||||
alertNotificationService,
|
||||
motorController);
|
||||
} else {
|
||||
currentItem = std::make_unique<NotificationItem>(alertNotificationService, motorController);
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
running = currentItem->IsRunning() && running;
|
||||
running = running && currentItem->IsRunning();
|
||||
}
|
||||
|
||||
void Notifications::OnPreviewInteraction() {
|
||||
systemTask.PushMessage(System::Messages::EnableSleeping);
|
||||
wakeLock.Release();
|
||||
motorController.StopRinging();
|
||||
if (timeoutLine != nullptr) {
|
||||
lv_obj_del(timeoutLine);
|
||||
@@ -173,7 +171,9 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
} else if (nextMessage.valid) {
|
||||
currentId = nextMessage.id;
|
||||
} else {
|
||||
// don't update id, won't be found be refresh and try to load latest message or no message box
|
||||
// don't update id, notification manager will try to fetch
|
||||
// but not find it. Refresh will try to load latest message
|
||||
// or dismiss to watchface
|
||||
}
|
||||
DismissToBlack();
|
||||
return true;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "components/ble/NotificationManager.h"
|
||||
#include "components/motor/MotorController.h"
|
||||
#include "systemtask/SystemTask.h"
|
||||
#include "systemtask/WakeLock.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
@@ -73,7 +74,7 @@ namespace Pinetime {
|
||||
Pinetime::Controllers::NotificationManager& notificationManager;
|
||||
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
|
||||
Pinetime::Controllers::MotorController& motorController;
|
||||
System::SystemTask& systemTask;
|
||||
System::WakeLock wakeLock;
|
||||
Modes mode = Modes::Normal;
|
||||
std::unique_ptr<NotificationItem> currentItem;
|
||||
Pinetime::Controllers::NotificationManager::Notification::Id currentId;
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace {
|
||||
constexpr TickType_t blinkInterval = pdMS_TO_TICKS(1000);
|
||||
}
|
||||
|
||||
StopWatch::StopWatch(System::SystemTask& systemTask) : systemTask {systemTask} {
|
||||
StopWatch::StopWatch(System::SystemTask& systemTask) : wakeLock(systemTask) {
|
||||
static constexpr uint8_t btnWidth = 115;
|
||||
static constexpr uint8_t btnHeight = 80;
|
||||
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
|
||||
@@ -79,7 +79,6 @@ StopWatch::StopWatch(System::SystemTask& systemTask) : systemTask {systemTask} {
|
||||
|
||||
StopWatch::~StopWatch() {
|
||||
lv_task_del(taskRefresh);
|
||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
@@ -135,7 +134,7 @@ void StopWatch::Start() {
|
||||
SetInterfaceRunning();
|
||||
startTime = xTaskGetTickCount();
|
||||
currentState = States::Running;
|
||||
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
|
||||
wakeLock.Lock();
|
||||
}
|
||||
|
||||
void StopWatch::Pause() {
|
||||
@@ -145,7 +144,7 @@ void StopWatch::Pause() {
|
||||
oldTimeElapsed = laps[lapsDone];
|
||||
blinkTime = xTaskGetTickCount() + blinkInterval;
|
||||
currentState = States::Halted;
|
||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||
wakeLock.Release();
|
||||
}
|
||||
|
||||
void StopWatch::Refresh() {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "portmacro_cmsis.h"
|
||||
|
||||
#include "systemtask/SystemTask.h"
|
||||
#include "systemtask/WakeLock.h"
|
||||
#include "displayapp/apps/Apps.h"
|
||||
#include "displayapp/Controllers.h"
|
||||
#include "Symbols.h"
|
||||
@@ -43,7 +44,7 @@ namespace Pinetime {
|
||||
void Start();
|
||||
void Pause();
|
||||
|
||||
Pinetime::System::SystemTask& systemTask;
|
||||
Pinetime::System::WakeLock wakeLock;
|
||||
States currentState = States::Init;
|
||||
TickType_t startTime;
|
||||
TickType_t oldTimeElapsed = 0;
|
||||
|
||||
@@ -38,15 +38,16 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
|
||||
const Pinetime::Controllers::Ble& bleController,
|
||||
const Pinetime::Drivers::Watchdog& watchdog,
|
||||
Pinetime::Controllers::MotionController& motionController,
|
||||
const Pinetime::Drivers::Cst816S& touchPanel)
|
||||
: app {app},
|
||||
dateTimeController {dateTimeController},
|
||||
const Pinetime::Drivers::Cst816S& touchPanel,
|
||||
const Pinetime::Drivers::SpiNorFlash& spiNorFlash)
|
||||
: dateTimeController {dateTimeController},
|
||||
batteryController {batteryController},
|
||||
brightnessController {brightnessController},
|
||||
bleController {bleController},
|
||||
watchdog {watchdog},
|
||||
motionController {motionController},
|
||||
touchPanel {touchPanel},
|
||||
spiNorFlash {spiNorFlash},
|
||||
screens {app,
|
||||
0,
|
||||
{[this]() -> std::unique_ptr<Screen> {
|
||||
@@ -186,10 +187,12 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
|
||||
lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_recolor(label, true);
|
||||
const auto& bleAddr = bleController.Address();
|
||||
auto spiFlashId = spiNorFlash.GetIdentification();
|
||||
lv_label_set_text_fmt(label,
|
||||
"#808080 BLE MAC#\n"
|
||||
" %02x:%02x:%02x:%02x:%02x:%02x"
|
||||
" %02x:%02x:%02x:%02x:%02x:%02x\n"
|
||||
"\n"
|
||||
"#808080 SPI Flash# %02x-%02x-%02x\n"
|
||||
"\n"
|
||||
"#808080 Memory heap#\n"
|
||||
" #808080 Free# %d\n"
|
||||
@@ -202,6 +205,9 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
|
||||
bleAddr[2],
|
||||
bleAddr[1],
|
||||
bleAddr[0],
|
||||
spiFlashId.manufacturer,
|
||||
spiFlashId.type,
|
||||
spiFlashId.density,
|
||||
xPortGetFreeHeapSize(),
|
||||
xPortGetMinimumEverFreeHeapSize(),
|
||||
mallocFailedCount,
|
||||
|
||||
@@ -29,12 +29,12 @@ namespace Pinetime {
|
||||
const Pinetime::Controllers::Ble& bleController,
|
||||
const Pinetime::Drivers::Watchdog& watchdog,
|
||||
Pinetime::Controllers::MotionController& motionController,
|
||||
const Pinetime::Drivers::Cst816S& touchPanel);
|
||||
const Pinetime::Drivers::Cst816S& touchPanel,
|
||||
const Pinetime::Drivers::SpiNorFlash& spiNorFlash);
|
||||
~SystemInfo() override;
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
|
||||
private:
|
||||
DisplayApp* app;
|
||||
Pinetime::Controllers::DateTime& dateTimeController;
|
||||
const Pinetime::Controllers::Battery& batteryController;
|
||||
Pinetime::Controllers::BrightnessController& brightnessController;
|
||||
@@ -42,6 +42,7 @@ namespace Pinetime {
|
||||
const Pinetime::Drivers::Watchdog& watchdog;
|
||||
Pinetime::Controllers::MotionController& motionController;
|
||||
const Pinetime::Drivers::Cst816S& touchPanel;
|
||||
const Pinetime::Drivers::SpiNorFlash& spiNorFlash;
|
||||
|
||||
ScreenList<5> screens;
|
||||
|
||||
|
||||
@@ -104,9 +104,7 @@ void Timer::UpdateMask() {
|
||||
|
||||
void Timer::Refresh() {
|
||||
if (timer.IsRunning()) {
|
||||
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
|
||||
minuteCounter.SetValue(secondsRemaining.count() / 60);
|
||||
secondCounter.SetValue(secondsRemaining.count() % 60);
|
||||
DisplayTime();
|
||||
} else if (buttonPressing && xTaskGetTickCount() > pressTime + pdMS_TO_TICKS(150)) {
|
||||
lv_label_set_text_static(txtPlayPause, "Reset");
|
||||
maskPosition += 15;
|
||||
@@ -119,6 +117,14 @@ void Timer::Refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
void Timer::DisplayTime() {
|
||||
displaySeconds = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
|
||||
if (displaySeconds.IsUpdated()) {
|
||||
minuteCounter.SetValue(displaySeconds.Get().count() / 60);
|
||||
secondCounter.SetValue(displaySeconds.Get().count() % 60);
|
||||
}
|
||||
}
|
||||
|
||||
void Timer::SetTimerRunning() {
|
||||
minuteCounter.HideControls();
|
||||
secondCounter.HideControls();
|
||||
@@ -133,9 +139,7 @@ void Timer::SetTimerStopped() {
|
||||
|
||||
void Timer::ToggleRunning() {
|
||||
if (timer.IsRunning()) {
|
||||
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
|
||||
minuteCounter.SetValue(secondsRemaining.count() / 60);
|
||||
secondCounter.SetValue(secondsRemaining.count() % 60);
|
||||
DisplayTime();
|
||||
timer.StopTimer();
|
||||
SetTimerStopped();
|
||||
} else if (secondCounter.GetValue() + minuteCounter.GetValue() > 0) {
|
||||
@@ -147,7 +151,6 @@ void Timer::ToggleRunning() {
|
||||
}
|
||||
|
||||
void Timer::Reset() {
|
||||
minuteCounter.SetValue(0);
|
||||
secondCounter.SetValue(0);
|
||||
DisplayTime();
|
||||
SetTimerStopped();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "components/datetime/DateTimeController.h"
|
||||
#include "systemtask/SystemTask.h"
|
||||
#include "displayapp/LittleVgl.h"
|
||||
#include "displayapp/widgets/Counter.h"
|
||||
#include "utility/DirtyValue.h"
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
#include "components/timer/Timer.h"
|
||||
@@ -26,6 +26,7 @@ namespace Pinetime::Applications {
|
||||
void SetTimerRunning();
|
||||
void SetTimerStopped();
|
||||
void UpdateMask();
|
||||
void DisplayTime();
|
||||
Pinetime::Controllers::Timer& timer;
|
||||
|
||||
lv_obj_t* btnPlayPause;
|
||||
@@ -43,6 +44,7 @@ namespace Pinetime::Applications {
|
||||
bool buttonPressing = false;
|
||||
lv_coord_t maskPosition = 0;
|
||||
TickType_t pressTime = 0;
|
||||
Utility::DirtyValue<std::chrono::seconds> displaySeconds;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,22 @@
|
||||
#include "displayapp/screens/WatchFaceAnalog.h"
|
||||
#include <cmath>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <nrf_log.h>
|
||||
#include "displayapp/screens/BatteryIcon.h"
|
||||
#include "displayapp/screens/BleIcon.h"
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
#include "displayapp/screens/NotificationIcon.h"
|
||||
#include "components/settings/Settings.h"
|
||||
#include "displayapp/InfiniTimeTheme.h"
|
||||
#include "sunset/src/sunset.h"
|
||||
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
namespace {
|
||||
int16_t HourLength = 70;
|
||||
constexpr int16_t HourLength = 70;
|
||||
constexpr int16_t MinuteLength = 90;
|
||||
constexpr int16_t SecondLength = 110;
|
||||
constexpr int16_t SunDialVerticalOffset = 40;
|
||||
|
||||
// sin(90) = 1 so the value of _lv_trigo_sin(90) is the scaling factor
|
||||
const auto LV_TRIG_SCALE = _lv_trigo_sin(90);
|
||||
const lv_color_t DARK_GRAY = lv_color_make(48, 48, 48);
|
||||
const lv_color_t DARK_ORANGE = lv_color_make(48, 26, 0);
|
||||
|
||||
int16_t Cosine(int16_t angle) {
|
||||
return _lv_trigo_sin(angle + 90);
|
||||
@@ -44,41 +39,6 @@ namespace {
|
||||
.y = CoordinateYRelocate(radius * static_cast<int32_t>(Cosine(angle)) / LV_TRIG_SCALE)};
|
||||
}
|
||||
|
||||
void printKoku(const char* str, uint8_t i, bool big){
|
||||
lv_obj_t* koku = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_label_set_align(koku, LV_LABEL_ALIGN_CENTER);
|
||||
lv_label_set_text(koku, str);
|
||||
lv_point_t pt;
|
||||
if (big) {
|
||||
pt = CoordinateRelocate(LV_HOR_RES/2-20, i*30);
|
||||
lv_obj_set_style_local_text_font(koku, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, ¬o_serif_cjk_20);
|
||||
} else {
|
||||
pt = CoordinateRelocate(LV_HOR_RES/2-45, i*30);
|
||||
lv_obj_set_style_local_text_font(koku, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, ¬o_serif_cjk_15);
|
||||
}
|
||||
lv_obj_align(koku, NULL, LV_ALIGN_CENTER, LV_HOR_RES/2-pt.x, LV_HOR_RES/2-pt.y);
|
||||
lv_obj_set_style_local_text_color(koku, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
}
|
||||
|
||||
void drawTime(lv_obj_t * obj, uint8_t hour, uint8_t minute, lv_color_t color, uint8_t x, uint8_t y) {
|
||||
lv_label_set_align(obj, LV_LABEL_ALIGN_CENTER);
|
||||
lv_label_set_text_fmt(obj, "%02d:%02d", hour, minute);
|
||||
lv_obj_set_pos(obj, 0, 0);
|
||||
lv_obj_align(obj, NULL, LV_ALIGN_CENTER, x, y);
|
||||
lv_obj_set_style_local_text_color(obj, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color);
|
||||
lv_obj_set_style_local_text_font(obj, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20);
|
||||
}
|
||||
|
||||
void drawCircle(uint8_t width, bool left, lv_coord_t offset, lv_color_t color){
|
||||
lv_obj_t * cir = lv_obj_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_size(cir, width, width);
|
||||
if (left)
|
||||
lv_obj_align(cir, nullptr, LV_ALIGN_IN_LEFT_MID, offset, 0);
|
||||
else
|
||||
lv_obj_align(cir, nullptr, LV_ALIGN_IN_RIGHT_MID, offset, 0);
|
||||
lv_obj_set_style_local_bg_color(cir, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, color);
|
||||
lv_obj_set_style_local_radius(cir, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
||||
}
|
||||
}
|
||||
|
||||
WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
|
||||
@@ -98,56 +58,6 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
|
||||
sMinute = 99;
|
||||
sSecond = 99;
|
||||
|
||||
location = settingsController.GetLocation();
|
||||
|
||||
// begin Japanese watch face
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::FUZZY) {
|
||||
lv_obj_t * nighttime = lv_obj_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_size(nighttime, LV_HOR_RES, LV_HOR_RES/2);
|
||||
lv_obj_set_pos(nighttime, 0, 0);
|
||||
lv_obj_set_style_local_bg_color(nighttime, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, DARK_GRAY);
|
||||
lv_obj_set_style_local_radius(nighttime, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||
|
||||
drawCircle(35, true, 4, DARK_GRAY);
|
||||
drawCircle(25, true, 33, DARK_GRAY);
|
||||
drawCircle(35, false, -3, LV_COLOR_BLACK);
|
||||
drawCircle(25, false, -32, LV_COLOR_BLACK);
|
||||
|
||||
major_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
||||
lv_linemeter_set_scale(major_scales, 360, 13);
|
||||
lv_linemeter_set_angle_offset(major_scales, 15);
|
||||
lv_obj_set_size(major_scales, 240, 240);
|
||||
lv_obj_align(major_scales, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_local_bg_opa(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 50);
|
||||
lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 1);
|
||||
lv_obj_set_style_local_scale_end_color(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
|
||||
axis = lv_arc_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_size(axis, 70, 70);
|
||||
lv_arc_set_bg_angles(axis, 0, 360);
|
||||
lv_arc_set_end_angle(axis, 360);
|
||||
lv_obj_align(axis, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_local_line_width(axis, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, 40);
|
||||
lv_obj_set_style_local_line_color(axis, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
|
||||
const char* kokuZodiac[] = {"子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"};
|
||||
const char* kokuNums[] = {"九","八","七","六","五","四"};
|
||||
|
||||
twelve = lv_label_create(lv_scr_act(), nullptr);
|
||||
|
||||
for (int i=0;i<12;i++) {
|
||||
printKoku(kokuZodiac[i], i, true);
|
||||
printKoku(kokuNums[i%6], i, false);
|
||||
}
|
||||
|
||||
lv_style_init(&hour_line_style);
|
||||
lv_style_set_line_width(&hour_line_style, LV_STATE_DEFAULT, 10);
|
||||
lv_style_set_line_rounded(&hour_line_style, LV_STATE_DEFAULT, true);
|
||||
lv_style_init(&hour_line_style_trace);
|
||||
lv_style_set_line_width(&hour_line_style_trace, LV_STATE_DEFAULT, 10);
|
||||
lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, true);
|
||||
} else {
|
||||
minor_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
||||
lv_linemeter_set_scale(minor_scales, 300, 51);
|
||||
lv_linemeter_set_angle_offset(minor_scales, 180);
|
||||
@@ -184,12 +94,6 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
|
||||
lv_obj_set_pos(twelve, 110, 10);
|
||||
lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA);
|
||||
|
||||
lv_style_init(&hour_line_style);
|
||||
lv_style_set_line_width(&hour_line_style, LV_STATE_DEFAULT, 7);
|
||||
lv_style_init(&hour_line_style_trace);
|
||||
lv_style_set_line_width(&hour_line_style_trace, LV_STATE_DEFAULT, 3);
|
||||
}
|
||||
|
||||
batteryIcon.Create(lv_scr_act());
|
||||
lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
||||
|
||||
@@ -207,6 +111,7 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
|
||||
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
||||
|
||||
// Date - Day / Week day
|
||||
|
||||
label_date_day = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
|
||||
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
|
||||
@@ -237,10 +142,16 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
|
||||
lv_style_set_line_rounded(&minute_line_style_trace, LV_STATE_DEFAULT, false);
|
||||
lv_obj_add_style(minute_body_trace, LV_LINE_PART_MAIN, &minute_line_style_trace);
|
||||
|
||||
lv_style_init(&hour_line_style);
|
||||
lv_style_set_line_width(&hour_line_style, LV_STATE_DEFAULT, 7);
|
||||
lv_style_set_line_color(&hour_line_style, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
lv_style_set_line_rounded(&hour_line_style, LV_STATE_DEFAULT, true);
|
||||
lv_obj_add_style(hour_body, LV_LINE_PART_MAIN, &hour_line_style);
|
||||
|
||||
lv_style_init(&hour_line_style_trace);
|
||||
lv_style_set_line_width(&hour_line_style_trace, LV_STATE_DEFAULT, 3);
|
||||
lv_style_set_line_color(&hour_line_style_trace, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false);
|
||||
lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace);
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||
@@ -260,73 +171,12 @@ WatchFaceAnalog::~WatchFaceAnalog() {
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
|
||||
void WatchFaceAnalog::drawWatchFaceWadokei(){
|
||||
uint8_t hour = dateTimeController.Hours();
|
||||
uint8_t minute = dateTimeController.Minutes();
|
||||
|
||||
if (sHour != hour || sMinute != minute) {
|
||||
sun.setPosition((float)location.latitude, (float)location.longitude, location.tzOffset);
|
||||
|
||||
//from minutes past midnight
|
||||
sun.setCurrentDate(dateTimeController.Year(), static_cast<uint8_t>(dateTimeController.Month())+1, dateTimeController.Day());
|
||||
sun.setTZOffset(location.tzOffset);
|
||||
|
||||
minutesSunrise = sun.calcSunrise();
|
||||
minutesSunset = sun.calcSunset();
|
||||
minutesDaytime = (minutesSunset - minutesSunrise);
|
||||
minutesNighttime = (1440 - minutesDaytime);
|
||||
|
||||
minutesBeforeSunset = minutesSunset - (hour * 60 + minute); // i.e.zero degrees
|
||||
HourLength = 40; // wadokei hand length
|
||||
|
||||
int16_t hourAngle=0;
|
||||
// auto const hourAngle = ((hour * 15 + minute / 2)+180)%360; //24-hr rotation with 0/24 at the bottom
|
||||
|
||||
if(minutesBeforeSunset > minutesDaytime) {
|
||||
hourAngle = -180.0 - 180.0 * (minutesBeforeSunset - minutesDaytime) / minutesNighttime;
|
||||
}
|
||||
else if(minutesBeforeSunset > 0 ) {
|
||||
hourAngle = -180.0 * minutesBeforeSunset / minutesDaytime;
|
||||
}
|
||||
else {
|
||||
hourAngle = -180.0 * minutesBeforeSunset / minutesNighttime;
|
||||
}
|
||||
|
||||
// NRF_LOG_INFO("angle: %d, day: %d, night: %d, bef: %d",
|
||||
// hourAngle+90,
|
||||
// minutesDaytime,
|
||||
// minutesNighttime,
|
||||
// minutesBeforeSunset);
|
||||
|
||||
sHour = hour;
|
||||
sMinute = minute;
|
||||
|
||||
hour_point_trace[0] = CoordinateRelocate(28, hourAngle+90-66); //axis radius minus line stroke
|
||||
hour_point_trace[1] = CoordinateRelocate(HourLength, hourAngle+90);
|
||||
|
||||
hour_point[0] = CoordinateRelocate(28, hourAngle+90+66); //axis radius minus line stroke
|
||||
hour_point[1] = CoordinateRelocate(HourLength, hourAngle+90);
|
||||
|
||||
lv_line_set_points(hour_body, hour_point, 2);
|
||||
lv_line_set_points(hour_body_trace, hour_point_trace, 2);
|
||||
|
||||
drawTime(twelve, hour, minute, LV_COLOR_BLACK, 0, 0);
|
||||
lv_obj_move_foreground(twelve);
|
||||
}
|
||||
}
|
||||
|
||||
void WatchFaceAnalog::UpdateClock() {
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::FUZZY) {
|
||||
drawWatchFaceWadokei();
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t hour = dateTimeController.Hours();
|
||||
uint8_t minute = dateTimeController.Minutes();
|
||||
uint8_t second = dateTimeController.Seconds();
|
||||
|
||||
if (minute>99 && sMinute != minute) { // disable
|
||||
if (sMinute != minute) {
|
||||
auto const angle = minute * 6;
|
||||
minute_point[0] = CoordinateRelocate(30, angle);
|
||||
minute_point[1] = CoordinateRelocate(MinuteLength, angle);
|
||||
@@ -353,8 +203,7 @@ void WatchFaceAnalog::UpdateClock() {
|
||||
lv_line_set_points(hour_body_trace, hour_point_trace, 2);
|
||||
}
|
||||
|
||||
|
||||
if (second>99 && sSecond != second) { // disable
|
||||
if (sSecond != second) {
|
||||
sSecond = second;
|
||||
auto const angle = second * 6;
|
||||
|
||||
@@ -407,20 +256,9 @@ void WatchFaceAnalog::Refresh() {
|
||||
if (currentDateTime.IsUpdated()) {
|
||||
UpdateClock();
|
||||
|
||||
currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
|
||||
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
|
||||
if (currentDate.IsUpdated()) {
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::FUZZY) {
|
||||
/*char const* MonthsString[] = {"--", "IANUARIUS","FEBRUARIUS","MARTIUS","APRILIS","MARTIUSIUNIUS","QUINTILIS","SEXTILIS","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"};
|
||||
char const* DaysString[] = {"--", "LUNAE", "MARTIS", "MERCURII", "IOVIS", "VENERIS", "SATURNI", "SOLIS"};
|
||||
char const* RomanNumeralsString[] = {"--", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII"};
|
||||
lv_label_set_text_fmt(label_date_day, "%s\n%s %s",
|
||||
DaysString[static_cast<uint8_t>(dateTimeController.DayOfWeek())],
|
||||
RomanNumeralsString[static_cast<uint8_t>(dateTimeController.Day())],
|
||||
MonthsString[static_cast<uint8_t>(dateTimeController.Month())]);*/
|
||||
lv_obj_align(label_date_day, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, -2000);
|
||||
} else {
|
||||
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "components/ble/NotificationManager.h"
|
||||
#include "displayapp/screens/BatteryIcon.h"
|
||||
#include "utility/DirtyValue.h"
|
||||
#include "sunset/src/sunset.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
@@ -44,15 +43,12 @@ namespace Pinetime {
|
||||
Utility::DirtyValue<bool> bleState {};
|
||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime;
|
||||
Utility::DirtyValue<bool> notificationState {false};
|
||||
using days = std::chrono::duration<int32_t, std::ratio<86400>>; // TODO: days is standard in c++20
|
||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, days>> currentDate;
|
||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
|
||||
|
||||
lv_obj_t* minor_scales;
|
||||
lv_obj_t* major_scales;
|
||||
lv_obj_t* large_scales;
|
||||
lv_obj_t* one;
|
||||
lv_obj_t* twelve;
|
||||
lv_obj_t* axis;
|
||||
|
||||
lv_obj_t* hour_body;
|
||||
lv_obj_t* hour_body_trace;
|
||||
@@ -71,7 +67,6 @@ namespace Pinetime {
|
||||
lv_style_t minute_line_style;
|
||||
lv_style_t minute_line_style_trace;
|
||||
lv_style_t second_line_style;
|
||||
lv_style_t axis_style;
|
||||
|
||||
lv_obj_t* label_date_day;
|
||||
lv_obj_t* plugIcon;
|
||||
@@ -80,21 +75,12 @@ namespace Pinetime {
|
||||
|
||||
BatteryIcon batteryIcon;
|
||||
|
||||
Controllers::Settings::Location location;
|
||||
SunSet sun;
|
||||
int16_t minutesSunrise;
|
||||
int16_t minutesSunset;
|
||||
int16_t minutesDaytime;
|
||||
int16_t minutesNighttime;
|
||||
int16_t minutesBeforeSunset;
|
||||
|
||||
const Controllers::DateTime& dateTimeController;
|
||||
Controllers::DateTime& dateTimeController;
|
||||
const Controllers::Battery& batteryController;
|
||||
const Controllers::Ble& bleController;
|
||||
Controllers::NotificationManager& notificationManager;
|
||||
Controllers::Settings& settingsController;
|
||||
|
||||
void drawWatchFaceWadokei();
|
||||
void UpdateClock();
|
||||
void SetBatteryIcon();
|
||||
|
||||
|
||||
334
src/displayapp/screens/WatchFaceCasioStyleG7710.cpp
Normal file
@@ -0,0 +1,334 @@
|
||||
#include "displayapp/screens/WatchFaceCasioStyleG7710.h"
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <cstdio>
|
||||
#include "displayapp/screens/BatteryIcon.h"
|
||||
#include "displayapp/screens/BleIcon.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;
|
||||
|
||||
WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTimeController,
|
||||
const Controllers::Battery& batteryController,
|
||||
const Controllers::Ble& bleController,
|
||||
Controllers::NotificationManager& notificatioManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::HeartRateController& heartRateController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::FS& filesystem)
|
||||
: currentDateTime {{}},
|
||||
batteryIcon(false),
|
||||
dateTimeController {dateTimeController},
|
||||
batteryController {batteryController},
|
||||
bleController {bleController},
|
||||
notificatioManager {notificatioManager},
|
||||
settingsController {settingsController},
|
||||
heartRateController {heartRateController},
|
||||
motionController {motionController} {
|
||||
|
||||
lfs_file f = {};
|
||||
if (filesystem.FileOpen(&f, "/fonts/lv_font_dots_40.bin", LFS_O_RDONLY) >= 0) {
|
||||
filesystem.FileClose(&f);
|
||||
font_dot40 = lv_font_load("F:/fonts/lv_font_dots_40.bin");
|
||||
}
|
||||
|
||||
if (filesystem.FileOpen(&f, "/fonts/7segments_40.bin", LFS_O_RDONLY) >= 0) {
|
||||
filesystem.FileClose(&f);
|
||||
font_segment40 = lv_font_load("F:/fonts/7segments_40.bin");
|
||||
}
|
||||
|
||||
if (filesystem.FileOpen(&f, "/fonts/7segments_115.bin", LFS_O_RDONLY) >= 0) {
|
||||
filesystem.FileClose(&f);
|
||||
font_segment115 = lv_font_load("F:/fonts/7segments_115.bin");
|
||||
}
|
||||
|
||||
label_battery_value = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_battery_value, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
||||
lv_obj_set_style_local_text_color(label_battery_value, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(label_battery_value, "00%");
|
||||
|
||||
batteryIcon.Create(lv_scr_act());
|
||||
batteryIcon.SetColor(color_text);
|
||||
lv_obj_align(batteryIcon.GetObject(), label_battery_value, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
batteryPlug = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(batteryPlug, Symbols::plug);
|
||||
lv_obj_align(batteryPlug, batteryIcon.GetObject(), 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, color_text);
|
||||
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, color_text);
|
||||
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
|
||||
lv_obj_align(notificationIcon, bleIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
label_day_of_week = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_day_of_week, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 10, 64);
|
||||
lv_obj_set_style_local_text_color(label_day_of_week, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_day_of_week, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_dot40);
|
||||
lv_label_set_text_static(label_day_of_week, "SUN");
|
||||
|
||||
label_week_number = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_week_number, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 22);
|
||||
lv_obj_set_style_local_text_color(label_week_number, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_week_number, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_dot40);
|
||||
lv_label_set_text_static(label_week_number, "WK26");
|
||||
|
||||
label_day_of_year = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_day_of_year, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 100, 30);
|
||||
lv_obj_set_style_local_text_color(label_day_of_year, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_day_of_year, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_segment40);
|
||||
lv_label_set_text_static(label_day_of_year, "181-184");
|
||||
|
||||
lv_style_init(&style_line);
|
||||
lv_style_set_line_width(&style_line, LV_STATE_DEFAULT, 2);
|
||||
lv_style_set_line_color(&style_line, LV_STATE_DEFAULT, color_text);
|
||||
lv_style_set_line_rounded(&style_line, LV_STATE_DEFAULT, true);
|
||||
|
||||
lv_style_init(&style_border);
|
||||
lv_style_set_line_width(&style_border, LV_STATE_DEFAULT, 6);
|
||||
lv_style_set_line_color(&style_border, LV_STATE_DEFAULT, color_text);
|
||||
lv_style_set_line_rounded(&style_border, LV_STATE_DEFAULT, true);
|
||||
|
||||
line_icons = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_line_set_points(line_icons, line_icons_points, 3);
|
||||
lv_obj_add_style(line_icons, LV_LINE_PART_MAIN, &style_line);
|
||||
lv_obj_align(line_icons, nullptr, LV_ALIGN_IN_TOP_RIGHT, -10, 18);
|
||||
|
||||
line_day_of_week_number = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_line_set_points(line_day_of_week_number, line_day_of_week_number_points, 4);
|
||||
lv_obj_add_style(line_day_of_week_number, LV_LINE_PART_MAIN, &style_border);
|
||||
lv_obj_align(line_day_of_week_number, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 8);
|
||||
|
||||
line_day_of_year = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_line_set_points(line_day_of_year, line_day_of_year_points, 3);
|
||||
lv_obj_add_style(line_day_of_year, LV_LINE_PART_MAIN, &style_line);
|
||||
lv_obj_align(line_day_of_year, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 60);
|
||||
|
||||
label_date = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 100, 70);
|
||||
lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_segment40);
|
||||
lv_label_set_text_static(label_date, "6-30");
|
||||
|
||||
line_date = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_line_set_points(line_date, line_date_points, 3);
|
||||
lv_obj_add_style(line_date, LV_LINE_PART_MAIN, &style_line);
|
||||
lv_obj_align(line_date, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 100);
|
||||
|
||||
label_time = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_segment115);
|
||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 40);
|
||||
|
||||
line_time = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_line_set_points(line_time, line_time_points, 3);
|
||||
lv_obj_add_style(line_time, LV_LINE_PART_MAIN, &style_line);
|
||||
lv_obj_align(line_time, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, -25);
|
||||
|
||||
label_time_ampm = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(label_time_ampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(label_time_ampm, "");
|
||||
lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 5, -5);
|
||||
|
||||
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_static(backgroundLabel, "");
|
||||
|
||||
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
|
||||
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 5, -2);
|
||||
|
||||
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
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, color_text);
|
||||
lv_label_set_text_static(stepValue, "0");
|
||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2);
|
||||
|
||||
stepIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
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);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
WatchFaceCasioStyleG7710::~WatchFaceCasioStyleG7710() {
|
||||
lv_task_del(taskRefresh);
|
||||
|
||||
lv_style_reset(&style_line);
|
||||
lv_style_reset(&style_border);
|
||||
|
||||
if (font_dot40 != nullptr) {
|
||||
lv_font_free(font_dot40);
|
||||
}
|
||||
|
||||
if (font_segment40 != nullptr) {
|
||||
lv_font_free(font_segment40);
|
||||
}
|
||||
|
||||
if (font_segment115 != nullptr) {
|
||||
lv_font_free(font_segment115);
|
||||
}
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
void WatchFaceCasioStyleG7710::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();
|
||||
batteryIcon.SetBatteryPercentage(batteryPercent);
|
||||
lv_label_set_text_fmt(label_battery_value, "%d%%", batteryPercent);
|
||||
}
|
||||
|
||||
bleState = bleController.IsConnected();
|
||||
bleRadioEnabled = bleController.IsRadioEnabled();
|
||||
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
|
||||
lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
|
||||
}
|
||||
lv_obj_realign(label_battery_value);
|
||||
lv_obj_realign(batteryIcon.GetObject());
|
||||
lv_obj_realign(batteryPlug);
|
||||
lv_obj_realign(bleIcon);
|
||||
lv_obj_realign(notificationIcon);
|
||||
|
||||
notificationState = notificatioManager.AreNewNotificationsAvailable();
|
||||
if (notificationState.IsUpdated()) {
|
||||
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
|
||||
}
|
||||
|
||||
currentDateTime = std::chrono::time_point_cast<std::chrono::minutes>(dateTimeController.CurrentDateTime());
|
||||
if (currentDateTime.IsUpdated()) {
|
||||
uint8_t hour = dateTimeController.Hours();
|
||||
uint8_t minute = dateTimeController.Minutes();
|
||||
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
char ampmChar[2] = "A";
|
||||
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(label_time_ampm, ampmChar);
|
||||
lv_label_set_text_fmt(label_time, "%2d:%02d", hour, minute);
|
||||
} else {
|
||||
lv_label_set_text_fmt(label_time, "%02d:%02d", hour, minute);
|
||||
}
|
||||
lv_obj_realign(label_time);
|
||||
|
||||
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
|
||||
if (currentDate.IsUpdated()) {
|
||||
const char* weekNumberFormat = "%V";
|
||||
|
||||
uint16_t year = dateTimeController.Year();
|
||||
Controllers::DateTime::Months month = dateTimeController.Month();
|
||||
uint8_t day = dateTimeController.Day();
|
||||
int dayOfYear = dateTimeController.DayOfYear();
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
|
||||
// 24h mode: ddmmyyyy, first DOW=Monday;
|
||||
lv_label_set_text_fmt(label_date, "%3d-%2d", day, month);
|
||||
weekNumberFormat = "%V"; // Replaced by the week number of the year (Monday as the first day of the week) as a decimal number
|
||||
// [01,53]. If the week containing 1 January has four or more days in the new year, then it is considered
|
||||
// week 1. Otherwise, it is the last week of the previous year, and the next week is week 1. Both January
|
||||
// 4th and the first Thursday of January are always in week 1. [ tm_year, tm_wday, tm_yday]
|
||||
} else {
|
||||
// 12h mode: mmddyyyy, first DOW=Sunday;
|
||||
lv_label_set_text_fmt(label_date, "%3d-%2d", month, day);
|
||||
weekNumberFormat = "%U"; // Replaced by the week number of the year as a decimal number [00,53]. The first Sunday of January is the
|
||||
// first day of week 1; days in the new year before this are in week 0. [ tm_year, tm_wday, tm_yday]
|
||||
}
|
||||
|
||||
time_t ttTime =
|
||||
std::chrono::system_clock::to_time_t(std::chrono::time_point_cast<std::chrono::system_clock::duration>(currentDateTime.Get()));
|
||||
tm* tmTime = std::localtime(&ttTime);
|
||||
|
||||
// TODO: When we start using C++20, use std::chrono::year::is_leap
|
||||
int daysInCurrentYear = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0 ? 366 : 365;
|
||||
uint16_t daysTillEndOfYearNumber = daysInCurrentYear - dayOfYear;
|
||||
|
||||
char buffer[8];
|
||||
strftime(buffer, 8, weekNumberFormat, tmTime);
|
||||
uint8_t weekNumber = atoi(buffer);
|
||||
|
||||
lv_label_set_text_fmt(label_day_of_week, "%s", dateTimeController.DayOfWeekShortToString());
|
||||
lv_label_set_text_fmt(label_day_of_year, "%3d-%3d", dayOfYear, daysTillEndOfYearNumber);
|
||||
lv_label_set_text_fmt(label_week_number, "WK%02d", weekNumber);
|
||||
|
||||
lv_obj_realign(label_day_of_week);
|
||||
lv_obj_realign(label_day_of_year);
|
||||
lv_obj_realign(label_week_number);
|
||||
lv_obj_realign(label_date);
|
||||
}
|
||||
}
|
||||
|
||||
heartbeat = heartRateController.HeartRate();
|
||||
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
|
||||
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
|
||||
if (heartbeatRunning.Get()) {
|
||||
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get());
|
||||
} else {
|
||||
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B));
|
||||
lv_label_set_text_static(heartbeatValue, "");
|
||||
}
|
||||
|
||||
lv_obj_realign(heartbeatIcon);
|
||||
lv_obj_realign(heartbeatValue);
|
||||
}
|
||||
|
||||
stepCount = motionController.NbSteps();
|
||||
if (stepCount.IsUpdated()) {
|
||||
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
|
||||
lv_obj_realign(stepValue);
|
||||
lv_obj_realign(stepIcon);
|
||||
}
|
||||
}
|
||||
|
||||
bool WatchFaceCasioStyleG7710::IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
lfs_file file = {};
|
||||
|
||||
if (filesystem.FileOpen(&file, "/fonts/lv_font_dots_40.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
filesystem.FileClose(&file);
|
||||
if (filesystem.FileOpen(&file, "/fonts/7segments_40.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
filesystem.FileClose(&file);
|
||||
if (filesystem.FileOpen(&file, "/fonts/7segments_115.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
filesystem.FileClose(&file);
|
||||
return true;
|
||||
}
|
||||
126
src/displayapp/screens/WatchFaceCasioStyleG7710.h
Normal file
@@ -0,0 +1,126 @@
|
||||
#pragma once
|
||||
|
||||
#include <displayapp/screens/BatteryIcon.h>
|
||||
#include <lvgl/src/lv_core/lv_obj.h>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <displayapp/Controllers.h>
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "components/datetime/DateTimeController.h"
|
||||
#include "components/ble/BleController.h"
|
||||
#include "utility/DirtyValue.h"
|
||||
#include "displayapp/apps/Apps.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
class Settings;
|
||||
class Battery;
|
||||
class Ble;
|
||||
class NotificationManager;
|
||||
class HeartRateController;
|
||||
class MotionController;
|
||||
}
|
||||
|
||||
namespace Applications {
|
||||
namespace Screens {
|
||||
|
||||
class WatchFaceCasioStyleG7710 : public Screen {
|
||||
public:
|
||||
WatchFaceCasioStyleG7710(Controllers::DateTime& dateTimeController,
|
||||
const Controllers::Battery& batteryController,
|
||||
const Controllers::Ble& bleController,
|
||||
Controllers::NotificationManager& notificatioManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::HeartRateController& heartRateController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::FS& filesystem);
|
||||
~WatchFaceCasioStyleG7710() override;
|
||||
|
||||
void Refresh() override;
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& filesystem);
|
||||
|
||||
private:
|
||||
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
|
||||
Utility::DirtyValue<bool> powerPresent {};
|
||||
Utility::DirtyValue<bool> bleState {};
|
||||
Utility::DirtyValue<bool> bleRadioEnabled {};
|
||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::minutes>> currentDateTime {};
|
||||
Utility::DirtyValue<uint32_t> stepCount {};
|
||||
Utility::DirtyValue<uint8_t> heartbeat {};
|
||||
Utility::DirtyValue<bool> heartbeatRunning {};
|
||||
Utility::DirtyValue<bool> notificationState {};
|
||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
|
||||
|
||||
lv_point_t line_icons_points[3] {{0, 5}, {117, 5}, {122, 0}};
|
||||
lv_point_t line_day_of_week_number_points[4] {{0, 0}, {100, 0}, {95, 95}, {0, 95}};
|
||||
lv_point_t line_day_of_year_points[3] {{0, 5}, {130, 5}, {135, 0}};
|
||||
lv_point_t line_date_points[3] {{0, 5}, {135, 5}, {140, 0}};
|
||||
lv_point_t line_time_points[3] {{0, 0}, {230, 0}, {235, 5}};
|
||||
|
||||
lv_color_t color_text = lv_color_hex(0x98B69A);
|
||||
|
||||
lv_style_t style_line;
|
||||
lv_style_t style_border;
|
||||
|
||||
lv_obj_t* label_time;
|
||||
lv_obj_t* line_time;
|
||||
lv_obj_t* label_time_ampm;
|
||||
lv_obj_t* label_date;
|
||||
lv_obj_t* line_date;
|
||||
lv_obj_t* label_day_of_week;
|
||||
lv_obj_t* label_week_number;
|
||||
lv_obj_t* line_day_of_week_number;
|
||||
lv_obj_t* label_day_of_year;
|
||||
lv_obj_t* line_day_of_year;
|
||||
lv_obj_t* backgroundLabel;
|
||||
lv_obj_t* bleIcon;
|
||||
lv_obj_t* batteryPlug;
|
||||
lv_obj_t* label_battery_value;
|
||||
lv_obj_t* heartbeatIcon;
|
||||
lv_obj_t* heartbeatValue;
|
||||
lv_obj_t* stepIcon;
|
||||
lv_obj_t* stepValue;
|
||||
lv_obj_t* notificationIcon;
|
||||
lv_obj_t* line_icons;
|
||||
|
||||
BatteryIcon batteryIcon;
|
||||
|
||||
Controllers::DateTime& dateTimeController;
|
||||
const Controllers::Battery& batteryController;
|
||||
const Controllers::Ble& bleController;
|
||||
Controllers::NotificationManager& notificatioManager;
|
||||
Controllers::Settings& settingsController;
|
||||
Controllers::HeartRateController& heartRateController;
|
||||
Controllers::MotionController& motionController;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
lv_font_t* font_dot40 = nullptr;
|
||||
lv_font_t* font_segment40 = nullptr;
|
||||
lv_font_t* font_segment115 = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
template <>
|
||||
struct WatchFaceTraits<WatchFace::CasioStyleG7710> {
|
||||
static constexpr WatchFace watchFace = WatchFace::CasioStyleG7710;
|
||||
static constexpr const char* name = "Casio G7710";
|
||||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::WatchFaceCasioStyleG7710(controllers.dateTimeController,
|
||||
controllers.batteryController,
|
||||
controllers.bleController,
|
||||
controllers.notificationManager,
|
||||
controllers.settingsController,
|
||||
controllers.heartRateController,
|
||||
controllers.motionController,
|
||||
controllers.filesystem);
|
||||
};
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
return Screens::WatchFaceCasioStyleG7710::IsAvailable(filesystem);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
#include "displayapp/screens/WatchFaceFuzzy.h"
|
||||
#include "displayapp/screens/WatchFaceDigital.h"
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include "displayapp/screens/NotificationIcon.h"
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
#include "displayapp/screens/WeatherSymbols.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"
|
||||
@@ -13,7 +16,9 @@
|
||||
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
WatchFaceFuzzy::WatchFaceFuzzy(Controllers::DateTime& dateTimeController,
|
||||
WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
|
||||
const Controllers::Battery& batteryController,
|
||||
const Controllers::Ble& bleController,
|
||||
Controllers::NotificationManager& notificationManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::HeartRateController& heartRateController,
|
||||
@@ -25,8 +30,10 @@ WatchFaceFuzzy::WatchFaceFuzzy(Controllers::DateTime& dateTimeController,
|
||||
settingsController {settingsController},
|
||||
heartRateController {heartRateController},
|
||||
motionController {motionController},
|
||||
weatherService {weatherService}
|
||||
{
|
||||
weatherService {weatherService},
|
||||
statusIcons(batteryController, bleController) {
|
||||
|
||||
statusIcons.Create();
|
||||
|
||||
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_LIME);
|
||||
@@ -50,9 +57,13 @@ WatchFaceFuzzy::WatchFaceFuzzy(Controllers::DateTime& dateTimeController,
|
||||
lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
|
||||
|
||||
label_time = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_24);
|
||||
lv_label_set_recolor(label_time, true);
|
||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
|
||||
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed);
|
||||
|
||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);
|
||||
|
||||
label_time_ampm = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_text_static(label_time_ampm, "");
|
||||
lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55);
|
||||
|
||||
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
|
||||
@@ -78,12 +89,14 @@ WatchFaceFuzzy::WatchFaceFuzzy(Controllers::DateTime& dateTimeController,
|
||||
Refresh();
|
||||
}
|
||||
|
||||
WatchFaceFuzzy::~WatchFaceFuzzy() {
|
||||
WatchFaceDigital::~WatchFaceDigital() {
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
void WatchFaceFuzzy::Refresh() {
|
||||
void WatchFaceDigital::Refresh() {
|
||||
statusIcons.Update();
|
||||
|
||||
notificationState = notificationManager.AreNewNotificationsAvailable();
|
||||
if (notificationState.IsUpdated()) {
|
||||
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
|
||||
@@ -95,18 +108,43 @@ void WatchFaceFuzzy::Refresh() {
|
||||
uint8_t hour = dateTimeController.Hours();
|
||||
uint8_t minute = dateTimeController.Minutes();
|
||||
|
||||
printTimeWords(hour, minute);
|
||||
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(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);
|
||||
}
|
||||
|
||||
currentDateTime = std::chrono::time_point_cast<std::chrono::minutes>(dateTimeController.CurrentDateTime());
|
||||
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
|
||||
if (currentDate.IsUpdated()) {
|
||||
uint16_t year = dateTimeController.Year();
|
||||
uint8_t day = dateTimeController.Day();
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
|
||||
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_obj_realign(label_date);
|
||||
}
|
||||
}
|
||||
@@ -137,13 +175,12 @@ void WatchFaceFuzzy::Refresh() {
|
||||
if (currentWeather.IsUpdated()) {
|
||||
auto optCurrentWeather = currentWeather.Get();
|
||||
if (optCurrentWeather) {
|
||||
int16_t temp = optCurrentWeather->temperature;
|
||||
int16_t temp = optCurrentWeather->temperature.Celsius();
|
||||
char tempUnit = 'C';
|
||||
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
|
||||
temp = Controllers::SimpleWeatherService::CelsiusToFahrenheit(temp);
|
||||
temp = optCurrentWeather->temperature.Fahrenheit();
|
||||
tempUnit = 'F';
|
||||
}
|
||||
temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0);
|
||||
lv_label_set_text_fmt(temperature, "%d°%c", temp, tempUnit);
|
||||
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
|
||||
} else {
|
||||
@@ -154,36 +191,3 @@ void WatchFaceFuzzy::Refresh() {
|
||||
lv_obj_realign(weatherIcon);
|
||||
}
|
||||
}
|
||||
|
||||
char const* WatchFaceFuzzy::mods[] = {"", "five", "ten", "quarter", "twenty", "twenty five", "half"};
|
||||
char const* WatchFaceFuzzy::nums[] = {"twelve", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve"};
|
||||
|
||||
void WatchFaceFuzzy::printTimeWords(int h, int m) {
|
||||
const char* mod;
|
||||
|
||||
if (m <= 30) {
|
||||
mod = mods[m / 5];
|
||||
} else {
|
||||
mod = mods[(60-m) / 5];
|
||||
}
|
||||
h = (h % 12);
|
||||
|
||||
if (m >= 57) {
|
||||
sprintf(timeStr, "#ffffff nearly %s#\n#808080 o' clock#", nums[(h+1) % 12]);
|
||||
}
|
||||
else if (m == 0 || m <= 4) {
|
||||
sprintf(timeStr, "#ffffff %s#\n#808080 o' clock#", nums[h]);
|
||||
}
|
||||
|
||||
else if (m <= 32) {
|
||||
sprintf(timeStr, "#ffffff %s#\n#808080 past# #FFFFFF %s#", mod, nums[h]);
|
||||
}
|
||||
|
||||
else if (m > 32) {
|
||||
sprintf(timeStr, "#ffffff %s#\n#808080 to# #FFFFFF %s#", mod, nums[(h+1) % 12]);
|
||||
}
|
||||
|
||||
printf("%s\n", timeStr);
|
||||
lv_label_set_text(label_time, timeStr);
|
||||
lv_obj_realign(label_time);
|
||||
}
|
||||
@@ -12,8 +12,6 @@
|
||||
#include "utility/DirtyValue.h"
|
||||
#include "displayapp/apps/Apps.h"
|
||||
|
||||
extern lv_font_t jetbrains_mono_bold_24;
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
class Settings;
|
||||
@@ -27,15 +25,17 @@ namespace Pinetime {
|
||||
namespace Applications {
|
||||
namespace Screens {
|
||||
|
||||
class WatchFaceFuzzy : public Screen {
|
||||
class WatchFaceDigital : public Screen {
|
||||
public:
|
||||
WatchFaceFuzzy(Controllers::DateTime& dateTimeController,
|
||||
WatchFaceDigital(Controllers::DateTime& dateTimeController,
|
||||
const Controllers::Battery& batteryController,
|
||||
const Controllers::Ble& bleController,
|
||||
Controllers::NotificationManager& notificationManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::HeartRateController& heartRateController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::SimpleWeatherService& weather);
|
||||
~WatchFaceFuzzy() override;
|
||||
~WatchFaceDigital() override;
|
||||
|
||||
void Refresh() override;
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace Pinetime {
|
||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
|
||||
|
||||
lv_obj_t* label_time;
|
||||
lv_obj_t* label_time_ampm;
|
||||
lv_obj_t* label_date;
|
||||
lv_obj_t* heartbeatIcon;
|
||||
lv_obj_t* heartbeatValue;
|
||||
@@ -70,21 +71,19 @@ namespace Pinetime {
|
||||
Controllers::SimpleWeatherService& weatherService;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
|
||||
static char const *nums[];
|
||||
static char const *mods[];
|
||||
char timeStr[64];
|
||||
void printTimeWords(int hour, int minute);
|
||||
Widgets::StatusIcons statusIcons;
|
||||
};
|
||||
}
|
||||
|
||||
template <>
|
||||
struct WatchFaceTraits<WatchFace::Fuzzy> {
|
||||
static constexpr WatchFace watchFace = WatchFace::Fuzzy;
|
||||
static constexpr const char* name = "Fuzzy face";
|
||||
struct WatchFaceTraits<WatchFace::Digital> {
|
||||
static constexpr WatchFace watchFace = WatchFace::Digital;
|
||||
static constexpr const char* name = "Digital face";
|
||||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::WatchFaceFuzzy(controllers.dateTimeController,
|
||||
return new Screens::WatchFaceDigital(controllers.dateTimeController,
|
||||
controllers.batteryController,
|
||||
controllers.bleController,
|
||||
controllers.notificationManager,
|
||||
controllers.settingsController,
|
||||
controllers.heartRateController,
|
||||
509
src/displayapp/screens/WatchFaceInfineat.cpp
Normal file
@@ -0,0 +1,509 @@
|
||||
#include "displayapp/screens/WatchFaceInfineat.h"
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <cstdio>
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
#include "displayapp/screens/BleIcon.h"
|
||||
#include "components/settings/Settings.h"
|
||||
#include "components/battery/BatteryController.h"
|
||||
#include "components/ble/BleController.h"
|
||||
#include "components/ble/NotificationManager.h"
|
||||
#include "components/motion/MotionController.h"
|
||||
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
namespace {
|
||||
void event_handler(lv_obj_t* obj, lv_event_t event) {
|
||||
auto* screen = static_cast<WatchFaceInfineat*>(obj->user_data);
|
||||
screen->UpdateSelected(obj, event);
|
||||
}
|
||||
|
||||
enum class colors {
|
||||
orange,
|
||||
blue,
|
||||
green,
|
||||
rainbow,
|
||||
gray,
|
||||
nordBlue,
|
||||
nordGreen,
|
||||
};
|
||||
|
||||
constexpr int nColors = 7; // must match number of colors in InfineatColors
|
||||
|
||||
constexpr int nLines = WatchFaceInfineat::nLines;
|
||||
|
||||
constexpr std::array<lv_color_t, nLines> orangeColors = {LV_COLOR_MAKE(0xfd, 0x87, 0x2b),
|
||||
LV_COLOR_MAKE(0xdb, 0x33, 0x16),
|
||||
LV_COLOR_MAKE(0x6f, 0x10, 0x00),
|
||||
LV_COLOR_MAKE(0xfd, 0x7a, 0x0a),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xe8, 0x51, 0x02),
|
||||
LV_COLOR_MAKE(0xea, 0x1c, 0x00)};
|
||||
constexpr std::array<lv_color_t, nLines> blueColors = {LV_COLOR_MAKE(0xe7, 0xf8, 0xff),
|
||||
LV_COLOR_MAKE(0x22, 0x32, 0xd0),
|
||||
LV_COLOR_MAKE(0x18, 0x2a, 0x8b),
|
||||
LV_COLOR_MAKE(0xe7, 0xf8, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0x59, 0x91, 0xff),
|
||||
LV_COLOR_MAKE(0x16, 0x36, 0xff)};
|
||||
constexpr std::array<lv_color_t, nLines> greenColors = {LV_COLOR_MAKE(0xb8, 0xff, 0x9b),
|
||||
LV_COLOR_MAKE(0x08, 0x86, 0x08),
|
||||
LV_COLOR_MAKE(0x00, 0x4a, 0x00),
|
||||
LV_COLOR_MAKE(0xb8, 0xff, 0x9b),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0x62, 0xd5, 0x15),
|
||||
LV_COLOR_MAKE(0x00, 0x74, 0x00)};
|
||||
constexpr std::array<lv_color_t, nLines> rainbowColors = {LV_COLOR_MAKE(0x2d, 0xa4, 0x00),
|
||||
LV_COLOR_MAKE(0xac, 0x09, 0xc4),
|
||||
LV_COLOR_MAKE(0xfe, 0x03, 0x03),
|
||||
LV_COLOR_MAKE(0x0d, 0x57, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xe0, 0xb9, 0x00),
|
||||
LV_COLOR_MAKE(0xe8, 0x51, 0x02)};
|
||||
constexpr std::array<lv_color_t, nLines> grayColors = {LV_COLOR_MAKE(0xee, 0xee, 0xee),
|
||||
LV_COLOR_MAKE(0x98, 0x95, 0x9b),
|
||||
LV_COLOR_MAKE(0x19, 0x19, 0x19),
|
||||
LV_COLOR_MAKE(0xee, 0xee, 0xee),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0x91, 0x91, 0x91),
|
||||
LV_COLOR_MAKE(0x3a, 0x3a, 0x3a)};
|
||||
constexpr std::array<lv_color_t, nLines> nordBlueColors = {LV_COLOR_MAKE(0xc3, 0xda, 0xf2),
|
||||
LV_COLOR_MAKE(0x4d, 0x78, 0xce),
|
||||
LV_COLOR_MAKE(0x15, 0x34, 0x51),
|
||||
LV_COLOR_MAKE(0xc3, 0xda, 0xf2),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0x5d, 0x8a, 0xd2),
|
||||
LV_COLOR_MAKE(0x21, 0x51, 0x8a)};
|
||||
constexpr std::array<lv_color_t, nLines> nordGreenColors = {LV_COLOR_MAKE(0xd5, 0xf0, 0xe9),
|
||||
LV_COLOR_MAKE(0x23, 0x83, 0x73),
|
||||
LV_COLOR_MAKE(0x1d, 0x41, 0x3f),
|
||||
LV_COLOR_MAKE(0xd5, 0xf0, 0xe9),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0xff, 0xff, 0xff),
|
||||
LV_COLOR_MAKE(0x2f, 0xb8, 0xa2),
|
||||
LV_COLOR_MAKE(0x11, 0x70, 0x5a)};
|
||||
|
||||
constexpr const std::array<lv_color_t, nLines>* returnColor(colors color) {
|
||||
if (color == colors::orange) {
|
||||
return &orangeColors;
|
||||
}
|
||||
if (color == colors::blue) {
|
||||
return &blueColors;
|
||||
}
|
||||
if (color == colors::green) {
|
||||
return &greenColors;
|
||||
}
|
||||
if (color == colors::rainbow) {
|
||||
return &rainbowColors;
|
||||
}
|
||||
if (color == colors::gray) {
|
||||
return &grayColors;
|
||||
}
|
||||
if (color == colors::nordBlue) {
|
||||
return &nordBlueColors;
|
||||
}
|
||||
return &nordGreenColors;
|
||||
}
|
||||
}
|
||||
|
||||
WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
||||
const Controllers::Battery& batteryController,
|
||||
const Controllers::Ble& bleController,
|
||||
Controllers::NotificationManager& notificationManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::FS& filesystem)
|
||||
: currentDateTime {{}},
|
||||
dateTimeController {dateTimeController},
|
||||
batteryController {batteryController},
|
||||
bleController {bleController},
|
||||
notificationManager {notificationManager},
|
||||
settingsController {settingsController},
|
||||
motionController {motionController} {
|
||||
lfs_file f = {};
|
||||
if (filesystem.FileOpen(&f, "/fonts/teko.bin", LFS_O_RDONLY) >= 0) {
|
||||
filesystem.FileClose(&f);
|
||||
font_teko = lv_font_load("F:/fonts/teko.bin");
|
||||
}
|
||||
|
||||
if (filesystem.FileOpen(&f, "/fonts/bebas.bin", LFS_O_RDONLY) >= 0) {
|
||||
filesystem.FileClose(&f);
|
||||
font_bebas = lv_font_load("F:/fonts/bebas.bin");
|
||||
}
|
||||
|
||||
// Side Cover
|
||||
static constexpr lv_point_t linePoints[nLines][2] = {{{30, 25}, {68, -8}},
|
||||
{{26, 167}, {43, 216}},
|
||||
{{27, 40}, {27, 196}},
|
||||
{{12, 182}, {65, 249}},
|
||||
{{17, 99}, {17, 144}},
|
||||
{{14, 81}, {40, 127}},
|
||||
{{14, 163}, {40, 118}},
|
||||
{{-20, 124}, {25, -11}},
|
||||
{{-29, 89}, {27, 254}}};
|
||||
|
||||
static constexpr lv_style_int_t lineWidths[nLines] = {18, 15, 14, 22, 20, 18, 18, 52, 48};
|
||||
|
||||
const std::array<lv_color_t, nLines>* colors = returnColor(static_cast<enum colors>(settingsController.GetInfineatColorIndex()));
|
||||
for (int i = 0; i < nLines; i++) {
|
||||
lines[i] = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_line_width(lines[i], LV_LINE_PART_MAIN, LV_STATE_DEFAULT, lineWidths[i]);
|
||||
lv_color_t color = (*colors)[i];
|
||||
lv_obj_set_style_local_line_color(lines[i], LV_LINE_PART_MAIN, LV_STATE_DEFAULT, color);
|
||||
lv_line_set_points(lines[i], linePoints[i], 2);
|
||||
}
|
||||
|
||||
logoPine = lv_img_create(lv_scr_act(), nullptr);
|
||||
lv_img_set_src(logoPine, "F:/images/pine_small.bin");
|
||||
lv_obj_set_pos(logoPine, 15, 106);
|
||||
|
||||
lineBattery = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_line_width(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 24);
|
||||
lv_obj_set_style_local_line_color(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, (*colors)[4]);
|
||||
lv_obj_set_style_local_line_opa(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 190);
|
||||
lineBatteryPoints[0] = {27, 105};
|
||||
lineBatteryPoints[1] = {27, 106};
|
||||
lv_line_set_points(lineBattery, lineBatteryPoints, 2);
|
||||
lv_obj_move_foreground(lineBattery);
|
||||
|
||||
notificationIcon = lv_obj_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, (*colors)[7]);
|
||||
lv_obj_set_style_local_radius(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
||||
lv_obj_set_size(notificationIcon, 13, 13);
|
||||
lv_obj_set_hidden(notificationIcon, true);
|
||||
|
||||
if (!settingsController.GetInfineatShowSideCover()) {
|
||||
ToggleBatteryIndicatorColor(false);
|
||||
for (auto& line : lines) {
|
||||
lv_obj_set_hidden(line, true);
|
||||
}
|
||||
}
|
||||
|
||||
timeContainer = lv_obj_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_bg_opa(timeContainer, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
lv_obj_set_size(timeContainer, 185, 185);
|
||||
lv_obj_align(timeContainer, lv_scr_act(), LV_ALIGN_CENTER, 0, -10);
|
||||
|
||||
labelHour = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_text_static(labelHour, "01");
|
||||
lv_obj_set_style_local_text_font(labelHour, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_bebas);
|
||||
lv_obj_align(labelHour, timeContainer, LV_ALIGN_IN_TOP_MID, 0, 0);
|
||||
|
||||
labelMinutes = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_font(labelMinutes, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_bebas);
|
||||
lv_label_set_text_static(labelMinutes, "00");
|
||||
lv_obj_align(labelMinutes, timeContainer, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
|
||||
labelTimeAmPm = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_font(labelTimeAmPm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||
|
||||
lv_label_set_text_static(labelTimeAmPm, "");
|
||||
lv_obj_align(labelTimeAmPm, timeContainer, LV_ALIGN_OUT_RIGHT_TOP, 0, 15);
|
||||
|
||||
dateContainer = lv_obj_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_bg_opa(dateContainer, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
lv_obj_set_size(dateContainer, 60, 30);
|
||||
lv_obj_align(dateContainer, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 5);
|
||||
|
||||
static constexpr lv_color_t grayColor = LV_COLOR_MAKE(0x99, 0x99, 0x99);
|
||||
labelDate = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
|
||||
lv_obj_set_style_local_text_font(labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||
lv_obj_align(labelDate, dateContainer, LV_ALIGN_IN_TOP_MID, 0, 0);
|
||||
lv_label_set_text_static(labelDate, "Mon 01");
|
||||
|
||||
bleIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
|
||||
lv_label_set_text_static(bleIcon, Symbols::bluetooth);
|
||||
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
|
||||
|
||||
stepValue = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
|
||||
lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 10, 0);
|
||||
lv_label_set_text_static(stepValue, "0");
|
||||
|
||||
stepIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
|
||||
lv_label_set_text_static(stepIcon, Symbols::shoe);
|
||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
// Setting buttons
|
||||
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_70);
|
||||
lv_obj_t* lblClose = lv_label_create(btnClose, nullptr);
|
||||
lv_label_set_text_static(lblClose, "X");
|
||||
lv_obj_set_event_cb(btnClose, event_handler);
|
||||
lv_obj_set_hidden(btnClose, true);
|
||||
|
||||
btnNextColor = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnNextColor->user_data = this;
|
||||
lv_obj_set_size(btnNextColor, 60, 60);
|
||||
lv_obj_align(btnNextColor, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0);
|
||||
lv_obj_set_style_local_bg_opa(btnNextColor, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
|
||||
lv_obj_t* lblNextColor = lv_label_create(btnNextColor, nullptr);
|
||||
lv_label_set_text_static(lblNextColor, ">");
|
||||
lv_obj_set_event_cb(btnNextColor, event_handler);
|
||||
lv_obj_set_hidden(btnNextColor, true);
|
||||
|
||||
btnPrevColor = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnPrevColor->user_data = this;
|
||||
lv_obj_set_size(btnPrevColor, 60, 60);
|
||||
lv_obj_align(btnPrevColor, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0);
|
||||
lv_obj_set_style_local_bg_opa(btnPrevColor, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
|
||||
lv_obj_t* lblPrevColor = lv_label_create(btnPrevColor, nullptr);
|
||||
lv_label_set_text_static(lblPrevColor, "<");
|
||||
lv_obj_set_event_cb(btnPrevColor, event_handler);
|
||||
lv_obj_set_hidden(btnPrevColor, true);
|
||||
|
||||
btnToggleCover = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnToggleCover->user_data = this;
|
||||
lv_obj_set_size(btnToggleCover, 60, 60);
|
||||
lv_obj_align(btnToggleCover, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
|
||||
lv_obj_set_style_local_bg_opa(btnToggleCover, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
|
||||
const char* labelToggle = settingsController.GetInfineatShowSideCover() ? "ON" : "OFF";
|
||||
lblToggle = lv_label_create(btnToggleCover, nullptr);
|
||||
lv_label_set_text_static(lblToggle, labelToggle);
|
||||
lv_obj_set_event_cb(btnToggleCover, event_handler);
|
||||
lv_obj_set_hidden(btnToggleCover, true);
|
||||
|
||||
// Button to access the settings
|
||||
btnSettings = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnSettings->user_data = this;
|
||||
lv_obj_set_size(btnSettings, 150, 150);
|
||||
lv_obj_align(btnSettings, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_local_radius(btnSettings, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 30);
|
||||
lv_obj_set_style_local_bg_opa(btnSettings, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
|
||||
lv_obj_set_event_cb(btnSettings, event_handler);
|
||||
labelBtnSettings = lv_label_create(btnSettings, nullptr);
|
||||
lv_obj_set_style_local_text_font(labelBtnSettings, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
|
||||
lv_label_set_text_static(labelBtnSettings, Symbols::settings);
|
||||
lv_obj_set_hidden(btnSettings, true);
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
WatchFaceInfineat::~WatchFaceInfineat() {
|
||||
lv_task_del(taskRefresh);
|
||||
|
||||
if (font_bebas != nullptr) {
|
||||
lv_font_free(font_bebas);
|
||||
}
|
||||
if (font_teko != nullptr) {
|
||||
lv_font_free(font_teko);
|
||||
}
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool WatchFaceInfineat::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
if ((event == Pinetime::Applications::TouchEvents::LongTap) && lv_obj_get_hidden(btnSettings)) {
|
||||
lv_obj_set_hidden(btnSettings, false);
|
||||
savedTick = lv_tick_get();
|
||||
return true;
|
||||
}
|
||||
// Prevent screen from sleeping when double tapping with settings on
|
||||
if ((event == Pinetime::Applications::TouchEvents::DoubleTap) && !lv_obj_get_hidden(btnClose)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void WatchFaceInfineat::CloseMenu() {
|
||||
settingsController.SaveSettings();
|
||||
lv_obj_set_hidden(btnClose, true);
|
||||
lv_obj_set_hidden(btnNextColor, true);
|
||||
lv_obj_set_hidden(btnPrevColor, true);
|
||||
lv_obj_set_hidden(btnToggleCover, true);
|
||||
}
|
||||
|
||||
bool WatchFaceInfineat::OnButtonPushed() {
|
||||
if (!lv_obj_get_hidden(btnClose)) {
|
||||
CloseMenu();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void WatchFaceInfineat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||
if (event == LV_EVENT_CLICKED) {
|
||||
bool showSideCover = settingsController.GetInfineatShowSideCover();
|
||||
int colorIndex = settingsController.GetInfineatColorIndex();
|
||||
|
||||
if (object == btnSettings) {
|
||||
lv_obj_set_hidden(btnSettings, true);
|
||||
lv_obj_set_hidden(btnClose, false);
|
||||
lv_obj_set_hidden(btnNextColor, !showSideCover);
|
||||
lv_obj_set_hidden(btnPrevColor, !showSideCover);
|
||||
lv_obj_set_hidden(btnToggleCover, false);
|
||||
}
|
||||
if (object == btnClose) {
|
||||
CloseMenu();
|
||||
}
|
||||
if (object == btnToggleCover) {
|
||||
settingsController.SetInfineatShowSideCover(!showSideCover);
|
||||
ToggleBatteryIndicatorColor(!showSideCover);
|
||||
for (auto& line : lines) {
|
||||
lv_obj_set_hidden(line, showSideCover);
|
||||
}
|
||||
lv_obj_set_hidden(btnNextColor, showSideCover);
|
||||
lv_obj_set_hidden(btnPrevColor, showSideCover);
|
||||
const char* labelToggle = showSideCover ? "OFF" : "ON";
|
||||
lv_label_set_text_static(lblToggle, labelToggle);
|
||||
}
|
||||
if (object == btnNextColor) {
|
||||
colorIndex = (colorIndex + 1) % nColors;
|
||||
settingsController.SetInfineatColorIndex(colorIndex);
|
||||
}
|
||||
if (object == btnPrevColor) {
|
||||
colorIndex -= 1;
|
||||
if (colorIndex < 0)
|
||||
colorIndex = nColors - 1;
|
||||
settingsController.SetInfineatColorIndex(colorIndex);
|
||||
}
|
||||
if (object == btnNextColor || object == btnPrevColor) {
|
||||
const std::array<lv_color_t, nLines>* colors = returnColor(static_cast<enum colors>(settingsController.GetInfineatColorIndex()));
|
||||
for (int i = 0; i < nLines; i++) {
|
||||
lv_color_t color = (*colors)[i];
|
||||
lv_obj_set_style_local_line_color(lines[i], LV_LINE_PART_MAIN, LV_STATE_DEFAULT, color);
|
||||
}
|
||||
lv_obj_set_style_local_line_color(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, (*colors)[4]);
|
||||
lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, (*colors)[7]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WatchFaceInfineat::Refresh() {
|
||||
notificationState = notificationManager.AreNewNotificationsAvailable();
|
||||
if (notificationState.IsUpdated()) {
|
||||
lv_obj_set_hidden(notificationIcon, !notificationState.Get());
|
||||
lv_obj_align(notificationIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
||||
}
|
||||
|
||||
currentDateTime = std::chrono::time_point_cast<std::chrono::minutes>(dateTimeController.CurrentDateTime());
|
||||
if (currentDateTime.IsUpdated()) {
|
||||
uint8_t hour = dateTimeController.Hours();
|
||||
uint8_t minute = dateTimeController.Minutes();
|
||||
|
||||
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(labelTimeAmPm, ampmChar);
|
||||
}
|
||||
lv_label_set_text_fmt(labelHour, "%02d", hour);
|
||||
lv_label_set_text_fmt(labelMinutes, "%02d", minute);
|
||||
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
lv_obj_align(labelTimeAmPm, timeContainer, LV_ALIGN_OUT_RIGHT_TOP, 0, 10);
|
||||
lv_obj_align(labelHour, timeContainer, LV_ALIGN_IN_TOP_MID, 0, 5);
|
||||
lv_obj_align(labelMinutes, timeContainer, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
}
|
||||
|
||||
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
|
||||
if (currentDate.IsUpdated()) {
|
||||
uint8_t day = dateTimeController.Day();
|
||||
Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek();
|
||||
lv_label_set_text_fmt(labelDate, "%s %02d", dateTimeController.DayOfWeekShortToStringLow(dayOfWeek), day);
|
||||
lv_obj_realign(labelDate);
|
||||
}
|
||||
}
|
||||
|
||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||
isCharging = batteryController.IsCharging();
|
||||
if (batteryController.IsCharging()) { // Charging battery animation
|
||||
chargingBatteryPercent += 1;
|
||||
if (chargingBatteryPercent > 100) {
|
||||
chargingBatteryPercent = batteryPercentRemaining.Get();
|
||||
}
|
||||
SetBatteryLevel(chargingBatteryPercent);
|
||||
} else if (isCharging.IsUpdated() || batteryPercentRemaining.IsUpdated()) {
|
||||
chargingBatteryPercent = batteryPercentRemaining.Get();
|
||||
SetBatteryLevel(chargingBatteryPercent);
|
||||
}
|
||||
|
||||
bleState = bleController.IsConnected();
|
||||
bleRadioEnabled = bleController.IsRadioEnabled();
|
||||
if (bleState.IsUpdated()) {
|
||||
lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
|
||||
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 3);
|
||||
}
|
||||
|
||||
stepCount = motionController.NbSteps();
|
||||
if (stepCount.IsUpdated()) {
|
||||
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
|
||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 10, 0);
|
||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
}
|
||||
|
||||
if (!lv_obj_get_hidden(btnSettings)) {
|
||||
if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) {
|
||||
lv_obj_set_hidden(btnSettings, true);
|
||||
savedTick = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WatchFaceInfineat::SetBatteryLevel(uint8_t batteryPercent) {
|
||||
// starting point (y) + Pine64 logo height * (100 - batteryPercent) / 100
|
||||
lineBatteryPoints[1] = {27, static_cast<lv_coord_t>(105 + 32 * (100 - batteryPercent) / 100)};
|
||||
lv_line_set_points(lineBattery, lineBatteryPoints, 2);
|
||||
}
|
||||
|
||||
void WatchFaceInfineat::ToggleBatteryIndicatorColor(bool showSideCover) {
|
||||
if (!showSideCover) { // make indicator and notification icon color white
|
||||
lv_obj_set_style_local_image_recolor_opa(logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_100);
|
||||
lv_obj_set_style_local_image_recolor(logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
lv_obj_set_style_local_line_color(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
} else {
|
||||
lv_obj_set_style_local_image_recolor_opa(logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
|
||||
const std::array<lv_color_t, nLines>* colors = returnColor(static_cast<enum colors>(settingsController.GetInfineatColorIndex()));
|
||||
lv_obj_set_style_local_line_color(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, (*colors)[4]);
|
||||
lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, (*colors)[7]);
|
||||
}
|
||||
}
|
||||
|
||||
bool WatchFaceInfineat::IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
lfs_file file = {};
|
||||
|
||||
if (filesystem.FileOpen(&file, "/fonts/teko.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
filesystem.FileClose(&file);
|
||||
if (filesystem.FileOpen(&file, "/fonts/bebas.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
filesystem.FileClose(&file);
|
||||
if (filesystem.FileOpen(&file, "/images/pine_small.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
filesystem.FileClose(&file);
|
||||
return true;
|
||||
}
|
||||