summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhubmartin <hub.martin@gmail.com>2021-09-16 22:04:31 +0200
committerhubmartin <hub.martin@gmail.com>2021-09-16 22:04:31 +0200
commit27366bdfdf05a5fd3128ad8eabedbeba720ca885 (patch)
tree94bf7fe9e60c7c88d269e207acb197915eb98660
parentdb50131ed49f2fdb639799ca12839862340f8396 (diff)
parent3eb73774a39e255cd4b5de76441a59f1525a989c (diff)
Merge branch 'develop' into wake-time
-rw-r--r--.github/workflows/main.yml32
-rw-r--r--CMakeLists.txt11
-rw-r--r--README.md25
-rwxr-xr-xcmake-nRF5x/readme.md2
-rw-r--r--doc/buildAndProgram.md1
-rw-r--r--doc/gettingStarted/ota-gadgetbridge-nrfconnect.md8
-rw-r--r--doc/versioning.md2
-rw-r--r--src/CMakeLists.txt19
-rw-r--r--src/components/battery/BatteryController.cpp16
-rw-r--r--src/components/battery/BatteryController.h9
-rw-r--r--src/components/ble/NimbleController.cpp125
-rw-r--r--src/components/ble/NimbleController.h7
-rw-r--r--src/components/brightness/BrightnessController.cpp32
-rw-r--r--src/components/brightness/BrightnessController.h3
-rw-r--r--src/components/motor/MotorController.cpp11
-rw-r--r--src/components/motor/MotorController.h2
-rw-r--r--src/components/settings/Settings.h45
-rw-r--r--src/displayapp/Apps.h3
-rw-r--r--src/displayapp/Colors.cpp27
-rw-r--r--src/displayapp/Colors.h10
-rw-r--r--src/displayapp/DisplayApp.cpp83
-rw-r--r--src/displayapp/DisplayApp.h11
-rw-r--r--src/displayapp/DisplayAppRecovery.cpp5
-rw-r--r--src/displayapp/DisplayAppRecovery.h32
-rw-r--r--src/displayapp/DummyLittleVgl.h3
-rw-r--r--src/displayapp/LittleVgl.cpp30
-rw-r--r--src/displayapp/LittleVgl.h2
-rw-r--r--src/displayapp/Messages.h1
-rw-r--r--src/displayapp/screens/ApplicationList.cpp6
-rw-r--r--src/displayapp/screens/ApplicationList.h3
-rw-r--r--src/displayapp/screens/BatteryInfo.cpp19
-rw-r--r--src/displayapp/screens/BatteryInfo.h6
-rw-r--r--src/displayapp/screens/Brightness.cpp4
-rw-r--r--src/displayapp/screens/Brightness.h3
-rw-r--r--src/displayapp/screens/Clock.cpp7
-rw-r--r--src/displayapp/screens/Clock.h2
-rw-r--r--src/displayapp/screens/FirmwareUpdate.cpp5
-rw-r--r--src/displayapp/screens/FirmwareUpdate.h3
-rw-r--r--src/displayapp/screens/FirmwareValidation.cpp8
-rw-r--r--src/displayapp/screens/FirmwareValidation.h2
-rw-r--r--src/displayapp/screens/FlashLight.cpp4
-rw-r--r--src/displayapp/screens/FlashLight.h2
-rw-r--r--src/displayapp/screens/HeartRate.cpp7
-rw-r--r--src/displayapp/screens/HeartRate.h4
-rw-r--r--src/displayapp/screens/InfiniPaint.cpp7
-rw-r--r--src/displayapp/screens/InfiniPaint.h2
-rw-r--r--src/displayapp/screens/Label.cpp4
-rw-r--r--src/displayapp/screens/Label.h2
-rw-r--r--src/displayapp/screens/List.cpp7
-rw-r--r--src/displayapp/screens/List.h2
-rw-r--r--src/displayapp/screens/Meter.cpp8
-rw-r--r--src/displayapp/screens/Meter.h4
-rw-r--r--src/displayapp/screens/Metronome.cpp7
-rw-r--r--src/displayapp/screens/Metronome.h4
-rw-r--r--src/displayapp/screens/Motion.cpp7
-rw-r--r--src/displayapp/screens/Motion.h3
-rw-r--r--src/displayapp/screens/Music.cpp7
-rw-r--r--src/displayapp/screens/Music.h4
-rw-r--r--src/displayapp/screens/Navigation.cpp9
-rw-r--r--src/displayapp/screens/Navigation.h4
-rw-r--r--src/displayapp/screens/Notifications.cpp8
-rw-r--r--src/displayapp/screens/Notifications.h12
-rw-r--r--src/displayapp/screens/Paddle.cpp10
-rw-r--r--src/displayapp/screens/Paddle.h4
-rw-r--r--src/displayapp/screens/PineTimeStyle.cpp38
-rw-r--r--src/displayapp/screens/PineTimeStyle.h4
-rw-r--r--src/displayapp/screens/Screen.cpp6
-rw-r--r--src/displayapp/screens/Screen.h25
-rw-r--r--src/displayapp/screens/ScreenList.h7
-rw-r--r--src/displayapp/screens/Steps.cpp8
-rw-r--r--src/displayapp/screens/Steps.h25
-rw-r--r--src/displayapp/screens/StopWatch.cpp16
-rw-r--r--src/displayapp/screens/StopWatch.h5
-rw-r--r--src/displayapp/screens/SystemInfo.cpp13
-rw-r--r--src/displayapp/screens/SystemInfo.h1
-rw-r--r--src/displayapp/screens/Tile.cpp5
-rw-r--r--src/displayapp/screens/Tile.h1
-rw-r--r--src/displayapp/screens/Timer.cpp46
-rw-r--r--src/displayapp/screens/Timer.h35
-rw-r--r--src/displayapp/screens/Twos.cpp6
-rw-r--r--src/displayapp/screens/Twos.h3
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.cpp7
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.h4
-rw-r--r--src/displayapp/screens/WatchFaceDigital.cpp8
-rw-r--r--src/displayapp/screens/WatchFaceDigital.h4
-rw-r--r--src/displayapp/screens/settings/QuickSettings.cpp10
-rw-r--r--src/displayapp/screens/settings/QuickSettings.h2
-rw-r--r--src/displayapp/screens/settings/SettingDisplay.cpp8
-rw-r--r--src/displayapp/screens/settings/SettingDisplay.h1
-rw-r--r--src/displayapp/screens/settings/SettingPineTimeStyle.cpp318
-rw-r--r--src/displayapp/screens/settings/SettingPineTimeStyle.h56
-rw-r--r--src/displayapp/screens/settings/SettingSteps.cpp7
-rw-r--r--src/displayapp/screens/settings/SettingSteps.h23
-rw-r--r--src/displayapp/screens/settings/SettingTimeFormat.cpp6
-rw-r--r--src/displayapp/screens/settings/SettingTimeFormat.h1
-rw-r--r--src/displayapp/screens/settings/SettingWakeUp.cpp4
-rw-r--r--src/displayapp/screens/settings/SettingWakeUp.h1
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.cpp4
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.h1
-rw-r--r--src/displayapp/screens/settings/Settings.cpp26
-rw-r--r--src/displayapp/screens/settings/Settings.h5
-rw-r--r--src/drivers/Cst816s.cpp49
-rw-r--r--src/drivers/Cst816s.h27
-rw-r--r--src/drivers/PinMap.h38
-rw-r--r--src/drivers/TwiMaster.cpp94
-rw-r--r--src/drivers/TwiMaster.h19
-rw-r--r--src/main.cpp57
-rw-r--r--src/recoveryLoader.cpp19
-rw-r--r--src/systemtask/Messages.h4
-rw-r--r--src/systemtask/SystemTask.cpp108
-rw-r--r--src/systemtask/SystemTask.h27
-rw-r--r--src/touchhandler/TouchHandler.cpp65
-rw-r--r--src/touchhandler/TouchHandler.h45
113 files changed, 1270 insertions, 779 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 4a71b7e0..bd24359a 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -9,13 +9,13 @@ name: Build PineTime Firmware
# When to run this Workflow...
on:
- # Run this Workflow when files are updated (Pushed) in the "master" Branch
+ # Run this Workflow when files are updated (Pushed) in the "master" and "develop" Branch
push:
- branches: [ master ]
+ branches: [ master, develop ]
- # Also run this Workflow when a Pull Request is created or updated in the "master" Branch
+ # Also run this Workflow when a Pull Request is created or updated in the "master" and "develop" Branch
pull_request:
- branches: [ master ]
+ branches: [ master, develop ]
# Steps to run for the Workflow
jobs:
@@ -44,7 +44,7 @@ jobs:
- name: Install Embedded Arm Toolchain arm-none-eabi-gcc
if: steps.cache-toolchain.outputs.cache-hit != 'true' # Install toolchain if not found in cache
- uses: fiam/arm-none-eabi-gcc@v1.0.2
+ uses: fiam/arm-none-eabi-gcc@v1.0.4
with:
# GNU Embedded Toolchain for Arm release name, in the V-YYYY-qZ format (e.g. "9-2019-q4")
release: 9-2020-q2
@@ -83,10 +83,11 @@ jobs:
if: steps.cache-mcuboot.outputs.cache-hit != 'true' # Install MCUBoot if not found in cache
run: |
cd ${{ runner.temp }}
- git clone --branch v1.5.0 https://github.com/JuulLabs-OSS/mcuboot
+ git clone --branch v1.7.2 https://github.com/mcu-tools/mcuboot
- name: Install imgtool dependencies
- run: pip3 install --user -r ${{ runner.temp }}/mcuboot/scripts/requirements.txt
+ run: |
+ pip3 install --user -r ${{ runner.temp }}/mcuboot/scripts/requirements.txt
- name: Install adafruit-nrfutil
run: |
@@ -99,6 +100,8 @@ jobs:
- name: Checkout source files
uses: actions/checkout@v2
+ with:
+ submodules: recursive
- name: Show files
run: set ; pwd ; ls -l
@@ -110,7 +113,7 @@ jobs:
run: |
mkdir -p build
cd build
- cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=${{ runner.temp }}/arm-none-eabi -DNRF5_SDK_PATH=${{ runner.temp }}/nrf5_sdk -DUSE_OPENOCD=1 ../
+ cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=${{ runner.temp }}/arm-none-eabi -DNRF5_SDK_PATH=${{ runner.temp }}/nrf5_sdk -DUSE_OPENOCD=1 -DBUILD_DFU=1 ../
#########################################################################################
# Make and Upload DFU Package
@@ -125,19 +128,10 @@ jobs:
cd build
make pinetime-mcuboot-app
- - name: Create firmware image
- run: |
- # The generated firmware binary looks like "pinetime-mcuboot-app-0.8.2.bin"
- ls -l build/src/pinetime-mcuboot-app*.bin
- ${{ runner.temp }}/mcuboot/scripts/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header build/src/pinetime-mcuboot-app*.bin build/src/pinetime-mcuboot-app-img.bin
- ${{ runner.temp }}/mcuboot/scripts/imgtool.py verify build/src/pinetime-mcuboot-app-img.bin
-
- - name: Create DFU package
+ - name: Unzip DFU package
run: |
- ~/.local/bin/adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application build/src/pinetime-mcuboot-app-img.bin build/src/pinetime-mcuboot-app-dfu.zip
- unzip -v build/src/pinetime-mcuboot-app-dfu.zip
# Unzip the package because Upload Artifact will zip up the files
- unzip build/src/pinetime-mcuboot-app-dfu.zip -d build/src/pinetime-mcuboot-app-dfu
+ unzip build/src/pinetime-mcuboot-app-dfu*.zip -d build/src/pinetime-mcuboot-app-dfu
- name: Upload DFU package
uses: actions/upload-artifact@v2
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b442fc11..f2402e57 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
-project(pinetime VERSION 1.3.0 LANGUAGES C CXX ASM)
+project(pinetime VERSION 1.4.0 LANGUAGES C CXX ASM)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 14)
@@ -51,6 +51,14 @@ if(BUILD_DFU)
set(BUILD_DFU true)
endif()
+option(WATCH_COLMI_P8 "Build for the Colmi P8" OFF)
+set(TARGET_DEVICE "PineTime")
+
+if(WATCH_COLMI_P8)
+ set(TARGET_DEVICE "Colmi P8")
+ add_definitions(-DWATCH_P8)
+endif()
+
set(PROJECT_GIT_COMMIT_HASH "")
execute_process(COMMAND git rev-parse --short HEAD
@@ -68,6 +76,7 @@ message(" * Version : " ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${P
message(" * Toolchain : " ${ARM_NONE_EABI_TOOLCHAIN_PATH})
message(" * GitRef(S) : " ${PROJECT_GIT_COMMIT_HASH})
message(" * NRF52 SDK : " ${NRF5_SDK_PATH})
+message(" * Target device : " ${TARGET_DEVICE})
set(PROGRAMMER "???")
if(USE_JLINK)
message(" * Programmer/debugger : JLINK")
diff --git a/README.md b/README.md
index 6549ece9..0d5cad93 100644
--- a/README.md
+++ b/README.md
@@ -1,20 +1,10 @@
-# PineTime
+# InfiniTime
[![Build PineTime Firmware](https://github.com/JF002/InfiniTime/workflows/Build%20PineTime%20Firmware/badge.svg?branch=master)](https://github.com/JF002/InfiniTime/actions)
-> The PineTime is a free and open source smartwatch capable of running custom-built open operating systems. Some of the notable features include a heart rate monitor, a week-long battery as well as a capacitive touch IPS display that is legible in direct sunlight. It is a fully community driven side-project, which means that it will ultimately be up to the developers and end-users to determine when they deem the PineTime ready to ship.
-
-> We envision the PineTime as a companion for not only your PinePhone but also for your favorite devices — any phone, tablet, or even PC.
-
-*https://www.pine64.org/pinetime/*
-
-The **Pinetime** smartwatch is built around the NRF52832 MCU (512KB Flash, 64KB RAM), a 240*240 LCD display driven by the ST7789 controller, an accelerometer, a heart rate sensor, and a vibration motor.
-
-# InfiniTime
-
![InfiniTime logo](images/infinitime-logo.jpg "InfiniTime Logo")
-The goal of this project is to design an open-source firmware for the Pinetime smartwatch :
+The goal of this project is to design an open-source firmware for the [Pinetime smartwatch](https://www.pine64.org/pinetime/) :
- Code written in **modern C++**;
- Build system based on **CMake**;
@@ -22,6 +12,11 @@ The goal of this project is to design an open-source firmware for the Pinetime s
- Using **[LittleVGL/LVGL 7](https://lvgl.io/)** as UI library...
- ... and **[NimBLE 1.3.0](https://github.com/apache/mynewt-nimble)** as BLE stack.
+## New to InfiniTime?
+
+ - [Getting started with InfiniTime 1.0 (quick user guide, update bootloader and InfiniTime,...)](doc/gettingStarted/gettingStarted-1.0.md)
+ - [Flash, upgrade (OTA), time synchronization,...](doc/gettingStarted/ota-gadgetbridge-nrfconnect.md)
+
## Overview
![Pinetime screens](images/1.0.0/collage.png "PinetimeScreens")
@@ -70,16 +65,12 @@ As of now, here is the list of achievements of this project:
* [Amazfish](https://openrepos.net/content/piggz/amazfish) (on SailfishOS and Linux)
* [Siglo](https://github.com/alexr4535/siglo) (on Linux)
* **[Experimental]** [WebBLEWatch](https://hubmartin.github.io/WebBLEWatch/) Synchronize time directly from your web browser. [video](https://youtu.be/IakiuhVDdrY)
+ * **[Experimental]** [Infini-iOS](https://github.com/xan-m/Infini-iOS) (on iOS)
- OTA (Over-the-air) update via BLE
- [Bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader) based on [MCUBoot](https://juullabs-oss.github.io/mcuboot/)
## Documentation
-### Getting started
-
- - [Getting started with InfiniTime 1.0 (quick user guide, update bootloader and InfiniTime,...)](doc/gettingStarted/gettingStarted-1.0.md)
- - [Flash, upgrade (OTA), time synchronization,...](doc/gettingStarted/ota-gadgetbridge-nrfconnect.md)
-
### Develop
- [Generate the fonts and symbols](src/displayapp/fonts/README.md)
diff --git a/cmake-nRF5x/readme.md b/cmake-nRF5x/readme.md
index 2ce76892..0127a2e6 100755
--- a/cmake-nRF5x/readme.md
+++ b/cmake-nRF5x/readme.md
@@ -98,7 +98,7 @@ The script makes use of the following tools:
After setup you can use cmake as usual:
-1. Generate the actual build files (out-of-source builds are strongly recomended):
+1. Generate the actual build files (out-of-source builds are strongly recommended):
```commandline
cmake -H. -B"cmake-build" -G "Unix Makefiles"
diff --git a/doc/buildAndProgram.md b/doc/buildAndProgram.md
index 87b6dd9a..e97bb30d 100644
--- a/doc/buildAndProgram.md
+++ b/doc/buildAndProgram.md
@@ -28,6 +28,7 @@ CMake configures the project according to variables you specify the command line
**GDB_CLIENT_BIN_PATH**|Path to arm-none-eabi-gdb executable. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_BIN_PATH=/home/jf/nrf52/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gdb`
**GDB_CLIENT_TARGET_REMOTE**|Target remote connection string. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_TARGET_REMOTE=/dev/ttyACM0`
**BUILD_DFU (\*\*)**|Build DFU files while building (needs [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-DBUILD_DFU=1`
+**WATCH_COLMI_P8**|Use pin configuration for Colmi P8 watch|`-DWATCH_COLMI_P8=1`
####(**) Note about **CMAKE_BUILD_TYPE**:
By default, this variable is set to *Release*. It compiles the code with size and speed optimizations. We use this value for all the binaries we publish when we [release](https://github.com/JF002/InfiniTime/releases) new versions of InfiniTime.
diff --git a/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md b/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md
index 1187a9b7..ffc27ed8 100644
--- a/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md
+++ b/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md
@@ -47,6 +47,8 @@ Read carefully the warning and tap **Install**:
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.
+
![Gadgetbridge 5](gadgetbridge5.jpg)
### Using NRFConnect
@@ -64,6 +66,8 @@ Select **Distribution packet (ZIP)**:
Browse to the DFU file you downloaded previously, the DFU transfer will start automatically. When the transfer is finished, your PineTime will reset and restart on 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.
+
![NRFConnect 3](nrfconnect3.jpg)
## How to flash InfiniTime using the SWD interface
@@ -88,6 +92,10 @@ If you are using OpenOCD with a STLinkV2, you can find more info [on this page](
### Using Gadgetbridge
Good news! Gadgetbridge **automatically** synchronizes the time when connecting to your PineTime!
+### Using any Chromium-based web browser
+You can use it from your PC, Mac, Android. Browsers now have BLE support.
+https://hubmartin.github.io/WebBLEWatch/
+
### Using NRFConnect
You must enable the **CTS** *GATT server* into NRFConnect so that InfiniTime can synchronize the time with your smartphone.
diff --git a/doc/versioning.md b/doc/versioning.md
index b08af714..48e05043 100644
--- a/doc/versioning.md
+++ b/doc/versioning.md
@@ -3,4 +3,4 @@ The versioning of this project is based on [Semantic versionning](https://semver
- The **patch** is incremented when we fix a bug on a **released** version (most of the time using a **hotfix** branch).
- The **minor** is incremented when we release a new version with new features. It corresponds to a merge of **develop** into **master**.
- - The **major** should be incremented when a breaking change is made to the application. We still have to define what is a breaking change in the context of this project. For now, I suggest that it stays **0** until we have a fully functionning firmware suited for the final user. \ No newline at end of file
+ - The **major** should be incremented when a breaking change is made to the application. We still have to define what is a breaking change in the context of this project. For now, I suggest that it stays **0** until we have a fully functioning firmware suited for the final user. \ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f72f50c9..be406ba4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -92,6 +92,9 @@ set(SDK_SOURCE_FILES
set(TINYCRYPT_SRC
libs/mynewt-nimble/ext/tinycrypt/src/aes_encrypt.c
libs/mynewt-nimble/ext/tinycrypt/src/utils.c
+ libs/mynewt-nimble/ext/tinycrypt/src/cmac_mode.c
+ libs/mynewt-nimble/ext/tinycrypt/src/ecc.c
+ libs/mynewt-nimble/ext/tinycrypt/src/ecc_dh.c
)
set(NIMBLE_SRC
@@ -104,6 +107,10 @@ set(NIMBLE_SRC
libs/mynewt-nimble/nimble/host/src/ble_l2cap.c
libs/mynewt-nimble/nimble/host/src/ble_hs_mbuf.c
libs/mynewt-nimble/nimble/host/src/ble_sm.c
+ libs/mynewt-nimble/nimble/host/src/ble_sm_cmd.c
+ libs/mynewt-nimble/nimble/host/src/ble_sm_lgcy.c
+ libs/mynewt-nimble/nimble/host/src/ble_sm_alg.c
+ libs/mynewt-nimble/nimble/host/src/ble_sm_sc.c
libs/mynewt-nimble/nimble/host/src/ble_gap.c
libs/mynewt-nimble/nimble/host/src/ble_gatts.c
libs/mynewt-nimble/nimble/host/src/ble_gattc.c
@@ -127,10 +134,6 @@ set(NIMBLE_SRC
libs/mynewt-nimble/nimble/host/src/ble_hs_atomic.c
libs/mynewt-nimble/nimble/host/src/ble_hs_adv.c
libs/mynewt-nimble/nimble/host/src/ble_hs_flow.c
- libs/mynewt-nimble/nimble/host/src/ble_sm.c
- libs/mynewt-nimble/nimble/host/src/ble_sm_cmd.c
- libs/mynewt-nimble/nimble/host/src/ble_sm_lgcy.c
- libs/mynewt-nimble/nimble/host/src/ble_sm_alg.c
libs/mynewt-nimble/nimble/host/src/ble_hs_mqueue.c
libs/mynewt-nimble/nimble/host/src/ble_hs_stop.c
libs/mynewt-nimble/nimble/host/src/ble_hs_startup.c
@@ -418,6 +421,7 @@ list(APPEND SOURCE_FILES
displayapp/screens/BatteryInfo.cpp
displayapp/screens/Steps.cpp
displayapp/screens/Timer.cpp
+ displayapp/Colors.cpp
## Settings
displayapp/screens/settings/QuickSettings.cpp
@@ -427,6 +431,7 @@ list(APPEND SOURCE_FILES
displayapp/screens/settings/SettingWakeUp.cpp
displayapp/screens/settings/SettingDisplay.cpp
displayapp/screens/settings/SettingSteps.cpp
+ displayapp/screens/settings/SettingPineTimeStyle.cpp
## Watch faces
displayapp/icons/bg_clock.c
@@ -495,6 +500,8 @@ list(APPEND SOURCE_FILES
components/heartrate/Biquad.cpp
components/heartrate/Ptagc.cpp
components/heartrate/HeartRateController.cpp
+
+ touchhandler/TouchHandler.cpp
)
list(APPEND RECOVERY_SOURCE_FILES
@@ -552,6 +559,7 @@ list(APPEND RECOVERY_SOURCE_FILES
components/heartrate/Ptagc.cpp
components/motor/MotorController.cpp
components/fs/FS.cpp
+ touchhandler/TouchHandler.cpp
)
list(APPEND RECOVERYLOADER_SOURCE_FILES
@@ -607,6 +615,7 @@ set(INCLUDE_FILES
displayapp/screens/Metronome.h
displayapp/screens/Motion.h
displayapp/screens/Timer.h
+ displayapp/Colors.h
drivers/St7789.h
drivers/SpiNorFlash.h
drivers/SpiMaster.h
@@ -615,6 +624,7 @@ set(INCLUDE_FILES
drivers/DebugPins.h
drivers/InternalFlash.h
drivers/Hrs3300.h
+ drivers/PinMap.h
drivers/Bma421.h
drivers/Bma421_C/bma4.c
drivers/Bma421_C/bma423.c
@@ -660,6 +670,7 @@ set(INCLUDE_FILES
components/heartrate/Ptagc.h
components/heartrate/HeartRateController.h
components/motor/MotorController.h
+ touchhandler/TouchHandler.h
)
include_directories(
diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp
index f8a64ecd..4ef20a24 100644
--- a/src/components/battery/BatteryController.cpp
+++ b/src/components/battery/BatteryController.cpp
@@ -1,4 +1,5 @@
#include "BatteryController.h"
+#include "drivers/PinMap.h"
#include <hal/nrf_gpio.h>
#include <nrfx_saadc.h>
#include <algorithm>
@@ -9,15 +10,12 @@ Battery* Battery::instance = nullptr;
Battery::Battery() {
instance = this;
-}
-
-void Battery::Init() {
- nrf_gpio_cfg_input(chargingPin, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Pullup);
+ nrf_gpio_cfg_input(PinMap::Charging, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Disabled);
}
void Battery::Update() {
- isCharging = !nrf_gpio_pin_read(chargingPin);
- isPowerPresent = !nrf_gpio_pin_read(powerPresentPin);
+ isCharging = !nrf_gpio_pin_read(PinMap::Charging);
+ isPowerPresent = !nrf_gpio_pin_read(PinMap::PowerPresent);
if (isReading) {
return;
@@ -75,5 +73,11 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) {
nrfx_saadc_uninit();
isReading = false;
+
+ systemTask->PushMessage(System::Messages::BatteryMeasurementDone);
}
}
+
+void Battery::Register(Pinetime::System::SystemTask* systemTask) {
+ this->systemTask = systemTask;
+}
diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h
index 6f09b737..8af27ea8 100644
--- a/src/components/battery/BatteryController.h
+++ b/src/components/battery/BatteryController.h
@@ -1,8 +1,7 @@
#pragma once
#include <cstdint>
#include <drivers/include/nrfx_saadc.h>
-#include <array>
-#include <numeric>
+#include <systemtask/SystemTask.h>
namespace Pinetime {
namespace Controllers {
@@ -11,8 +10,8 @@ namespace Pinetime {
public:
Battery();
- void Init();
void Update();
+ void Register(System::SystemTask* systemTask);
uint8_t PercentRemaining() const {
return percentRemaining;
@@ -34,8 +33,6 @@ namespace Pinetime {
static Battery* instance;
nrf_saadc_value_t saadc_value;
- static constexpr uint32_t chargingPin = 12;
- static constexpr uint32_t powerPresentPin = 19;
static constexpr nrf_saadc_input_t batteryVoltageAdcInput = NRF_SAADC_INPUT_AIN7;
uint16_t voltage = 0;
uint8_t percentRemaining = 0;
@@ -49,6 +46,8 @@ namespace Pinetime {
static void AdcCallbackStatic(nrfx_saadc_evt_t const* event);
bool isReading = false;
+
+ Pinetime::System::SystemTask* systemTask = nullptr;
};
}
}
diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp
index 5eb227bf..879421e7 100644
--- a/src/components/ble/NimbleController.cpp
+++ b/src/components/ble/NimbleController.cpp
@@ -42,6 +42,19 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask,
serviceDiscovery({&currentTimeClient, &alertNotificationClient}) {
}
+void nimble_on_reset(int reason) {
+ NRF_LOG_INFO("Resetting state; reason=%d\n", reason);
+}
+
+void nimble_on_sync(void) {
+ int rc;
+
+ rc = ble_hs_util_ensure_addr(0);
+ ASSERT(rc == 0);
+
+ nptr->StartAdvertising();
+}
+
int GAPEventCallback(struct ble_gap_event* event, void* arg) {
auto nimbleController = static_cast<NimbleController*>(arg);
return nimbleController->OnGAPEvent(event);
@@ -51,6 +64,10 @@ void NimbleController::Init() {
while (!ble_hs_synced()) {
}
+ nptr = this;
+ ble_hs_cfg.reset_cb = nimble_on_reset;
+ ble_hs_cfg.sync_cb = nimble_on_sync;
+
ble_svc_gap_init();
ble_svc_gatt_init();
@@ -64,28 +81,31 @@ void NimbleController::Init() {
batteryInformationService.Init();
immediateAlertService.Init();
heartRateService.Init();
- int res;
- res = ble_hs_util_ensure_addr(0);
- ASSERT(res == 0);
- res = ble_hs_id_infer_auto(0, &addrType);
- ASSERT(res == 0);
- res = ble_svc_gap_device_name_set(deviceName);
- ASSERT(res == 0);
+
+ int rc;
+ rc = ble_hs_util_ensure_addr(0);
+ ASSERT(rc == 0);
+ rc = ble_hs_id_infer_auto(0, &addrType);
+ ASSERT(rc == 0);
+ rc = ble_svc_gap_device_name_set(deviceName);
+ ASSERT(rc == 0);
+ rc = ble_svc_gap_device_appearance_set(0xC2);
+ ASSERT(rc == 0);
Pinetime::Controllers::Ble::BleAddress address;
- res = ble_hs_id_copy_addr(addrType, address.data(), nullptr);
- ASSERT(res == 0);
+ rc = ble_hs_id_copy_addr(addrType, address.data(), nullptr);
+ ASSERT(rc == 0);
bleController.AddressType((addrType == 0) ? Ble::AddressTypes::Public : Ble::AddressTypes::Random);
bleController.Address(std::move(address));
- res = ble_gatts_start();
- ASSERT(res == 0);
+ rc = ble_gatts_start();
+ ASSERT(rc == 0);
+
+ if (!ble_gap_adv_active() && !bleController.IsConnected())
+ StartAdvertising();
}
void NimbleController::StartAdvertising() {
- if (bleController.IsConnected() || ble_gap_conn_active() || ble_gap_adv_active())
- return;
-
- ble_svc_gap_device_name_set(deviceName);
+ int rc;
/* set adv parameters */
struct ble_gap_adv_params adv_params;
@@ -102,11 +122,17 @@ void NimbleController::StartAdvertising() {
adv_params.conn_mode = BLE_GAP_CONN_MODE_UND;
adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN;
+ /* fast advertise for 30 sec */
+ if (fastAdvCount < 15) {
+ adv_params.itvl_min = 32;
+ adv_params.itvl_max = 47;
+ fastAdvCount++;
+ } else {
+ adv_params.itvl_min = 1636;
+ adv_params.itvl_max = 1651;
+ }
fields.flags = BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP;
- // fields.uuids128 = BLE_UUID128(BLE_UUID128_DECLARE(
- // 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
- // 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff));
fields.uuids128 = &dfuServiceUuid;
fields.num_uuids128 = 1;
fields.uuids128_is_complete = 1;
@@ -116,28 +142,25 @@ void NimbleController::StartAdvertising() {
rsp_fields.name_len = strlen(deviceName);
rsp_fields.name_is_complete = 1;
- ble_gap_adv_set_fields(&fields);
- // ASSERT(res == 0); // TODO this one sometimes fails with error 22 (notsync)
+ rc = ble_gap_adv_set_fields(&fields);
+ ASSERT(rc == 0);
- ble_gap_adv_rsp_set_fields(&rsp_fields);
- // ASSERT(res == 0);
+ rc = ble_gap_adv_rsp_set_fields(&rsp_fields);
+ ASSERT(rc == 0);
- ble_gap_adv_start(addrType, NULL, 180000, &adv_params, GAPEventCallback, this);
- // ASSERT(res == 0);// TODO I've disabled these ASSERT as they sometime asserts and reset the mcu.
- // For now, the advertising is restarted as soon as it ends. There may be a race condition
- // that prevent the advertising from restarting reliably.
- // I remove the assert to prevent this uncesseray crash, but in the long term, the management of
- // the advertising should be improve (better error handling, and advertise for 3 minutes after
- // the application has been woken up, for example.
+ rc = ble_gap_adv_start(addrType, NULL, 2000, &adv_params, GAPEventCallback, this);
+ ASSERT(rc == 0);
}
int NimbleController::OnGAPEvent(ble_gap_event* event) {
switch (event->type) {
case BLE_GAP_EVENT_ADV_COMPLETE:
NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_ADV_COMPLETE");
- NRF_LOG_INFO("advertise complete; reason=%dn status=%d", event->adv_complete.reason, event->connect.status);
+ NRF_LOG_INFO("reason=%d; status=%d", event->adv_complete.reason, event->connect.status);
+ StartAdvertising();
break;
- case BLE_GAP_EVENT_CONNECT: {
+
+ case BLE_GAP_EVENT_CONNECT:
NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_CONNECT");
/* A new connection was established or a connection attempt failed. */
@@ -145,35 +168,44 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
if (event->connect.status != 0) {
/* Connection failed; resume advertising. */
- StartAdvertising();
+ currentTimeClient.Reset();
+ alertNotificationClient.Reset();
+ connectionHandle = BLE_HS_CONN_HANDLE_NONE;
bleController.Disconnect();
+ fastAdvCount = 0;
+ StartAdvertising();
} else {
+ connectionHandle = event->connect.conn_handle;
bleController.Connect();
systemTask.PushMessage(Pinetime::System::Messages::BleConnected);
- connectionHandle = event->connect.conn_handle;
- // Service discovery is deffered via systemtask
+ // Service discovery is deferred via systemtask
}
- } break;
+ break;
+
case BLE_GAP_EVENT_DISCONNECT:
NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_DISCONNECT");
- NRF_LOG_INFO("disconnect; reason=%d", event->disconnect.reason);
+ NRF_LOG_INFO("disconnect reason=%d", event->disconnect.reason);
/* Connection terminated; resume advertising. */
currentTimeClient.Reset();
alertNotificationClient.Reset();
connectionHandle = BLE_HS_CONN_HANDLE_NONE;
bleController.Disconnect();
+ fastAdvCount = 0;
StartAdvertising();
break;
+
case BLE_GAP_EVENT_CONN_UPDATE:
NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_CONN_UPDATE");
/* The central has updated the connection parameters. */
- NRF_LOG_INFO("connection updated; status=%d ", event->conn_update.status);
+ NRF_LOG_INFO("update status=%d ", event->conn_update.status);
break;
+
case BLE_GAP_EVENT_ENC_CHANGE:
/* Encryption has been enabled or disabled for this connection. */
NRF_LOG_INFO("encryption change event; status=%d ", event->enc_change.status);
- return 0;
+ break;
+
case BLE_GAP_EVENT_SUBSCRIBE:
NRF_LOG_INFO("subscribe event; conn_handle=%d attr_handle=%d "
"reason=%d prevn=%d curn=%d previ=%d curi=???\n",
@@ -183,10 +215,12 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
event->subscribe.prev_notify,
event->subscribe.cur_notify,
event->subscribe.prev_indicate);
- return 0;
+ break;
+
case BLE_GAP_EVENT_MTU:
- NRF_LOG_INFO("mtu update event; conn_handle=%d cid=%d mtu=%d\n", event->mtu.conn_handle, event->mtu.channel_id, event->mtu.value);
- return 0;
+ NRF_LOG_INFO("mtu update event; conn_handle=%d cid=%d mtu=%d\n",
+ event->mtu.conn_handle, event->mtu.channel_id, event->mtu.value);
+ break;
case BLE_GAP_EVENT_REPEAT_PAIRING: {
/* We already have a bond with the peer, but it is attempting to
@@ -217,8 +251,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
notifSize);
alertNotificationClient.OnNotification(event);
- return 0;
- }
+ } break;
/* Attribute data is contained in event->notify_rx.attr_data. */
default:
@@ -229,7 +262,9 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
}
void NimbleController::StartDiscovery() {
- serviceDiscovery.StartDiscovery(connectionHandle);
+ if (connectionHandle != BLE_HS_CONN_HANDLE_NONE) {
+ serviceDiscovery.StartDiscovery(connectionHandle);
+ }
}
uint16_t NimbleController::connHandle() {
@@ -237,7 +272,7 @@ uint16_t NimbleController::connHandle() {
}
void NimbleController::NotifyBatteryLevel(uint8_t level) {
- if(connectionHandle != BLE_HS_CONN_HANDLE_NONE) {
+ if (connectionHandle != BLE_HS_CONN_HANDLE_NONE) {
batteryInformationService.NotifyBatteryLevel(connectionHandle, level);
}
}
diff --git a/src/components/ble/NimbleController.h b/src/components/ble/NimbleController.h
index 0cfe983c..473bb1af 100644
--- a/src/components/ble/NimbleController.h
+++ b/src/components/ble/NimbleController.h
@@ -72,6 +72,10 @@ namespace Pinetime {
uint16_t connHandle();
void NotifyBatteryLevel(uint8_t level);
+ void RestartFastAdv() {
+ fastAdvCount = 0;
+ }
+
private:
static constexpr const char* deviceName = "InfiniTime";
Pinetime::System::SystemTask& systemTask;
@@ -94,6 +98,7 @@ namespace Pinetime {
uint8_t addrType; // 1 = Random, 0 = PUBLIC
uint16_t connectionHandle = BLE_HS_CONN_HANDLE_NONE;
+ uint8_t fastAdvCount = 0;
ble_uuid128_t dfuServiceUuid {
.u {.type = BLE_UUID_TYPE_128},
@@ -101,5 +106,7 @@ namespace Pinetime {
ServiceDiscovery serviceDiscovery;
};
+
+ static NimbleController* nptr;
}
}
diff --git a/src/components/brightness/BrightnessController.cpp b/src/components/brightness/BrightnessController.cpp
index 8ad987d1..6c524679 100644
--- a/src/components/brightness/BrightnessController.cpp
+++ b/src/components/brightness/BrightnessController.cpp
@@ -1,13 +1,13 @@
#include "BrightnessController.h"
#include <hal/nrf_gpio.h>
#include "displayapp/screens/Symbols.h"
-
+#include "drivers/PinMap.h"
using namespace Pinetime::Controllers;
void BrightnessController::Init() {
- nrf_gpio_cfg_output(pinLcdBacklight1);
- nrf_gpio_cfg_output(pinLcdBacklight2);
- nrf_gpio_cfg_output(pinLcdBacklight3);
+ nrf_gpio_cfg_output(PinMap::LcdBacklightLow);
+ nrf_gpio_cfg_output(PinMap::LcdBacklightMedium);
+ nrf_gpio_cfg_output(PinMap::LcdBacklightHigh);
Set(level);
}
@@ -16,24 +16,24 @@ void BrightnessController::Set(BrightnessController::Levels level) {
switch (level) {
default:
case Levels::High:
- nrf_gpio_pin_clear(pinLcdBacklight1);
- nrf_gpio_pin_clear(pinLcdBacklight2);
- nrf_gpio_pin_clear(pinLcdBacklight3);
+ nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
+ nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
+ nrf_gpio_pin_clear(PinMap::LcdBacklightHigh);
break;
case Levels::Medium:
- nrf_gpio_pin_clear(pinLcdBacklight1);
- nrf_gpio_pin_clear(pinLcdBacklight2);
- nrf_gpio_pin_set(pinLcdBacklight3);
+ nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
+ nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
+ nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
break;
case Levels::Low:
- nrf_gpio_pin_clear(pinLcdBacklight1);
- nrf_gpio_pin_set(pinLcdBacklight2);
- nrf_gpio_pin_set(pinLcdBacklight3);
+ nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
+ nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
+ nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
break;
case Levels::Off:
- nrf_gpio_pin_set(pinLcdBacklight1);
- nrf_gpio_pin_set(pinLcdBacklight2);
- nrf_gpio_pin_set(pinLcdBacklight3);
+ nrf_gpio_pin_set(PinMap::LcdBacklightLow);
+ nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
+ nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
break;
}
}
diff --git a/src/components/brightness/BrightnessController.h b/src/components/brightness/BrightnessController.h
index c47158a9..0d7ac2ff 100644
--- a/src/components/brightness/BrightnessController.h
+++ b/src/components/brightness/BrightnessController.h
@@ -22,9 +22,6 @@ namespace Pinetime {
const char* ToString();
private:
- static constexpr uint8_t pinLcdBacklight1 = 14;
- static constexpr uint8_t pinLcdBacklight2 = 22;
- static constexpr uint8_t pinLcdBacklight3 = 23;
Levels level = Levels::High;
Levels backupLevel = Levels::High;
};
diff --git a/src/components/motor/MotorController.cpp b/src/components/motor/MotorController.cpp
index b25e6bc8..42057a86 100644
--- a/src/components/motor/MotorController.cpp
+++ b/src/components/motor/MotorController.cpp
@@ -2,6 +2,7 @@
#include <hal/nrf_gpio.h>
#include "systemtask/SystemTask.h"
#include "app_timer.h"
+#include "drivers/PinMap.h"
APP_TIMER_DEF(shortVibTimer);
APP_TIMER_DEF(longVibTimer);
@@ -12,8 +13,8 @@ MotorController::MotorController(Controllers::Settings& settingsController) : se
}
void MotorController::Init() {
- nrf_gpio_cfg_output(pinMotor);
- nrf_gpio_pin_set(pinMotor);
+ nrf_gpio_cfg_output(PinMap::Motor);
+ nrf_gpio_pin_set(PinMap::Motor);
app_timer_init();
app_timer_create(&shortVibTimer, APP_TIMER_MODE_SINGLE_SHOT, StopMotor);
@@ -30,7 +31,7 @@ void MotorController::RunForDuration(uint8_t motorDuration) {
return;
}
- nrf_gpio_pin_clear(pinMotor);
+ nrf_gpio_pin_clear(PinMap::Motor);
app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr);
}
@@ -44,9 +45,9 @@ void MotorController::StartRinging() {
void MotorController::StopRinging() {
app_timer_stop(longVibTimer);
- nrf_gpio_pin_set(pinMotor);
+ nrf_gpio_pin_set(PinMap::Motor);
}
void MotorController::StopMotor(void* p_context) {
- nrf_gpio_pin_set(pinMotor);
+ nrf_gpio_pin_set(PinMap::Motor);
}
diff --git a/src/components/motor/MotorController.h b/src/components/motor/MotorController.h
index d2c9fe5f..cf78088e 100644
--- a/src/components/motor/MotorController.h
+++ b/src/components/motor/MotorController.h
@@ -1,12 +1,10 @@
#pragma once
#include <cstdint>
-#include "app_timer.h"
#include "components/settings/Settings.h"
namespace Pinetime {
namespace Controllers {
- static constexpr uint8_t pinMotor = 16;
class MotorController {
public:
diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h
index 93d6d217..a54ba976 100644
--- a/src/components/settings/Settings.h
+++ b/src/components/settings/Settings.h
@@ -17,6 +17,14 @@ namespace Pinetime {
DoubleTap = 1,
RaiseWrist = 2,
};
+ enum class Colors : uint8_t {
+ White, Silver, Gray, Black, Red, Maroon, Yellow, Olive, Lime, Green, Cyan, Teal, Blue, Navy, Magenta, Purple, Orange
+ };
+ struct PineTimeStyle {
+ Colors ColorTime = Colors::Teal;
+ Colors ColorBar = Colors::Teal;
+ Colors ColorBG = Colors::Black;
+ };
Settings(Pinetime::Controllers::FS& fs);
@@ -33,10 +41,38 @@ namespace Pinetime {
return settings.clockFace;
};
+ void SetPTSColorTime(Colors colorTime) {
+ if (colorTime != settings.PTS.ColorTime)
+ settingsChanged = true;
+ settings.PTS.ColorTime = colorTime;
+ };
+ Colors GetPTSColorTime() const {
+ return settings.PTS.ColorTime;
+ };
+
+ void SetPTSColorBar(Colors colorBar) {
+ if (colorBar != settings.PTS.ColorBar)
+ settingsChanged = true;
+ settings.PTS.ColorBar = colorBar;
+ };
+ Colors GetPTSColorBar() const {
+ return settings.PTS.ColorBar;
+ };
+
+ void SetPTSColorBG(Colors colorBG) {
+ if (colorBG != settings.PTS.ColorBG)
+ settingsChanged = true;
+ settings.PTS.ColorBG = colorBG;
+ };
+ Colors GetPTSColorBG() const {
+ return settings.PTS.ColorBG;
+ };
+
void SetAppMenu(uint8_t menu) {
appMenu = menu;
};
- uint8_t GetAppMenu() {
+
+ uint8_t GetAppMenu() const {
return appMenu;
};
@@ -78,7 +114,7 @@ namespace Pinetime {
};
void setWakeUpMode(WakeUpMode wakeUp, bool enabled) {
- if (!isWakeUpModeOn(wakeUp)) {
+ if (enabled != isWakeUpModeOn(wakeUp)) {
settingsChanged = true;
}
settings.wakeUpMode.set(static_cast<size_t>(wakeUp), enabled);
@@ -127,9 +163,8 @@ namespace Pinetime {
private:
Pinetime::Controllers::FS& fs;
- static constexpr uint32_t settingsVersion = 0x0001;
+ static constexpr uint32_t settingsVersion = 0x0002;
struct SettingsData {
-
uint32_t version = settingsVersion;
uint32_t stepsGoal = 10000;
uint32_t screenTimeOut = 15000;
@@ -139,6 +174,8 @@ namespace Pinetime {
uint8_t clockFace = 0;
+ PineTimeStyle PTS;
+
std::bitset<3> wakeUpMode {0};
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h
index 684e3a46..dd51fdb4 100644
--- a/src/displayapp/Apps.h
+++ b/src/displayapp/Apps.h
@@ -30,7 +30,8 @@ namespace Pinetime {
SettingTimeFormat,
SettingDisplay,
SettingWakeUp,
- SettingSteps
+ SettingSteps,
+ SettingPineTimeStyle
};
}
}
diff --git a/src/displayapp/Colors.cpp b/src/displayapp/Colors.cpp
new file mode 100644
index 00000000..f45f0722
--- /dev/null
+++ b/src/displayapp/Colors.cpp
@@ -0,0 +1,27 @@
+#include "Colors.h"
+
+using namespace Pinetime::Applications;
+using namespace Pinetime::Controllers;
+
+lv_color_t Pinetime::Applications::Convert(Pinetime::Controllers::Settings::Colors color) {
+ switch (color) {
+ case Pinetime::Controllers::Settings::Colors::White: return LV_COLOR_WHITE;
+ case Pinetime::Controllers::Settings::Colors::Silver: return LV_COLOR_SILVER;
+ case Pinetime::Controllers::Settings::Colors::Gray: return LV_COLOR_GRAY;
+ case Pinetime::Controllers::Settings::Colors::Black: return LV_COLOR_BLACK;
+ case Pinetime::Controllers::Settings::Colors::Red: return LV_COLOR_RED;
+ case Pinetime::Controllers::Settings::Colors::Maroon: return LV_COLOR_MAROON;
+ case Pinetime::Controllers::Settings::Colors::Yellow: return LV_COLOR_YELLOW;
+ case Pinetime::Controllers::Settings::Colors::Olive: return LV_COLOR_OLIVE;
+ case Pinetime::Controllers::Settings::Colors::Lime: return LV_COLOR_LIME;
+ case Pinetime::Controllers::Settings::Colors::Green: return LV_COLOR_GREEN;
+ case Pinetime::Controllers::Settings::Colors::Cyan: return LV_COLOR_CYAN;
+ case Pinetime::Controllers::Settings::Colors::Teal: return LV_COLOR_TEAL;
+ case Pinetime::Controllers::Settings::Colors::Blue: return LV_COLOR_BLUE;
+ case Pinetime::Controllers::Settings::Colors::Navy: return LV_COLOR_NAVY;
+ case Pinetime::Controllers::Settings::Colors::Magenta: return LV_COLOR_MAGENTA;
+ case Pinetime::Controllers::Settings::Colors::Purple: return LV_COLOR_PURPLE;
+ case Pinetime::Controllers::Settings::Colors::Orange: return LV_COLOR_ORANGE;
+ default: return LV_COLOR_WHITE;
+ }
+}
diff --git a/src/displayapp/Colors.h b/src/displayapp/Colors.h
new file mode 100644
index 00000000..9db7dd20
--- /dev/null
+++ b/src/displayapp/Colors.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#include <lvgl/src/lv_misc/lv_color.h>
+#include <components/settings/Settings.h>
+
+namespace Pinetime {
+ namespace Applications {
+ lv_color_t Convert(Controllers::Settings::Colors color);
+ }
+} \ No newline at end of file
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index 5150162a..5e74baa0 100644
--- a/src/displayapp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -42,6 +42,7 @@
#include "displayapp/screens/settings/SettingWakeUp.h"
#include "displayapp/screens/settings/SettingDisplay.h"
#include "displayapp/screens/settings/SettingSteps.h"
+#include "displayapp/screens/settings/SettingPineTimeStyle.h"
#include "libs/lv_conf.h"
@@ -53,29 +54,26 @@ namespace {
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
}
- TouchEvents Convert(Pinetime::Drivers::Cst816S::TouchInfos info) {
- if (info.isTouch) {
- switch (info.gesture) {
- case Pinetime::Drivers::Cst816S::Gestures::SingleTap:
- return TouchEvents::Tap;
- case Pinetime::Drivers::Cst816S::Gestures::LongPress:
- return TouchEvents::LongTap;
- case Pinetime::Drivers::Cst816S::Gestures::DoubleTap:
- return TouchEvents::DoubleTap;
- case Pinetime::Drivers::Cst816S::Gestures::SlideRight:
- return TouchEvents::SwipeRight;
- case Pinetime::Drivers::Cst816S::Gestures::SlideLeft:
- return TouchEvents::SwipeLeft;
- case Pinetime::Drivers::Cst816S::Gestures::SlideDown:
- return TouchEvents::SwipeDown;
- case Pinetime::Drivers::Cst816S::Gestures::SlideUp:
- return TouchEvents::SwipeUp;
- case Pinetime::Drivers::Cst816S::Gestures::None:
- default:
- return TouchEvents::None;
- }
+ TouchEvents ConvertGesture(Pinetime::Drivers::Cst816S::Gestures gesture) {
+ switch (gesture) {
+ case Pinetime::Drivers::Cst816S::Gestures::SingleTap:
+ return TouchEvents::Tap;
+ case Pinetime::Drivers::Cst816S::Gestures::LongPress:
+ return TouchEvents::LongTap;
+ case Pinetime::Drivers::Cst816S::Gestures::DoubleTap:
+ return TouchEvents::DoubleTap;
+ case Pinetime::Drivers::Cst816S::Gestures::SlideRight:
+ return TouchEvents::SwipeRight;
+ case Pinetime::Drivers::Cst816S::Gestures::SlideLeft:
+ return TouchEvents::SwipeLeft;
+ case Pinetime::Drivers::Cst816S::Gestures::SlideDown:
+ return TouchEvents::SwipeDown;
+ case Pinetime::Drivers::Cst816S::Gestures::SlideUp:
+ return TouchEvents::SwipeUp;
+ case Pinetime::Drivers::Cst816S::Gestures::None:
+ default:
+ return TouchEvents::None;
}
- return TouchEvents::None;
}
}
@@ -91,7 +89,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Controllers::Settings& settingsController,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Controllers::MotionController& motionController,
- Pinetime::Controllers::TimerController& timerController)
+ Pinetime::Controllers::TimerController& timerController,
+ Pinetime::Controllers::TouchHandler& touchHandler)
: lcd {lcd},
lvgl {lvgl},
touchPanel {touchPanel},
@@ -104,7 +103,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
settingsController {settingsController},
motorController {motorController},
motionController {motionController},
- timerController {timerController} {
+ timerController {timerController},
+ touchHandler {touchHandler} {
}
void DisplayApp::Start() {
@@ -136,9 +136,6 @@ void DisplayApp::InitHw() {
brightnessController.Set(settingsController.GetBrightness());
}
-uint32_t acc = 0;
-uint32_t count = 0;
-bool toggle = true;
void DisplayApp::Refresh() {
TickType_t queueTimeout;
TickType_t delta;
@@ -194,9 +191,6 @@ void DisplayApp::Refresh() {
// clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected :
// Screens::Clock::BleConnectionStates::NotConnected);
break;
- case Messages::UpdateBatteryLevel:
- batteryController.Update();
- break;
case Messages::NewNotification:
LoadApp(Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down);
break;
@@ -212,8 +206,7 @@ void DisplayApp::Refresh() {
if (state != States::Running) {
break;
}
- auto info = touchPanel.GetTouchInfo();
- auto gesture = Convert(info);
+ auto gesture = ConvertGesture(touchHandler.GestureGet());
if (gesture == TouchEvents::None) {
break;
}
@@ -239,11 +232,9 @@ void DisplayApp::Refresh() {
LoadApp(returnToApp, returnDirection);
brightnessController.Set(settingsController.GetBrightness());
brightnessController.Backup();
- } else if (touchMode == TouchModes::Gestures) {
- if (gesture == TouchEvents::Tap) {
- lvgl.SetNewTapEvent(info.x, info.y);
- }
}
+ } else {
+ touchHandler.CancelTap();
}
} break;
case Messages::ButtonPushed:
@@ -273,18 +264,13 @@ void DisplayApp::Refresh() {
nextApp = Apps::None;
}
- if (state != States::Idle && touchMode == TouchModes::Polling) {
- auto info = touchPanel.GetTouchInfo();
- if (info.action == 2) { // 2 = contact
- if (!currentScreen->OnTouchEvent(info.x, info.y)) {
- lvgl.SetNewTapEvent(info.x, info.y);
- }
- }
+ if (touchHandler.IsTouching()) {
+ currentScreen->OnTouchEvent(touchHandler.GetX(), touchHandler.GetY());
}
}
void DisplayApp::RunningState() {
- if (!currentScreen->Refresh()) {
+ if (!currentScreen->IsRunning()) {
LoadApp(returnToApp, returnDirection);
}
lv_task_handler();
@@ -302,6 +288,7 @@ void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction
}
void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) {
+ touchHandler.CancelTap();
currentScreen.reset(nullptr);
SetFullRefresh(direction);
@@ -378,6 +365,10 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
currentScreen = std::make_unique<Screens::SettingSteps>(this, settingsController);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
+ case Apps::SettingPineTimeStyle:
+ currentScreen = std::make_unique<Screens::SettingPineTimeStyle>(this, settingsController);
+ ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
+ break;
case Apps::BatteryInfo:
currentScreen = std::make_unique<Screens::BatteryInfo>(this, batteryController);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
@@ -467,10 +458,6 @@ void DisplayApp::SetFullRefresh(DisplayApp::FullRefreshDirections direction) {
}
}
-void DisplayApp::SetTouchMode(DisplayApp::TouchModes mode) {
- touchMode = mode;
-}
-
void DisplayApp::PushMessageToSystemTask(Pinetime::System::Messages message) {
if (systemTask != nullptr)
systemTask->PushMessage(message);
diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h
index 574be63f..96951d1c 100644
--- a/src/displayapp/DisplayApp.h
+++ b/src/displayapp/DisplayApp.h
@@ -14,6 +14,7 @@
#include "components/settings/Settings.h"
#include "displayapp/screens/Screen.h"
#include "components/timer/TimerController.h"
+#include "touchhandler/TouchHandler.h"
#include "Messages.h"
namespace Pinetime {
@@ -31,6 +32,7 @@ namespace Pinetime {
class NotificationManager;
class HeartRateController;
class MotionController;
+ class TouchHandler;
}
namespace System {
@@ -41,7 +43,6 @@ namespace Pinetime {
public:
enum class States { Idle, Running };
enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim };
- enum class TouchModes { Gestures, Polling };
DisplayApp(Drivers::St7789& lcd,
Components::LittleVgl& lvgl,
@@ -55,14 +56,14 @@ namespace Pinetime {
Controllers::Settings& settingsController,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Controllers::MotionController& motionController,
- Pinetime::Controllers::TimerController& timerController);
+ Pinetime::Controllers::TimerController& timerController,
+ Pinetime::Controllers::TouchHandler& touchHandler);
void Start();
void PushMessage(Display::Messages msg);
void StartApp(Apps app, DisplayApp::FullRefreshDirections direction);
void SetFullRefresh(FullRefreshDirections direction);
- void SetTouchMode(TouchModes mode);
void Register(Pinetime::System::SystemTask* systemTask);
@@ -81,6 +82,7 @@ namespace Pinetime {
Pinetime::Controllers::MotorController& motorController;
Pinetime::Controllers::MotionController& motionController;
Pinetime::Controllers::TimerController& timerController;
+ Pinetime::Controllers::TouchHandler& touchHandler;
Pinetime::Controllers::FirmwareValidator validator;
Controllers::BrightnessController brightnessController;
@@ -100,8 +102,7 @@ namespace Pinetime {
FullRefreshDirections returnDirection = FullRefreshDirections::None;
TouchEvents returnTouchEvent = TouchEvents::None;
- TouchModes touchMode = TouchModes::Gestures;
-
+ TouchEvents GetGesture();
void RunningState();
void IdleState();
static void Process(void* instance);
diff --git a/src/displayapp/DisplayAppRecovery.cpp b/src/displayapp/DisplayAppRecovery.cpp
index fd517b11..7a202629 100644
--- a/src/displayapp/DisplayAppRecovery.cpp
+++ b/src/displayapp/DisplayAppRecovery.cpp
@@ -3,7 +3,9 @@
#include <task.h>
#include <libraries/log/nrf_log.h>
#include <components/rle/RleDecoder.h>
+#include <touchhandler/TouchHandler.h>
#include "displayapp/icons/infinitime/infinitime-nb.c"
+#include "components/ble/BleController.h"
using namespace Pinetime::Applications;
@@ -19,7 +21,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Controllers::Settings& settingsController,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Controllers::MotionController& motionController,
- Pinetime::Controllers::TimerController& timerController)
+ Pinetime::Controllers::TimerController& timerController,
+ Pinetime::Controllers::TouchHandler& touchHandler)
: lcd {lcd}, bleController {bleController} {
}
diff --git a/src/displayapp/DisplayAppRecovery.h b/src/displayapp/DisplayAppRecovery.h
index 638c0071..4184ea49 100644
--- a/src/displayapp/DisplayAppRecovery.h
+++ b/src/displayapp/DisplayAppRecovery.h
@@ -6,29 +6,38 @@
#include <bits/unique_ptr.h>
#include <queue.h>
#include "components/gfx/Gfx.h"
-#include "components/battery/BatteryController.h"
-#include "components/brightness/BrightnessController.h"
-#include "components/ble/BleController.h"
-#include "components/datetime/DateTimeController.h"
-#include "components/ble/NotificationManager.h"
-#include "components/firmwarevalidator/FirmwareValidator.h"
#include "drivers/Cst816s.h"
#include <date/date.h>
#include <drivers/Watchdog.h>
-#include <components/heartrate/HeartRateController.h>
-#include <components/motion/MotionController.h>
#include <components/motor/MotorController.h>
-#include <components/settings/Settings.h>
#include "TouchEvents.h"
#include "Apps.h"
#include "Messages.h"
#include "DummyLittleVgl.h"
-#include "components/timer/TimerController.h"
namespace Pinetime {
+ namespace Drivers {
+ class St7789;
+ class Cst816S;
+ class WatchdogView;
+ }
+ namespace Controllers {
+ class Settings;
+ class Battery;
+ class Ble;
+ class DateTime;
+ class NotificationManager;
+ class HeartRateController;
+ class MotionController;
+ class TouchHandler;
+ class MotorController;
+ class TimerController;
+ }
+
namespace System {
class SystemTask;
};
+
namespace Applications {
class DisplayApp {
public:
@@ -44,7 +53,8 @@ namespace Pinetime {
Controllers::Settings& settingsController,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Controllers::MotionController& motionController,
- Pinetime::Controllers::TimerController& timerController);
+ Pinetime::Controllers::TimerController& timerController,
+ Pinetime::Controllers::TouchHandler& touchHandler);
void Start();
void PushMessage(Pinetime::Applications::Display::Messages msg);
void Register(Pinetime::System::SystemTask* systemTask);
diff --git a/src/displayapp/DummyLittleVgl.h b/src/displayapp/DummyLittleVgl.h
index 016165b8..1db51343 100644
--- a/src/displayapp/DummyLittleVgl.h
+++ b/src/displayapp/DummyLittleVgl.h
@@ -32,6 +32,9 @@ namespace Pinetime {
}
void SetNewTapEvent(uint16_t x, uint16_t y) {
}
+ void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) {
+
+ }
};
}
}
diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp
index c069afa2..2bd5e57b 100644
--- a/src/displayapp/LittleVgl.cpp
+++ b/src/displayapp/LittleVgl.cpp
@@ -166,43 +166,21 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) {
lv_disp_flush_ready(&disp_drv);
}
-void LittleVgl::SetNewTapEvent(uint16_t x, uint16_t y) {
+void LittleVgl::SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) {
tap_x = x;
tap_y = y;
- tapped = true;
+ tapped = contact;
}
bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
+ ptr->point.x = tap_x;
+ ptr->point.y = tap_y;
if (tapped) {
- ptr->point.x = tap_x;
- ptr->point.y = tap_y;
ptr->state = LV_INDEV_STATE_PR;
- tapped = false;
} else {
ptr->state = LV_INDEV_STATE_REL;
}
return false;
- /*
- auto info = touchPanel.GetTouchInfo();
-
- if((previousClick.x != info.x || previousClick.y != info.y) &&
- (info.gesture == Drivers::Cst816S::Gestures::SingleTap)) {
- // TODO For an unknown reason, the first touch is taken twice into account.
- // 'firstTouch' is a quite'n'dirty workaound until I find a better solution
- if(firstTouch) ptr->state = LV_INDEV_STATE_REL;
- else ptr->state = LV_INDEV_STATE_PR;
- firstTouch = false;
- previousClick.x = info.x;
- previousClick.y = info.y;
- }
- else {
- ptr->state = LV_INDEV_STATE_REL;
- }
-
- ptr->point.x = info.x;
- ptr->point.y = info.y;
- return false;
- */
}
void LittleVgl::InitTheme() {
diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h
index 41f934a7..1f8a3d79 100644
--- a/src/displayapp/LittleVgl.h
+++ b/src/displayapp/LittleVgl.h
@@ -24,7 +24,7 @@ namespace Pinetime {
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p);
bool GetTouchPadInfo(lv_indev_data_t* ptr);
void SetFullRefresh(FullRefreshDirections direction);
- void SetNewTapEvent(uint16_t x, uint16_t y);
+ void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact);
private:
void InitDisplay();
diff --git a/src/displayapp/Messages.h b/src/displayapp/Messages.h
index 322505e6..8e4884db 100644
--- a/src/displayapp/Messages.h
+++ b/src/displayapp/Messages.h
@@ -7,7 +7,6 @@ namespace Pinetime {
GoToRunning,
UpdateDateTime,
UpdateBleConnection,
- UpdateBatteryLevel,
TouchEvent,
ButtonPushed,
NewNotification,
diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp
index d6c3970b..6e7bbb74 100644
--- a/src/displayapp/screens/ApplicationList.cpp
+++ b/src/displayapp/screens/ApplicationList.cpp
@@ -34,12 +34,6 @@ ApplicationList::~ApplicationList() {
lv_obj_clean(lv_scr_act());
}
-bool ApplicationList::Refresh() {
- if (running)
- running = screens.Refresh();
- return running;
-}
-
bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screens.OnTouchEvent(event);
}
diff --git a/src/displayapp/screens/ApplicationList.h b/src/displayapp/screens/ApplicationList.h
index 88534ec4..103c38ae 100644
--- a/src/displayapp/screens/ApplicationList.h
+++ b/src/displayapp/screens/ApplicationList.h
@@ -18,7 +18,6 @@ namespace Pinetime {
Pinetime::Controllers::Battery& batteryController,
Controllers::DateTime& dateTimeController);
~ApplicationList() override;
- bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override;
private:
@@ -33,4 +32,4 @@ namespace Pinetime {
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp
index 0ab47ebf..ad9af153 100644
--- a/src/displayapp/screens/BatteryInfo.cpp
+++ b/src/displayapp/screens/BatteryInfo.cpp
@@ -4,11 +4,6 @@
using namespace Pinetime::Applications::Screens;
-static void lv_update_task(struct _lv_task_t* task) {
- auto user_data = static_cast<BatteryInfo*>(task->user_data);
- user_data->UpdateScreen();
-}
-
BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Battery& batteryController)
: Screen(app), batteryController {batteryController} {
@@ -49,18 +44,16 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont
lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text_static(backgroundLabel, "");
- taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_LOW, this);
- UpdateScreen();
+ taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this);
+ Refresh();
}
BatteryInfo::~BatteryInfo() {
- lv_task_del(taskUpdate);
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-void BatteryInfo::UpdateScreen() {
-
- batteryController.Update();
+void BatteryInfo::Refresh() {
batteryPercent = batteryController.PercentRemaining();
batteryVoltage = batteryController.Voltage();
@@ -85,7 +78,3 @@ void BatteryInfo::UpdateScreen() {
lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10);
lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON);
}
-
-bool BatteryInfo::Refresh() {
- return running;
-}
diff --git a/src/displayapp/screens/BatteryInfo.h b/src/displayapp/screens/BatteryInfo.h
index 69793244..63454a26 100644
--- a/src/displayapp/screens/BatteryInfo.h
+++ b/src/displayapp/screens/BatteryInfo.h
@@ -19,9 +19,7 @@ namespace Pinetime {
BatteryInfo(DisplayApp* app, Pinetime::Controllers::Battery& batteryController);
~BatteryInfo() override;
- bool Refresh() override;
-
- void UpdateScreen();
+ void Refresh() override;
private:
Pinetime::Controllers::Battery& batteryController;
@@ -31,7 +29,7 @@ namespace Pinetime {
lv_obj_t* charging_bar;
lv_obj_t* status;
- lv_task_t* taskUpdate;
+ lv_task_t* taskRefresh;
uint8_t batteryPercent = 0;
uint16_t batteryVoltage = 0;
diff --git a/src/displayapp/screens/Brightness.cpp b/src/displayapp/screens/Brightness.cpp
index 47c10561..1278cd62 100644
--- a/src/displayapp/screens/Brightness.cpp
+++ b/src/displayapp/screens/Brightness.cpp
@@ -30,10 +30,6 @@ Brightness::~Brightness() {
lv_obj_clean(lv_scr_act());
}
-bool Brightness::Refresh() {
- return running;
-}
-
const char* Brightness::LevelToString(Pinetime::Controllers::BrightnessController::Levels level) {
switch (level) {
case Pinetime::Controllers::BrightnessController::Levels::Off:
diff --git a/src/displayapp/screens/Brightness.h b/src/displayapp/screens/Brightness.h
index 9ee33753..14e48592 100644
--- a/src/displayapp/screens/Brightness.h
+++ b/src/displayapp/screens/Brightness.h
@@ -12,7 +12,6 @@ namespace Pinetime {
public:
Brightness(DisplayApp* app, Controllers::BrightnessController& brightness);
~Brightness() override;
- bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override;
@@ -31,4 +30,4 @@ namespace Pinetime {
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp
index 86afee0c..5a5cd18b 100644
--- a/src/displayapp/screens/Clock.cpp
+++ b/src/displayapp/screens/Clock.cpp
@@ -50,11 +50,6 @@ Clock::~Clock() {
lv_obj_clean(lv_scr_act());
}
-bool Clock::Refresh() {
- screen->Refresh();
- return running;
-}
-
bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screen->OnTouchEvent(event);
}
@@ -83,4 +78,4 @@ std::unique_ptr<Screen> Clock::PineTimeStyleScreen() {
notificatioManager,
settingsController,
motionController);
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h
index 7968cced..648f72da 100644
--- a/src/displayapp/screens/Clock.h
+++ b/src/displayapp/screens/Clock.h
@@ -31,8 +31,6 @@ namespace Pinetime {
Controllers::MotionController& motionController);
~Clock() override;
- bool Refresh() override;
-
bool OnTouchEvent(TouchEvents event) override;
private:
diff --git a/src/displayapp/screens/FirmwareUpdate.cpp b/src/displayapp/screens/FirmwareUpdate.cpp
index edb2e49d..79bda0ba 100644
--- a/src/displayapp/screens/FirmwareUpdate.cpp
+++ b/src/displayapp/screens/FirmwareUpdate.cpp
@@ -30,14 +30,16 @@ FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp* app, Pinetime
lv_label_set_text(percentLabel, "Waiting...");
lv_obj_set_auto_realign(percentLabel, true);
lv_obj_align(percentLabel, bar1, LV_ALIGN_OUT_TOP_MID, 0, 60);
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
startTime = xTaskGetTickCount();
}
FirmwareUpdate::~FirmwareUpdate() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool FirmwareUpdate::Refresh() {
+void FirmwareUpdate::Refresh() {
switch (bleController.State()) {
default:
case Pinetime::Controllers::Ble::FirmwareUpdateStates::Idle:
@@ -73,7 +75,6 @@ bool FirmwareUpdate::Refresh() {
}
break;
}
- return running;
}
void FirmwareUpdate::DisplayProgression() const {
diff --git a/src/displayapp/screens/FirmwareUpdate.h b/src/displayapp/screens/FirmwareUpdate.h
index 90c99f4c..8fc86d8c 100644
--- a/src/displayapp/screens/FirmwareUpdate.h
+++ b/src/displayapp/screens/FirmwareUpdate.h
@@ -16,7 +16,7 @@ namespace Pinetime {
FirmwareUpdate(DisplayApp* app, Pinetime::Controllers::Ble& bleController);
~FirmwareUpdate() override;
- bool Refresh() override;
+ void Refresh() override;
private:
enum class States { Idle, Running, Validated, Error };
@@ -36,6 +36,7 @@ namespace Pinetime {
void UpdateError();
+ lv_task_t* taskRefresh;
TickType_t startTime;
};
}
diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp
index 233ebd5b..eef8f919 100644
--- a/src/displayapp/screens/FirmwareValidation.cpp
+++ b/src/displayapp/screens/FirmwareValidation.cpp
@@ -63,15 +63,11 @@ FirmwareValidation::~FirmwareValidation() {
lv_obj_clean(lv_scr_act());
}
-bool FirmwareValidation::Refresh() {
- return running;
-}
-
void FirmwareValidation::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
- if (object == buttonValidate && event == LV_EVENT_PRESSED) {
+ if (object == buttonValidate && event == LV_EVENT_CLICKED) {
validator.Validate();
running = false;
- } else if (object == buttonReset && event == LV_EVENT_PRESSED) {
+ } else if (object == buttonReset && event == LV_EVENT_CLICKED) {
validator.Reset();
}
}
diff --git a/src/displayapp/screens/FirmwareValidation.h b/src/displayapp/screens/FirmwareValidation.h
index 1ef5ba0a..bfdb096d 100644
--- a/src/displayapp/screens/FirmwareValidation.h
+++ b/src/displayapp/screens/FirmwareValidation.h
@@ -16,8 +16,6 @@ namespace Pinetime {
FirmwareValidation(DisplayApp* app, Pinetime::Controllers::FirmwareValidator& validator);
~FirmwareValidation() override;
- bool Refresh() override;
-
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
private:
diff --git a/src/displayapp/screens/FlashLight.cpp b/src/displayapp/screens/FlashLight.cpp
index 63b2345e..4bc5b558 100644
--- a/src/displayapp/screens/FlashLight.cpp
+++ b/src/displayapp/screens/FlashLight.cpp
@@ -65,10 +65,6 @@ void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) {
}
}
-bool FlashLight::Refresh() {
- return running;
-}
-
bool FlashLight::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return false;
}
diff --git a/src/displayapp/screens/FlashLight.h b/src/displayapp/screens/FlashLight.h
index a862ffdb..7f5ca6c5 100644
--- a/src/displayapp/screens/FlashLight.h
+++ b/src/displayapp/screens/FlashLight.h
@@ -16,8 +16,6 @@ namespace Pinetime {
FlashLight(DisplayApp* app, System::SystemTask& systemTask, Controllers::BrightnessController& brightness);
~FlashLight() override;
- bool Refresh() override;
-
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
void OnClickEvent(lv_obj_t* obj, lv_event_t event);
diff --git a/src/displayapp/screens/HeartRate.cpp b/src/displayapp/screens/HeartRate.cpp
index 5689b63e..b6ece27f 100644
--- a/src/displayapp/screens/HeartRate.cpp
+++ b/src/displayapp/screens/HeartRate.cpp
@@ -64,14 +64,17 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
UpdateStartStopButton(isHrRunning);
if (isHrRunning)
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
}
HeartRate::~HeartRate() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
}
-bool HeartRate::Refresh() {
+void HeartRate::Refresh() {
auto state = heartRateController.State();
switch (state) {
@@ -86,8 +89,6 @@ bool HeartRate::Refresh() {
lv_label_set_text(label_status, ToString(state));
lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
-
- return running;
}
void HeartRate::OnStartStopEvent(lv_event_t event) {
diff --git a/src/displayapp/screens/HeartRate.h b/src/displayapp/screens/HeartRate.h
index a23c5af8..7f7d3ad3 100644
--- a/src/displayapp/screens/HeartRate.h
+++ b/src/displayapp/screens/HeartRate.h
@@ -20,7 +20,7 @@ namespace Pinetime {
HeartRate(DisplayApp* app, Controllers::HeartRateController& HeartRateController, System::SystemTask& systemTask);
~HeartRate() override;
- bool Refresh() override;
+ void Refresh() override;
void OnStartStopEvent(lv_event_t event);
@@ -33,6 +33,8 @@ namespace Pinetime {
lv_obj_t* label_status;
lv_obj_t* btn_startStop;
lv_obj_t* label_startStop;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp
index 32240084..85a5e826 100644
--- a/src/displayapp/screens/InfiniPaint.cpp
+++ b/src/displayapp/screens/InfiniPaint.cpp
@@ -5,20 +5,13 @@
using namespace Pinetime::Applications::Screens;
InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl {lvgl} {
- app->SetTouchMode(DisplayApp::TouchModes::Polling);
std::fill(b, b + bufferSize, selectColor);
}
InfiniPaint::~InfiniPaint() {
- // Reset the touchmode
- app->SetTouchMode(DisplayApp::TouchModes::Gestures);
lv_obj_clean(lv_scr_act());
}
-bool InfiniPaint::Refresh() {
- return running;
-}
-
bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch (event) {
case Pinetime::Applications::TouchEvents::LongTap:
diff --git a/src/displayapp/screens/InfiniPaint.h b/src/displayapp/screens/InfiniPaint.h
index 6251752a..0a70e033 100644
--- a/src/displayapp/screens/InfiniPaint.h
+++ b/src/displayapp/screens/InfiniPaint.h
@@ -17,8 +17,6 @@ namespace Pinetime {
~InfiniPaint() override;
- bool Refresh() override;
-
bool OnTouchEvent(TouchEvents event) override;
bool OnTouchEvent(uint16_t x, uint16_t y) override;
diff --git a/src/displayapp/screens/Label.cpp b/src/displayapp/screens/Label.cpp
index f724fd48..1761a7b5 100644
--- a/src/displayapp/screens/Label.cpp
+++ b/src/displayapp/screens/Label.cpp
@@ -36,7 +36,3 @@ Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::Displ
Label::~Label() {
lv_obj_clean(lv_scr_act());
}
-
-bool Label::Refresh() {
- return running;
-}
diff --git a/src/displayapp/screens/Label.h b/src/displayapp/screens/Label.h
index 834f8c88..f1e49079 100644
--- a/src/displayapp/screens/Label.h
+++ b/src/displayapp/screens/Label.h
@@ -12,8 +12,6 @@ namespace Pinetime {
Label(uint8_t screenID, uint8_t numScreens, DisplayApp* app, lv_obj_t* labelText);
~Label() override;
- bool Refresh() override;
-
private:
lv_obj_t* labelText = nullptr;
lv_point_t pageIndicatorBasePoints[2];
diff --git a/src/displayapp/screens/List.cpp b/src/displayapp/screens/List.cpp
index eb53820b..064b47a6 100644
--- a/src/displayapp/screens/List.cpp
+++ b/src/displayapp/screens/List.cpp
@@ -98,13 +98,8 @@ List::~List() {
lv_obj_clean(lv_scr_act());
}
-bool List::Refresh() {
-
- return running;
-}
-
void List::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
- if (event == LV_EVENT_RELEASED) {
+ if (event == LV_EVENT_CLICKED) {
for (int i = 0; i < MAXLISTITEMS; i++) {
if (apps[i] != Apps::None && object == itemApps[i]) {
app->StartApp(apps[i], DisplayApp::FullRefreshDirections::Up);
diff --git a/src/displayapp/screens/List.h b/src/displayapp/screens/List.h
index a45fd1d3..d9f61f29 100644
--- a/src/displayapp/screens/List.h
+++ b/src/displayapp/screens/List.h
@@ -27,8 +27,6 @@ namespace Pinetime {
std::array<Applications, MAXLISTITEMS>& applications);
~List() override;
- bool Refresh() override;
-
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
private:
diff --git a/src/displayapp/screens/Meter.cpp b/src/displayapp/screens/Meter.cpp
index e0dbdfad..57cde9cf 100644
--- a/src/displayapp/screens/Meter.cpp
+++ b/src/displayapp/screens/Meter.cpp
@@ -20,17 +20,17 @@ Meter::Meter(Pinetime::Applications::DisplayApp* app) : Screen(app) {
lv_obj_set_size(lmeter, 200, 200);
lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Meter::~Meter() {
-
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool Meter::Refresh() {
+void Meter::Refresh() {
lv_linemeter_set_value(lmeter, value++); /*Set the current value*/
if (value >= 60)
value = 0;
-
- return running;
}
diff --git a/src/displayapp/screens/Meter.h b/src/displayapp/screens/Meter.h
index 24af15ad..9b3d1d48 100644
--- a/src/displayapp/screens/Meter.h
+++ b/src/displayapp/screens/Meter.h
@@ -14,13 +14,15 @@ namespace Pinetime {
Meter(DisplayApp* app);
~Meter() override;
- bool Refresh() override;
+ void Refresh() override;
private:
lv_style_t style_lmeter;
lv_obj_t* lmeter;
uint32_t value = 0;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp
index 66f8f621..884a4a51 100644
--- a/src/displayapp/screens/Metronome.cpp
+++ b/src/displayapp/screens/Metronome.cpp
@@ -67,16 +67,16 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl
lv_obj_align(playPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
lv_obj_set_style_local_value_str(playPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Symbols::play);
- app->SetTouchMode(DisplayApp::TouchModes::Polling);
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Metronome::~Metronome() {
- app->SetTouchMode(DisplayApp::TouchModes::Gestures);
+ lv_task_del(taskRefresh);
systemTask.PushMessage(System::Messages::EnableSleeping);
lv_obj_clean(lv_scr_act());
}
-bool Metronome::Refresh() {
+void Metronome::Refresh() {
if (metronomeStarted) {
if (xTaskGetTickCount() - startTime > 60 * configTICK_RATE_HZ / bpm) {
startTime += 60 * configTICK_RATE_HZ / bpm;
@@ -89,7 +89,6 @@ bool Metronome::Refresh() {
}
}
}
- return running;
}
void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
diff --git a/src/displayapp/screens/Metronome.h b/src/displayapp/screens/Metronome.h
index a4baa096..f3a84dc8 100644
--- a/src/displayapp/screens/Metronome.h
+++ b/src/displayapp/screens/Metronome.h
@@ -11,7 +11,7 @@ namespace Pinetime {
public:
Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask);
~Metronome() override;
- bool Refresh() override;
+ void Refresh() override;
void OnEvent(lv_obj_t* obj, lv_event_t event);
private:
@@ -28,6 +28,8 @@ namespace Pinetime {
lv_obj_t *bpmArc, *bpmTap, *bpmValue;
lv_obj_t *bpbDropdown, *currentBpbText;
lv_obj_t *playPause;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp
index 43a5575e..2f1f7c21 100644
--- a/src/displayapp/screens/Motion.cpp
+++ b/src/displayapp/screens/Motion.cpp
@@ -36,13 +36,16 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr
labelStep = lv_label_create(lv_scr_act(), NULL);
lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_label_set_text(labelStep, "Steps ---");
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Motion::~Motion() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool Motion::Refresh() {
+void Motion::Refresh() {
lv_chart_set_next(chart, ser1, motionController.X());
lv_chart_set_next(chart, ser2, motionController.Y());
lv_chart_set_next(chart, ser3, motionController.Z());
@@ -55,6 +58,4 @@ bool Motion::Refresh() {
motionController.Y() / 0x10,
motionController.Z() / 0x10);
lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
-
- return running;
}
diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h
index 7e65197b..20a18d02 100644
--- a/src/displayapp/screens/Motion.h
+++ b/src/displayapp/screens/Motion.h
@@ -17,7 +17,7 @@ namespace Pinetime {
Motion(DisplayApp* app, Controllers::MotionController& motionController);
~Motion() override;
- bool Refresh() override;
+ void Refresh() override;
private:
Controllers::MotionController& motionController;
@@ -28,6 +28,7 @@ namespace Pinetime {
lv_obj_t* label;
lv_obj_t* labelStep;
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp
index 257e9aea..47ddb655 100644
--- a/src/displayapp/screens/Music.cpp
+++ b/src/displayapp/screens/Music.cpp
@@ -139,14 +139,17 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus
frameB = false;
musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Music::~Music() {
+ lv_task_del(taskRefresh);
lv_style_reset(&btn_style);
lv_obj_clean(lv_scr_act());
}
-bool Music::Refresh() {
+void Music::Refresh() {
if (artist != musicService.getArtist()) {
artist = musicService.getArtist();
currentLength = 0;
@@ -210,8 +213,6 @@ bool Music::Refresh() {
} else {
lv_label_set_text(txtPlayPause, Symbols::play);
}
-
- return running;
}
void Music::UpdateLength() {
diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h
index 00d3ad92..6f2d80a0 100644
--- a/src/displayapp/screens/Music.h
+++ b/src/displayapp/screens/Music.h
@@ -35,7 +35,7 @@ namespace Pinetime {
~Music() override;
- bool Refresh() override;
+ void Refresh() override;
void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
@@ -79,6 +79,8 @@ namespace Pinetime {
bool playing;
+ lv_task_t* taskRefresh;
+
/** Watchapp */
};
}
diff --git a/src/displayapp/screens/Navigation.cpp b/src/displayapp/screens/Navigation.cpp
index 79b04e21..d437cc6d 100644
--- a/src/displayapp/screens/Navigation.cpp
+++ b/src/displayapp/screens/Navigation.cpp
@@ -161,13 +161,16 @@ Navigation::Navigation(Pinetime::Applications::DisplayApp* app, Pinetime::Contro
lv_bar_set_anim_time(barProgress, 500);
lv_bar_set_range(barProgress, 0, 100);
lv_bar_set_value(barProgress, 0, LV_ANIM_OFF);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Navigation::~Navigation() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool Navigation::Refresh() {
+void Navigation::Refresh() {
if (flag != navService.getFlag()) {
flag = navService.getFlag();
lv_label_set_text(imgFlag, iconForName(flag));
@@ -192,8 +195,4 @@ bool Navigation::Refresh() {
lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
}
}
-
- return running;
}
-
-
diff --git a/src/displayapp/screens/Navigation.h b/src/displayapp/screens/Navigation.h
index eb7e00c4..48f00a76 100644
--- a/src/displayapp/screens/Navigation.h
+++ b/src/displayapp/screens/Navigation.h
@@ -35,7 +35,7 @@ namespace Pinetime {
Navigation(DisplayApp* app, Pinetime::Controllers::NavigationService& nav);
~Navigation() override;
- bool Refresh() override;
+ void Refresh() override;
private:
lv_obj_t* imgFlag;
@@ -49,6 +49,8 @@ namespace Pinetime {
std::string narrative;
std::string manDist;
int progress;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index c061c146..417dff00 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -52,15 +52,18 @@ Notifications::Notifications(DisplayApp* app,
timeoutTickCountEnd = timeoutTickCountStart + (5 * 1024);
}
}
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Notifications::~Notifications() {
+ lv_task_del(taskRefresh);
// make sure we stop any vibrations before exiting
Controllers::MotorController::StopRinging();
lv_obj_clean(lv_scr_act());
}
-bool Notifications::Refresh() {
+void Notifications::Refresh() {
if (mode == Modes::Preview && timeoutLine != nullptr) {
auto tick = xTaskGetTickCount();
int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240));
@@ -70,7 +73,6 @@ bool Notifications::Refresh() {
timeoutLinePoints[1].x = pos;
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
}
- return running && currentItem->IsRunning();
}
bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
@@ -150,7 +152,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
uint8_t notifNb,
Modes mode,
Pinetime::Controllers::AlertNotificationService& alertNotificationService)
- : notifNr {notifNr}, notifNb {notifNb}, mode {mode}, alertNotificationService {alertNotificationService} {
+ : mode {mode}, alertNotificationService {alertNotificationService} {
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL);
lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222));
diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h
index a02d9b46..0b5271e7 100644
--- a/src/displayapp/screens/Notifications.h
+++ b/src/displayapp/screens/Notifications.h
@@ -24,7 +24,7 @@ namespace Pinetime {
Modes mode);
~Notifications() override;
- bool Refresh() override;
+ void Refresh() override;
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
class NotificationItem {
@@ -43,21 +43,13 @@ namespace Pinetime {
void OnCallButtonEvent(lv_obj_t*, lv_event_t event);
private:
- uint8_t notifNr = 0;
- uint8_t notifNb = 0;
- char pageText[4];
-
lv_obj_t* container1;
- lv_obj_t* t1;
- lv_obj_t* l1;
- lv_obj_t* l2;
lv_obj_t* bt_accept;
lv_obj_t* bt_mute;
lv_obj_t* bt_reject;
lv_obj_t* label_accept;
lv_obj_t* label_mute;
lv_obj_t* label_reject;
- lv_obj_t* bottomPlaceholder;
Modes mode;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
bool running = true;
@@ -79,6 +71,8 @@ namespace Pinetime {
lv_obj_t* timeoutLine = nullptr;
uint32_t timeoutTickCountStart;
uint32_t timeoutTickCountEnd;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp
index 5a939ac7..3b6d60e3 100644
--- a/src/displayapp/screens/Paddle.cpp
+++ b/src/displayapp/screens/Paddle.cpp
@@ -5,8 +5,6 @@
using namespace Pinetime::Applications::Screens;
Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl {lvgl} {
- app->SetTouchMode(DisplayApp::TouchModes::Polling);
-
background = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_size(background, LV_HOR_RES + 1, LV_VER_RES);
lv_obj_set_pos(background, -1, 0);
@@ -29,15 +27,16 @@ Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::Li
lv_obj_set_style_local_bg_color(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_set_style_local_radius(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_obj_set_size(ball, ballSize, ballSize);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Paddle::~Paddle() {
- // Reset the touchmode
- app->SetTouchMode(DisplayApp::TouchModes::Gestures);
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool Paddle::Refresh() {
+void Paddle::Refresh() {
ballX += dx;
ballY += dy;
@@ -69,7 +68,6 @@ bool Paddle::Refresh() {
}
}
lv_label_set_text_fmt(points, "%04d", score);
- return running;
}
bool Paddle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
diff --git a/src/displayapp/screens/Paddle.h b/src/displayapp/screens/Paddle.h
index 30ab8f94..fc2131a1 100644
--- a/src/displayapp/screens/Paddle.h
+++ b/src/displayapp/screens/Paddle.h
@@ -16,7 +16,7 @@ namespace Pinetime {
Paddle(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
~Paddle() override;
- bool Refresh() override;
+ void Refresh() override;
bool OnTouchEvent(TouchEvents event) override;
bool OnTouchEvent(uint16_t x, uint16_t y) override;
@@ -40,6 +40,8 @@ namespace Pinetime {
lv_obj_t* paddle;
lv_obj_t* ball;
lv_obj_t* background;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp
index 98fd976c..7a712f43 100644
--- a/src/displayapp/screens/PineTimeStyle.cpp
+++ b/src/displayapp/screens/PineTimeStyle.cpp
@@ -23,6 +23,7 @@
#include <date/date.h>
#include <lvgl/lvgl.h>
#include <cstdio>
+#include <displayapp/Colors.h>
#include "BatteryIcon.h"
#include "BleIcon.h"
#include "NotificationIcon.h"
@@ -51,7 +52,8 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
notificatioManager {notificatioManager},
settingsController {settingsController},
motionController {motionController} {
- /* This sets the watchface number to return to after leaving the menu */
+
+ // This sets the watchface number to return to after leaving the menu
settingsController.SetClockFace(2);
displayedChar[0] = 0;
@@ -60,40 +62,40 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
displayedChar[3] = 0;
displayedChar[4] = 0;
- /* Create a 200px wide background rectangle */
+ //Create a 200px wide background rectangle
timebar = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(timebar, 200, 240);
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
- /* Display the time */
+ // Display the time
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD1, "12");
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD2, "34");
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
lv_label_set_text(timeAMPM, "");
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
- /* Create a 40px wide bar down the right side of the screen */
+ // Create a 40px wide bar down the right side of the screen
sidebar = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(sidebar, 40, 240);
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
- /* Display icons */
+ // Display icons
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
lv_label_set_text(batteryIcon, Symbols::batteryFull);
@@ -111,7 +113,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 40);
- /* Calendar icon */
+ // Calendar icon
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
@@ -148,7 +150,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_size(calendarCrossBar2, 8, 3);
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
- /* Display date */
+ // Display date
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
lv_label_set_text(dateDayOfWeek, "THU");
@@ -184,7 +186,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
- lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
+ lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
@@ -193,13 +195,17 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text(backgroundLabel, "");
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
+ Refresh();
}
PineTimeStyle::~PineTimeStyle() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool PineTimeStyle::Refresh() {
+void PineTimeStyle::Refresh() {
batteryPercentRemaining = batteryController.PercentRemaining();
if (batteryPercentRemaining.IsUpdated()) {
auto batteryPercent = batteryPercentRemaining.Get();
@@ -303,6 +309,4 @@ bool PineTimeStyle::Refresh() {
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
}
}
-
- return running;
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h
index f4cd28e4..cb74ead5 100644
--- a/src/displayapp/screens/PineTimeStyle.h
+++ b/src/displayapp/screens/PineTimeStyle.h
@@ -30,7 +30,7 @@ namespace Pinetime {
Controllers::MotionController& motionController);
~PineTimeStyle() override;
- bool Refresh() override;
+ void Refresh() override;
private:
char displayedChar[5];
@@ -75,6 +75,8 @@ namespace Pinetime {
Controllers::NotificationManager& notificatioManager;
Controllers::Settings& settingsController;
Controllers::MotionController& motionController;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/Screen.cpp b/src/displayapp/screens/Screen.cpp
index 1467df33..6ae5b7bb 100644
--- a/src/displayapp/screens/Screen.cpp
+++ b/src/displayapp/screens/Screen.cpp
@@ -1,2 +1,6 @@
#include "Screen.h"
-using namespace Pinetime::Applications::Screens; \ No newline at end of file
+using namespace Pinetime::Applications::Screens;
+
+void Screen::RefreshTaskCallback(lv_task_t* task) {
+ static_cast<Screen*>(task->user_data)->Refresh();
+}
diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h
index 6c9110c6..ce5741b2 100644
--- a/src/displayapp/screens/Screen.h
+++ b/src/displayapp/screens/Screen.h
@@ -2,6 +2,7 @@
#include <cstdint>
#include "../TouchEvents.h"
+#include <lvgl/lvgl.h>
namespace Pinetime {
namespace Applications {
@@ -38,25 +39,20 @@ namespace Pinetime {
};
class Screen {
+ private:
+ virtual void Refresh() {
+ }
+
public:
explicit Screen(DisplayApp* app) : app {app} {
}
virtual ~Screen() = default;
- /**
- * Most of the time, apps only react to events (touch events, for example).
- * In this case you don't need to do anything in this method.
- *
- * For example, InfiniPaint does nothing in Refresh().
- * But, if you want to update your display periodically, draw an animation...
- * you cannot do it in a touch event handler because these handlers are not
- * called if the user does not touch the screen.
- *
- * That's why Refresh() is there: update the display periodically.
- *
- * @return false if the app can be closed, true if it must continue to run
- **/
- virtual bool Refresh() = 0;
+ static void RefreshTaskCallback(lv_task_t* task);
+
+ bool IsRunning() const {
+ return running;
+ }
/** @return false if the button hasn't been handled by the app, true if it has been handled */
virtual bool OnButtonPushed() {
@@ -64,6 +60,7 @@ namespace Pinetime {
}
/** @return false if the event hasn't been handled by the app, true if it has been handled */
+ // Returning true will cancel lvgl tap
virtual bool OnTouchEvent(TouchEvents event) {
return false;
}
diff --git a/src/displayapp/screens/ScreenList.h b/src/displayapp/screens/ScreenList.h
index ea66bfb2..a9d747aa 100644
--- a/src/displayapp/screens/ScreenList.h
+++ b/src/displayapp/screens/ScreenList.h
@@ -30,11 +30,6 @@ namespace Pinetime {
lv_obj_clean(lv_scr_act());
}
- bool Refresh() override {
- running = current->Refresh();
- return running;
- }
-
bool OnTouchEvent(TouchEvents event) override {
if (mode == ScreenListModes::UpDown) {
@@ -110,4 +105,4 @@ namespace Pinetime {
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp
index d72e8333..c41163ab 100644
--- a/src/displayapp/screens/Steps.cpp
+++ b/src/displayapp/screens/Steps.cpp
@@ -47,20 +47,20 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text_static(backgroundLabel, "");
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
}
Steps::~Steps() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool Steps::Refresh() {
-
+void Steps::Refresh() {
stepsCount = motionController.NbSteps();
lv_label_set_text_fmt(lSteps, "%li", stepsCount);
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20);
lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal()));
-
- return running;
}
diff --git a/src/displayapp/screens/Steps.h b/src/displayapp/screens/Steps.h
index 9c135e26..d7cf31e1 100644
--- a/src/displayapp/screens/Steps.h
+++ b/src/displayapp/screens/Steps.h
@@ -15,24 +15,23 @@ namespace Pinetime {
namespace Screens {
class Steps : public Screen {
- public:
- Steps(DisplayApp* app, Controllers::MotionController& motionController, Controllers::Settings &settingsController);
- ~Steps() override;
+ public:
+ Steps(DisplayApp* app, Controllers::MotionController& motionController, Controllers::Settings& settingsController);
+ ~Steps() override;
- bool Refresh() override;
-
+ void Refresh() override;
- private:
+ private:
+ Controllers::MotionController& motionController;
+ Controllers::Settings& settingsController;
- Controllers::MotionController& motionController;
- Controllers::Settings& settingsController;
+ lv_obj_t* lSteps;
+ lv_obj_t* lStepsIcon;
+ lv_obj_t* stepsArc;
- lv_obj_t * lSteps;
- lv_obj_t * lStepsIcon;
- lv_obj_t * stepsArc;
-
- uint32_t stepsCount;
+ uint32_t stepsCount;
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp
index f4db5d6e..9b27a89d 100644
--- a/src/displayapp/screens/StopWatch.cpp
+++ b/src/displayapp/screens/StopWatch.cpp
@@ -48,7 +48,6 @@ static void stop_lap_event_handler(lv_obj_t* obj, lv_event_t event) {
StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
: Screen(app),
systemTask {systemTask},
- running {true},
currentState {States::Init},
startTime {},
oldTimeElapsed {},
@@ -101,9 +100,12 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
lv_obj_set_style_local_text_color(lapTwoText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
lv_obj_align(lapTwoText, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 50, 55);
lv_label_set_text(lapTwoText, "");
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
StopWatch::~StopWatch() {
+ lv_task_del(taskRefresh);
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
lv_obj_clean(lv_scr_act());
}
@@ -149,7 +151,7 @@ void StopWatch::pause() {
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
}
-bool StopWatch::Refresh() {
+void StopWatch::Refresh() {
if (currentState == States::Running) {
timeElapsed = calculateDelta(startTime, xTaskGetTickCount());
currentTimeSeparated = convertTicksToTimeSegments((oldTimeElapsed + timeElapsed));
@@ -157,11 +159,10 @@ bool StopWatch::Refresh() {
lv_label_set_text_fmt(time, "%02d:%02d", currentTimeSeparated.mins, currentTimeSeparated.secs);
lv_label_set_text_fmt(msecTime, "%02d", currentTimeSeparated.hundredths);
}
- return running;
}
void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
- if (event != LV_EVENT_PRESSED) {
+ if (event != LV_EVENT_CLICKED) {
return;
}
if (currentState == States::Init) {
@@ -174,7 +175,7 @@ void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
}
void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
- if (event != LV_EVENT_PRESSED) {
+ if (event != LV_EVENT_CLICKED) {
return;
}
// If running, then this button is used to save laps
@@ -196,8 +197,7 @@ void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
bool StopWatch::OnButtonPushed() {
if (currentState == States::Running) {
pause();
- } else {
- running = false;
+ return true;
}
- return true;
+ return false;
}
diff --git a/src/displayapp/screens/StopWatch.h b/src/displayapp/screens/StopWatch.h
index e132f158..25634e92 100644
--- a/src/displayapp/screens/StopWatch.h
+++ b/src/displayapp/screens/StopWatch.h
@@ -64,7 +64,7 @@ namespace Pinetime::Applications::Screens {
public:
StopWatch(DisplayApp* app, System::SystemTask& systemTask);
~StopWatch() override;
- bool Refresh() override;
+ void Refresh() override;
void playPauseBtnEventHandler(lv_event_t event);
void stopLapBtnEventHandler(lv_event_t event);
@@ -77,7 +77,6 @@ namespace Pinetime::Applications::Screens {
private:
Pinetime::System::SystemTask& systemTask;
TickType_t timeElapsed;
- bool running;
States currentState;
TickType_t startTime;
TickType_t oldTimeElapsed;
@@ -86,5 +85,7 @@ namespace Pinetime::Applications::Screens {
int lapNr = 0;
lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap;
lv_obj_t *lapOneText, *lapTwoText;
+
+ lv_task_t* taskRefresh;
};
}
diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp
index e7c5b65a..b7a4fc60 100644
--- a/src/displayapp/screens/SystemInfo.cpp
+++ b/src/displayapp/screens/SystemInfo.cpp
@@ -65,13 +65,6 @@ SystemInfo::~SystemInfo() {
lv_obj_clean(lv_scr_act());
}
-bool SystemInfo::Refresh() {
- if (running) {
- screens.Refresh();
- }
- return running;
-}
-
bool SystemInfo::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screens.OnTouchEvent(event);
}
@@ -207,7 +200,7 @@ bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
}
std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
- TaskStatus_t tasksStatus[7];
+ TaskStatus_t tasksStatus[10];
lv_obj_t* infoTask = lv_table_create(lv_scr_act(), NULL);
lv_table_set_col_cnt(infoTask, 4);
lv_table_set_row_cnt(infoTask, 8);
@@ -222,9 +215,9 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
lv_table_set_cell_value(infoTask, 0, 3, "Free");
lv_table_set_col_width(infoTask, 3, 90);
- auto nb = uxTaskGetSystemState(tasksStatus, 7, nullptr);
+ auto nb = uxTaskGetSystemState(tasksStatus, sizeof(tasksStatus) / sizeof(tasksStatus[0]), nullptr);
std::sort(tasksStatus, tasksStatus + nb, sortById);
- for (uint8_t i = 0; i < nb; i++) {
+ for (uint8_t i = 0; i < nb && i < 7; i++) {
lv_table_set_cell_value(infoTask, i + 1, 0, std::to_string(tasksStatus[i].xTaskNumber).c_str());
char state[2] = {0};
diff --git a/src/displayapp/screens/SystemInfo.h b/src/displayapp/screens/SystemInfo.h
index a9ad652d..5eb7054d 100644
--- a/src/displayapp/screens/SystemInfo.h
+++ b/src/displayapp/screens/SystemInfo.h
@@ -30,7 +30,6 @@ namespace Pinetime {
Pinetime::Drivers::WatchdogView& watchdog,
Pinetime::Controllers::MotionController& motionController);
~SystemInfo() override;
- bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override;
private:
diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp
index 777b5bb7..1d4f0d0e 100644
--- a/src/displayapp/screens/Tile.cpp
+++ b/src/displayapp/screens/Tile.cpp
@@ -95,6 +95,7 @@ Tile::Tile(uint8_t screenID,
lv_obj_set_style_local_pad_inner(btnm1, LV_BTNMATRIX_PART_BG, LV_STATE_DEFAULT, 10);
for (uint8_t i = 0; i < 6; i++) {
+ lv_btnmatrix_set_btn_ctrl(btnm1, i, LV_BTNMATRIX_CTRL_CLICK_TRIG);
if (applications[i].application == Apps::None) {
lv_btnmatrix_set_btn_ctrl(btnm1, i, LV_BTNMATRIX_CTRL_DISABLED);
}
@@ -122,10 +123,6 @@ void Tile::UpdateScreen() {
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
}
-bool Tile::Refresh() {
- return running;
-}
-
void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) {
if(obj != btnm1) return;
diff --git a/src/displayapp/screens/Tile.h b/src/displayapp/screens/Tile.h
index 765a8def..83d3fdf5 100644
--- a/src/displayapp/screens/Tile.h
+++ b/src/displayapp/screens/Tile.h
@@ -30,7 +30,6 @@ namespace Pinetime {
~Tile() override;
- bool Refresh() override;
void UpdateScreen();
void OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId);
diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp
index 99e979ba..ff3099d5 100644
--- a/src/displayapp/screens/Timer.cpp
+++ b/src/displayapp/screens/Timer.cpp
@@ -4,10 +4,8 @@
#include "Symbols.h"
#include "lvgl/lvgl.h"
-
using namespace Pinetime::Applications::Screens;
-
static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
Timer* screen = static_cast<Timer*>(obj->user_data);
screen->OnButtonEvent(obj, event);
@@ -22,7 +20,7 @@ void Timer::createButtons() {
lv_obj_set_width(btnMinutesUp, 60);
txtMUp = lv_label_create(btnMinutesUp, nullptr);
lv_label_set_text(txtMUp, "+");
-
+
btnMinutesDown = lv_btn_create(lv_scr_act(), nullptr);
btnMinutesDown->user_data = this;
lv_obj_set_event_cb(btnMinutesDown, btnEventHandler);
@@ -31,7 +29,7 @@ void Timer::createButtons() {
lv_obj_set_width(btnMinutesDown, 60);
txtMDown = lv_label_create(btnMinutesDown, nullptr);
lv_label_set_text(txtMDown, "-");
-
+
btnSecondsUp = lv_btn_create(lv_scr_act(), nullptr);
btnSecondsUp->user_data = this;
lv_obj_set_event_cb(btnSecondsUp, btnEventHandler);
@@ -40,7 +38,7 @@ void Timer::createButtons() {
lv_obj_set_width(btnSecondsUp, 60);
txtSUp = lv_label_create(btnSecondsUp, nullptr);
lv_label_set_text(txtSUp, "+");
-
+
btnSecondsDown = lv_btn_create(lv_scr_act(), nullptr);
btnSecondsDown->user_data = this;
lv_obj_set_event_cb(btnSecondsDown, btnEventHandler);
@@ -49,24 +47,20 @@ void Timer::createButtons() {
lv_obj_set_width(btnSecondsDown, 60);
txtSDown = lv_label_create(btnSecondsDown, nullptr);
lv_label_set_text(txtSDown, "-");
-
}
-
Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
- : Screen(app),
- running{true},
- timerController{timerController} {
-
+ : Screen(app), running {true}, timerController {timerController} {
+
time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
-
+
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60);
lv_obj_align(time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
-
+
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
btnPlayPause->user_data = this;
lv_obj_set_event_cb(btnPlayPause, btnEventHandler);
@@ -79,20 +73,20 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
lv_label_set_text(txtPlayPause, Symbols::play);
createButtons();
}
-
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Timer::~Timer() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
-
}
-bool Timer::Refresh() {
+void Timer::Refresh() {
if (timerController.IsRunning()) {
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60);
}
- return running;
}
void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
@@ -105,11 +99,11 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
secondsToSet = seconds % 60;
timerController.StopTimer();
createButtons();
-
+
} else if (secondsToSet + minutesToSet > 0) {
lv_label_set_text(txtPlayPause, Symbols::pause);
timerController.StartTimer((secondsToSet + minutesToSet * 60) * 1000);
-
+
lv_obj_del(btnSecondsDown);
btnSecondsDown = nullptr;
lv_obj_del(btnSecondsUp);
@@ -118,7 +112,6 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
btnMinutesDown = nullptr;
lv_obj_del(btnMinutesUp);
btnMinutesUp = nullptr;
-
}
} else {
if (!timerController.IsRunning()) {
@@ -129,7 +122,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
minutesToSet++;
}
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
-
+
} else if (obj == btnMinutesDown) {
if (minutesToSet == 0) {
minutesToSet = 59;
@@ -137,7 +130,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
minutesToSet--;
}
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
-
+
} else if (obj == btnSecondsUp) {
if (secondsToSet >= 59) {
secondsToSet = 0;
@@ -145,7 +138,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
secondsToSet++;
}
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
-
+
} else if (obj == btnSecondsDown) {
if (secondsToSet == 0) {
secondsToSet = 59;
@@ -153,21 +146,16 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
secondsToSet--;
}
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
-
}
}
-
}
-
}
-
}
-
void Timer::setDone() {
lv_label_set_text(time, "00:00");
lv_label_set_text(txtPlayPause, Symbols::play);
secondsToSet = 0;
minutesToSet = 0;
createButtons();
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h
index 0d66f2d4..d0fc8ed1 100644
--- a/src/displayapp/screens/Timer.h
+++ b/src/displayapp/screens/Timer.h
@@ -8,35 +8,32 @@
#include "components/timer/TimerController.h"
namespace Pinetime::Applications::Screens {
-
-
+
class Timer : public Screen {
public:
-
- enum class Modes {
- Normal, Done
- };
-
+ enum class Modes { Normal, Done };
+
Timer(DisplayApp* app, Controllers::TimerController& timerController);
-
+
~Timer() override;
-
- bool Refresh() override;
-
+
+ void Refresh() override;
+
void setDone();
-
+
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
-
+
private:
-
bool running;
uint8_t secondsToSet = 0;
uint8_t minutesToSet = 0;
Controllers::TimerController& timerController;
-
+
void createButtons();
-
- lv_obj_t* time, * msecTime, * btnPlayPause, * txtPlayPause, * btnMinutesUp, * btnMinutesDown, * btnSecondsUp, * btnSecondsDown, * txtMUp,
- * txtMDown, * txtSUp, * txtSDown;
+
+ lv_obj_t *time, *msecTime, *btnPlayPause, *txtPlayPause, *btnMinutesUp, *btnMinutesDown, *btnSecondsUp, *btnSecondsDown, *txtMUp,
+ *txtMDown, *txtSUp, *txtSDown;
+
+ lv_task_t* taskRefresh;
};
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Twos.cpp b/src/displayapp/screens/Twos.cpp
index eb268077..4201d501 100644
--- a/src/displayapp/screens/Twos.cpp
+++ b/src/displayapp/screens/Twos.cpp
@@ -102,10 +102,6 @@ Twos::~Twos() {
lv_obj_clean(lv_scr_act());
}
-bool Twos::Refresh() {
- return running;
-}
-
bool Twos::placeNewTile() {
std::vector<std::pair<int, int>> availableCells;
for (int row = 0; row < 4; row++) {
@@ -295,4 +291,4 @@ void Twos::updateGridDisplay(Tile grid[][4]) {
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Twos.h b/src/displayapp/screens/Twos.h
index 3367618f..6d85cff6 100644
--- a/src/displayapp/screens/Twos.h
+++ b/src/displayapp/screens/Twos.h
@@ -14,7 +14,6 @@ namespace Pinetime {
public:
Twos(DisplayApp* app);
~Twos() override;
- bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override;
@@ -36,4 +35,4 @@ namespace Pinetime {
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp
index 1410fc28..75e35c1b 100644
--- a/src/displayapp/screens/WatchFaceAnalog.cpp
+++ b/src/displayapp/screens/WatchFaceAnalog.cpp
@@ -118,10 +118,13 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
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);
UpdateClock();
}
WatchFaceAnalog::~WatchFaceAnalog() {
+ lv_task_del(taskRefresh);
+
lv_style_reset(&hour_line_style);
lv_style_reset(&hour_line_style_trace);
lv_style_reset(&minute_line_style);
@@ -173,7 +176,7 @@ void WatchFaceAnalog::UpdateClock() {
}
}
-bool WatchFaceAnalog::Refresh() {
+void WatchFaceAnalog::Refresh() {
batteryPercentRemaining = batteryController.PercentRemaining();
if (batteryPercentRemaining.IsUpdated()) {
auto batteryPercent = batteryPercentRemaining.Get();
@@ -203,6 +206,4 @@ bool WatchFaceAnalog::Refresh() {
currentDay = day;
}
}
-
- return true;
}
diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h
index 5d8c6a24..406f4d50 100644
--- a/src/displayapp/screens/WatchFaceAnalog.h
+++ b/src/displayapp/screens/WatchFaceAnalog.h
@@ -32,7 +32,7 @@ namespace Pinetime {
~WatchFaceAnalog() override;
- bool Refresh() override;
+ void Refresh() override;
private:
uint8_t sHour, sMinute, sSecond;
@@ -81,6 +81,8 @@ namespace Pinetime {
Controllers::Settings& settingsController;
void UpdateClock();
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp
index 2b902b3b..58ab6190 100644
--- a/src/displayapp/screens/WatchFaceDigital.cpp
+++ b/src/displayapp/screens/WatchFaceDigital.cpp
@@ -91,13 +91,17 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
lv_label_set_text(stepIcon, Symbols::shoe);
lv_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();
}
WatchFaceDigital::~WatchFaceDigital() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool WatchFaceDigital::Refresh() {
+void WatchFaceDigital::Refresh() {
batteryPercentRemaining = batteryController.PercentRemaining();
if (batteryPercentRemaining.IsUpdated()) {
auto batteryPercent = batteryPercentRemaining.Get();
@@ -219,6 +223,4 @@ bool WatchFaceDigital::Refresh() {
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
}
-
- return running;
}
diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h
index 6a6e1ac6..48dc1373 100644
--- a/src/displayapp/screens/WatchFaceDigital.h
+++ b/src/displayapp/screens/WatchFaceDigital.h
@@ -33,7 +33,7 @@ namespace Pinetime {
Controllers::MotionController& motionController);
~WatchFaceDigital() override;
- bool Refresh() override;
+ void Refresh() override;
private:
char displayedChar[5] {};
@@ -72,6 +72,8 @@ namespace Pinetime {
Controllers::Settings& settingsController;
Controllers::HeartRateController& heartRateController;
Controllers::MotionController& motionController;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp
index 54e2f3e2..22b56360 100644
--- a/src/displayapp/screens/settings/QuickSettings.cpp
+++ b/src/displayapp/screens/settings/QuickSettings.cpp
@@ -128,12 +128,12 @@ void QuickSettings::UpdateScreen() {
}
void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
- if (object == btn2 && event == LV_EVENT_PRESSED) {
+ if (object == btn2 && event == LV_EVENT_CLICKED) {
running = false;
app->StartApp(Apps::FlashLight, DisplayApp::FullRefreshDirections::None);
- } else if (object == btn1 && event == LV_EVENT_PRESSED) {
+ } else if (object == btn1 && event == LV_EVENT_CLICKED) {
brightness.Step();
lv_label_set_text_static(btn1_lvl, brightness.GetIcon());
@@ -150,13 +150,9 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff);
}
- } else if (object == btn4 && event == LV_EVENT_PRESSED) {
+ } else if (object == btn4 && event == LV_EVENT_CLICKED) {
running = false;
settingsController.SetSettingsMenu(0);
app->StartApp(Apps::Settings, DisplayApp::FullRefreshDirections::Up);
}
}
-
-bool QuickSettings::Refresh() {
- return running;
-}
diff --git a/src/displayapp/screens/settings/QuickSettings.h b/src/displayapp/screens/settings/QuickSettings.h
index 2eefe1a7..c036fa5c 100644
--- a/src/displayapp/screens/settings/QuickSettings.h
+++ b/src/displayapp/screens/settings/QuickSettings.h
@@ -27,8 +27,6 @@ namespace Pinetime {
~QuickSettings() override;
- bool Refresh() override;
-
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
void UpdateScreen();
diff --git a/src/displayapp/screens/settings/SettingDisplay.cpp b/src/displayapp/screens/settings/SettingDisplay.cpp
index 4954185d..d8d6c767 100644
--- a/src/displayapp/screens/settings/SettingDisplay.cpp
+++ b/src/displayapp/screens/settings/SettingDisplay.cpp
@@ -80,12 +80,8 @@ SettingDisplay::~SettingDisplay() {
settingsController.SaveSettings();
}
-bool SettingDisplay::Refresh() {
- return running;
-}
-
void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
- if (event == LV_EVENT_VALUE_CHANGED) {
+ if (event == LV_EVENT_CLICKED) {
for (int i = 0; i < optionsTotal; i++) {
if (object == cbOption[i]) {
lv_checkbox_set_checked(cbOption[i], true);
@@ -110,4 +106,4 @@ void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/settings/SettingDisplay.h b/src/displayapp/screens/settings/SettingDisplay.h
index b8ed87ec..51b23aca 100644
--- a/src/displayapp/screens/settings/SettingDisplay.h
+++ b/src/displayapp/screens/settings/SettingDisplay.h
@@ -15,7 +15,6 @@ namespace Pinetime {
SettingDisplay(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingDisplay() override;
- bool Refresh() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp
new file mode 100644
index 00000000..c9af19b6
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp
@@ -0,0 +1,318 @@
+#include "SettingPineTimeStyle.h"
+#include <lvgl/lvgl.h>
+#include <displayapp/Colors.h>
+#include "displayapp/DisplayApp.h"
+#include "displayapp/screens/Symbols.h"
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ static void event_handler(lv_obj_t* obj, lv_event_t event) {
+ SettingPineTimeStyle* screen = static_cast<SettingPineTimeStyle*>(obj->user_data);
+ screen->UpdateSelected(obj, event);
+ }
+}
+
+SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
+ : Screen(app), settingsController {settingsController} {
+ timebar = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
+ lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(timebar, 200, 240);
+ lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
+
+ // Display the time
+
+ timeDD1 = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
+ lv_label_set_text(timeDD1, "12");
+ lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
+
+ timeDD2 = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
+ lv_label_set_text(timeDD2, "34");
+ lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
+
+ timeAMPM = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
+ lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
+ lv_label_set_text(timeAMPM, "A\nM");
+ lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
+
+ // Create a 40px wide bar down the right side of the screen
+
+ sidebar = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
+ lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(sidebar, 40, 240);
+ lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
+
+ // Display icons
+
+ batteryIcon = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_label_set_text(batteryIcon, Symbols::batteryFull);
+ lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
+
+ bleIcon = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_label_set_text(bleIcon, Symbols::bluetooth);
+ lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25);
+
+ // Calendar icon
+
+ calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(calendarOuter, 34, 34);
+ lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
+
+ calendarInner = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff));
+ lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(calendarInner, 27, 27);
+ lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0);
+
+ calendarBar1 = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(calendarBar1, 3, 12);
+ lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3);
+
+ calendarBar2 = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(calendarBar2, 3, 12);
+ lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3);
+
+ calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(calendarCrossBar1, 8, 3);
+ lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+
+ calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(calendarCrossBar2, 8, 3);
+ lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+
+ // Display date
+
+ dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_label_set_text(dateDayOfWeek, "THU");
+ lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
+
+ dateDay = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_label_set_text(dateDay, "25");
+ lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
+
+ dateMonth = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_label_set_text(dateMonth, "MAR");
+ lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
+
+ // Step count gauge
+ needle_colors[0] = LV_COLOR_WHITE;
+ stepGauge = lv_gauge_create(lv_scr_act(), nullptr);
+ lv_gauge_set_needle_count(stepGauge, 1, needle_colors);
+ lv_obj_set_size(stepGauge, 40, 40);
+ lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+ lv_gauge_set_scale(stepGauge, 360, 11, 0);
+ lv_gauge_set_angle_offset(stepGauge, 180);
+ lv_gauge_set_critical_value(stepGauge, (100));
+ lv_gauge_set_range(stepGauge, 0, (100));
+ lv_gauge_set_value(stepGauge, 0, 0);
+
+ lv_obj_set_style_local_pad_right(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
+ lv_obj_set_style_local_pad_left(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
+ lv_obj_set_style_local_pad_bottom(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
+ lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
+ lv_obj_set_style_local_scale_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
+ lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
+ lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+ lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
+ lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
+ lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
+
+ backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_click(backgroundLabel, true);
+ lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
+ lv_obj_set_size(backgroundLabel, 240, 240);
+ lv_obj_set_pos(backgroundLabel, 0, 0);
+ lv_label_set_text(backgroundLabel, "");
+
+ btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
+ btnNextTime->user_data = this;
+ lv_obj_set_size(btnNextTime, 60, 60);
+ lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, -80);
+ lv_obj_set_style_local_bg_opa(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
+ lv_obj_set_event_cb(btnNextTime, event_handler);
+
+ btnPrevTime = lv_btn_create(lv_scr_act(), nullptr);
+ btnPrevTime->user_data = this;
+ lv_obj_set_size(btnPrevTime, 60, 60);
+ lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, -80);
+ lv_obj_set_style_local_bg_opa(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
+ lv_obj_set_event_cb(btnPrevTime, event_handler);
+
+ btnNextBar = lv_btn_create(lv_scr_act(), nullptr);
+ btnNextBar->user_data = this;
+ lv_obj_set_size(btnNextBar, 60, 60);
+ lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0);
+ lv_obj_set_style_local_bg_opa(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
+ lv_obj_set_event_cb(btnNextBar, event_handler);
+
+ btnPrevBar = lv_btn_create(lv_scr_act(), nullptr);
+ btnPrevBar->user_data = this;
+ lv_obj_set_size(btnPrevBar, 60, 60);
+ lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0);
+ lv_obj_set_style_local_bg_opa(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
+ lv_obj_set_event_cb(btnPrevBar, event_handler);
+
+ btnNextBG = lv_btn_create(lv_scr_act(), nullptr);
+ btnNextBG->user_data = this;
+ lv_obj_set_size(btnNextBG, 60, 60);
+ lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 80);
+ lv_obj_set_style_local_bg_opa(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
+ lv_obj_set_event_cb(btnNextBG, event_handler);
+
+ btnPrevBG = lv_btn_create(lv_scr_act(), nullptr);
+ btnPrevBG->user_data = this;
+ lv_obj_set_size(btnPrevBG, 60, 60);
+ lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 80);
+ lv_obj_set_style_local_bg_opa(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
+ lv_obj_set_event_cb(btnPrevBG, event_handler);
+
+ btnReset = lv_btn_create(lv_scr_act(), nullptr);
+ btnReset->user_data = this;
+ lv_obj_set_size(btnReset, 60, 60);
+ lv_obj_align(btnReset, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
+ lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst");
+ lv_obj_set_event_cb(btnReset, event_handler);
+
+ btnRandom = lv_btn_create(lv_scr_act(), nullptr);
+ btnRandom->user_data = this;
+ lv_obj_set_size(btnRandom, 60, 60);
+ lv_obj_align(btnRandom, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
+ lv_obj_set_style_local_bg_opa(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rnd");
+ lv_obj_set_event_cb(btnRandom, event_handler);
+}
+
+SettingPineTimeStyle::~SettingPineTimeStyle() {
+ lv_obj_clean(lv_scr_act());
+ settingsController.SaveSettings();
+}
+
+void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
+ auto valueTime = settingsController.GetPTSColorTime();
+ auto valueBar = settingsController.GetPTSColorBar();
+ auto valueBG = settingsController.GetPTSColorBG();
+
+ if (event == LV_EVENT_CLICKED) {
+ if (object == btnNextTime) {
+ valueTime = GetNext(valueTime);
+
+ settingsController.SetPTSColorTime(valueTime);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ }
+ if (object == btnPrevTime) {
+ valueTime = GetPrevious(valueTime);
+ settingsController.SetPTSColorTime(valueTime);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ }
+ if (object == btnNextBar) {
+ valueBar = GetNext(valueBar);
+ if(valueBar == Controllers::Settings::Colors::Black)
+ valueBar = GetNext(valueBar);
+ settingsController.SetPTSColorBar(valueBar);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
+ }
+ if (object == btnPrevBar) {
+ valueBar = GetPrevious(valueBar);
+ if(valueBar == Controllers::Settings::Colors::Black)
+ valueBar = GetPrevious(valueBar);
+ settingsController.SetPTSColorBar(valueBar);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
+ }
+ if (object == btnNextBG) {
+ valueBG = GetNext(valueBG);
+ settingsController.SetPTSColorBG(valueBG);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
+ }
+ if (object == btnPrevBG) {
+ valueBG = GetPrevious(valueBG);
+ settingsController.SetPTSColorBG(valueBG);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
+ }
+ if (object == btnReset) {
+ settingsController.SetPTSColorTime(Controllers::Settings::Colors::Teal);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ settingsController.SetPTSColorBar(Controllers::Settings::Colors::Teal);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ settingsController.SetPTSColorBG(Controllers::Settings::Colors::Black);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black));
+ }
+ if (object == btnRandom) {
+ uint8_t randTime = rand() % 17;
+ uint8_t randBar = rand() % 17;
+ uint8_t randBG = rand() % 17;
+ // Check if the time color is the same as its background, or if the sidebar is black. If so, change them to more useful values.
+ if (randTime == randBG) {
+ randBG += 1;
+ }
+ if (randBar == 3) {
+ randBar -= 1;
+ }
+ settingsController.SetPTSColorTime(static_cast<Controllers::Settings::Colors>(randTime));
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
+ settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(randBar));
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBar)));
+ settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(randBG));
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBG)));
+ }
+ }
+}
+
+Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
+ auto colorAsInt = static_cast<uint8_t>(color);
+ Pinetime::Controllers::Settings::Colors nextColor;
+ if (colorAsInt < 16) {
+ nextColor = static_cast<Controllers::Settings::Colors>(colorAsInt + 1);
+ } else {
+ nextColor = static_cast<Controllers::Settings::Colors>(0);
+ }
+ return nextColor;
+}
+
+Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
+ auto colorAsInt = static_cast<uint8_t>(color);
+ Pinetime::Controllers::Settings::Colors prevColor;
+
+ if (colorAsInt > 0) {
+ prevColor = static_cast<Controllers::Settings::Colors>(colorAsInt - 1);
+ } else {
+ prevColor = static_cast<Controllers::Settings::Colors>(16);
+ }
+ return prevColor;
+}
diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h
new file mode 100644
index 00000000..397bd86d
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h
@@ -0,0 +1,56 @@
+#pragma once
+
+#include <cstdint>
+#include <lvgl/lvgl.h>
+#include "components/settings/Settings.h"
+#include "displayapp/screens/Screen.h"
+
+namespace Pinetime {
+
+ namespace Applications {
+ namespace Screens {
+
+ class SettingPineTimeStyle : public Screen{
+ public:
+ SettingPineTimeStyle(DisplayApp* app, Pinetime::Controllers::Settings &settingsController);
+ ~SettingPineTimeStyle() override;
+
+ void UpdateSelected(lv_obj_t *object, lv_event_t event);
+
+ private:
+ Controllers::Settings& settingsController;
+
+ Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color);
+ Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color);
+
+ lv_obj_t * btnNextTime;
+ lv_obj_t * btnPrevTime;
+ lv_obj_t * btnNextBar;
+ lv_obj_t * btnPrevBar;
+ lv_obj_t * btnNextBG;
+ lv_obj_t * btnPrevBG;
+ lv_obj_t * btnReset;
+ lv_obj_t * btnRandom;
+ lv_obj_t * timebar;
+ lv_obj_t * sidebar;
+ lv_obj_t * timeDD1;
+ lv_obj_t * timeDD2;
+ lv_obj_t * timeAMPM;
+ lv_obj_t * dateDayOfWeek;
+ lv_obj_t * dateDay;
+ lv_obj_t * dateMonth;
+ lv_obj_t * backgroundLabel;
+ lv_obj_t * batteryIcon;
+ lv_obj_t * bleIcon;
+ lv_obj_t * calendarOuter;
+ lv_obj_t * calendarInner;
+ lv_obj_t * calendarBar1;
+ lv_obj_t * calendarBar2;
+ lv_obj_t * calendarCrossBar1;
+ lv_obj_t * calendarCrossBar2;
+ lv_obj_t * stepGauge;
+ lv_color_t needle_colors[1];
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingSteps.cpp b/src/displayapp/screens/settings/SettingSteps.cpp
index faa843e6..bec7972b 100644
--- a/src/displayapp/screens/settings/SettingSteps.cpp
+++ b/src/displayapp/screens/settings/SettingSteps.cpp
@@ -70,11 +70,6 @@ SettingSteps::~SettingSteps() {
settingsController.SaveSettings();
}
-bool SettingSteps::Refresh() {
- return running;
-}
-
-
void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) {
uint32_t value = settingsController.GetStepsGoal();
if(object == btnPlus && (event == LV_EVENT_PRESSED)) {
@@ -95,4 +90,4 @@ void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) {
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/settings/SettingSteps.h b/src/displayapp/screens/settings/SettingSteps.h
index 0a4c2056..5fc05dee 100644
--- a/src/displayapp/screens/settings/SettingSteps.h
+++ b/src/displayapp/screens/settings/SettingSteps.h
@@ -10,22 +10,19 @@ namespace Pinetime {
namespace Applications {
namespace Screens {
- class SettingSteps : public Screen{
- public:
- SettingSteps(DisplayApp* app, Pinetime::Controllers::Settings &settingsController);
- ~SettingSteps() override;
+ class SettingSteps : public Screen {
+ public:
+ SettingSteps(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
+ ~SettingSteps() override;
- bool Refresh() override;
- void UpdateSelected(lv_obj_t *object, lv_event_t event);
-
- private:
+ void UpdateSelected(lv_obj_t* object, lv_event_t event);
- Controllers::Settings& settingsController;
+ private:
+ Controllers::Settings& settingsController;
- lv_obj_t * stepValue;
- lv_obj_t * btnPlus;
- lv_obj_t * btnMinus;
-
+ lv_obj_t* stepValue;
+ lv_obj_t* btnPlus;
+ lv_obj_t* btnMinus;
};
}
}
diff --git a/src/displayapp/screens/settings/SettingTimeFormat.cpp b/src/displayapp/screens/settings/SettingTimeFormat.cpp
index 031a2a72..c99e3a0e 100644
--- a/src/displayapp/screens/settings/SettingTimeFormat.cpp
+++ b/src/displayapp/screens/settings/SettingTimeFormat.cpp
@@ -64,10 +64,6 @@ SettingTimeFormat::~SettingTimeFormat() {
settingsController.SaveSettings();
}
-bool SettingTimeFormat::Refresh() {
- return running;
-}
-
void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_VALUE_CHANGED) {
for (int i = 0; i < optionsTotal; i++) {
@@ -86,4 +82,4 @@ void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/settings/SettingTimeFormat.h b/src/displayapp/screens/settings/SettingTimeFormat.h
index 9203b45b..eac4bdc9 100644
--- a/src/displayapp/screens/settings/SettingTimeFormat.h
+++ b/src/displayapp/screens/settings/SettingTimeFormat.h
@@ -15,7 +15,6 @@ namespace Pinetime {
SettingTimeFormat(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingTimeFormat() override;
- bool Refresh() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
diff --git a/src/displayapp/screens/settings/SettingWakeUp.cpp b/src/displayapp/screens/settings/SettingWakeUp.cpp
index cce9a60d..d999004b 100644
--- a/src/displayapp/screens/settings/SettingWakeUp.cpp
+++ b/src/displayapp/screens/settings/SettingWakeUp.cpp
@@ -72,10 +72,6 @@ SettingWakeUp::~SettingWakeUp() {
settingsController.SaveSettings();
}
-bool SettingWakeUp::Refresh() {
- return running;
-}
-
void SettingWakeUp::UpdateSelected(lv_obj_t* object, lv_event_t event) {
using WakeUpMode = Pinetime::Controllers::Settings::WakeUpMode;
if (event == LV_EVENT_VALUE_CHANGED && !ignoringEvents) {
diff --git a/src/displayapp/screens/settings/SettingWakeUp.h b/src/displayapp/screens/settings/SettingWakeUp.h
index 248dd9ac..b9a31dc9 100644
--- a/src/displayapp/screens/settings/SettingWakeUp.h
+++ b/src/displayapp/screens/settings/SettingWakeUp.h
@@ -15,7 +15,6 @@ namespace Pinetime {
SettingWakeUp(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingWakeUp() override;
- bool Refresh() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp
index 02b90816..cdec704c 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.cpp
+++ b/src/displayapp/screens/settings/SettingWatchFace.cpp
@@ -75,10 +75,6 @@ SettingWatchFace::~SettingWatchFace() {
settingsController.SaveSettings();
}
-bool SettingWatchFace::Refresh() {
- return running;
-}
-
void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_VALUE_CHANGED) {
for (uint8_t i = 0; i < optionsTotal; i++) {
diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h
index 1930a228..d4a96c6d 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.h
+++ b/src/displayapp/screens/settings/SettingWatchFace.h
@@ -15,7 +15,6 @@ namespace Pinetime {
SettingWatchFace(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingWatchFace() override;
- bool Refresh() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp
index 0ab21377..e3319f03 100644
--- a/src/displayapp/screens/settings/Settings.cpp
+++ b/src/displayapp/screens/settings/Settings.cpp
@@ -18,6 +18,9 @@ Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controller
},
[this]() -> std::unique_ptr<Screen> {
return CreateScreen2();
+ },
+ [this]() -> std::unique_ptr<Screen> {
+ return CreateScreen3();
}},
Screens::ScreenListModes::UpDown} {
}
@@ -26,13 +29,6 @@ Settings::~Settings() {
lv_obj_clean(lv_scr_act());
}
-bool Settings::Refresh() {
-
- if (running)
- running = screens.Refresh();
- return running;
-}
-
bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screens.OnTouchEvent(event);
}
@@ -46,7 +42,7 @@ std::unique_ptr<Screen> Settings::CreateScreen1() {
{Symbols::home, "Watch face", Apps::SettingWatchFace},
}};
- return std::make_unique<Screens::List>(0, 2, app, settingsController, applications);
+ return std::make_unique<Screens::List>(0, 3, app, settingsController, applications);
}
std::unique_ptr<Screen> Settings::CreateScreen2() {
@@ -54,9 +50,21 @@ std::unique_ptr<Screen> Settings::CreateScreen2() {
std::array<Screens::List::Applications, 4> applications {{
{Symbols::shoe, "Steps", Apps::SettingSteps},
{Symbols::batteryHalf, "Battery", Apps::BatteryInfo},
+ {Symbols::paintbrush, "PTS Colors", Apps::SettingPineTimeStyle},
{Symbols::check, "Firmware", Apps::FirmwareValidation},
+ }};
+
+ return std::make_unique<Screens::List>(1, 3, app, settingsController, applications);
+}
+
+std::unique_ptr<Screen> Settings::CreateScreen3() {
+
+ std::array<Screens::List::Applications, 4> applications {{
{Symbols::list, "About", Apps::SysInfo},
+ {Symbols::none, "None", Apps::None},
+ {Symbols::none, "None", Apps::None},
+ {Symbols::none, "None", Apps::None},
}};
- return std::make_unique<Screens::List>(1, 2, app, settingsController, applications);
+ return std::make_unique<Screens::List>(2, 3, app, settingsController, applications);
}
diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h
index 711a6be6..6c54cdeb 100644
--- a/src/displayapp/screens/settings/Settings.h
+++ b/src/displayapp/screens/settings/Settings.h
@@ -14,17 +14,16 @@ namespace Pinetime {
Settings(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~Settings() override;
- bool Refresh() override;
-
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
private:
Controllers::Settings& settingsController;
- ScreenList<2> screens;
+ ScreenList<3> screens;
std::unique_ptr<Screen> CreateScreen1();
std::unique_ptr<Screen> CreateScreen2();
+ std::unique_ptr<Screen> CreateScreen3();
};
}
}
diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp
index 2e70a469..61d540c1 100644
--- a/src/drivers/Cst816s.cpp
+++ b/src/drivers/Cst816s.cpp
@@ -3,6 +3,7 @@
#include <legacy/nrf_drv_gpiote.h>
#include <nrfx_log.h>
#include <task.h>
+#include "drivers/PinMap.h"
using namespace Pinetime::Drivers;
@@ -18,10 +19,10 @@ Cst816S::Cst816S(TwiMaster& twiMaster, uint8_t twiAddress) : twiMaster {twiMaste
}
void Cst816S::Init() {
- nrf_gpio_cfg_output(pinReset);
- nrf_gpio_pin_clear(pinReset);
+ nrf_gpio_cfg_output(PinMap::Cst816sReset);
+ nrf_gpio_pin_clear(PinMap::Cst816sReset);
vTaskDelay(5);
- nrf_gpio_pin_set(pinReset);
+ nrf_gpio_pin_set(PinMap::Cst816sReset);
vTaskDelay(50);
// Wake the touchpanel up
@@ -38,47 +39,49 @@ void Cst816S::Init() {
*/
static constexpr uint8_t motionMask = 0b00000101;
twiMaster.Write(twiAddress, 0xEC, &motionMask, 1);
+
+ /*
+ [7] EnTest - Interrupt pin to test, enable automatic periodic issued after a low pulse.
+ [6] EnTouch - When a touch is detected, a periodic pulsed Low.
+ [5] EnChange - Upon detecting a touch state changes, pulsed Low.
+ [4] EnMotion - When the detected gesture is pulsed Low.
+ [0] OnceWLP - Press gesture only issue a pulse signal is low.
+ */
+ static constexpr uint8_t irqCtl = 0b01110000;
+ twiMaster.Write(twiAddress, 0xFA, &irqCtl, 1);
}
Cst816S::TouchInfos Cst816S::GetTouchInfo() {
Cst816S::TouchInfos info;
auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData));
- if (ret != TwiMaster::ErrorCodes::NoError)
- return {};
-
- auto nbTouchPoints = touchData[2] & 0x0f;
-
- uint8_t i = 0;
-
- uint8_t pointId = (touchData[touchIdIndex + (touchStep * i)]) >> 4;
- if (nbTouchPoints == 0 && pointId == lastTouchId)
+ if (ret != TwiMaster::ErrorCodes::NoError) {
+ info.isValid = false;
return info;
+ }
- info.isTouch = true;
+ auto nbTouchPoints = touchData[2] & 0x0f;
- auto xHigh = touchData[touchXHighIndex + (touchStep * i)] & 0x0f;
- auto xLow = touchData[touchXLowIndex + (touchStep * i)];
+ auto xHigh = touchData[touchXHighIndex] & 0x0f;
+ auto xLow = touchData[touchXLowIndex];
uint16_t x = (xHigh << 8) | xLow;
- auto yHigh = touchData[touchYHighIndex + (touchStep * i)] & 0x0f;
- auto yLow = touchData[touchYLowIndex + (touchStep * i)];
+ auto yHigh = touchData[touchYHighIndex] & 0x0f;
+ auto yLow = touchData[touchYLowIndex];
uint16_t y = (yHigh << 8) | yLow;
- auto action = touchData[touchEventIndex + (touchStep * i)] >> 6; /* 0 = Down, 1 = Up, 2 = contact*/
-
info.x = x;
info.y = y;
- info.action = action;
+ info.touching = (nbTouchPoints > 0);
info.gesture = static_cast<Gestures>(touchData[gestureIndex]);
return info;
}
void Cst816S::Sleep() {
- nrf_gpio_pin_clear(pinReset);
+ nrf_gpio_pin_clear(PinMap::Cst816sReset);
vTaskDelay(5);
- nrf_gpio_pin_set(pinReset);
+ nrf_gpio_pin_set(PinMap::Cst816sReset);
vTaskDelay(50);
static constexpr uint8_t sleepValue = 0x03;
twiMaster.Write(twiAddress, 0xA5, &sleepValue, 1);
@@ -88,4 +91,4 @@ void Cst816S::Sleep() {
void Cst816S::Wakeup() {
Init();
NRF_LOG_INFO("[TOUCHPANEL] Wakeup");
-} \ No newline at end of file
+}
diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h
index 14c296ea..7b46c5d5 100644
--- a/src/drivers/Cst816s.h
+++ b/src/drivers/Cst816s.h
@@ -19,12 +19,9 @@ namespace Pinetime {
struct TouchInfos {
uint16_t x = 0;
uint16_t y = 0;
- uint8_t action = 0;
- uint8_t finger = 0;
- uint8_t pressure = 0;
- uint8_t area = 0;
Gestures gesture = Gestures::None;
- bool isTouch = false;
+ bool touching = false;
+ bool isValid = true;
};
Cst816S(TwiMaster& twiMaster, uint8_t twiAddress);
@@ -39,25 +36,23 @@ namespace Pinetime {
void Wakeup();
private:
- static constexpr uint8_t pinIrq = 28;
- static constexpr uint8_t pinReset = 10;
- static constexpr uint8_t lastTouchId = 0x0f;
+ // Unused/Unavailable commented out
+ static constexpr uint8_t gestureIndex = 1;
static constexpr uint8_t touchPointNumIndex = 2;
- static constexpr uint8_t touchMiscIndex = 8;
- static constexpr uint8_t touchXYIndex = 7;
- static constexpr uint8_t touchEventIndex = 3;
+ //static constexpr uint8_t touchEventIndex = 3;
static constexpr uint8_t touchXHighIndex = 3;
static constexpr uint8_t touchXLowIndex = 4;
+ //static constexpr uint8_t touchIdIndex = 5;
static constexpr uint8_t touchYHighIndex = 5;
static constexpr uint8_t touchYLowIndex = 6;
- static constexpr uint8_t touchIdIndex = 5;
- static constexpr uint8_t touchStep = 6;
- static constexpr uint8_t gestureIndex = 1;
+ //static constexpr uint8_t touchStep = 6;
+ //static constexpr uint8_t touchXYIndex = 7;
+ //static constexpr uint8_t touchMiscIndex = 8;
- uint8_t touchData[10];
+ uint8_t touchData[7];
TwiMaster& twiMaster;
uint8_t twiAddress;
};
}
-} \ No newline at end of file
+}
diff --git a/src/drivers/PinMap.h b/src/drivers/PinMap.h
new file mode 100644
index 00000000..57964020
--- /dev/null
+++ b/src/drivers/PinMap.h
@@ -0,0 +1,38 @@
+#pragma once
+
+namespace Pinetime {
+ namespace PinMap {
+
+ #ifdef WATCH_P8
+ // COLMI P8
+ static constexpr uint8_t Charging = 19;
+ static constexpr uint8_t Cst816sReset = 13;
+ static constexpr uint8_t Button = 17;
+ #else
+ // Pinetime
+ static constexpr uint8_t Charging = 12;
+ static constexpr uint8_t Cst816sReset = 10;
+ static constexpr uint8_t Button = 13;
+ #endif
+
+ static constexpr uint8_t Cst816sIrq = 28;
+ static constexpr uint8_t PowerPresent = 19;
+
+ static constexpr uint8_t Motor = 16;
+
+ static constexpr uint8_t LcdBacklightLow = 14;
+ static constexpr uint8_t LcdBacklightMedium = 22;
+ static constexpr uint8_t LcdBacklightHigh = 23;
+
+ static constexpr uint8_t SpiSck = 2;
+ static constexpr uint8_t SpiMosi = 3;
+ static constexpr uint8_t SpiMiso = 4;
+
+ static constexpr uint8_t SpiFlashCsn = 5;
+ static constexpr uint8_t SpiLcdCsn = 25;
+ static constexpr uint8_t LcdDataCommand = 18;
+
+ static constexpr uint8_t TwiScl = 7;
+ static constexpr uint8_t TwiSda = 6;
+ }
+}
diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp
index fc9edf81..76009278 100644
--- a/src/drivers/TwiMaster.cpp
+++ b/src/drivers/TwiMaster.cpp
@@ -8,45 +8,39 @@ using namespace Pinetime::Drivers;
// TODO use shortcut to automatically send STOP when receive LastTX, for example
// TODO use DMA/IRQ
-TwiMaster::TwiMaster(const Modules module, const Parameters& params) : module {module}, params {params} {
+TwiMaster::TwiMaster(NRF_TWIM_Type* module, uint32_t frequency, uint8_t pinSda, uint8_t pinScl)
+ : module {module}, frequency {frequency}, pinSda {pinSda}, pinScl {pinScl} {
+}
+
+void TwiMaster::ConfigurePins() const {
+ NRF_GPIO->PIN_CNF[pinScl] =
+ (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) |
+ (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
+ (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) |
+ (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
+ (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
+
+ NRF_GPIO->PIN_CNF[pinSda] =
+ (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) |
+ (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
+ (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) |
+ (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
+ (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
}
void TwiMaster::Init() {
- if(mutex == nullptr)
+ if (mutex == nullptr) {
mutex = xSemaphoreCreateBinary();
-
- NRF_GPIO->PIN_CNF[params.pinScl] =
- ((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
- ((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
- ((uint32_t) GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
-
- NRF_GPIO->PIN_CNF[params.pinSda] =
- ((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
- ((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
- ((uint32_t) GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
-
- switch (module) {
- case Modules::TWIM1:
- twiBaseAddress = NRF_TWIM1;
- break;
- default:
- return;
}
- switch (static_cast<Frequencies>(params.frequency)) {
- case Frequencies::Khz100:
- twiBaseAddress->FREQUENCY = TWIM_FREQUENCY_FREQUENCY_K100;
- break;
- case Frequencies::Khz250:
- twiBaseAddress->FREQUENCY = TWIM_FREQUENCY_FREQUENCY_K250;
- break;
- case Frequencies::Khz400:
- twiBaseAddress->FREQUENCY = TWIM_FREQUENCY_FREQUENCY_K400;
- break;
- }
+ ConfigurePins();
- twiBaseAddress->PSEL.SCL = params.pinScl;
- twiBaseAddress->PSEL.SDA = params.pinSda;
+ twiBaseAddress = module;
+
+ twiBaseAddress->FREQUENCY = frequency;
+
+ twiBaseAddress->PSEL.SCL = pinScl;
+ twiBaseAddress->PSEL.SDA = pinSda;
twiBaseAddress->EVENTS_LASTRX = 0;
twiBaseAddress->EVENTS_STOPPED = 0;
twiBaseAddress->EVENTS_LASTTX = 0;
@@ -57,19 +51,15 @@ void TwiMaster::Init() {
twiBaseAddress->ENABLE = (TWIM_ENABLE_ENABLE_Enabled << TWIM_ENABLE_ENABLE_Pos);
- /* // IRQ
- NVIC_ClearPendingIRQ(_IRQn);
- NVIC_SetPriority(_IRQn, 2);
- NVIC_EnableIRQ(_IRQn);
- */
-
xSemaphoreGive(mutex);
}
TwiMaster::ErrorCodes TwiMaster::Read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* data, size_t size) {
xSemaphoreTake(mutex, portMAX_DELAY);
+ Wakeup();
auto ret = Write(deviceAddress, &registerAddress, 1, false);
ret = Read(deviceAddress, data, size, true);
+ Sleep();
xSemaphoreGive(mutex);
return ret;
}
@@ -77,9 +67,11 @@ TwiMaster::ErrorCodes TwiMaster::Read(uint8_t deviceAddress, uint8_t registerAdd
TwiMaster::ErrorCodes TwiMaster::Write(uint8_t deviceAddress, uint8_t registerAddress, const uint8_t* data, size_t size) {
ASSERT(size <= maxDataSize);
xSemaphoreTake(mutex, portMAX_DELAY);
+ Wakeup();
internalBuffer[0] = registerAddress;
std::memcpy(internalBuffer + 1, data, size);
auto ret = Write(deviceAddress, internalBuffer, size + 1, true);
+ Sleep();
xSemaphoreGive(mutex);
return ret;
}
@@ -170,17 +162,11 @@ TwiMaster::ErrorCodes TwiMaster::Write(uint8_t deviceAddress, const uint8_t* dat
}
void TwiMaster::Sleep() {
- while (twiBaseAddress->ENABLE != 0) {
- twiBaseAddress->ENABLE = (TWIM_ENABLE_ENABLE_Disabled << TWIM_ENABLE_ENABLE_Pos);
- }
- nrf_gpio_cfg_default(6);
- nrf_gpio_cfg_default(7);
- NRF_LOG_INFO("[TWIMASTER] Sleep");
+ twiBaseAddress->ENABLE = (TWIM_ENABLE_ENABLE_Disabled << TWIM_ENABLE_ENABLE_Pos);
}
void TwiMaster::Wakeup() {
- Init();
- NRF_LOG_INFO("[TWIMASTER] Wakeup");
+ twiBaseAddress->ENABLE = (TWIM_ENABLE_ENABLE_Enabled << TWIM_ENABLE_ENABLE_Pos);
}
/* Sometimes, the TWIM device just freeze and never set the event EVENTS_LASTTX.
@@ -190,20 +176,10 @@ void TwiMaster::Wakeup() {
* */
void TwiMaster::FixHwFreezed() {
NRF_LOG_INFO("I2C device frozen, reinitializing it!");
- // Disable I²C
- uint32_t twi_state = NRF_TWI1->ENABLE;
- twiBaseAddress->ENABLE = TWIM_ENABLE_ENABLE_Disabled << TWI_ENABLE_ENABLE_Pos;
- NRF_GPIO->PIN_CNF[params.pinScl] =
- ((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
- ((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) |
- ((uint32_t) GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
+ uint32_t twi_state = NRF_TWI1->ENABLE;
- NRF_GPIO->PIN_CNF[params.pinSda] =
- ((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
- ((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) |
- ((uint32_t) GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
+ Sleep();
- // Re-enable I²C
twiBaseAddress->ENABLE = twi_state;
-} \ No newline at end of file
+}
diff --git a/src/drivers/TwiMaster.h b/src/drivers/TwiMaster.h
index 6175b99b..30ac6c5f 100644
--- a/src/drivers/TwiMaster.h
+++ b/src/drivers/TwiMaster.h
@@ -8,16 +8,9 @@ namespace Pinetime {
namespace Drivers {
class TwiMaster {
public:
- enum class Modules { TWIM1 };
- enum class Frequencies { Khz100, Khz250, Khz400 };
enum class ErrorCodes { NoError, TransactionFailed };
- struct Parameters {
- uint32_t frequency;
- uint8_t pinSda;
- uint8_t pinScl;
- };
- TwiMaster(const Modules module, const Parameters& params);
+ TwiMaster(NRF_TWIM_Type* module, uint32_t frequency, uint8_t pinSda, uint8_t pinScl);
void Init();
ErrorCodes Read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, size_t size);
@@ -30,10 +23,14 @@ namespace Pinetime {
ErrorCodes Read(uint8_t deviceAddress, uint8_t* buffer, size_t size, bool stop);
ErrorCodes Write(uint8_t deviceAddress, const uint8_t* data, size_t size, bool stop);
void FixHwFreezed();
+ void ConfigurePins() const;
+
NRF_TWIM_Type* twiBaseAddress;
SemaphoreHandle_t mutex = nullptr;
- const Modules module;
- const Parameters params;
+ NRF_TWIM_Type* module;
+ uint32_t frequency;
+ uint8_t pinSda;
+ uint8_t pinScl;
static constexpr uint8_t maxDataSize {16};
static constexpr uint8_t registerSize {1};
uint8_t internalBuffer[maxDataSize + registerSize];
@@ -41,4 +38,4 @@ namespace Pinetime {
static constexpr uint32_t HwFreezedDelay {161000};
};
}
-} \ No newline at end of file
+}
diff --git a/src/main.cpp b/src/main.cpp
index d301be67..0d4ba42f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -43,7 +43,10 @@
#include "drivers/St7789.h"
#include "drivers/TwiMaster.h"
#include "drivers/Cst816s.h"
+#include "drivers/PinMap.h"
#include "systemtask/SystemTask.h"
+#include "drivers/PinMap.h"
+#include "touchhandler/TouchHandler.h"
#if NRF_LOG_ENABLED
#include "logging/NrfLogger.h"
@@ -53,14 +56,6 @@ Pinetime::Logging::NrfLogger logger;
Pinetime::Logging::DummyLogger logger;
#endif
-static constexpr uint8_t pinSpiSck = 2;
-static constexpr uint8_t pinSpiMosi = 3;
-static constexpr uint8_t pinSpiMiso = 4;
-static constexpr uint8_t pinSpiFlashCsn = 5;
-static constexpr uint8_t pinLcdCsn = 25;
-static constexpr uint8_t pinLcdDataCommand = 18;
-static constexpr uint8_t pinTwiScl = 7;
-static constexpr uint8_t pinTwiSda = 6;
static constexpr uint8_t touchPanelTwiAddress = 0x15;
static constexpr uint8_t motionSensorTwiAddress = 0x18;
static constexpr uint8_t heartRateSensorTwiAddress = 0x44;
@@ -69,34 +64,30 @@ Pinetime::Drivers::SpiMaster spi {Pinetime::Drivers::SpiMaster::SpiModule::SPI0,
{Pinetime::Drivers::SpiMaster::BitOrder::Msb_Lsb,
Pinetime::Drivers::SpiMaster::Modes::Mode3,
Pinetime::Drivers::SpiMaster::Frequencies::Freq8Mhz,
- pinSpiSck,
- pinSpiMosi,
- pinSpiMiso}};
+ Pinetime::PinMap::SpiSck,
+ Pinetime::PinMap::SpiMosi,
+ Pinetime::PinMap::SpiMiso}};
-Pinetime::Drivers::Spi lcdSpi {spi, pinLcdCsn};
-Pinetime::Drivers::St7789 lcd {lcdSpi, pinLcdDataCommand};
+Pinetime::Drivers::Spi lcdSpi {spi, Pinetime::PinMap::SpiLcdCsn};
+Pinetime::Drivers::St7789 lcd {lcdSpi, Pinetime::PinMap::LcdDataCommand};
-Pinetime::Drivers::Spi flashSpi {spi, pinSpiFlashCsn};
+Pinetime::Drivers::Spi flashSpi {spi, Pinetime::PinMap::SpiFlashCsn};
Pinetime::Drivers::SpiNorFlash spiNorFlash {flashSpi};
// The TWI device should work @ up to 400Khz but there is a HW bug which prevent it from
// respecting correct timings. According to erratas heet, this magic value makes it run
// at ~390Khz with correct timings.
static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000};
-Pinetime::Drivers::TwiMaster twiMaster {Pinetime::Drivers::TwiMaster::Modules::TWIM1,
- Pinetime::Drivers::TwiMaster::Parameters {MaxTwiFrequencyWithoutHardwareBug, pinTwiSda, pinTwiScl}};
+Pinetime::Drivers::TwiMaster twiMaster {NRF_TWIM1, MaxTwiFrequencyWithoutHardwareBug, Pinetime::PinMap::TwiSda, Pinetime::PinMap::TwiScl};
Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress};
#ifdef PINETIME_IS_RECOVERY
-static constexpr bool isFactory = true;
#include "displayapp/DummyLittleVgl.h"
#include "displayapp/DisplayAppRecovery.h"
-Pinetime::Components::LittleVgl lvgl {lcd, touchPanel};
#else
-static constexpr bool isFactory = false;
#include "displayapp/LittleVgl.h"
#include "displayapp/DisplayApp.h"
-Pinetime::Components::LittleVgl lvgl {lcd, touchPanel};
#endif
+Pinetime::Components::LittleVgl lvgl {lcd, touchPanel};
Pinetime::Drivers::Bma421 motionSensor {twiMaster, motionSensorTwiAddress};
Pinetime::Drivers::Hrs3300 heartRateSensor {twiMaster, heartRateSensorTwiAddress};
@@ -105,10 +96,8 @@ TimerHandle_t debounceTimer;
TimerHandle_t debounceChargeTimer;
Pinetime::Controllers::Battery batteryController;
Pinetime::Controllers::Ble bleController;
-void ble_manager_set_ble_connection_callback(void (*connection)());
-void ble_manager_set_ble_disconnection_callback(void (*disconnection)());
-static constexpr uint8_t pinTouchIrq = 28;
-static constexpr uint8_t pinPowerPresentIrq = 19;
+static constexpr uint8_t pinTouchIrq = Pinetime::PinMap::Cst816sIrq;
+static constexpr uint8_t pinPowerPresentIrq = Pinetime::PinMap::PowerPresent;
Pinetime::Controllers::HeartRateController heartRateController;
Pinetime::Applications::HeartRateTask heartRateApp(heartRateSensor, heartRateController);
@@ -119,6 +108,7 @@ Pinetime::Drivers::WatchdogView watchdogView(watchdog);
Pinetime::Controllers::NotificationManager notificationManager;
Pinetime::Controllers::MotionController motionController;
Pinetime::Controllers::TimerController timerController;
+Pinetime::Controllers::TouchHandler touchHandler(touchPanel, lvgl);
Pinetime::Controllers::FS fs {spiNorFlash};
Pinetime::Controllers::Settings settingsController {fs};
@@ -137,7 +127,8 @@ Pinetime::Applications::DisplayApp displayApp(lcd,
settingsController,
motorController,
motionController,
- timerController);
+ timerController,
+ touchHandler);
Pinetime::System::SystemTask systemTask(spi,
lcd,
@@ -159,17 +150,18 @@ Pinetime::System::SystemTask systemTask(spi,
heartRateController,
displayApp,
heartRateApp,
- fs);
+ fs,
+ touchHandler);
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
- if (pin == pinTouchIrq) {
+ if (pin == Pinetime::PinMap::Cst816sIrq) {
systemTask.OnTouchEvent();
return;
}
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
- if (pin == pinPowerPresentIrq and action == NRF_GPIOTE_POLARITY_TOGGLE) {
+ if (pin == Pinetime::PinMap::PowerPresent and action == NRF_GPIOTE_POLARITY_TOGGLE) {
xTimerStartFromISR(debounceChargeTimer, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
return;
@@ -302,18 +294,18 @@ int main(void) {
nrf_drv_clock_init();
// Unblock i2c?
- nrf_gpio_cfg(pinTwiScl,
+ nrf_gpio_cfg(Pinetime::PinMap::TwiScl,
NRF_GPIO_PIN_DIR_OUTPUT,
NRF_GPIO_PIN_INPUT_DISCONNECT,
NRF_GPIO_PIN_NOPULL,
NRF_GPIO_PIN_S0D1,
NRF_GPIO_PIN_NOSENSE);
- nrf_gpio_pin_set(pinTwiScl);
+ nrf_gpio_pin_set(Pinetime::PinMap::TwiScl);
for (uint8_t i = 0; i < 16; i++) {
- nrf_gpio_pin_toggle(pinTwiScl);
+ nrf_gpio_pin_toggle(Pinetime::PinMap::TwiScl);
nrf_delay_us(5);
}
- nrf_gpio_cfg_default(pinTwiScl);
+ nrf_gpio_cfg_default(Pinetime::PinMap::TwiScl);
debounceTimer = xTimerCreate("debounceTimer", 200, pdFALSE, (void*) 0, DebounceTimerCallback);
debounceChargeTimer = xTimerCreate("debounceTimerCharge", 200, pdFALSE, (void*) 0, DebounceTimerChargeCallback);
@@ -324,6 +316,7 @@ int main(void) {
lvgl.Init();
systemTask.Start();
+
nimble_port_init();
vTaskStartScheduler();
diff --git a/src/recoveryLoader.cpp b/src/recoveryLoader.cpp
index 9818179d..acec14c8 100644
--- a/src/recoveryLoader.cpp
+++ b/src/recoveryLoader.cpp
@@ -15,6 +15,7 @@
#include <components/brightness/BrightnessController.h>
#include <algorithm>
#include "recoveryImage.h"
+#include "drivers/PinMap.h"
#include "displayapp/icons/infinitime/infinitime-nb.c"
#include "components/rle/RleDecoder.h"
@@ -27,12 +28,6 @@ Pinetime::Logging::NrfLogger logger;
Pinetime::Logging::DummyLogger logger;
#endif
-static constexpr uint8_t pinSpiSck = 2;
-static constexpr uint8_t pinSpiMosi = 3;
-static constexpr uint8_t pinSpiMiso = 4;
-static constexpr uint8_t pinSpiFlashCsn = 5;
-static constexpr uint8_t pinLcdCsn = 25;
-static constexpr uint8_t pinLcdDataCommand = 18;
static constexpr uint8_t displayWidth = 240;
static constexpr uint8_t displayHeight = 240;
@@ -45,14 +40,14 @@ Pinetime::Drivers::SpiMaster spi {Pinetime::Drivers::SpiMaster::SpiModule::SPI0,
{Pinetime::Drivers::SpiMaster::BitOrder::Msb_Lsb,
Pinetime::Drivers::SpiMaster::Modes::Mode3,
Pinetime::Drivers::SpiMaster::Frequencies::Freq8Mhz,
- pinSpiSck,
- pinSpiMosi,
- pinSpiMiso}};
-Pinetime::Drivers::Spi flashSpi {spi, pinSpiFlashCsn};
+ Pinetime::PinMap::SpiSck,
+ Pinetime::PinMap::SpiMosi,
+ Pinetime::PinMap::SpiMiso}};
+Pinetime::Drivers::Spi flashSpi {spi, Pinetime::PinMap::SpiFlashCsn};
Pinetime::Drivers::SpiNorFlash spiNorFlash {flashSpi};
-Pinetime::Drivers::Spi lcdSpi {spi, pinLcdCsn};
-Pinetime::Drivers::St7789 lcd {lcdSpi, pinLcdDataCommand};
+Pinetime::Drivers::Spi lcdSpi {spi, Pinetime::PinMap::SpiLcdCsn};
+Pinetime::Drivers::St7789 lcd {lcdSpi, Pinetime::PinMap::LcdDataCommand};
Pinetime::Components::Gfx gfx {lcd};
Pinetime::Controllers::BrightnessController brightnessController;
diff --git a/src/systemtask/Messages.h b/src/systemtask/Messages.h
index 3a195e2d..ebe6a2b1 100644
--- a/src/systemtask/Messages.h
+++ b/src/systemtask/Messages.h
@@ -20,7 +20,9 @@ namespace Pinetime {
EnableSleeping,
DisableSleeping,
OnNewDay,
- OnChargingEvent
+ OnChargingEvent,
+ MeasureBatteryTimerExpired,
+ BatteryMeasurementDone,
};
}
}
diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp
index 3553f449..0cbce6b4 100644
--- a/src/systemtask/SystemTask.cpp
+++ b/src/systemtask/SystemTask.cpp
@@ -21,8 +21,10 @@
#include "drivers/SpiNorFlash.h"
#include "drivers/TwiMaster.h"
#include "drivers/Hrs3300.h"
+#include "drivers/PinMap.h"
#include "main.h"
+
#include <memory>
using namespace Pinetime::System;
@@ -47,6 +49,11 @@ void IdleTimerCallback(TimerHandle_t xTimer) {
sysTask->OnIdle();
}
+void MeasureBatteryTimerCallback(TimerHandle_t xTimer) {
+ auto* sysTask = static_cast<SystemTask*>(pvTimerGetTimerID(xTimer));
+ sysTask->PushMessage(Pinetime::System::Messages::MeasureBatteryTimerExpired);
+}
+
SystemTask::SystemTask(Drivers::SpiMaster& spi,
Drivers::St7789& lcd,
Pinetime::Drivers::SpiNorFlash& spiNorFlash,
@@ -67,7 +74,8 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi,
Pinetime::Controllers::HeartRateController& heartRateController,
Pinetime::Applications::DisplayApp& displayApp,
Pinetime::Applications::HeartRateTask& heartRateApp,
- Pinetime::Controllers::FS& fs)
+ Pinetime::Controllers::FS& fs,
+ Pinetime::Controllers::TouchHandler& touchHandler)
: spi {spi},
lcd {lcd},
spiNorFlash {spiNorFlash},
@@ -79,18 +87,18 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi,
dateTimeController {dateTimeController},
timerController {timerController},
watchdog {watchdog},
- notificationManager{notificationManager},
+ notificationManager {notificationManager},
motorController {motorController},
heartRateSensor {heartRateSensor},
motionSensor {motionSensor},
settingsController {settingsController},
- heartRateController{heartRateController},
- motionController{motionController},
- displayApp{displayApp},
+ heartRateController {heartRateController},
+ motionController {motionController},
+ displayApp {displayApp},
heartRateApp(heartRateApp),
- fs{fs},
+ fs {fs},
+ touchHandler {touchHandler},
nimbleController(*this, bleController, dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController) {
-
}
void SystemTask::Start() {
@@ -116,17 +124,17 @@ void SystemTask::Work() {
spi.Init();
spiNorFlash.Init();
spiNorFlash.Wakeup();
-
+
fs.Init();
nimbleController.Init();
- nimbleController.StartAdvertising();
lcd.Init();
twiMaster.Init();
touchPanel.Init();
dateTimeController.Register(this);
- batteryController.Init();
+ batteryController.Register(this);
+ batteryController.Update();
motorController.Init();
motionSensor.SoftReset();
timerController.Register(this);
@@ -143,13 +151,11 @@ void SystemTask::Work() {
displayApp.Register(this);
displayApp.Start();
- displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel);
-
heartRateSensor.Init();
heartRateSensor.Disable();
heartRateApp.Start();
- nrf_gpio_cfg_sense_input(pinButton, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_High);
+ nrf_gpio_cfg_sense_input(PinMap::Button, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_High);
nrf_gpio_cfg_output(15);
nrf_gpio_pin_set(15);
@@ -160,9 +166,9 @@ void SystemTask::Work() {
pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_HITOLO;
pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown;
- nrfx_gpiote_in_init(pinButton, &pinConfig, nrfx_gpiote_evt_handler);
+ nrfx_gpiote_in_init(PinMap::Button, &pinConfig, nrfx_gpiote_evt_handler);
- nrf_gpio_cfg_sense_input(pinTouchIrq, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_Low);
+ nrf_gpio_cfg_sense_input(PinMap::Cst816sIrq, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_Low);
pinConfig.skip_gpio_setup = true;
pinConfig.hi_accuracy = false;
@@ -170,24 +176,26 @@ void SystemTask::Work() {
pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_HITOLO;
pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup;
- nrfx_gpiote_in_init(pinTouchIrq, &pinConfig, nrfx_gpiote_evt_handler);
+ nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler);
pinConfig.sense = NRF_GPIOTE_POLARITY_TOGGLE;
pinConfig.pull = NRF_GPIO_PIN_NOPULL;
pinConfig.is_watcher = false;
pinConfig.hi_accuracy = false;
pinConfig.skip_gpio_setup = true;
- nrfx_gpiote_in_init(pinPowerPresentIrq, &pinConfig, nrfx_gpiote_evt_handler);
+ nrfx_gpiote_in_init(PinMap::PowerPresent, &pinConfig, nrfx_gpiote_evt_handler);
- if (nrf_gpio_pin_read(pinPowerPresentIrq)) {
- nrf_gpio_cfg_sense_input(pinPowerPresentIrq, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
+ if (nrf_gpio_pin_read(PinMap::PowerPresent)) {
+ nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
} else {
- nrf_gpio_cfg_sense_input(pinPowerPresentIrq, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
+ nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
}
idleTimer = xTimerCreate("idleTimer", pdMS_TO_TICKS(2000), pdFALSE, this, IdleTimerCallback);
dimTimer = xTimerCreate("dimTimer", pdMS_TO_TICKS(settingsController.GetScreenTimeOut() - 2000), pdFALSE, this, DimTimerCallback);
+ measureBatteryTimer = xTimerCreate("measureBattery", batteryMeasurementPeriod, pdTRUE, this, MeasureBatteryTimerCallback);
xTimerStart(dimTimer, 0);
+ xTimerStart(measureBatteryTimer, portMAX_DELAY);
// Suppress endless loop diagnostic
#pragma clang diagnostic push
@@ -197,11 +205,6 @@ void SystemTask::Work() {
uint8_t msg;
if (xQueueReceive(systemTasksMsgQueue, &msg, 100)) {
-
- batteryController.Update();
- // the battery does not emit events when changing charge levels, so we piggyback
- // on any system event to read and update the current values
-
Messages message = static_cast<Messages>(msg);
switch (message) {
case Messages::EnableSleeping:
@@ -219,35 +222,35 @@ void SystemTask::Work() {
break;
case Messages::GoToRunning:
spi.Wakeup();
- twiMaster.Wakeup();
// Double Tap needs the touch screen to be in normal mode
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
touchPanel.Wakeup();
}
- nimbleController.StartAdvertising();
xTimerStart(dimTimer, 0);
spiNorFlash.Wakeup();
lcd.Wakeup();
displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToRunning);
- displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel);
heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::WakeUp);
+ if (!bleController.IsConnected())
+ nimbleController.RestartFastAdv();
+
isSleeping = false;
isWakingUp = false;
isDimmed = false;
break;
case Messages::TouchWakeUp: {
- twiMaster.Wakeup();
- auto touchInfo = touchPanel.GetTouchInfo();
- twiMaster.Sleep();
- if (touchInfo.isTouch and ((touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap and
- settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) or
- (touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::SingleTap and
- settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
- GoToRunning();
+ if(touchHandler.GetNewTouchInfo()) {
+ auto gesture = touchHandler.GestureGet();
+ if (gesture != Pinetime::Drivers::Cst816S::Gestures::None and ((gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap and
+ settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) or
+ (gesture == Pinetime::Drivers::Cst816S::Gestures::SingleTap and
+ settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
+ GoToRunning();
+ }
}
} break;
case Messages::GoToSleep:
@@ -294,6 +297,9 @@ void SystemTask::Work() {
xTimerStart(dimTimer, 0);
break;
case Messages::OnTouchEvent:
+ if (touchHandler.GetNewTouchInfo()) {
+ touchHandler.UpdateLvglTouchPoint();
+ }
ReloadIdleTimer();
displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
break;
@@ -314,7 +320,6 @@ void SystemTask::Work() {
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
touchPanel.Sleep();
}
- twiMaster.Sleep();
isSleeping = true;
isGoingToSleep = false;
@@ -325,8 +330,18 @@ void SystemTask::Work() {
stepCounterMustBeReset = true;
break;
case Messages::OnChargingEvent:
+ batteryController.Update();
motorController.RunForDuration(15);
- // Battery level is updated on every message - there's no need to do anything
+ break;
+ case Messages::MeasureBatteryTimerExpired:
+ sendBatteryNotification = true;
+ batteryController.Update();
+ break;
+ case Messages::BatteryMeasurementDone:
+ if (sendBatteryNotification) {
+ sendBatteryNotification = false;
+ nimbleController.NotifyBatteryLevel(batteryController.PercentRemaining());
+ }
break;
default:
@@ -338,22 +353,17 @@ void SystemTask::Work() {
if (bleDiscoveryTimer == 0) {
isBleDiscoveryTimerRunning = false;
// Services discovery is deffered from 3 seconds to avoid the conflicts between the host communicating with the
- // tharget and vice-versa. I'm not sure if this is the right way to handle this...
+ // target and vice-versa. I'm not sure if this is the right way to handle this...
nimbleController.StartDiscovery();
} else {
bleDiscoveryTimer--;
}
}
- if (xTaskGetTickCount() - batteryNotificationTick > batteryNotificationPeriod) {
- nimbleController.NotifyBatteryLevel(batteryController.PercentRemaining());
- batteryNotificationTick = xTaskGetTickCount();
- }
-
monitor.Process();
uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG);
dateTimeController.UpdateTime(systick_counter);
- if (!nrf_gpio_pin_read(pinButton))
+ if (!nrf_gpio_pin_read(PinMap::Button))
watchdog.Kick();
}
// Clear diagnostic suppression
@@ -366,17 +376,12 @@ void SystemTask::UpdateMotion() {
if (isSleeping && !settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist))
return;
- if (isSleeping)
- twiMaster.Wakeup();
-
if (stepCounterMustBeReset) {
motionSensor.ResetStepCounter();
stepCounterMustBeReset = false;
}
auto motionValues = motionSensor.Process();
- if (isSleeping)
- twiMaster.Sleep();
motionController.IsSensorOk(motionSensor.IsOk());
motionController.Update(motionValues.x, motionValues.y, motionValues.z, motionValues.steps);
@@ -424,14 +429,13 @@ void SystemTask::PushMessage(System::Messages msg) {
isGoingToSleep = true;
}
- if(in_isr()) {
+ if (in_isr()) {
BaseType_t xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(systemTasksMsgQueue, &msg, &xHigherPriorityTaskWoken);
if (xHigherPriorityTaskWoken) {
/* Actual macro used here is port specific. */
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
-
}
} else {
xQueueSend(systemTasksMsgQueue, &msg, portMAX_DELAY);
diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h
index ba434298..1f8be75f 100644
--- a/src/systemtask/SystemTask.h
+++ b/src/systemtask/SystemTask.h
@@ -8,6 +8,7 @@
#include <heartratetask/HeartRateTask.h>
#include <components/settings/Settings.h>
#include <drivers/Bma421.h>
+#include <drivers/PinMap.h>
#include <components/motion/MotionController.h>
#include "SystemMonitor.h"
@@ -17,6 +18,7 @@
#include "components/motor/MotorController.h"
#include "components/timer/TimerController.h"
#include "components/fs/FS.h"
+#include "touchhandler/TouchHandler.h"
#ifdef PINETIME_IS_RECOVERY
#include "displayapp/DisplayAppRecovery.h"
@@ -24,7 +26,7 @@
#else
#include "components/settings/Settings.h"
#include "displayapp/DisplayApp.h"
- #include "displayapp/LittleVgl.h"
+ #include "displayapp/LittleVgl.h"
#endif
#include "drivers/Watchdog.h"
@@ -39,6 +41,9 @@ namespace Pinetime {
class TwiMaster;
class Hrs3300;
}
+ namespace Controllers {
+ class TouchHandler;
+ }
namespace System {
class SystemTask {
public:
@@ -62,7 +67,8 @@ namespace Pinetime {
Pinetime::Controllers::HeartRateController& heartRateController,
Pinetime::Applications::DisplayApp& displayApp,
Pinetime::Applications::HeartRateTask& heartRateApp,
- Pinetime::Controllers::FS& fs);
+ Pinetime::Controllers::FS& fs,
+ Pinetime::Controllers::TouchHandler& touchHandler);
void Start();
void PushMessage(Messages msg);
@@ -92,7 +98,6 @@ namespace Pinetime {
Pinetime::Components::LittleVgl& lvgl;
Pinetime::Controllers::Battery& batteryController;
-
Pinetime::Controllers::Ble& bleController;
Pinetime::Controllers::DateTime& dateTimeController;
Pinetime::Controllers::TimerController& timerController;
@@ -113,17 +118,9 @@ namespace Pinetime {
Pinetime::Applications::DisplayApp& displayApp;
Pinetime::Applications::HeartRateTask& heartRateApp;
Pinetime::Controllers::FS& fs;
+ Pinetime::Controllers::TouchHandler& touchHandler;
Pinetime::Controllers::NimbleController nimbleController;
- static constexpr uint8_t pinSpiSck = 2;
- static constexpr uint8_t pinSpiMosi = 3;
- static constexpr uint8_t pinSpiMiso = 4;
- static constexpr uint8_t pinSpiCsn = 25;
- static constexpr uint8_t pinLcdDataCommand = 18;
- static constexpr uint8_t pinButton = 13;
- static constexpr uint8_t pinTouchIrq = 28;
- static constexpr uint8_t pinPowerPresentIrq = 19;
-
static void Process(void* instance);
void Work();
void ReloadIdleTimer();
@@ -131,13 +128,15 @@ namespace Pinetime {
uint8_t bleDiscoveryTimer = 0;
TimerHandle_t dimTimer;
TimerHandle_t idleTimer;
+ TimerHandle_t measureBatteryTimer;
+ bool sendBatteryNotification = false;
bool doNotGoToSleep = false;
void GoToRunning();
void UpdateMotion();
bool stepCounterMustBeReset = false;
- static constexpr TickType_t batteryNotificationPeriod = 1000 * 60 * 10; // 1 tick ~= 1ms. 1ms * 60 * 10 = 10 minutes
- TickType_t batteryNotificationTick = 0;
+ static constexpr TickType_t batteryMeasurementPeriod = pdMS_TO_TICKS(10 * 60 * 1000);
+ TickType_t lastBatteryNotificationTime = 0;
#if configUSE_TRACE_FACILITY == 1
SystemMonitor<FreeRtosMonitor> monitor;
diff --git a/src/touchhandler/TouchHandler.cpp b/src/touchhandler/TouchHandler.cpp
new file mode 100644
index 00000000..735b311a
--- /dev/null
+++ b/src/touchhandler/TouchHandler.cpp
@@ -0,0 +1,65 @@
+#include "TouchHandler.h"
+
+using namespace Pinetime::Controllers;
+
+TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel, Components::LittleVgl& lvgl) : touchPanel {touchPanel}, lvgl {lvgl} {
+}
+
+void TouchHandler::CancelTap() {
+ if (info.touching) {
+ isCancelled = true;
+ lvgl.SetNewTouchPoint(-1, -1, true);
+ }
+}
+
+Pinetime::Drivers::Cst816S::Gestures TouchHandler::GestureGet() {
+ auto returnGesture = gesture;
+ gesture = Drivers::Cst816S::Gestures::None;
+ return returnGesture;
+}
+
+bool TouchHandler::GetNewTouchInfo() {
+ info = touchPanel.GetTouchInfo();
+
+ if (!info.isValid) {
+ return false;
+ }
+
+ if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) {
+ if (gestureReleased) {
+ if (info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideDown ||
+ info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideLeft ||
+ info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideUp ||
+ info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideRight ||
+ info.gesture == Pinetime::Drivers::Cst816S::Gestures::LongPress) {
+ if (info.touching) {
+ gesture = info.gesture;
+ gestureReleased = false;
+ }
+ } else {
+ gesture = info.gesture;
+ }
+ }
+ }
+
+ if (!info.touching) {
+ gestureReleased = true;
+ }
+
+ return true;
+}
+
+void TouchHandler::UpdateLvglTouchPoint() {
+ if (info.touching) {
+ if (!isCancelled) {
+ lvgl.SetNewTouchPoint(info.x, info.y, true);
+ }
+ } else {
+ if (isCancelled) {
+ lvgl.SetNewTouchPoint(-1, -1, false);
+ isCancelled = false;
+ } else {
+ lvgl.SetNewTouchPoint(info.x, info.y, false);
+ }
+ }
+}
diff --git a/src/touchhandler/TouchHandler.h b/src/touchhandler/TouchHandler.h
new file mode 100644
index 00000000..f5442939
--- /dev/null
+++ b/src/touchhandler/TouchHandler.h
@@ -0,0 +1,45 @@
+#pragma once
+#include "drivers/Cst816s.h"
+#include "systemtask/SystemTask.h"
+#include <FreeRTOS.h>
+#include <task.h>
+
+namespace Pinetime {
+ namespace Components {
+ class LittleVgl;
+ }
+ namespace Drivers {
+ class Cst816S;
+ }
+ namespace System {
+ class SystemTask;
+ }
+ namespace Controllers {
+ class TouchHandler {
+ public:
+ explicit TouchHandler(Drivers::Cst816S&, Components::LittleVgl&);
+ void CancelTap();
+ bool GetNewTouchInfo();
+ void UpdateLvglTouchPoint();
+
+ bool IsTouching() const {
+ return info.touching;
+ }
+ uint8_t GetX() const {
+ return info.x;
+ }
+ uint8_t GetY() const {
+ return info.y;
+ }
+ Drivers::Cst816S::Gestures GestureGet();
+ private:
+
+ Pinetime::Drivers::Cst816S::TouchInfos info;
+ Pinetime::Drivers::Cst816S& touchPanel;
+ Pinetime::Components::LittleVgl& lvgl;
+ Pinetime::Drivers::Cst816S::Gestures gesture;
+ bool isCancelled = false;
+ bool gestureReleased = true;
+ };
+ }
+}