From 378fa6b4016b65e2d7b128fdc3ce89c4ca779a4d Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Tue, 18 May 2021 15:23:26 +0200 Subject: Reset --- .clang-tidy | 6 +- CMakeLists.txt | 12 - README.md | 3 +- doc/buildAndProgram.md | 3 +- doc/contribute.md | 24 +- doc/gettingStarted/appmenu-071.jpg | Bin 109376 -> 0 bytes doc/gettingStarted/appmenu.jpg | Bin 120674 -> 0 bytes doc/gettingStarted/bootloader-1.0.jpg | Bin 160275 -> 0 bytes doc/gettingStarted/gettingStarted-1.0.md | 112 --------- doc/gettingStarted/oldbootloaderlogo.jpg | Bin 116236 -> 0 bytes doc/gettingStarted/ota-gadgetbridge-nrfconnect.md | 101 -------- doc/gettingStarted/quickactions.jpg | Bin 114900 -> 0 bytes doc/gettingStarted/settings.jpg | Bin 130022 -> 0 bytes doc/gettingStarted/version-071.jpg | Bin 111556 -> 0 bytes doc/gettingStarted/version-1.0.jpg | Bin 116881 -> 0 bytes docker/.gitpod.Dockerfile | 3 - docker/Dockerfile | 3 - src/CMakeLists.txt | 5 +- src/Version.h.in | 2 - src/components/motion/MotionController.h | 6 +- src/components/settings/Settings.h | 10 +- src/displayapp/Apps.h | 4 +- src/displayapp/DisplayApp.cpp | 53 ++--- src/displayapp/DisplayApp.h | 2 +- src/displayapp/DisplayAppRecovery.cpp | 7 +- src/displayapp/fonts/jetbrains_mono_42.c | 258 --------------------- src/displayapp/screens/ApplicationList.cpp | 4 +- src/displayapp/screens/Clock.cpp | 16 +- src/displayapp/screens/Clock.h | 3 +- src/displayapp/screens/FirmwareValidation.cpp | 11 - src/displayapp/screens/FirmwareValidation.h | 3 - src/displayapp/screens/Motion.cpp | 19 +- src/displayapp/screens/Motion.h | 2 +- src/displayapp/screens/Notifications.cpp | 10 - src/displayapp/screens/Steps.cpp | 72 ------ src/displayapp/screens/Steps.h | 39 ---- src/displayapp/screens/StopWatch.cpp | 3 +- src/displayapp/screens/SystemInfo.cpp | 8 +- src/displayapp/screens/settings/SettingSteps.cpp | 98 -------- src/displayapp/screens/settings/SettingSteps.h | 32 --- .../screens/settings/SettingWatchFace.cpp | 11 +- src/displayapp/screens/settings/SettingWatchFace.h | 2 +- src/displayapp/screens/settings/Settings.cpp | 10 +- src/libs/lv_conf.h | 4 +- src/logging/NrfLogger.cpp | 5 +- 45 files changed, 101 insertions(+), 865 deletions(-) delete mode 100644 doc/gettingStarted/appmenu-071.jpg delete mode 100644 doc/gettingStarted/appmenu.jpg delete mode 100644 doc/gettingStarted/bootloader-1.0.jpg delete mode 100644 doc/gettingStarted/gettingStarted-1.0.md delete mode 100644 doc/gettingStarted/oldbootloaderlogo.jpg delete mode 100644 doc/gettingStarted/ota-gadgetbridge-nrfconnect.md delete mode 100644 doc/gettingStarted/quickactions.jpg delete mode 100644 doc/gettingStarted/settings.jpg delete mode 100644 doc/gettingStarted/version-071.jpg delete mode 100644 doc/gettingStarted/version-1.0.jpg delete mode 100644 src/displayapp/fonts/jetbrains_mono_42.c delete mode 100644 src/displayapp/screens/Steps.cpp delete mode 100644 src/displayapp/screens/Steps.h delete mode 100644 src/displayapp/screens/settings/SettingSteps.cpp delete mode 100644 src/displayapp/screens/settings/SettingSteps.h diff --git a/.clang-tidy b/.clang-tidy index 8a7d38f0..d6036802 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -22,9 +22,5 @@ Checks: '*, -hicpp-no-assembler, -hicpp-avoid-c-arrays, -hicpp-uppercase-literal-suffix, - -hicpp-no-array-decay, -cert-err58-cpp, - -cert-err60-cpp' -CheckOptions: - - key: readability-function-cognitive-complexity.Threshold - value: 100 \ No newline at end of file + -cert-err60-cpp' \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c529f39..f7770136 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,22 +55,10 @@ if(BUILD_DFU) set(BUILD_DFU true) endif() -set(PROJECT_GIT_COMMIT_HASH "") - -execute_process(COMMAND git rev-parse --short HEAD - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE PROJECT_GIT_COMMIT_HASH - RESULT_VARIABLE PROJECT_GIT_COMMIT_HASH_SUCCESS) - -string(STRIP ${PROJECT_GIT_COMMIT_HASH} PROJECT_GIT_COMMIT_HASH) - -message("PROJECT_GIT_COMMIT_HASH_SUCCESS? " ${PROJECT_GIT_COMMIT_HASH_SUCCESS}) - message("BUILD CONFIGURATION") message("-------------------") message(" * Version : " ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) message(" * Toolchain : " ${ARM_NONE_EABI_TOOLCHAIN_PATH}) -message(" * GitRef(S) : " ${PROJECT_GIT_COMMIT_HASH}) message(" * NRF52 SDK : " ${NRF5_SDK_PATH}) set(PROGRAMMER "???") if(USE_JLINK) diff --git a/README.md b/README.md index 396d7462..34f6e841 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,7 @@ As of now, here is the list of achievements of this project: ## 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) + - [Flash, upgrade (OTA), time synchronization,...](doc/gettingStarted/gettingStarted.md) ### Develop - [Generate the fonts and symbols](src/displayapp/fonts/README.md) diff --git a/doc/buildAndProgram.md b/doc/buildAndProgram.md index afd526e0..b70bdfc0 100644 --- a/doc/buildAndProgram.md +++ b/doc/buildAndProgram.md @@ -3,7 +3,6 @@ To build this project, you'll need: - A cross-compiler : [ARM-GCC (9-2020-q2-update)](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads/9-2020-q2-update) - The NRF52 SDK 15.3.0 : [nRF-SDK v15.3.0](https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip) - - The `cbor` and `intelhex` modules for Python 3 - A reasonably recent version of CMake (I use 3.16.5) ## Build steps @@ -222,4 +221,4 @@ Loading section .sec6, size 0x10000 lma 0x30000 Loading section .sec7, size 0xdf08 lma 0x40000 Start address 0x0, load size 314200 Transfer rate: 45 KB/sec, 969 bytes/write. -``` +``` \ No newline at end of file diff --git a/doc/contribute.md b/doc/contribute.md index 09d20774..7958eea1 100644 --- a/doc/contribute.md +++ b/doc/contribute.md @@ -2,13 +2,13 @@ ## Report bugs You use your Pinetime and find a bug in the firmware? [Create an issue on Github](https://github.com/JF002/InfiniTime/issues) explaining the bug, how to reproduce it, the version of the firmware you use... ## Write and improve documentation -Documentation might be incomplete, or not clear enough, and it is always possible to improve it with better wording, pictures, photo, video,... +Documentation might be incomplete, or not clear enough, and it is always possible to improve it with better wording, pictures, photo, video,... As the documentation is part of the source code, you can submit your improvements to the documentation by submitting a pull request (see below). ## Fix bugs, add functionalities and improve the code You want to fix a bug, add a cool new functionality or improve the code? See *How to submit a pull request below*. ## Spread the word -The Pinetime is a cool open source project that deserves to be known. Talk about it around you, on social networks, on your blog,... and let people know that we are working on an open-source firmware for a smartwatch! +Pinetime is a cool open source project that deserves to be know. Talk about it around you, on social networks, on your blog,... and let people know that we are working on an open-source firmware for a smartwatch! # How to submit a pull request ? @@ -21,28 +21,28 @@ The Pinetime is a cool open source project that deserves to be known. Talk about - Write documentation related to your new feature is applicable; - Create the pull-request and write a great description about it : what does your PR do, why, how,... Add pictures and video if possible; - Wait for someone to review your PR and take part in the review process; - - Your PR will eventually be merged :) + - You PR will eventually be merged :) -Your contribution is more than welcome! +Your contribution is more than welcome! If you want to fix a bug, add a functionality or improve the code, you'll first need to create a branch from the **develop** branch (see [this page about the branching model](./branches.md)). This branch is called a feature branch, and you should choose a name that explains what you are working on (ex: "add-doc-about-contributions"). In this branch, **focus on only one topic, bug or feature**. For example, if you created this branch to work on the UI of a specific application, do not commit modifications about the SPI driver. If you want to work on multiple topics, create one branch per topic. When your feature branch is ready, **make sure it actually works** and **do not forget to write documentation** about it if it's relevant. -I **strongly discourage to create a PR containing modifications that haven't been tested**. If, for any reason, you cannot test your modifications but want to publish them anyway, **please mention it in the description**. This way, other contributors might be willing to test it and provide feedback about your code. +I **strongly discourage to create a PR containing modifications that haven't been tested**. If, for any reason, you cannot test your modifications but want to publish them anyway, **please mention it in the description**. This way, other contributors might be willing to test it and provide feedbacks about your code. Also, before submitting your PR, check the coding style of your code against the **coding conventions** detailed below. This project also provides [clang-format](../.clang-format) and [clang-tidy](../.clang-tidy) configuration files. You can use them to ensure correct formatting of your code. Do not forget to check the files you are going to commit and remove those who are not necessary (config files from your IDE, for example). Remove old comments, commented code,... -Then, you can submit a pull-request for review. Try to **describe your pull request as much as possible**: what did you do in this branch, how does it work, how is it designed, are there any limitations,... This will help the contributors to understand and review your code easily. You can add pictures and video to the description so that contributors will have a quick overview of your work. +Then, you can submit a pull-request for review. Try to **describe your pull request as much as possible**: what did you do in this branch, how does it work, how is it designed, are there any limitations,... This will help the contributors to understand and review your code easily. You can add pictures and video to the description so that contributors will have a quick overview of you work. -Other contributors can post comments about the pull request, maybe ask for more info or adjustments in the code. +Other contributors can post comments about the pull request, maybe ask for more info or adjustements in the code. -Once the pull request is reviewed and accepted, it'll be merge in **develop** and will be released in the next release version of the firmware. +Once the pull request is reviewed an accepted, it'll be merge in **develop** and will be released in the next release version of the firmware. ## Why all these rules? -Reviewing pull-requests is a **very time consuming task** for the creator of this project ([JF002](https://github.com/JF002)) and for other contributors who take the time to review them. Every little thing you do to make their lives easier will **increase the chances your PR will be merge quickly**. +Reviewing pull-requests is a **very time consuming task** for the creator of this project ([JF002](https://github.com/JF002)) and for other contributors who take the time to review them. Every little thing you do to make their lifes easier will **increase the chances your PR will be merge quickly**. When reviewing PR, the author and contributors will first look at the **description**. If it's easy to understand what the PR does, why the modification is needed or interesting and how it's done, a good part of the work is already done : we understand the PR and its context. @@ -58,12 +58,12 @@ It's totally normal for a PR to need some more work even after it was created, t ## Language The language of this project is **C++**, and all new code must be written in C++. (Modern) C++ provides a lot of useful tools and functionalities that are beneficial for embedded software development like `constexpr`, `template` and anything that provides zero-cost abstraction. -It's OK to include C code if this code comes from another library like FreeRTOS, NimBLE, LVGL or the NRF-SDK. +It's OK to include C code if this code comes from another library like FreeRTOS, NimBLE, LVGL or the NRF-SDK. ## Coding style -The most important rule to follow is to try to keep the code as easy to read and maintain as possible. +The most important rule to follow is to try to keep the code as easy to read and maintain as possible. - - **Indentation** : 2 spaces, no tabulation + - **Identation** : 2 spaces, no tabulation - **Opening brace** at the end of the line - **Naming** : Choose self-describing variable name - **class** : PascalCase diff --git a/doc/gettingStarted/appmenu-071.jpg b/doc/gettingStarted/appmenu-071.jpg deleted file mode 100644 index dee7c8f6..00000000 Binary files a/doc/gettingStarted/appmenu-071.jpg and /dev/null differ diff --git a/doc/gettingStarted/appmenu.jpg b/doc/gettingStarted/appmenu.jpg deleted file mode 100644 index 1e52fe78..00000000 Binary files a/doc/gettingStarted/appmenu.jpg and /dev/null differ diff --git a/doc/gettingStarted/bootloader-1.0.jpg b/doc/gettingStarted/bootloader-1.0.jpg deleted file mode 100644 index 7b639184..00000000 Binary files a/doc/gettingStarted/bootloader-1.0.jpg and /dev/null differ diff --git a/doc/gettingStarted/gettingStarted-1.0.md b/doc/gettingStarted/gettingStarted-1.0.md deleted file mode 100644 index 2ac22b97..00000000 --- a/doc/gettingStarted/gettingStarted-1.0.md +++ /dev/null @@ -1,112 +0,0 @@ -# Getting started with InfiniTime 1.0 -On April 22 2021, InfiniTime and Pine64 [announced the release of InfiniTime 1.0](https://www.pine64.org/2021/04/22/its-time-infinitime-1-0/) and the availability of PineTime smartwatches as *enthusiast grade end-user product*. This page aims to guide you with your first step with your new PineTime. - -## Firmware, InfiniTime, Bootloader, Recovery firmware, OTA, DFU... What is it? -You might have already seen these words by reading the announcement, release notes, or [the wiki guide](https://wiki.pine64.org/wiki/Upgrade_PineTime_to_InfiniTime_1.0.0) and, you may find them misleading if you're not familiar with the project. - -Basically, a **firmware** is just a software running on the embedded hardware of a device, the PineTime in this case. -**InfiniTime** is based on 3 distinct **firmwares**: - - **[InfiniTime](https://github.com/JF002/InfiniTime)** itself, this is the *application firmware* running on the PineTime. This is the main firmware which provides most of the functionalities you'll use on a daily basis : bluetooth low-energy (BLE) connectivity, applications, watchfaces,... - - **[The bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader)** is responsible for safely applying **updates** of the *application firmware*, reverting them in case of issues and load the recovery firmware when requested. - - **The recovery firmware** is a specific *application firmware* than can be loaded by the bootloader on user request. This firmware can be useful in case of serious issue, when the main application firmware cannot perform an OTA update correctly. Currently, this recovery firmware is based on [InfiniTime 0.14.1](https://github.com/JF002/InfiniTime/releases/tag/0.14.1). - -**OTA** and **DFU** refer to the update of the firmware over BLE (**B**luetooth **L**ow **E**nergy). **OTA** means **O**ver **T**he **A**ir, this is a functionality that allows the user to update the firmware how their device using a wireless communication like BLE. When we talk about **DFU** (**D**igital **F**irmware **U**pdate), we refer to the file format and protocol used to send the update of the firmware to the watch over-the-air. InfiniTime implement the (legacy) DFU protocol from Nordic Semiconductor (NRF). - -## How to check the version of InfiniTime and the bootloader? -Since September 2020, all PineTimes (devkits or sealed) are flashed using the **[first iteration of the bootloader](https://github.com/lupyuen/pinetime-rust-mynewt/releases/tag/v4.1.7)** and **[InfiniTime 0.7.1](https://github.com/JF002/InfiniTime/releases/tag/0.7.1)**. There was no recovery firmware at that time. - -The bootloader only runs when the watch starts (from an empty battery, for example) or after a reset (after a succesful OTA or a manual reset - long push on the button). - -You can recognize this first iteration of the bootloader with it greenish **PINETIME** logo. - -![Old bootloader logo](oldbootloaderlogo.jpg) - -You can check the version of InfiniTime by opening the app *SystemInfo*. For version < 1.0: - -![InfiniTime 0.7.1 Application menu](appmenu-071.jpg) -![InfiniTime 0.7.1 version](version-071.jpg) - -And for version >= 1.0 : - -![InfiniTime 1.0 version](version-1.0.jpg) - - -PineTime shipped from June 2020 (to be confirmed) will be flashed with the [new version of the bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader/releases/tag/1.0.0), the [recovery firmware](https://github.com/JF002/InfiniTime/releases/tag/0.14.1) and [InfiniTime 1.0](https://github.com/JF002/InfiniTime/releases/tag/1.0.0). - -The bootloader is easily recognizable with it white pine cone that is progressively drawn in green. It also displays its own version on the bottom (1.0.0 as of now). - -![Bootloader 1.0](bootloader-1.0.jpg) - -## How to update your PineTime? -To update your PineTime, you can use one of the compatible companion applications. Here are the main ones: - - - **[Amazfish](https://github.com/piggz/harbour-amazfish)** (Desktop Linux, mobile Linux, SailfishOS, runs on the PinebookPro and the Pinephone) - - **[Gadgetbridge](https://www.gadgetbridge.org/)** (Android) - - **[Siglo](https://github.com/alexr4535/siglo)** (Linux, GTK based) - - **NRFConnect** (closed source, Android & iOS). - -See [this page](ota-gadgetbridge-nrfconnect.md) for more info about the OTA procedure using Gadgetbrige and NRFCOnnect. - -### From InfiniTime 0.7.1 / old bootloader -If your PineTime is currently running InfiniTime 0.7.1 and the old bootloader, we strongly recommend you update them to more recent version (Bootloader 1.0.0 and InfiniTime 1.0.0 as of now). We also recommend you install the recovery firmware once the bootloader is up-do-date. - -Using the companion app of your choice, you'll need to apply the OTA procedure for these 3 firmwares in this sequence (failing to follow this specific order might temporarily or permanently brick your device): - - 1. Flash the latest version of InfiniTime. The file to upload is named **pinetime-mcuboot-app-dfu-x.y.z.zip**. Here is the link to [InfiniTime 1.0](https://github.com/JF002/InfiniTime/releases/download/1.0.0/pinetime-mcuboot-app-dfu-1.0.0.zip). - 2. Update the bootloader by applying the OTA procedure with the file named [**reloader-mcuboot.zip** from the repo of the bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader/releases/download/1.0.0/reloader-mcuboot.zip). - 3. Install the recovery firmware by applying the OTA procedure with the file named [**pinetime-mcuboot-recovery-loader-dfu-0.14.1.zip** from the version 0.14.1 of InfiniTime](https://github.com/JF002/InfiniTime/releases/download/0.14.1/pinetime-mcuboot-recovery-loader-dfu-0.14.1.zip). - -You'll find more info about this process in [this wiki page](https://wiki.pine64.org/wiki/Upgrade_PineTime_to_InfiniTime_1.0.0). You can also see the procedure in video [here](https://video.codingfield.com/videos/watch/831077c5-16f3-47b4-9b2b-c4bbfecc6529) and [here (from Amazfish)](https://video.codingfield.com/videos/watch/f7bffb3d-a6a1-43c4-8f01-f4aeff4adf9e) - -### From version > 1.0 -If you are already running the new "1.0.0" bootloader, all you have to do is update your version of InfiniTime when it'll be available. We'll write specific instructions when (if) we release a new version of the bootloader. - -### Firmware validation -The bootloader requires a (manual) validation of the firmware. If the watch reset with an updated firmware that was not validated, the bootloader will consider it as non-functionning and will revert to the previous version of the firmware. This is a safety feature to prevent bricking your device with a faulty firmware. - -You can validate your updated firmware on InfiniTime >= 1.0 by following this simple procedure: - - - From the watchface, swipe **right** to display the *Quick Actions menu* - - Open the **Settings** app by tapping the *gear* icon on the bottom right - - Swipe down and tap on the entry named **Firmware** - - This app shows the version that is currently running. If it's not validated yet, it displays 2 buttons: - - **Validate** to validate your firmware - - **Reset** to reset the watch and revert to the previously running version of the firmware - -## InfiniTime 1.0 quick user guide -### Setting the time -By default, InfiniTime starts on the digital watchface. It'll probably display the epoch time (1 Jan 1970, 00:00). The time will be automatically synchronized once you connect on of the companion app to your PineTime using BLE connectivity. InfiniTime does not provide any way to manually set the time for now. - -### Navigation in the menu - -![Quick actions](quickactions.jpg) -![Settings](settings.jpg) -![Application menu](appmenu.jpg) - - - Swipe **down** to display the notification panel. Notification sent by your companion app will be displayed in this panel. - - Swipe **up** to display the application menus. Apps (stopwatch, music, step, games,...) can be started from this menu. - - Swipe **right** to display the Quick Actions menu. This menu allows you to - - Set the brightness of the display - - Start the **flashlight** app - - Enable/disable vibrations on notifications (Do Not Disturb mode) - - Enter the **settings** menu - - Settings - - Display timeout - - Wake up event (Tap, wrist rotation) - - Time format (12/24H) - - Default watchface (digital / analog) - - Battery info - - Firmware validation - - About (system info, firmware version,...) - -### Bootloader - -Most of the time, the bootloader just runs without your intervention (update and load the firmware). - -However, you can enable 2 functionalities using the push button: - - - Push the button until the pine cone is drawn in **blue** to force the rollback of the previous version of the firmware, even if you've already validated the updated one - - Push the button until the pine cone is drawn in **red** to load the recovery firmware. This recovery firmware only provides BLE connectivity and OTA functionality. - -More info about the bootloader in [its project page](https://github.com/JF002/pinetime-mcuboot-bootloader/blob/master/README.md). - diff --git a/doc/gettingStarted/oldbootloaderlogo.jpg b/doc/gettingStarted/oldbootloaderlogo.jpg deleted file mode 100644 index b4d0cdfb..00000000 Binary files a/doc/gettingStarted/oldbootloaderlogo.jpg and /dev/null differ diff --git a/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md b/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md deleted file mode 100644 index 1187a9b7..00000000 --- a/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md +++ /dev/null @@ -1,101 +0,0 @@ -# Flash and upgrade InfiniTime -If you just want to flash or upgrade InfiniTime on your PineTime, this page is for you! - -- [InfiniTime releases and versions](#infinitime-releases-and-versions) -- [How to upgrade Over-The-Air (OTA)](#how-to-upgrade-over-the-air-ota) - - [Using Gadgetbridge](#using-gadgetbridge) - - [Using NRFConnect](#Using-nrfconnect) -- [How to flash InfiniTime using the SWD interface](#how-to-flash-infinitime-using-the-swd-interface) - -## InfiniTime releases and versions -All releases of InfiniTime are available on the [release page of the GitHub repo](https://github.com/JF002/InfiniTime/releases). - -Versions that are tagged as **RELEASE CANDIDATE** are pre-release versions, that are available for testing before actually releasing a new stable version. If you want to help us debug the project and provide stable versions to other user, you can use them. If you want stable and tested version, you should not flash these release candidate version. - -Release files are available under the *Assets* button. - -## How to upgrade Over-The-Air (OTA) -OTA is the easiest method to upgrade InfiniTime. Note that it's only possible is your PineTime is already running InfiniTime (>= 0.7.1). - -2 companion apps provide support for OTA : - - [Gadgetbridge](https://gadgetbridge.org/) (open source, runs on Android, [available on F-Droid](https://f-droid.org/packages/nodomain.freeyourgadget.gadgetbridge/)). - - [NRFConnect](https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Connect-for-mobile) (close source, runs on Android and iOS). - -Both applications need you to download the **DFU file** of InfiniTime. This file contains the new version of InfiniTime that will be flashed into your device. It's called **dfu-x.y.z.zip** (ex: dfu-0.9.0.zip) in the release note. -![Dfu file](dfuFile.png ) - -### Using Gadgetbridge -Launch Gadgetbridge and tap on the **"+"** button on the bottom right to add a new device: - -![Gadgetbridge 0](gadgetbridge0.jpg) - -Wait for the scan to complete, your PineTime should be detected: - -![Gadgetbridge 1](gadgetbridge1.jpg) - -Tap on it. Gadgdetbridge will pair and connect to your device: - -![Gadgetbridge 2](gadgetbridge2.jpg) - -Now that Gadgetbridge is connected to your PineTime, use a file browser application (I'm using Seafile to browse my NAS) and browse to the DFU file (image-xxx.zip) you downloaded previously. Tap on it and open it using the Gadgetbridge application/firmware installer: - -![Gadgetbridge 3](gadgetbridge3.jpg) - -Read carefully the warning and tap **Install**: - -![Gadgetbridge 4](gadgetbridge4.jpg) - -Wait for the transfer to finish. Your PineTime should reset and reboot with the new version of InfiniTime! - -![Gadgetbridge 5](gadgetbridge5.jpg) - -### Using NRFConnect -Open NRFConnect. Swipe down in the *Scanner* tab and wait for your device to appear: - -![NRFConnect 0](nrfconnect0.jpg) - -Tap on the *Connect* button on the right of your device. NRFConnect will connect to your PineTime and discover its characteristics. Tap on the **DFU** button on the top right: - -![NRFConnect 1](nrfconnect1.jpg) - -Select **Distribution packet (ZIP)**: - -![NRFConnect 2](nrfconnect2.jpg) - -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! - -![NRFConnect 3](nrfconnect3.jpg) - -## How to flash InfiniTime using the SWD interface -Download the files **bootloader.bin**, **image-x.y.z.bin** and **pinetime-graphics-x.y.z.bin** from the release page: - -![Image file](imageFile.png ) - -The bootloader reads a boot logo from the external SPI flash memory. The first step consists in flashing a tool in the MCU that will flash the boot logo into this SPI flash memory. This first step is optional but recommanded (the bootloader will display garbage on screen for a few second if you don't do it). -Using your SWD tool, flash **pinetime-graphics-x.y.z.bin** at offset **0x0000**. Reset the MCU and wait for a few second, until the logo is completely drawn on the display. - -Then, using your SWD tool, flash those file at specific offset: - - - bootloader.bin : **0x0000** - - image-x.y.z.bin : **0x8000** - -Reset and voilà, you're running InfiniTime on your PineTime! - -If you are using OpenOCD with a STLinkV2, you can find more info [on this page](../openOCD.md). - -## How to synchronize the time - -### Using Gadgetbridge -Good news! Gadgetbridge **automatically** synchronizes the time when connecting to your PineTime! - -### Using NRFConnect -You must enable the **CTS** *GATT server* into NRFConnect so that InfiniTime can synchronize the time with your smartphone. - -Launch NRFConnect, tap the sandwich button on the top left and select *Configure GATT server*: - -![NRFConnect CTS 0](nrfconnectcts0.jpg) - - -Tap *Add service* and select the server configuration *Current Time service*. Tap OK and connect to your PineTime, it should automcatically sync the time once the connection is established! - -![NRFConnect CTS 1](nrfconnectcts1.jpg) diff --git a/doc/gettingStarted/quickactions.jpg b/doc/gettingStarted/quickactions.jpg deleted file mode 100644 index 0d92b134..00000000 Binary files a/doc/gettingStarted/quickactions.jpg and /dev/null differ diff --git a/doc/gettingStarted/settings.jpg b/doc/gettingStarted/settings.jpg deleted file mode 100644 index 510b29eb..00000000 Binary files a/doc/gettingStarted/settings.jpg and /dev/null differ diff --git a/doc/gettingStarted/version-071.jpg b/doc/gettingStarted/version-071.jpg deleted file mode 100644 index bc9bc5b5..00000000 Binary files a/doc/gettingStarted/version-071.jpg and /dev/null differ diff --git a/doc/gettingStarted/version-1.0.jpg b/doc/gettingStarted/version-1.0.jpg deleted file mode 100644 index bcfc8c63..00000000 Binary files a/doc/gettingStarted/version-1.0.jpg and /dev/null differ diff --git a/docker/.gitpod.Dockerfile b/docker/.gitpod.Dockerfile index 4fbc7be0..2f7099a5 100644 --- a/docker/.gitpod.Dockerfile +++ b/docker/.gitpod.Dockerfile @@ -19,11 +19,8 @@ RUN apt-get update -qq \ libffi-dev \ libssl-dev \ python3-dev \ - git \ && rm -rf /var/cache/apt/* /var/lib/apt/lists/*; -# Git needed for PROJECT_GIT_COMMIT_HASH variable setting - # Needs to be installed as root RUN pip3 install adafruit-nrfutil RUN pip3 install -Iv cryptography==3.3 diff --git a/docker/Dockerfile b/docker/Dockerfile index 0a4f69f0..a6caa24e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -19,11 +19,8 @@ RUN apt-get update -qq \ libssl-dev \ python3-dev \ python \ - git \ && rm -rf /var/cache/apt/* /var/lib/apt/lists/*; -# Git needed for PROJECT_GIT_COMMIT_HASH variable setting - RUN pip3 install adafruit-nrfutil RUN pip3 install -Iv cryptography==3.3 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index acbfba18..5c6af93b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -406,7 +406,6 @@ list(APPEND SOURCE_FILES displayapp/screens/FlashLight.cpp displayapp/screens/List.cpp displayapp/screens/BatteryInfo.cpp - displayapp/screens/Steps.cpp ## Settings displayapp/screens/settings/QuickSettings.cpp @@ -415,12 +414,12 @@ list(APPEND SOURCE_FILES displayapp/screens/settings/SettingTimeFormat.cpp displayapp/screens/settings/SettingWakeUp.cpp displayapp/screens/settings/SettingDisplay.cpp - displayapp/screens/settings/SettingSteps.cpp ## Watch faces displayapp/icons/bg_clock.c displayapp/screens/WatchFaceAnalog.cpp displayapp/screens/WatchFaceDigital.cpp + displayapp/screens/PineTimeStyle.cpp ## @@ -468,7 +467,7 @@ list(APPEND SOURCE_FILES displayapp/fonts/jetbrains_mono_extrabold_compressed.c displayapp/fonts/jetbrains_mono_bold_20.c displayapp/fonts/jetbrains_mono_76.c - displayapp/fonts/jetbrains_mono_42.c + displayapp/fonts/open_sans_light.c displayapp/fonts/lv_font_sys_48.c displayapp/lv_pinetime_theme.c diff --git a/src/Version.h.in b/src/Version.h.in index 8cd39c96..6ff5938e 100644 --- a/src/Version.h.in +++ b/src/Version.h.in @@ -8,13 +8,11 @@ namespace Pinetime { static constexpr uint32_t Major() {return major;} static constexpr uint32_t Minor() {return minor;} static constexpr uint32_t Patch() {return patch;} - static constexpr const char* GitCommitHash() {return commitHash;} static constexpr const char* VersionString() {return versionString;} private: static constexpr uint32_t major = @PROJECT_VERSION_MAJOR@; static constexpr uint32_t minor = @PROJECT_VERSION_MINOR@; static constexpr uint32_t patch = @PROJECT_VERSION_PATCH@; - static constexpr const char* commitHash = "@PROJECT_GIT_COMMIT_HASH@"; static constexpr const char* versionString = "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@"; }; } \ No newline at end of file diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h index 3a238262..bf644812 100644 --- a/src/components/motion/MotionController.h +++ b/src/components/motion/MotionController.h @@ -8,13 +8,13 @@ namespace Pinetime { public: void Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps); - int16_t X() const { + uint16_t X() const { return x; } - int16_t Y() const { + uint16_t Y() const { return y; } - int16_t Z() const { + uint16_t Z() const { return z; } uint32_t NbSteps() const { diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 4409425b..18c87fd4 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -86,14 +86,6 @@ namespace Pinetime { return settings.brightLevel; }; - void SetStepsGoal( uint32_t goal ) { - if ( goal != settings.stepsGoal ) - settingsChanged = true; - settings.stepsGoal = goal; - }; - - uint32_t GetStepsGoal() const { return settings.stepsGoal; }; - private: Pinetime::Drivers::SpiNorFlash& spiNorFlash; struct SettingsData { @@ -103,7 +95,7 @@ namespace Pinetime { uint8_t clockFace = 0; - uint32_t stepsGoal = 10000; + uint32_t stepsGoal = 1000; uint32_t screenTimeOut = 15000; WakeUpMode wakeUpMode = WakeUpMode::None; diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h index 09a20181..936a3ae8 100644 --- a/src/displayapp/Apps.h +++ b/src/displayapp/Apps.h @@ -21,14 +21,12 @@ namespace Pinetime { Navigation, StopWatch, Motion, - Steps, QuickSettings, Settings, SettingWatchFace, SettingTimeFormat, SettingDisplay, - SettingWakeUp, - SettingSteps + SettingWakeUp }; } } diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index a6c4a3ec..3a20c766 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -25,7 +25,6 @@ #include "displayapp/screens/Twos.h" #include "displayapp/screens/FlashLight.h" #include "displayapp/screens/BatteryInfo.h" -#include "displayapp/screens/Steps.h" #include "drivers/Cst816s.h" #include "drivers/St7789.h" @@ -38,7 +37,6 @@ #include "displayapp/screens/settings/SettingTimeFormat.h" #include "displayapp/screens/settings/SettingWakeUp.h" #include "displayapp/screens/settings/SettingDisplay.h" -#include "displayapp/screens/settings/SettingSteps.h" using namespace Pinetime::Applications; using namespace Pinetime::Applications::Display; @@ -67,7 +65,7 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd, notificationManager {notificationManager}, heartRateController {heartRateController}, settingsController {settingsController}, - motorController {motorController}, + motorController{motorController}, motionController {motionController} { msgQueue = xQueueCreate(queueSize, itemSize); // Start clock when smartwatch boots @@ -75,9 +73,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd, } void DisplayApp::Start() { - if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) { + if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); - } } void DisplayApp::Process(void* instance) { @@ -88,7 +85,7 @@ void DisplayApp::Process(void* instance) { // Send a dummy notification to unlock the lvgl display driver for the first iteration xTaskNotifyGive(xTaskGetCurrentTaskHandle()); - while (true) { + while (1) { app->Refresh(); } } @@ -216,7 +213,7 @@ void DisplayApp::StartApp(Apps app, DisplayApp::FullRefreshDirections direction) LoadApp(app, direction); } -void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent) { +void DisplayApp::returnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent) { returnToApp = app; returnDirection = direction; returnTouchEvent = touchEvent; @@ -227,12 +224,12 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) SetFullRefresh(direction); // default return to launcher - ReturnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::SwipeDown); + returnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::SwipeDown); switch (app) { case Apps::Launcher: currentScreen = std::make_unique(this, settingsController, batteryController, dateTimeController); - ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::SwipeDown); + returnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::None: case Apps::Clock: @@ -248,7 +245,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) case Apps::FirmwareValidation: currentScreen = std::make_unique(this, validator); - ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::FirmwareUpdate: currentScreen = std::make_unique(this, bleController); @@ -257,58 +254,54 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) case Apps::Notifications: currentScreen = std::make_unique( this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Normal); - ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); + returnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); break; case Apps::NotificationsPreview: currentScreen = std::make_unique( this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Preview); - ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); + returnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); break; // Settings case Apps::QuickSettings: - currentScreen = std::make_unique( - this, batteryController, dateTimeController, brightnessController, motorController, settingsController); - ReturnApp(Apps::Clock, FullRefreshDirections::LeftAnim, TouchEvents::SwipeLeft); + currentScreen = + std::make_unique(this, batteryController, dateTimeController, brightnessController, motorController, settingsController); + returnApp(Apps::Clock, FullRefreshDirections::LeftAnim, TouchEvents::SwipeLeft); break; case Apps::Settings: currentScreen = std::make_unique(this, settingsController); - ReturnApp(Apps::QuickSettings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + returnApp(Apps::QuickSettings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SettingWatchFace: currentScreen = std::make_unique(this, settingsController); - ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SettingTimeFormat: currentScreen = std::make_unique(this, settingsController); - ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SettingWakeUp: currentScreen = std::make_unique(this, settingsController); - ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SettingDisplay: currentScreen = std::make_unique(this, settingsController); - ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); - break; - case Apps::SettingSteps: - currentScreen = std::make_unique(this, settingsController); - ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::BatteryInfo: currentScreen = std::make_unique(this, batteryController); - ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SysInfo: currentScreen = std::make_unique(this, dateTimeController, batteryController, brightnessController, bleController, watchdog); - ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; // case Apps::FlashLight: currentScreen = std::make_unique(this, systemTask, brightnessController); - ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None); + returnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None); break; case Apps::StopWatch: currentScreen = std::make_unique(this); @@ -334,9 +327,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) case Apps::Motion: currentScreen = std::make_unique(this, motionController); break; - case Apps::Steps: - currentScreen = std::make_unique(this, motionController, settingsController); - break; } currentApp = app; } @@ -359,9 +349,8 @@ TouchEvents DisplayApp::OnTouchEvent() { if (info.isTouch) { switch (info.gesture) { case Pinetime::Drivers::Cst816S::Gestures::SingleTap: - if (touchMode == TouchModes::Gestures) { + if (touchMode == TouchModes::Gestures) lvgl.SetNewTapEvent(info.x, info.y); - } return TouchEvents::Tap; case Pinetime::Drivers::Cst816S::Gestures::LongPress: return TouchEvents::LongTap; diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index ffe27cf1..75e52755 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -103,7 +103,7 @@ namespace Pinetime { static void Process(void* instance); void InitHw(); void Refresh(); - void ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent); + void returnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent); void LoadApp(Apps app, DisplayApp::FullRefreshDirections direction); }; } diff --git a/src/displayapp/DisplayAppRecovery.cpp b/src/displayapp/DisplayAppRecovery.cpp index a132a47c..6db987fa 100644 --- a/src/displayapp/DisplayAppRecovery.cpp +++ b/src/displayapp/DisplayAppRecovery.cpp @@ -37,7 +37,7 @@ void DisplayApp::Process(void* instance) { xTaskNotifyGive(xTaskGetCurrentTaskHandle()); app->InitHw(); - while (true) { + while (1) { app->Refresh(); } } @@ -51,11 +51,10 @@ void DisplayApp::Refresh() { if (xQueueReceive(msgQueue, &msg, 200)) { switch (msg) { case Display::Messages::UpdateBleConnection: - if (bleController.IsConnected()) { + if (bleController.IsConnected()) DisplayLogo(colorBlue); - } else { + else DisplayLogo(colorWhite); - } break; case Display::Messages::BleFirmwareUpdateStarted: DisplayLogo(colorGreen); diff --git a/src/displayapp/fonts/jetbrains_mono_42.c b/src/displayapp/fonts/jetbrains_mono_42.c deleted file mode 100644 index 6f25f5ab..00000000 --- a/src/displayapp/fonts/jetbrains_mono_42.c +++ /dev/null @@ -1,258 +0,0 @@ -/******************************************************************************* - * Size: 42 px - * Bpp: 1 - * Opts: - ******************************************************************************/ - -#ifdef LV_LVGL_H_INCLUDE_SIMPLE -#include "lvgl.h" -#else -#include "lvgl/lvgl.h" -#endif - -#ifndef JETBRAINS_MONO_42 -#define JETBRAINS_MONO_42 1 -#endif - -#if JETBRAINS_MONO_42 - -/*----------------- - * BITMAPS - *----------------*/ - -/*Store the image of the glyphs*/ -static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = { - /* U+0025 "%" */ - 0x1f, 0x80, 0x7, 0x3f, 0xc0, 0xe, 0x7f, 0xe0, - 0x1c, 0xf0, 0xf0, 0x1c, 0xe0, 0x70, 0x38, 0xe0, - 0x70, 0x70, 0xe0, 0x70, 0x70, 0xe0, 0x70, 0xe0, - 0xe0, 0x71, 0xc0, 0xe0, 0x71, 0xc0, 0xf0, 0xf3, - 0x80, 0x7f, 0xe7, 0x0, 0x3f, 0xc7, 0x0, 0x1f, - 0x8e, 0x0, 0x0, 0x1c, 0x0, 0x0, 0x3c, 0x0, - 0x0, 0x38, 0x0, 0x0, 0x71, 0xf8, 0x0, 0xe3, - 0xfc, 0x0, 0xe7, 0xfe, 0x1, 0xcf, 0xf, 0x3, - 0x8e, 0x7, 0x3, 0x8e, 0x7, 0x7, 0xe, 0x7, - 0xe, 0xe, 0x7, 0xe, 0xe, 0x7, 0x1c, 0xe, - 0x7, 0x38, 0xf, 0xf, 0x38, 0x7, 0xfe, 0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e, - 0x3f, 0xff, 0xc1, 0xff, 0xfc, 0x7, 0xe7, 0x80, - 0x0, 0xf8, 0x0, 0xf, 0x0, 0x1, 0xe0, 0x0, - 0x1e, 0x0, 0x3, 0xc0, 0x0, 0x3c, 0x0, 0x7, - 0x80, 0x0, 0xf8, 0x0, 0xf, 0x0, 0x1, 0xe0, - 0x0, 0x1e, 0x0, 0x3, 0xc0, 0x0, - - /* U+003A ":" */ - 0x7d, 0xff, 0xff, 0xff, 0xef, 0x80, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, - 0xf7, 0xff, 0xff, 0xff, 0xbe -}; - - -/*--------------------- - * GLYPH DESCRIPTION - *--------------------*/ - -static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { - {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, - {.bitmap_index = 0, .adv_w = 403, .box_w = 24, .box_h = 31, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 93, .adv_w = 403, .box_w = 19, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, - {.bitmap_index = 167, .adv_w = 403, .box_w = 19, .box_h = 31, .ofs_x = 4, .ofs_y = 0}, - {.bitmap_index = 241, .adv_w = 403, .box_w = 19, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, - {.bitmap_index = 315, .adv_w = 403, .box_w = 19, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, - {.bitmap_index = 389, .adv_w = 403, .box_w = 18, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, - {.bitmap_index = 459, .adv_w = 403, .box_w = 18, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, - {.bitmap_index = 529, .adv_w = 403, .box_w = 20, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, - {.bitmap_index = 607, .adv_w = 403, .box_w = 20, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, - {.bitmap_index = 685, .adv_w = 403, .box_w = 20, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, - {.bitmap_index = 763, .adv_w = 403, .box_w = 20, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, - {.bitmap_index = 841, .adv_w = 403, .box_w = 7, .box_h = 24, .ofs_x = 9, .ofs_y = 0} -}; - -/*--------------------- - * CHARACTER MAPPING - *--------------------*/ - - - -/*Collect the unicode lists and glyph_id offsets*/ -static const lv_font_fmt_txt_cmap_t cmaps[] = -{ - { - .range_start = 37, .range_length = 1, .glyph_id_start = 1, - .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY - }, - { - .range_start = 48, .range_length = 11, .glyph_id_start = 2, - .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY - } -}; - - - -/*-------------------- - * ALL CUSTOM DATA - *--------------------*/ - -#if LV_VERSION_CHECK(8, 0, 0) -/*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; -static const lv_font_fmt_txt_dsc_t font_dsc = { -#else -static lv_font_fmt_txt_dsc_t font_dsc = { -#endif - .glyph_bitmap = glyph_bitmap, - .glyph_dsc = glyph_dsc, - .cmaps = cmaps, - .kern_dsc = NULL, - .kern_scale = 0, - .cmap_num = 2, - .bpp = 1, - .kern_classes = 0, - .bitmap_format = 0, -#if LV_VERSION_CHECK(8, 0, 0) - .cache = &cache -#endif -}; - - -/*----------------- - * PUBLIC FONT - *----------------*/ - -/*Initialize a public general font descriptor*/ -#if LV_VERSION_CHECK(8, 0, 0) -const lv_font_t jetbrains_mono_42 = { -#else -lv_font_t jetbrains_mono_42 = { -#endif - .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ - .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ - .line_height = 31, /*The maximum line height required by the font*/ - .base_line = 0, /*Baseline measured from the bottom of the line*/ -#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) - .subpx = LV_FONT_SUBPX_NONE, -#endif -#if LV_VERSION_CHECK(7, 4, 0) - .underline_position = -7, - .underline_thickness = 2, -#endif - .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ -}; - - - -#endif /*#if JETBRAINS_MONO_42*/ - diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp index 1eb36999..7e38b3f4 100644 --- a/src/displayapp/screens/ApplicationList.cpp +++ b/src/displayapp/screens/ApplicationList.cpp @@ -49,7 +49,7 @@ std::unique_ptr ApplicationList::CreateScreen1() { {Symbols::stopWatch, Apps::StopWatch}, {Symbols::music, Apps::Music}, {Symbols::map, Apps::Navigation}, - {Symbols::shoe, Apps::Steps}, + {Symbols::shoe, Apps::Motion}, {Symbols::heartBeat, Apps::HeartRate}, {"", Apps::None}, }}; @@ -62,7 +62,7 @@ std::unique_ptr ApplicationList::CreateScreen2() { {Symbols::paintbrush, Apps::Paint}, {Symbols::paddle, Apps::Paddle}, {"2", Apps::Twos}, - {"M", Apps::Motion}, + {"", Apps::None}, {"", Apps::None}, {"", Apps::None}, }}; diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index 14299840..e0c1f62b 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -14,6 +14,7 @@ #include "../DisplayApp.h" #include "WatchFaceDigital.h" #include "WatchFaceAnalog.h" +#include "PineTimeStyle.h" using namespace Pinetime::Applications::Screens; @@ -42,6 +43,9 @@ Clock::Clock(DisplayApp* app, [this]() -> std::unique_ptr { return WatchFaceAnalogScreen(); }, + [this]() -> std::unique_ptr { + return PineTimeStyleScreen(); + }, // Examples for more watch faces //[this]() -> std::unique_ptr { return WatchFaceMinimalScreen(); }, //[this]() -> std::unique_ptr { return WatchFaceCustomScreen(); } @@ -80,6 +84,16 @@ std::unique_ptr Clock::WatchFaceAnalogScreen() { app, dateTimeController, batteryController, bleController, notificatioManager, settingsController); } +std::unique_ptr Clock::PineTimeStyleScreen() { + return std::make_unique(app, + dateTimeController, + batteryController, + bleController, + notificatioManager, + settingsController, + heartRateController); +} + /* // Examples for more watch faces std::unique_ptr Clock::WatchFaceMinimalScreen() { @@ -91,4 +105,4 @@ std::unique_ptr Clock::WatchFaceCustomScreen() { return std::make_unique(app, dateTimeController, batteryController, bleController, notificatioManager, settingsController); } -*/ \ No newline at end of file +*/ diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h index 9879985f..920d58bb 100644 --- a/src/displayapp/screens/Clock.h +++ b/src/displayapp/screens/Clock.h @@ -47,9 +47,10 @@ namespace Pinetime { Controllers::HeartRateController& heartRateController; Controllers::MotionController& motionController; - ScreenList<2> screens; + ScreenList<3> screens; std::unique_ptr WatchFaceDigitalScreen(); std::unique_ptr WatchFaceAnalogScreen(); + std::unique_ptr PineTimeStyleScreen(); // Examples for more watch faces // std::unique_ptr WatchFaceMinimalScreen(); diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp index ad37a3df..873a22f5 100644 --- a/src/displayapp/screens/FirmwareValidation.cpp +++ b/src/displayapp/screens/FirmwareValidation.cpp @@ -27,17 +27,6 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app, sprintf(version, "%ld.%ld.%ld", Version::Major(), Version::Minor(), Version::Patch()); lv_label_set_text(labelVersionValue, version); - labelShortRefInfo = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(labelShortRefInfo, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 25); - lv_label_set_text(labelShortRefInfo, "ShortRef : "); - lv_label_set_align(labelShortRefInfo, LV_LABEL_ALIGN_LEFT); - - labelShortRefValue = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(labelShortRefValue, labelShortRefInfo, LV_ALIGN_OUT_RIGHT_MID, 0, 0); - lv_label_set_recolor(labelShortRefValue, true); - sprintf(shortref, "%s", Version::GitCommitHash()); - lv_label_set_text(labelShortRefValue, shortref); - labelIsValidated = lv_label_create(lv_scr_act(), nullptr); lv_obj_align(labelIsValidated, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 50); lv_label_set_recolor(labelIsValidated, true); diff --git a/src/displayapp/screens/FirmwareValidation.h b/src/displayapp/screens/FirmwareValidation.h index 303c2154..67662fd9 100644 --- a/src/displayapp/screens/FirmwareValidation.h +++ b/src/displayapp/screens/FirmwareValidation.h @@ -25,10 +25,7 @@ namespace Pinetime { lv_obj_t* labelVersionInfo; lv_obj_t* labelVersionValue; - lv_obj_t* labelShortRefInfo; - lv_obj_t* labelShortRefValue; char version[9]; - char shortref[9]; lv_obj_t* labelIsValidated; lv_obj_t* buttonValidate; lv_obj_t* labelButtonValidate; diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp index a8bb3c18..e7196267 100644 --- a/src/displayapp/screens/Motion.cpp +++ b/src/displayapp/screens/Motion.cpp @@ -3,6 +3,8 @@ #include "../DisplayApp.h" using namespace Pinetime::Applications::Screens; +extern lv_font_t jetbrains_mono_extrabold_compressed; +extern lv_font_t jetbrains_mono_bold_20; Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionController& motionController) : Screen(app), motionController {motionController} { @@ -27,16 +29,13 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr lv_chart_init_points(chart, ser3, 0); lv_chart_refresh(chart); /*Required after direct set*/ - label = lv_label_create(lv_scr_act(), NULL); - lv_label_set_text_fmt(label, "X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#", 0, 0, 0); - lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); - lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); - lv_label_set_recolor(label, true); - 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 ---"); + lv_label_set_text(labelStep, "Steps: "); + labelStepValue = lv_label_create(lv_scr_act(), NULL); + lv_obj_align(labelStepValue, labelStep, LV_ALIGN_OUT_RIGHT_MID, 0, 0); + lv_label_set_text(labelStepValue, "-"); } Motion::~Motion() { @@ -48,10 +47,8 @@ bool Motion::Refresh() { lv_chart_set_next(chart, ser2, motionController.Y()); lv_chart_set_next(chart, ser3, motionController.Z()); - lv_label_set_text_fmt(labelStep, "Steps %lu", motionController.NbSteps()); - - lv_label_set_text_fmt(label, "X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#", motionController.X() / 0x10, motionController.Y() / 0x10, motionController.Z() / 0x10); - lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); + snprintf(nbStepsBuffer, nbStepsBufferSize, "%lu", motionController.NbSteps()); + lv_label_set_text(labelStepValue, nbStepsBuffer); return running; } diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h index 132b20ec..11007866 100644 --- a/src/displayapp/screens/Motion.h +++ b/src/displayapp/screens/Motion.h @@ -26,9 +26,9 @@ namespace Pinetime { lv_chart_series_t* ser1; lv_chart_series_t* ser2; lv_chart_series_t* ser3; - lv_obj_t* label; lv_obj_t* labelStep; + lv_obj_t* labelStepValue; static constexpr uint8_t nbStepsBufferSize = 9; char nbStepsBuffer[nbStepsBufferSize + 1]; bool running = true; diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 1f113750..f0fd2f66 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -176,17 +176,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x888888)); if (title == nullptr) title = "Notification"; - char* pchar; - pchar = strchr(title, '\n'); - while (pchar != nullptr) { - *pchar = ' '; - pchar = - pchar = strchr(pchar + 1, '\n'); - } lv_label_set_text(alert_type, title); - lv_label_set_long_mode(alert_type, LV_LABEL_LONG_SROLL_CIRC); - lv_label_set_anim_speed(alert_type, 3); - lv_obj_set_width(alert_type, 180); lv_obj_align(alert_type, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 16); ///////// diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp deleted file mode 100644 index b485c975..00000000 --- a/src/displayapp/screens/Steps.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "Steps.h" -#include -#include "../DisplayApp.h" -#include "Symbols.h" - -using namespace Pinetime::Applications::Screens; - -Steps::Steps( - Pinetime::Applications::DisplayApp *app, - Controllers::MotionController& motionController, - Controllers::Settings &settingsController) - : Screen(app), - motionController{motionController}, - settingsController{settingsController} { - - stepsArc = lv_arc_create(lv_scr_act(), nullptr); - - lv_obj_set_style_local_bg_opa(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, LV_OPA_0); - lv_obj_set_style_local_border_width(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 2); - lv_obj_set_style_local_radius(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0); - lv_obj_set_style_local_line_color(stepsArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, lv_color_hex(0x0000FF)); - lv_arc_set_end_angle(stepsArc, 200); - lv_obj_set_size(stepsArc, 220, 220); - lv_arc_set_range(stepsArc, 0, 500); - lv_obj_align(stepsArc, nullptr, LV_ALIGN_CENTER, 0, 0); - - stepsCount = motionController.NbSteps(); - - lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal())); - - lSteps = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); - lv_obj_set_style_local_text_font(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); - lv_label_set_text_fmt(lSteps, "%li", stepsCount); - lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20); - - lv_obj_t * lstepsL = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(lstepsL, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); - lv_label_set_text_static(lstepsL, "Steps"); - lv_obj_align(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); - - lv_obj_t * lstepsGoal = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(lstepsGoal, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN); - lv_label_set_text_fmt(lstepsGoal,"Goal\n%i", settingsController.GetStepsGoal()); - lv_label_set_align(lstepsGoal, LV_LABEL_ALIGN_CENTER); - lv_obj_align(lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 60); - - lv_obj_t * backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); - lv_obj_set_size(backgroundLabel, 240, 240); - lv_obj_set_pos(backgroundLabel, 0, 0); - lv_label_set_text_static(backgroundLabel, ""); - -} - -Steps::~Steps() { - lv_obj_clean(lv_scr_act()); -} - -bool 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 deleted file mode 100644 index 9c135e26..00000000 --- a/src/displayapp/screens/Steps.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include -#include -#include "Screen.h" -#include - -namespace Pinetime { - - namespace Controllers { - class Settings; - } - - namespace Applications { - namespace Screens { - - class Steps : public Screen { - public: - Steps(DisplayApp* app, Controllers::MotionController& motionController, Controllers::Settings &settingsController); - ~Steps() override; - - bool Refresh() override; - - - private: - - Controllers::MotionController& motionController; - Controllers::Settings& settingsController; - - lv_obj_t * lSteps; - lv_obj_t * lStepsIcon; - lv_obj_t * stepsArc; - - uint32_t stepsCount; - - }; - } - } -} diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index d7cd20c3..e06981af 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -115,9 +115,8 @@ bool StopWatch::Refresh() { // Init state when an user first opens the app // and when a stop/reset button is pressed case States::Init: { - if (btnStopLap != nullptr) { + if (btnStopLap) { lv_obj_del(btnStopLap); - btnStopLap = nullptr; } // The initial default value lv_label_set_text(time, "00:00"); diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index e4ef6911..f6e8d61a 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -69,14 +69,12 @@ std::unique_ptr SystemInfo::CreateScreen1() { lv_label_set_text_fmt(label, "#FFFF00 InfiniTime#\n\n" "#444444 Version# %ld.%ld.%ld\n\n" - "#444444 Short Ref# %s\n\n" "#444444 Build date#\n" - "%s\n" - "%s\n", + "\t%s\n" + "\t%s\n", Version::Major(), Version::Minor(), Version::Patch(), - Version::GitCommitHash(), __DATE__, __TIME__); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); @@ -244,4 +242,4 @@ std::unique_ptr SystemInfo::CreateScreen5() { lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); return std::unique_ptr(new Screens::Label(4, 5, app, label)); -} +} \ No newline at end of file diff --git a/src/displayapp/screens/settings/SettingSteps.cpp b/src/displayapp/screens/settings/SettingSteps.cpp deleted file mode 100644 index b7c024f1..00000000 --- a/src/displayapp/screens/settings/SettingSteps.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "SettingSteps.h" -#include -#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) { - SettingSteps* screen = static_cast(obj->user_data); - screen->UpdateSelected(obj, event); - } -} - -SettingSteps::SettingSteps( - Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) : - Screen(app), - settingsController{settingsController} -{ - - lv_obj_t * container1 = lv_cont_create(lv_scr_act(), nullptr); - - //lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); - lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10); - lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); - lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); - lv_obj_set_pos(container1, 30, 60); - lv_obj_set_width(container1, LV_HOR_RES - 50); - lv_obj_set_height(container1, LV_VER_RES - 60); - lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); - - lv_obj_t * title = lv_label_create(lv_scr_act(), NULL); - lv_label_set_text_static(title,"Daily steps goal"); - lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); - lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15); - - lv_obj_t * icon = lv_label_create(lv_scr_act(), NULL); - lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); - - lv_label_set_text_static(icon, Symbols::shoe); - lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); - lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); - - - stepValue = lv_label_create(lv_scr_act(), NULL); - lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); - lv_label_set_text_fmt(stepValue,"%i", settingsController.GetStepsGoal()); - lv_label_set_align(stepValue, LV_LABEL_ALIGN_CENTER); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); - - btnPlus = lv_btn_create(lv_scr_act(), NULL); - btnPlus->user_data = this; - lv_obj_set_size(btnPlus, 80, 50); - lv_obj_align(btnPlus, lv_scr_act(), LV_ALIGN_CENTER, 55, 80); - lv_obj_set_style_local_value_str(btnPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+"); - lv_obj_set_event_cb(btnPlus, event_handler); - - btnMinus = lv_btn_create(lv_scr_act(), NULL); - btnMinus->user_data = this; - lv_obj_set_size(btnMinus, 80, 50); - lv_obj_set_event_cb(btnMinus, event_handler); - lv_obj_align(btnMinus, lv_scr_act(), LV_ALIGN_CENTER, -55, 80); - lv_obj_set_style_local_value_str(btnMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-"); - -} - -SettingSteps::~SettingSteps() { - lv_obj_clean(lv_scr_act()); - 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)) { - value += 1000; - if ( value <= 500000 ) { - settingsController.SetStepsGoal(value); - lv_label_set_text_fmt(stepValue,"%i", settingsController.GetStepsGoal()); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); - } - } - - if(object == btnMinus && (event == LV_EVENT_PRESSED)) { - value -= 1000; - if ( value >= 1000 ) { - settingsController.SetStepsGoal(value); - lv_label_set_text_fmt(stepValue,"%i", settingsController.GetStepsGoal()); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); - } - } - -} \ No newline at end of file diff --git a/src/displayapp/screens/settings/SettingSteps.h b/src/displayapp/screens/settings/SettingSteps.h deleted file mode 100644 index 0a4c2056..00000000 --- a/src/displayapp/screens/settings/SettingSteps.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include -#include -#include "components/settings/Settings.h" -#include "displayapp/screens/Screen.h" - -namespace Pinetime { - - namespace Applications { - namespace Screens { - - 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: - - Controllers::Settings& settingsController; - - lv_obj_t * stepValue; - lv_obj_t * btnPlus; - lv_obj_t * btnMinus; - - }; - } - } -} diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp index 457cebf6..3914a048 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.cpp +++ b/src/displayapp/screens/settings/SettingWatchFace.cpp @@ -58,6 +58,15 @@ SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pine lv_checkbox_set_checked(cbOption[optionsTotal], true); } + optionsTotal++; + cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + lv_checkbox_set_text_static(cbOption[optionsTotal], " PineTimeStyle"); + cbOption[optionsTotal]->user_data = this; + lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + if (settingsController.GetClockFace() == 2) { + lv_checkbox_set_checked(cbOption[optionsTotal], true); + } + optionsTotal++; } @@ -81,4 +90,4 @@ void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) { } } } -} \ No newline at end of file +} diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h index 1930a228..6f65d692 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.h +++ b/src/displayapp/screens/settings/SettingWatchFace.h @@ -21,7 +21,7 @@ namespace Pinetime { private: Controllers::Settings& settingsController; uint8_t optionsTotal; - lv_obj_t* cbOption[2]; + lv_obj_t* cbOption[3]; }; } } diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp index 2c72c832..e24be3d7 100644 --- a/src/displayapp/screens/settings/Settings.cpp +++ b/src/displayapp/screens/settings/Settings.cpp @@ -44,7 +44,9 @@ std::unique_ptr Settings::CreateScreen1() { {Symbols::clock, "Wake Up", Apps::SettingWakeUp}, {Symbols::clock, "Time format", Apps::SettingTimeFormat}, {Symbols::clock, "Watch face", Apps::SettingWatchFace}, - }}; + } + + }; return std::unique_ptr(new Screens::List(0, 2, app, settingsController, applications)); } @@ -52,11 +54,13 @@ std::unique_ptr Settings::CreateScreen1() { std::unique_ptr Settings::CreateScreen2() { std::array applications {{ - {Symbols::shoe, "Steps", Apps::SettingSteps}, {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}, {Symbols::check, "Firmware", Apps::FirmwareValidation}, {Symbols::list, "About", Apps::SysInfo}, - }}; + {"", "", Apps::None}, + } + + }; return std::unique_ptr(new Screens::List(1, 2, app, settingsController, applications)); } diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index 761baba2..e774091b 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -415,8 +415,8 @@ typedef void* lv_indev_drv_user_data_t; /*Type of user data in the in #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(jetbrains_mono_bold_20) \ LV_FONT_DECLARE(jetbrains_mono_extrabold_compressed) \ - LV_FONT_DECLARE(jetbrains_mono_42) \ LV_FONT_DECLARE(jetbrains_mono_76) \ + LV_FONT_DECLARE(open_sans_light) \ LV_FONT_DECLARE(lv_font_sys_48) /* Enable it if you have fonts with a lot of characters. @@ -758,4 +758,4 @@ typedef void* lv_obj_user_data_t; /*--END OF LV_CONF_H--*/ -#endif /*LV_CONF_H*/ \ No newline at end of file +#endif /*LV_CONF_H*/ diff --git a/src/logging/NrfLogger.cpp b/src/logging/NrfLogger.cpp index 1c048f2c..70a00e61 100644 --- a/src/logging/NrfLogger.cpp +++ b/src/logging/NrfLogger.cpp @@ -12,9 +12,8 @@ void NrfLogger::Init() { NRF_LOG_DEFAULT_BACKENDS_INIT(); - if (pdPASS != xTaskCreate(NrfLogger::Process, "LOGGER", 200, this, 0, &m_logger_thread)) { + if (pdPASS != xTaskCreate(NrfLogger::Process, "LOGGER", 200, this, 0, &m_logger_thread)) APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); - } } void NrfLogger::Process(void*) { @@ -22,7 +21,7 @@ void NrfLogger::Process(void*) { // Suppress endless loop diagnostic #pragma clang diagnostic push #pragma ide diagnostic ignored "EndlessLoop" - while (true) { + while (1) { NRF_LOG_FLUSH(); vTaskDelay(100); // Not good for power consumption, it will wake up every 100ms... } -- cgit v1.2.3 From a4968b502990f4a9e848c5240be2ee73348dd38e Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Tue, 18 May 2021 15:25:38 +0200 Subject: PineTimeStyle --- src/displayapp/fonts/open_sans_light.c | 1261 ++++++++++++++++++++++++++++++ src/displayapp/screens/PineTimeStyle.cpp | 294 +++++++ src/displayapp/screens/PineTimeStyle.h | 83 ++ 3 files changed, 1638 insertions(+) create mode 100644 src/displayapp/fonts/open_sans_light.c create mode 100644 src/displayapp/screens/PineTimeStyle.cpp create mode 100644 src/displayapp/screens/PineTimeStyle.h diff --git a/src/displayapp/fonts/open_sans_light.c b/src/displayapp/fonts/open_sans_light.c new file mode 100644 index 00000000..15f0ddf6 --- /dev/null +++ b/src/displayapp/fonts/open_sans_light.c @@ -0,0 +1,1261 @@ +/******************************************************************************* + * Size: 150 px + * Bpp: 1 + * Opts: + ******************************************************************************/ + +#ifdef LV_LVGL_H_INCLUDE_SIMPLE +#include "lvgl.h" +#else +#include "lvgl/lvgl.h" +#endif + +#ifndef OPEN_SANS_LIGHT +#define OPEN_SANS_LIGHT 1 +#endif + +#if OPEN_SANS_LIGHT + +/*----------------- + * BITMAPS + *----------------*/ + +/*Store the image of the glyphs*/ +static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = { + /* U+0030 "0" */ + 0x0, 0x0, 0x0, 0xf, 0xff, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x7, 0xff, 0xff, 0xc0, 0x0, + 0x0, 0x0, 0x0, 0x1, 0xff, 0xff, 0xff, 0x80, + 0x0, 0x0, 0x0, 0x0, 0x3f, 0xff, 0xff, 0xff, + 0x0, 0x0, 0x0, 0x0, 0x7, 0xff, 0xff, 0xff, + 0xfe, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xff, 0xff, + 0xff, 0xf8, 0x0, 0x0, 0x0, 0xf, 0xff, 0xe0, + 0x3, 0xff, 0xf0, 0x0, 0x0, 0x0, 0xff, 0xf8, + 0x0, 0x3, 0xff, 0xc0, 0x0, 0x0, 0xf, 0xfe, + 0x0, 0x0, 0x7, 0xff, 0x0, 0x0, 0x0, 0xff, + 0xe0, 0x0, 0x0, 0xf, 0xfc, 0x0, 0x0, 0x7, + 0xfe, 0x0, 0x0, 0x0, 0x3f, 0xf0, 0x0, 0x0, + 0x7f, 0xc0, 0x0, 0x0, 0x0, 0xff, 0x80, 0x0, + 0x7, 0xfc, 0x0, 0x0, 0x0, 0x1, 0xfe, 0x0, + 0x0, 0x7f, 0xc0, 0x0, 0x0, 0x0, 0xf, 0xf8, + 0x0, 0x3, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x3f, + 0xc0, 0x0, 0x3f, 0xe0, 0x0, 0x0, 0x0, 0x0, + 0xff, 0x0, 0x1, 0xfe, 0x0, 0x0, 0x0, 0x0, + 0x3, 0xfc, 0x0, 0x1f, 0xf0, 0x0, 0x0, 0x0, + 0x0, 0x1f, 0xe0, 0x0, 0xff, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x7f, 0x80, 0xf, 0xf8, 0x0, 0x0, + 0x0, 0x0, 0x3, 0xfc, 0x0, 0x7f, 0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xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xf0, + + /* U+0033 "3" */ + 0x0, 0x0, 0x0, 0x1f, 0xff, 0x80, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x7f, 0xff, 0xff, 0xc0, 0x0, + 0x0, 0x0, 0x0, 0x3f, 0xff, 0xff, 0xff, 0x80, + 0x0, 0x0, 0x0, 0x1f, 0xff, 0xff, 0xff, 0xff, + 0x0, 0x0, 0x0, 0xf, 0xff, 0xff, 0xff, 0xff, + 0xf8, 0x0, 0x0, 0x3, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xe0, 0x0, 0x0, 0xff, 0xff, 0xe0, 0x0, + 0xff, 0xff, 0x0, 0x0, 0x3f, 0xff, 0xc0, 0x0, + 0x0, 0xff, 0xf8, 0x0, 0x7, 0xff, 0xe0, 0x0, + 0x0, 0x3, 0xff, 0xc0, 0x1, 0xff, 0xf0, 0x0, + 0x0, 0x0, 0xf, 0xfe, 0x0, 0x3f, 0xfc, 0x0, + 0x0, 0x0, 0x0, 0x7f, 0xf0, 0x7, 0xff, 0x0, + 0x0, 0x0, 0x0, 0x1, 0xff, 0x80, 0x3f, 0xc0, + 0x0, 0x0, 0x0, 0x0, 0xf, 0xfc, 0x1, 0xf8, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xc0, 0xe, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xfe, 0x0, + 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, 0xe0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xfe, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0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, 0x0, 0x1f, 0xf0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x3, 0xff, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xe0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xfc, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xff, 0x80, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f, 0xf0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xfe, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0xff, + 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xff, + 0xf8, 0x0, 0x0, 0x1, 0x80, 0x0, 0x0, 0xff, + 0xff, 0x0, 0x0, 0x0, 0x1f, 0xe0, 0x0, 0xff, + 0xff, 0xc0, 0x0, 0x0, 0x1, 0xff, 0xff, 0xff, + 0xff, 0xf0, 0x0, 0x0, 0x0, 0x1f, 0xff, 0xff, + 0xff, 0xfc, 0x0, 0x0, 0x0, 0x1, 0xff, 0xff, + 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x1f, 0xff, + 0xff, 0xff, 0xc0, 0x0, 0x0, 0x0, 0x0, 0xff, + 0xff, 0xff, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x7f, 0xff, 0x80, 0x0, 0x0, 0x0, 0x0 +}; + + +/*--------------------- + * GLYPH DESCRIPTION + *--------------------*/ + +static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { + {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, + {.bitmap_index = 0, .adv_w = 1370, .box_w = 69, .box_h = 110, .ofs_x = 8, .ofs_y = -1}, + {.bitmap_index = 949, .adv_w = 1370, .box_w = 35, .box_h = 107, .ofs_x = 15, .ofs_y = 0}, + {.bitmap_index = 1418, .adv_w = 1370, .box_w = 67, .box_h = 108, .ofs_x = 8, .ofs_y = 0}, + {.bitmap_index = 2323, .adv_w = 1370, .box_w = 68, .box_h = 110, .ofs_x = 7, .ofs_y = -1}, + {.bitmap_index = 3258, .adv_w = 1370, .box_w = 81, .box_h = 108, .ofs_x = 3, .ofs_y = -1}, + {.bitmap_index = 4352, .adv_w = 1370, .box_w = 66, .box_h = 108, .ofs_x = 10, .ofs_y = -1}, + {.bitmap_index = 5243, .adv_w = 1370, .box_w = 69, .box_h = 110, .ofs_x = 9, .ofs_y = -1}, + {.bitmap_index = 6192, .adv_w = 1370, .box_w = 69, .box_h = 106, .ofs_x = 8, .ofs_y = 0}, + {.bitmap_index = 7107, .adv_w = 1370, .box_w = 68, .box_h = 110, .ofs_x = 9, .ofs_y = -1}, + {.bitmap_index = 8042, .adv_w = 1370, .box_w = 68, .box_h = 110, .ofs_x = 8, .ofs_y = -1} +}; + +/*--------------------- + * CHARACTER MAPPING + *--------------------*/ + + + +/*Collect the unicode lists and glyph_id offsets*/ +static const lv_font_fmt_txt_cmap_t cmaps[] = +{ + { + .range_start = 48, .range_length = 10, .glyph_id_start = 1, + .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY + } +}; + + + +/*-------------------- + * ALL CUSTOM DATA + *--------------------*/ + +#if LV_VERSION_CHECK(8, 0, 0) +/*Store all the custom data of the font*/ +static lv_font_fmt_txt_glyph_cache_t cache; +static const lv_font_fmt_txt_dsc_t font_dsc = { +#else +static lv_font_fmt_txt_dsc_t font_dsc = { +#endif + .glyph_bitmap = glyph_bitmap, + .glyph_dsc = glyph_dsc, + .cmaps = cmaps, + .kern_dsc = NULL, + .kern_scale = 0, + .cmap_num = 1, + .bpp = 1, + .kern_classes = 0, + .bitmap_format = 0, +#if LV_VERSION_CHECK(8, 0, 0) + .cache = &cache +#endif +}; + + +/*----------------- + * PUBLIC FONT + *----------------*/ + +/*Initialize a public general font descriptor*/ +#if LV_VERSION_CHECK(8, 0, 0) +const lv_font_t open_sans_light = { +#else +lv_font_t open_sans_light = { +#endif + .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ + .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ + .line_height = 110, /*The maximum line height required by the font*/ + .base_line = 1, /*Baseline measured from the bottom of the line*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -11, + .underline_thickness = 7, +#endif + .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ +}; + + + +#endif /*#if OPEN_SANS_LIGHT*/ + diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp new file mode 100644 index 00000000..b249416a --- /dev/null +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -0,0 +1,294 @@ +#include "PineTimeStyle.h" + +#include +#include +#include +#include "BatteryIcon.h" +#include "BleIcon.h" +#include "NotificationIcon.h" +#include "Symbols.h" +#include "components/battery/BatteryController.h" +#include "components/ble/BleController.h" +#include "components/ble/NotificationManager.h" +#include "components/heartrate/HeartRateController.h" +#include "components/settings/Settings.h" +#include "../DisplayApp.h" + +/* + * PineTimeStyle watchface for Infinitime created by Kieran Cawthray + * Based on WatchFaceDigital + * Style/layout copied from TimeStyle for Pebble by Dan Tilden (github.com/tilden) + */ + +using namespace Pinetime::Applications::Screens; + +PineTimeStyle::PineTimeStyle(DisplayApp* app, + Controllers::DateTime& dateTimeController, + Controllers::Battery& batteryController, + Controllers::Ble& bleController, + Controllers::NotificationManager& notificatioManager, + Controllers::Settings& settingsController, + Controllers::HeartRateController& heartRateController) + : Screen(app), + currentDateTime {{}}, + dateTimeController {dateTimeController}, + batteryController {batteryController}, + bleController {bleController}, + notificatioManager {notificatioManager}, + settingsController {settingsController}, + heartRateController {heartRateController} { + + /* This sets the watchface number to return to after leaving the menu*/ + settingsController.SetClockFace(2); + + displayedChar[0] = 0; + displayedChar[1] = 0; + displayedChar[2] = 0; + displayedChar[3] = 0; + displayedChar[4] = 0; + + /*Create a 200px wide background rectangle*/ + + 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_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, lv_color_hex(0x008080)); + 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_label_set_text(timeDD2, "34"); + lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5); + + /*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_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); + + batteryPlug = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + //lv_label_set_text(batteryPlug, Symbols::plug); + lv_obj_align(batteryPlug, 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, BleIcon::GetIcon(false)); + lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25); + + notificationIcon = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + //lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false)); + lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 40); + + /* 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); + + /*Display heartrate info*/ + + heartbeatIcon = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_label_set_text(heartbeatIcon, Symbols::heartBeat); + lv_obj_align(heartbeatIcon, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, -30); + + heartbeatValue = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_label_set_text(heartbeatValue, "---"); + lv_obj_align(heartbeatValue, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, -10); + + 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, ""); +} + +PineTimeStyle::~PineTimeStyle() { + lv_obj_clean(lv_scr_act()); +} + +bool PineTimeStyle::Refresh() { + batteryPercentRemaining = batteryController.PercentRemaining(); + if (batteryPercentRemaining.IsUpdated()) { + auto batteryPercent = batteryPercentRemaining.Get(); + if (batteryController.IsCharging()) { + auto isCharging = batteryController.IsCharging() || batteryController.IsPowerPresent(); + lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging)); + lv_obj_realign(batteryPlug); + lv_label_set_text(batteryIcon, ""); + } else { + lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); + lv_label_set_text(batteryPlug, ""); + } + } + + bleState = bleController.IsConnected(); + if (bleState.IsUpdated()) { + if (bleState.Get() == true) { + lv_label_set_text(bleIcon, BleIcon::GetIcon(true)); + lv_obj_realign(bleIcon); + } else { + lv_label_set_text(bleIcon, BleIcon::GetIcon(false)); + } + } + + notificationState = notificatioManager.AreNewNotificationsAvailable(); + if (notificationState.IsUpdated()) { + if (notificationState.Get() == true) { + lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(true)); + lv_obj_realign(notificationIcon); + //lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, -8, 25); + } else { + lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false)); + //lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25); + } + } + + currentDateTime = dateTimeController.CurrentDateTime(); + + if (currentDateTime.IsUpdated()) { + auto newDateTime = currentDateTime.Get(); + + auto dp = date::floor(newDateTime); + auto time = date::make_time(newDateTime - dp); + auto yearMonthDay = date::year_month_day(dp); + + auto year = (int) yearMonthDay.year(); + auto month = static_cast((unsigned) yearMonthDay.month()); + auto day = (unsigned) yearMonthDay.day(); + auto dayOfWeek = static_cast(date::weekday(yearMonthDay).iso_encoding()); + + int hour = time.hours().count(); + auto minute = time.minutes().count(); + + char minutesChar[3]; + sprintf(minutesChar, "%02d", static_cast(minute)); + + char hoursChar[3]; + sprintf(hoursChar, "%02d", hour); + + if (hoursChar[0] != displayedChar[0] || hoursChar[1] != displayedChar[1] || minutesChar[0] != displayedChar[2] || + minutesChar[1] != displayedChar[3]) { + displayedChar[0] = hoursChar[0]; + displayedChar[1] = hoursChar[1]; + displayedChar[2] = minutesChar[0]; + displayedChar[3] = minutesChar[1]; + + char hourStr[3]; + char minStr[3]; + + /*Display the time as 2 pairs of digits*/ + sprintf(hourStr, "%c%c", hoursChar[0], hoursChar[1]); + lv_label_set_text(timeDD1, hourStr); + + sprintf(minStr, "%c%c", minutesChar[0], minutesChar[1]); + lv_label_set_text(timeDD2, minStr); + } + + if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) { + char dayOfWeekStr[4]; + char dayStr[3]; + char monthStr[4]; + + sprintf(dayOfWeekStr, "%s", dateTimeController.DayOfWeekShortToString()); + sprintf(dayStr, "%d", day); + sprintf(monthStr, "%s", dateTimeController.MonthShortToString()); + + lv_label_set_text(dateDayOfWeek, dayOfWeekStr); + lv_label_set_text(dateDay, dayStr); + lv_obj_realign(dateDay); + lv_label_set_text(dateMonth, monthStr); + + currentYear = year; + currentMonth = month; + currentDayOfWeek = dayOfWeek; + currentDay = day; + } + } + + heartbeat = heartRateController.HeartRate(); + heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; + if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { + char heartbeatBuffer[4]; + if (heartbeatRunning.Get()) + sprintf(heartbeatBuffer, "%d", heartbeat.Get()); + else + sprintf(heartbeatBuffer, "---"); + + lv_label_set_text(heartbeatValue, heartbeatBuffer); + lv_obj_realign(heartbeatValue); + } + + return running; +} diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h new file mode 100644 index 00000000..55752412 --- /dev/null +++ b/src/displayapp/screens/PineTimeStyle.h @@ -0,0 +1,83 @@ +#pragma once + +#include +#include +#include +#include +#include "Screen.h" +#include "ScreenList.h" +#include "components/datetime/DateTimeController.h" + +namespace Pinetime { + namespace Controllers { + class Settings; + class Battery; + class Ble; + class NotificationManager; + class HeartRateController; + } + + namespace Applications { + namespace Screens { + class PineTimeStyle : public Screen { + public: + PineTimeStyle(DisplayApp* app, + Controllers::DateTime& dateTimeController, + Controllers::Battery& batteryController, + Controllers::Ble& bleController, + Controllers::NotificationManager& notificatioManager, + Controllers::Settings& settingsController, + Controllers::HeartRateController& heartRateController); + ~PineTimeStyle() override; + + bool Refresh() override; + + void OnObjectEvent(lv_obj_t* pObj, lv_event_t i); + + private: + char displayedChar[5]; + + uint16_t currentYear = 1970; + Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown; + Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown; + uint8_t currentDay = 0; + + DirtyValue batteryPercentRemaining {}; + DirtyValue bleState {}; + DirtyValue> currentDateTime {}; + DirtyValue heartbeat {}; + DirtyValue heartbeatRunning {}; + DirtyValue notificationState {}; + + lv_obj_t* timebar; + lv_obj_t* sidebar; + lv_obj_t* timeDD1; + lv_obj_t* timeDD2; + 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* batteryPlug; + 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* heartbeatIcon; + lv_obj_t* heartbeatValue; + lv_obj_t* heartbeatBpm; + lv_obj_t* notificationIcon; + + Controllers::DateTime& dateTimeController; + Controllers::Battery& batteryController; + Controllers::Ble& bleController; + Controllers::NotificationManager& notificatioManager; + Controllers::Settings& settingsController; + Controllers::HeartRateController& heartRateController; + }; + } + } +} -- cgit v1.2.3 From 6a925292722be365f4efc288c64b023639f0c201 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Tue, 18 May 2021 17:45:16 +0200 Subject: Revert "Reset" This reverts commit 378fa6b4016b65e2d7b128fdc3ce89c4ca779a4d. --- .clang-tidy | 6 +- CMakeLists.txt | 12 + README.md | 3 +- doc/buildAndProgram.md | 3 +- doc/contribute.md | 24 +- doc/gettingStarted/appmenu-071.jpg | Bin 0 -> 109376 bytes doc/gettingStarted/appmenu.jpg | Bin 0 -> 120674 bytes doc/gettingStarted/bootloader-1.0.jpg | Bin 0 -> 160275 bytes doc/gettingStarted/gettingStarted-1.0.md | 112 +++++++++ doc/gettingStarted/oldbootloaderlogo.jpg | Bin 0 -> 116236 bytes doc/gettingStarted/ota-gadgetbridge-nrfconnect.md | 101 ++++++++ doc/gettingStarted/quickactions.jpg | Bin 0 -> 114900 bytes doc/gettingStarted/settings.jpg | Bin 0 -> 130022 bytes doc/gettingStarted/version-071.jpg | Bin 0 -> 111556 bytes doc/gettingStarted/version-1.0.jpg | Bin 0 -> 116881 bytes docker/.gitpod.Dockerfile | 3 + docker/Dockerfile | 3 + src/CMakeLists.txt | 5 +- src/Version.h.in | 2 + src/components/motion/MotionController.h | 6 +- src/components/settings/Settings.h | 10 +- src/displayapp/Apps.h | 4 +- src/displayapp/DisplayApp.cpp | 53 +++-- src/displayapp/DisplayApp.h | 2 +- src/displayapp/DisplayAppRecovery.cpp | 7 +- src/displayapp/fonts/jetbrains_mono_42.c | 258 +++++++++++++++++++++ src/displayapp/screens/ApplicationList.cpp | 4 +- src/displayapp/screens/Clock.cpp | 16 +- src/displayapp/screens/Clock.h | 3 +- src/displayapp/screens/FirmwareValidation.cpp | 11 + src/displayapp/screens/FirmwareValidation.h | 3 + src/displayapp/screens/Motion.cpp | 19 +- src/displayapp/screens/Motion.h | 2 +- src/displayapp/screens/Notifications.cpp | 10 + src/displayapp/screens/Steps.cpp | 72 ++++++ src/displayapp/screens/Steps.h | 39 ++++ src/displayapp/screens/StopWatch.cpp | 3 +- src/displayapp/screens/SystemInfo.cpp | 8 +- src/displayapp/screens/settings/SettingSteps.cpp | 98 ++++++++ src/displayapp/screens/settings/SettingSteps.h | 32 +++ .../screens/settings/SettingWatchFace.cpp | 11 +- src/displayapp/screens/settings/SettingWatchFace.h | 2 +- src/displayapp/screens/settings/Settings.cpp | 10 +- src/libs/lv_conf.h | 4 +- src/logging/NrfLogger.cpp | 5 +- 45 files changed, 865 insertions(+), 101 deletions(-) create mode 100644 doc/gettingStarted/appmenu-071.jpg create mode 100644 doc/gettingStarted/appmenu.jpg create mode 100644 doc/gettingStarted/bootloader-1.0.jpg create mode 100644 doc/gettingStarted/gettingStarted-1.0.md create mode 100644 doc/gettingStarted/oldbootloaderlogo.jpg create mode 100644 doc/gettingStarted/ota-gadgetbridge-nrfconnect.md create mode 100644 doc/gettingStarted/quickactions.jpg create mode 100644 doc/gettingStarted/settings.jpg create mode 100644 doc/gettingStarted/version-071.jpg create mode 100644 doc/gettingStarted/version-1.0.jpg create mode 100644 src/displayapp/fonts/jetbrains_mono_42.c create mode 100644 src/displayapp/screens/Steps.cpp create mode 100644 src/displayapp/screens/Steps.h create mode 100644 src/displayapp/screens/settings/SettingSteps.cpp create mode 100644 src/displayapp/screens/settings/SettingSteps.h diff --git a/.clang-tidy b/.clang-tidy index d6036802..8a7d38f0 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -22,5 +22,9 @@ Checks: '*, -hicpp-no-assembler, -hicpp-avoid-c-arrays, -hicpp-uppercase-literal-suffix, + -hicpp-no-array-decay, -cert-err58-cpp, - -cert-err60-cpp' \ No newline at end of file + -cert-err60-cpp' +CheckOptions: + - key: readability-function-cognitive-complexity.Threshold + value: 100 \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index f7770136..6c529f39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,10 +55,22 @@ if(BUILD_DFU) set(BUILD_DFU true) endif() +set(PROJECT_GIT_COMMIT_HASH "") + +execute_process(COMMAND git rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE PROJECT_GIT_COMMIT_HASH + RESULT_VARIABLE PROJECT_GIT_COMMIT_HASH_SUCCESS) + +string(STRIP ${PROJECT_GIT_COMMIT_HASH} PROJECT_GIT_COMMIT_HASH) + +message("PROJECT_GIT_COMMIT_HASH_SUCCESS? " ${PROJECT_GIT_COMMIT_HASH_SUCCESS}) + message("BUILD CONFIGURATION") message("-------------------") message(" * Version : " ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) message(" * Toolchain : " ${ARM_NONE_EABI_TOOLCHAIN_PATH}) +message(" * GitRef(S) : " ${PROJECT_GIT_COMMIT_HASH}) message(" * NRF52 SDK : " ${NRF5_SDK_PATH}) set(PROGRAMMER "???") if(USE_JLINK) diff --git a/README.md b/README.md index 34f6e841..396d7462 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,8 @@ As of now, here is the list of achievements of this project: ## Documentation ### Getting started - - [Flash, upgrade (OTA), time synchronization,...](doc/gettingStarted/gettingStarted.md) + - [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/doc/buildAndProgram.md b/doc/buildAndProgram.md index b70bdfc0..afd526e0 100644 --- a/doc/buildAndProgram.md +++ b/doc/buildAndProgram.md @@ -3,6 +3,7 @@ To build this project, you'll need: - A cross-compiler : [ARM-GCC (9-2020-q2-update)](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads/9-2020-q2-update) - The NRF52 SDK 15.3.0 : [nRF-SDK v15.3.0](https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip) + - The `cbor` and `intelhex` modules for Python 3 - A reasonably recent version of CMake (I use 3.16.5) ## Build steps @@ -221,4 +222,4 @@ Loading section .sec6, size 0x10000 lma 0x30000 Loading section .sec7, size 0xdf08 lma 0x40000 Start address 0x0, load size 314200 Transfer rate: 45 KB/sec, 969 bytes/write. -``` \ No newline at end of file +``` diff --git a/doc/contribute.md b/doc/contribute.md index 7958eea1..09d20774 100644 --- a/doc/contribute.md +++ b/doc/contribute.md @@ -2,13 +2,13 @@ ## Report bugs You use your Pinetime and find a bug in the firmware? [Create an issue on Github](https://github.com/JF002/InfiniTime/issues) explaining the bug, how to reproduce it, the version of the firmware you use... ## Write and improve documentation -Documentation might be incomplete, or not clear enough, and it is always possible to improve it with better wording, pictures, photo, video,... +Documentation might be incomplete, or not clear enough, and it is always possible to improve it with better wording, pictures, photo, video,... As the documentation is part of the source code, you can submit your improvements to the documentation by submitting a pull request (see below). ## Fix bugs, add functionalities and improve the code You want to fix a bug, add a cool new functionality or improve the code? See *How to submit a pull request below*. ## Spread the word -Pinetime is a cool open source project that deserves to be know. Talk about it around you, on social networks, on your blog,... and let people know that we are working on an open-source firmware for a smartwatch! +The Pinetime is a cool open source project that deserves to be known. Talk about it around you, on social networks, on your blog,... and let people know that we are working on an open-source firmware for a smartwatch! # How to submit a pull request ? @@ -21,28 +21,28 @@ Pinetime is a cool open source project that deserves to be know. Talk about it a - Write documentation related to your new feature is applicable; - Create the pull-request and write a great description about it : what does your PR do, why, how,... Add pictures and video if possible; - Wait for someone to review your PR and take part in the review process; - - You PR will eventually be merged :) + - Your PR will eventually be merged :) -Your contribution is more than welcome! +Your contribution is more than welcome! If you want to fix a bug, add a functionality or improve the code, you'll first need to create a branch from the **develop** branch (see [this page about the branching model](./branches.md)). This branch is called a feature branch, and you should choose a name that explains what you are working on (ex: "add-doc-about-contributions"). In this branch, **focus on only one topic, bug or feature**. For example, if you created this branch to work on the UI of a specific application, do not commit modifications about the SPI driver. If you want to work on multiple topics, create one branch per topic. When your feature branch is ready, **make sure it actually works** and **do not forget to write documentation** about it if it's relevant. -I **strongly discourage to create a PR containing modifications that haven't been tested**. If, for any reason, you cannot test your modifications but want to publish them anyway, **please mention it in the description**. This way, other contributors might be willing to test it and provide feedbacks about your code. +I **strongly discourage to create a PR containing modifications that haven't been tested**. If, for any reason, you cannot test your modifications but want to publish them anyway, **please mention it in the description**. This way, other contributors might be willing to test it and provide feedback about your code. Also, before submitting your PR, check the coding style of your code against the **coding conventions** detailed below. This project also provides [clang-format](../.clang-format) and [clang-tidy](../.clang-tidy) configuration files. You can use them to ensure correct formatting of your code. Do not forget to check the files you are going to commit and remove those who are not necessary (config files from your IDE, for example). Remove old comments, commented code,... -Then, you can submit a pull-request for review. Try to **describe your pull request as much as possible**: what did you do in this branch, how does it work, how is it designed, are there any limitations,... This will help the contributors to understand and review your code easily. You can add pictures and video to the description so that contributors will have a quick overview of you work. +Then, you can submit a pull-request for review. Try to **describe your pull request as much as possible**: what did you do in this branch, how does it work, how is it designed, are there any limitations,... This will help the contributors to understand and review your code easily. You can add pictures and video to the description so that contributors will have a quick overview of your work. -Other contributors can post comments about the pull request, maybe ask for more info or adjustements in the code. +Other contributors can post comments about the pull request, maybe ask for more info or adjustments in the code. -Once the pull request is reviewed an accepted, it'll be merge in **develop** and will be released in the next release version of the firmware. +Once the pull request is reviewed and accepted, it'll be merge in **develop** and will be released in the next release version of the firmware. ## Why all these rules? -Reviewing pull-requests is a **very time consuming task** for the creator of this project ([JF002](https://github.com/JF002)) and for other contributors who take the time to review them. Every little thing you do to make their lifes easier will **increase the chances your PR will be merge quickly**. +Reviewing pull-requests is a **very time consuming task** for the creator of this project ([JF002](https://github.com/JF002)) and for other contributors who take the time to review them. Every little thing you do to make their lives easier will **increase the chances your PR will be merge quickly**. When reviewing PR, the author and contributors will first look at the **description**. If it's easy to understand what the PR does, why the modification is needed or interesting and how it's done, a good part of the work is already done : we understand the PR and its context. @@ -58,12 +58,12 @@ It's totally normal for a PR to need some more work even after it was created, t ## Language The language of this project is **C++**, and all new code must be written in C++. (Modern) C++ provides a lot of useful tools and functionalities that are beneficial for embedded software development like `constexpr`, `template` and anything that provides zero-cost abstraction. -It's OK to include C code if this code comes from another library like FreeRTOS, NimBLE, LVGL or the NRF-SDK. +It's OK to include C code if this code comes from another library like FreeRTOS, NimBLE, LVGL or the NRF-SDK. ## Coding style -The most important rule to follow is to try to keep the code as easy to read and maintain as possible. +The most important rule to follow is to try to keep the code as easy to read and maintain as possible. - - **Identation** : 2 spaces, no tabulation + - **Indentation** : 2 spaces, no tabulation - **Opening brace** at the end of the line - **Naming** : Choose self-describing variable name - **class** : PascalCase diff --git a/doc/gettingStarted/appmenu-071.jpg b/doc/gettingStarted/appmenu-071.jpg new file mode 100644 index 00000000..dee7c8f6 Binary files /dev/null and b/doc/gettingStarted/appmenu-071.jpg differ diff --git a/doc/gettingStarted/appmenu.jpg b/doc/gettingStarted/appmenu.jpg new file mode 100644 index 00000000..1e52fe78 Binary files /dev/null and b/doc/gettingStarted/appmenu.jpg differ diff --git a/doc/gettingStarted/bootloader-1.0.jpg b/doc/gettingStarted/bootloader-1.0.jpg new file mode 100644 index 00000000..7b639184 Binary files /dev/null and b/doc/gettingStarted/bootloader-1.0.jpg differ diff --git a/doc/gettingStarted/gettingStarted-1.0.md b/doc/gettingStarted/gettingStarted-1.0.md new file mode 100644 index 00000000..2ac22b97 --- /dev/null +++ b/doc/gettingStarted/gettingStarted-1.0.md @@ -0,0 +1,112 @@ +# Getting started with InfiniTime 1.0 +On April 22 2021, InfiniTime and Pine64 [announced the release of InfiniTime 1.0](https://www.pine64.org/2021/04/22/its-time-infinitime-1-0/) and the availability of PineTime smartwatches as *enthusiast grade end-user product*. This page aims to guide you with your first step with your new PineTime. + +## Firmware, InfiniTime, Bootloader, Recovery firmware, OTA, DFU... What is it? +You might have already seen these words by reading the announcement, release notes, or [the wiki guide](https://wiki.pine64.org/wiki/Upgrade_PineTime_to_InfiniTime_1.0.0) and, you may find them misleading if you're not familiar with the project. + +Basically, a **firmware** is just a software running on the embedded hardware of a device, the PineTime in this case. +**InfiniTime** is based on 3 distinct **firmwares**: + - **[InfiniTime](https://github.com/JF002/InfiniTime)** itself, this is the *application firmware* running on the PineTime. This is the main firmware which provides most of the functionalities you'll use on a daily basis : bluetooth low-energy (BLE) connectivity, applications, watchfaces,... + - **[The bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader)** is responsible for safely applying **updates** of the *application firmware*, reverting them in case of issues and load the recovery firmware when requested. + - **The recovery firmware** is a specific *application firmware* than can be loaded by the bootloader on user request. This firmware can be useful in case of serious issue, when the main application firmware cannot perform an OTA update correctly. Currently, this recovery firmware is based on [InfiniTime 0.14.1](https://github.com/JF002/InfiniTime/releases/tag/0.14.1). + +**OTA** and **DFU** refer to the update of the firmware over BLE (**B**luetooth **L**ow **E**nergy). **OTA** means **O**ver **T**he **A**ir, this is a functionality that allows the user to update the firmware how their device using a wireless communication like BLE. When we talk about **DFU** (**D**igital **F**irmware **U**pdate), we refer to the file format and protocol used to send the update of the firmware to the watch over-the-air. InfiniTime implement the (legacy) DFU protocol from Nordic Semiconductor (NRF). + +## How to check the version of InfiniTime and the bootloader? +Since September 2020, all PineTimes (devkits or sealed) are flashed using the **[first iteration of the bootloader](https://github.com/lupyuen/pinetime-rust-mynewt/releases/tag/v4.1.7)** and **[InfiniTime 0.7.1](https://github.com/JF002/InfiniTime/releases/tag/0.7.1)**. There was no recovery firmware at that time. + +The bootloader only runs when the watch starts (from an empty battery, for example) or after a reset (after a succesful OTA or a manual reset - long push on the button). + +You can recognize this first iteration of the bootloader with it greenish **PINETIME** logo. + +![Old bootloader logo](oldbootloaderlogo.jpg) + +You can check the version of InfiniTime by opening the app *SystemInfo*. For version < 1.0: + +![InfiniTime 0.7.1 Application menu](appmenu-071.jpg) +![InfiniTime 0.7.1 version](version-071.jpg) + +And for version >= 1.0 : + +![InfiniTime 1.0 version](version-1.0.jpg) + + +PineTime shipped from June 2020 (to be confirmed) will be flashed with the [new version of the bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader/releases/tag/1.0.0), the [recovery firmware](https://github.com/JF002/InfiniTime/releases/tag/0.14.1) and [InfiniTime 1.0](https://github.com/JF002/InfiniTime/releases/tag/1.0.0). + +The bootloader is easily recognizable with it white pine cone that is progressively drawn in green. It also displays its own version on the bottom (1.0.0 as of now). + +![Bootloader 1.0](bootloader-1.0.jpg) + +## How to update your PineTime? +To update your PineTime, you can use one of the compatible companion applications. Here are the main ones: + + - **[Amazfish](https://github.com/piggz/harbour-amazfish)** (Desktop Linux, mobile Linux, SailfishOS, runs on the PinebookPro and the Pinephone) + - **[Gadgetbridge](https://www.gadgetbridge.org/)** (Android) + - **[Siglo](https://github.com/alexr4535/siglo)** (Linux, GTK based) + - **NRFConnect** (closed source, Android & iOS). + +See [this page](ota-gadgetbridge-nrfconnect.md) for more info about the OTA procedure using Gadgetbrige and NRFCOnnect. + +### From InfiniTime 0.7.1 / old bootloader +If your PineTime is currently running InfiniTime 0.7.1 and the old bootloader, we strongly recommend you update them to more recent version (Bootloader 1.0.0 and InfiniTime 1.0.0 as of now). We also recommend you install the recovery firmware once the bootloader is up-do-date. + +Using the companion app of your choice, you'll need to apply the OTA procedure for these 3 firmwares in this sequence (failing to follow this specific order might temporarily or permanently brick your device): + + 1. Flash the latest version of InfiniTime. The file to upload is named **pinetime-mcuboot-app-dfu-x.y.z.zip**. Here is the link to [InfiniTime 1.0](https://github.com/JF002/InfiniTime/releases/download/1.0.0/pinetime-mcuboot-app-dfu-1.0.0.zip). + 2. Update the bootloader by applying the OTA procedure with the file named [**reloader-mcuboot.zip** from the repo of the bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader/releases/download/1.0.0/reloader-mcuboot.zip). + 3. Install the recovery firmware by applying the OTA procedure with the file named [**pinetime-mcuboot-recovery-loader-dfu-0.14.1.zip** from the version 0.14.1 of InfiniTime](https://github.com/JF002/InfiniTime/releases/download/0.14.1/pinetime-mcuboot-recovery-loader-dfu-0.14.1.zip). + +You'll find more info about this process in [this wiki page](https://wiki.pine64.org/wiki/Upgrade_PineTime_to_InfiniTime_1.0.0). You can also see the procedure in video [here](https://video.codingfield.com/videos/watch/831077c5-16f3-47b4-9b2b-c4bbfecc6529) and [here (from Amazfish)](https://video.codingfield.com/videos/watch/f7bffb3d-a6a1-43c4-8f01-f4aeff4adf9e) + +### From version > 1.0 +If you are already running the new "1.0.0" bootloader, all you have to do is update your version of InfiniTime when it'll be available. We'll write specific instructions when (if) we release a new version of the bootloader. + +### Firmware validation +The bootloader requires a (manual) validation of the firmware. If the watch reset with an updated firmware that was not validated, the bootloader will consider it as non-functionning and will revert to the previous version of the firmware. This is a safety feature to prevent bricking your device with a faulty firmware. + +You can validate your updated firmware on InfiniTime >= 1.0 by following this simple procedure: + + - From the watchface, swipe **right** to display the *Quick Actions menu* + - Open the **Settings** app by tapping the *gear* icon on the bottom right + - Swipe down and tap on the entry named **Firmware** + - This app shows the version that is currently running. If it's not validated yet, it displays 2 buttons: + - **Validate** to validate your firmware + - **Reset** to reset the watch and revert to the previously running version of the firmware + +## InfiniTime 1.0 quick user guide +### Setting the time +By default, InfiniTime starts on the digital watchface. It'll probably display the epoch time (1 Jan 1970, 00:00). The time will be automatically synchronized once you connect on of the companion app to your PineTime using BLE connectivity. InfiniTime does not provide any way to manually set the time for now. + +### Navigation in the menu + +![Quick actions](quickactions.jpg) +![Settings](settings.jpg) +![Application menu](appmenu.jpg) + + - Swipe **down** to display the notification panel. Notification sent by your companion app will be displayed in this panel. + - Swipe **up** to display the application menus. Apps (stopwatch, music, step, games,...) can be started from this menu. + - Swipe **right** to display the Quick Actions menu. This menu allows you to + - Set the brightness of the display + - Start the **flashlight** app + - Enable/disable vibrations on notifications (Do Not Disturb mode) + - Enter the **settings** menu + - Settings + - Display timeout + - Wake up event (Tap, wrist rotation) + - Time format (12/24H) + - Default watchface (digital / analog) + - Battery info + - Firmware validation + - About (system info, firmware version,...) + +### Bootloader + +Most of the time, the bootloader just runs without your intervention (update and load the firmware). + +However, you can enable 2 functionalities using the push button: + + - Push the button until the pine cone is drawn in **blue** to force the rollback of the previous version of the firmware, even if you've already validated the updated one + - Push the button until the pine cone is drawn in **red** to load the recovery firmware. This recovery firmware only provides BLE connectivity and OTA functionality. + +More info about the bootloader in [its project page](https://github.com/JF002/pinetime-mcuboot-bootloader/blob/master/README.md). + diff --git a/doc/gettingStarted/oldbootloaderlogo.jpg b/doc/gettingStarted/oldbootloaderlogo.jpg new file mode 100644 index 00000000..b4d0cdfb Binary files /dev/null and b/doc/gettingStarted/oldbootloaderlogo.jpg differ diff --git a/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md b/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md new file mode 100644 index 00000000..1187a9b7 --- /dev/null +++ b/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md @@ -0,0 +1,101 @@ +# Flash and upgrade InfiniTime +If you just want to flash or upgrade InfiniTime on your PineTime, this page is for you! + +- [InfiniTime releases and versions](#infinitime-releases-and-versions) +- [How to upgrade Over-The-Air (OTA)](#how-to-upgrade-over-the-air-ota) + - [Using Gadgetbridge](#using-gadgetbridge) + - [Using NRFConnect](#Using-nrfconnect) +- [How to flash InfiniTime using the SWD interface](#how-to-flash-infinitime-using-the-swd-interface) + +## InfiniTime releases and versions +All releases of InfiniTime are available on the [release page of the GitHub repo](https://github.com/JF002/InfiniTime/releases). + +Versions that are tagged as **RELEASE CANDIDATE** are pre-release versions, that are available for testing before actually releasing a new stable version. If you want to help us debug the project and provide stable versions to other user, you can use them. If you want stable and tested version, you should not flash these release candidate version. + +Release files are available under the *Assets* button. + +## How to upgrade Over-The-Air (OTA) +OTA is the easiest method to upgrade InfiniTime. Note that it's only possible is your PineTime is already running InfiniTime (>= 0.7.1). + +2 companion apps provide support for OTA : + - [Gadgetbridge](https://gadgetbridge.org/) (open source, runs on Android, [available on F-Droid](https://f-droid.org/packages/nodomain.freeyourgadget.gadgetbridge/)). + - [NRFConnect](https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Connect-for-mobile) (close source, runs on Android and iOS). + +Both applications need you to download the **DFU file** of InfiniTime. This file contains the new version of InfiniTime that will be flashed into your device. It's called **dfu-x.y.z.zip** (ex: dfu-0.9.0.zip) in the release note. +![Dfu file](dfuFile.png ) + +### Using Gadgetbridge +Launch Gadgetbridge and tap on the **"+"** button on the bottom right to add a new device: + +![Gadgetbridge 0](gadgetbridge0.jpg) + +Wait for the scan to complete, your PineTime should be detected: + +![Gadgetbridge 1](gadgetbridge1.jpg) + +Tap on it. Gadgdetbridge will pair and connect to your device: + +![Gadgetbridge 2](gadgetbridge2.jpg) + +Now that Gadgetbridge is connected to your PineTime, use a file browser application (I'm using Seafile to browse my NAS) and browse to the DFU file (image-xxx.zip) you downloaded previously. Tap on it and open it using the Gadgetbridge application/firmware installer: + +![Gadgetbridge 3](gadgetbridge3.jpg) + +Read carefully the warning and tap **Install**: + +![Gadgetbridge 4](gadgetbridge4.jpg) + +Wait for the transfer to finish. Your PineTime should reset and reboot with the new version of InfiniTime! + +![Gadgetbridge 5](gadgetbridge5.jpg) + +### Using NRFConnect +Open NRFConnect. Swipe down in the *Scanner* tab and wait for your device to appear: + +![NRFConnect 0](nrfconnect0.jpg) + +Tap on the *Connect* button on the right of your device. NRFConnect will connect to your PineTime and discover its characteristics. Tap on the **DFU** button on the top right: + +![NRFConnect 1](nrfconnect1.jpg) + +Select **Distribution packet (ZIP)**: + +![NRFConnect 2](nrfconnect2.jpg) + +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! + +![NRFConnect 3](nrfconnect3.jpg) + +## How to flash InfiniTime using the SWD interface +Download the files **bootloader.bin**, **image-x.y.z.bin** and **pinetime-graphics-x.y.z.bin** from the release page: + +![Image file](imageFile.png ) + +The bootloader reads a boot logo from the external SPI flash memory. The first step consists in flashing a tool in the MCU that will flash the boot logo into this SPI flash memory. This first step is optional but recommanded (the bootloader will display garbage on screen for a few second if you don't do it). +Using your SWD tool, flash **pinetime-graphics-x.y.z.bin** at offset **0x0000**. Reset the MCU and wait for a few second, until the logo is completely drawn on the display. + +Then, using your SWD tool, flash those file at specific offset: + + - bootloader.bin : **0x0000** + - image-x.y.z.bin : **0x8000** + +Reset and voilà, you're running InfiniTime on your PineTime! + +If you are using OpenOCD with a STLinkV2, you can find more info [on this page](../openOCD.md). + +## How to synchronize the time + +### Using Gadgetbridge +Good news! Gadgetbridge **automatically** synchronizes the time when connecting to your PineTime! + +### Using NRFConnect +You must enable the **CTS** *GATT server* into NRFConnect so that InfiniTime can synchronize the time with your smartphone. + +Launch NRFConnect, tap the sandwich button on the top left and select *Configure GATT server*: + +![NRFConnect CTS 0](nrfconnectcts0.jpg) + + +Tap *Add service* and select the server configuration *Current Time service*. Tap OK and connect to your PineTime, it should automcatically sync the time once the connection is established! + +![NRFConnect CTS 1](nrfconnectcts1.jpg) diff --git a/doc/gettingStarted/quickactions.jpg b/doc/gettingStarted/quickactions.jpg new file mode 100644 index 00000000..0d92b134 Binary files /dev/null and b/doc/gettingStarted/quickactions.jpg differ diff --git a/doc/gettingStarted/settings.jpg b/doc/gettingStarted/settings.jpg new file mode 100644 index 00000000..510b29eb Binary files /dev/null and b/doc/gettingStarted/settings.jpg differ diff --git a/doc/gettingStarted/version-071.jpg b/doc/gettingStarted/version-071.jpg new file mode 100644 index 00000000..bc9bc5b5 Binary files /dev/null and b/doc/gettingStarted/version-071.jpg differ diff --git a/doc/gettingStarted/version-1.0.jpg b/doc/gettingStarted/version-1.0.jpg new file mode 100644 index 00000000..bcfc8c63 Binary files /dev/null and b/doc/gettingStarted/version-1.0.jpg differ diff --git a/docker/.gitpod.Dockerfile b/docker/.gitpod.Dockerfile index 2f7099a5..4fbc7be0 100644 --- a/docker/.gitpod.Dockerfile +++ b/docker/.gitpod.Dockerfile @@ -19,8 +19,11 @@ RUN apt-get update -qq \ libffi-dev \ libssl-dev \ python3-dev \ + git \ && rm -rf /var/cache/apt/* /var/lib/apt/lists/*; +# Git needed for PROJECT_GIT_COMMIT_HASH variable setting + # Needs to be installed as root RUN pip3 install adafruit-nrfutil RUN pip3 install -Iv cryptography==3.3 diff --git a/docker/Dockerfile b/docker/Dockerfile index a6caa24e..0a4f69f0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -19,8 +19,11 @@ RUN apt-get update -qq \ libssl-dev \ python3-dev \ python \ + git \ && rm -rf /var/cache/apt/* /var/lib/apt/lists/*; +# Git needed for PROJECT_GIT_COMMIT_HASH variable setting + RUN pip3 install adafruit-nrfutil RUN pip3 install -Iv cryptography==3.3 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5c6af93b..acbfba18 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -406,6 +406,7 @@ list(APPEND SOURCE_FILES displayapp/screens/FlashLight.cpp displayapp/screens/List.cpp displayapp/screens/BatteryInfo.cpp + displayapp/screens/Steps.cpp ## Settings displayapp/screens/settings/QuickSettings.cpp @@ -414,12 +415,12 @@ list(APPEND SOURCE_FILES displayapp/screens/settings/SettingTimeFormat.cpp displayapp/screens/settings/SettingWakeUp.cpp displayapp/screens/settings/SettingDisplay.cpp + displayapp/screens/settings/SettingSteps.cpp ## Watch faces displayapp/icons/bg_clock.c displayapp/screens/WatchFaceAnalog.cpp displayapp/screens/WatchFaceDigital.cpp - displayapp/screens/PineTimeStyle.cpp ## @@ -467,7 +468,7 @@ list(APPEND SOURCE_FILES displayapp/fonts/jetbrains_mono_extrabold_compressed.c displayapp/fonts/jetbrains_mono_bold_20.c displayapp/fonts/jetbrains_mono_76.c - displayapp/fonts/open_sans_light.c + displayapp/fonts/jetbrains_mono_42.c displayapp/fonts/lv_font_sys_48.c displayapp/lv_pinetime_theme.c diff --git a/src/Version.h.in b/src/Version.h.in index 6ff5938e..8cd39c96 100644 --- a/src/Version.h.in +++ b/src/Version.h.in @@ -8,11 +8,13 @@ namespace Pinetime { static constexpr uint32_t Major() {return major;} static constexpr uint32_t Minor() {return minor;} static constexpr uint32_t Patch() {return patch;} + static constexpr const char* GitCommitHash() {return commitHash;} static constexpr const char* VersionString() {return versionString;} private: static constexpr uint32_t major = @PROJECT_VERSION_MAJOR@; static constexpr uint32_t minor = @PROJECT_VERSION_MINOR@; static constexpr uint32_t patch = @PROJECT_VERSION_PATCH@; + static constexpr const char* commitHash = "@PROJECT_GIT_COMMIT_HASH@"; static constexpr const char* versionString = "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@"; }; } \ No newline at end of file diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h index bf644812..3a238262 100644 --- a/src/components/motion/MotionController.h +++ b/src/components/motion/MotionController.h @@ -8,13 +8,13 @@ namespace Pinetime { public: void Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps); - uint16_t X() const { + int16_t X() const { return x; } - uint16_t Y() const { + int16_t Y() const { return y; } - uint16_t Z() const { + int16_t Z() const { return z; } uint32_t NbSteps() const { diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 18c87fd4..4409425b 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -86,6 +86,14 @@ namespace Pinetime { return settings.brightLevel; }; + void SetStepsGoal( uint32_t goal ) { + if ( goal != settings.stepsGoal ) + settingsChanged = true; + settings.stepsGoal = goal; + }; + + uint32_t GetStepsGoal() const { return settings.stepsGoal; }; + private: Pinetime::Drivers::SpiNorFlash& spiNorFlash; struct SettingsData { @@ -95,7 +103,7 @@ namespace Pinetime { uint8_t clockFace = 0; - uint32_t stepsGoal = 1000; + uint32_t stepsGoal = 10000; uint32_t screenTimeOut = 15000; WakeUpMode wakeUpMode = WakeUpMode::None; diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h index 936a3ae8..09a20181 100644 --- a/src/displayapp/Apps.h +++ b/src/displayapp/Apps.h @@ -21,12 +21,14 @@ namespace Pinetime { Navigation, StopWatch, Motion, + Steps, QuickSettings, Settings, SettingWatchFace, SettingTimeFormat, SettingDisplay, - SettingWakeUp + SettingWakeUp, + SettingSteps }; } } diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 3a20c766..a6c4a3ec 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -25,6 +25,7 @@ #include "displayapp/screens/Twos.h" #include "displayapp/screens/FlashLight.h" #include "displayapp/screens/BatteryInfo.h" +#include "displayapp/screens/Steps.h" #include "drivers/Cst816s.h" #include "drivers/St7789.h" @@ -37,6 +38,7 @@ #include "displayapp/screens/settings/SettingTimeFormat.h" #include "displayapp/screens/settings/SettingWakeUp.h" #include "displayapp/screens/settings/SettingDisplay.h" +#include "displayapp/screens/settings/SettingSteps.h" using namespace Pinetime::Applications; using namespace Pinetime::Applications::Display; @@ -65,7 +67,7 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd, notificationManager {notificationManager}, heartRateController {heartRateController}, settingsController {settingsController}, - motorController{motorController}, + motorController {motorController}, motionController {motionController} { msgQueue = xQueueCreate(queueSize, itemSize); // Start clock when smartwatch boots @@ -73,8 +75,9 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd, } void DisplayApp::Start() { - if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) + if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) { APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); + } } void DisplayApp::Process(void* instance) { @@ -85,7 +88,7 @@ void DisplayApp::Process(void* instance) { // Send a dummy notification to unlock the lvgl display driver for the first iteration xTaskNotifyGive(xTaskGetCurrentTaskHandle()); - while (1) { + while (true) { app->Refresh(); } } @@ -213,7 +216,7 @@ void DisplayApp::StartApp(Apps app, DisplayApp::FullRefreshDirections direction) LoadApp(app, direction); } -void DisplayApp::returnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent) { +void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent) { returnToApp = app; returnDirection = direction; returnTouchEvent = touchEvent; @@ -224,12 +227,12 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) SetFullRefresh(direction); // default return to launcher - returnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::SwipeDown); + ReturnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::SwipeDown); switch (app) { case Apps::Launcher: currentScreen = std::make_unique(this, settingsController, batteryController, dateTimeController); - returnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::SwipeDown); + ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::None: case Apps::Clock: @@ -245,7 +248,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) case Apps::FirmwareValidation: currentScreen = std::make_unique(this, validator); - returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::FirmwareUpdate: currentScreen = std::make_unique(this, bleController); @@ -254,54 +257,58 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) case Apps::Notifications: currentScreen = std::make_unique( this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Normal); - returnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); + ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); break; case Apps::NotificationsPreview: currentScreen = std::make_unique( this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Preview); - returnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); + ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); break; // Settings case Apps::QuickSettings: - currentScreen = - std::make_unique(this, batteryController, dateTimeController, brightnessController, motorController, settingsController); - returnApp(Apps::Clock, FullRefreshDirections::LeftAnim, TouchEvents::SwipeLeft); + currentScreen = std::make_unique( + this, batteryController, dateTimeController, brightnessController, motorController, settingsController); + ReturnApp(Apps::Clock, FullRefreshDirections::LeftAnim, TouchEvents::SwipeLeft); break; case Apps::Settings: currentScreen = std::make_unique(this, settingsController); - returnApp(Apps::QuickSettings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + ReturnApp(Apps::QuickSettings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SettingWatchFace: currentScreen = std::make_unique(this, settingsController); - returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SettingTimeFormat: currentScreen = std::make_unique(this, settingsController); - returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SettingWakeUp: currentScreen = std::make_unique(this, settingsController); - returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SettingDisplay: currentScreen = std::make_unique(this, settingsController); - returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + break; + case Apps::SettingSteps: + currentScreen = std::make_unique(this, settingsController); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::BatteryInfo: currentScreen = std::make_unique(this, batteryController); - returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SysInfo: currentScreen = std::make_unique(this, dateTimeController, batteryController, brightnessController, bleController, watchdog); - returnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; // case Apps::FlashLight: currentScreen = std::make_unique(this, systemTask, brightnessController); - returnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None); + ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None); break; case Apps::StopWatch: currentScreen = std::make_unique(this); @@ -327,6 +334,9 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) case Apps::Motion: currentScreen = std::make_unique(this, motionController); break; + case Apps::Steps: + currentScreen = std::make_unique(this, motionController, settingsController); + break; } currentApp = app; } @@ -349,8 +359,9 @@ TouchEvents DisplayApp::OnTouchEvent() { if (info.isTouch) { switch (info.gesture) { case Pinetime::Drivers::Cst816S::Gestures::SingleTap: - if (touchMode == TouchModes::Gestures) + if (touchMode == TouchModes::Gestures) { lvgl.SetNewTapEvent(info.x, info.y); + } return TouchEvents::Tap; case Pinetime::Drivers::Cst816S::Gestures::LongPress: return TouchEvents::LongTap; diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index 75e52755..ffe27cf1 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -103,7 +103,7 @@ namespace Pinetime { static void Process(void* instance); void InitHw(); void Refresh(); - void returnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent); + void ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent); void LoadApp(Apps app, DisplayApp::FullRefreshDirections direction); }; } diff --git a/src/displayapp/DisplayAppRecovery.cpp b/src/displayapp/DisplayAppRecovery.cpp index 6db987fa..a132a47c 100644 --- a/src/displayapp/DisplayAppRecovery.cpp +++ b/src/displayapp/DisplayAppRecovery.cpp @@ -37,7 +37,7 @@ void DisplayApp::Process(void* instance) { xTaskNotifyGive(xTaskGetCurrentTaskHandle()); app->InitHw(); - while (1) { + while (true) { app->Refresh(); } } @@ -51,10 +51,11 @@ void DisplayApp::Refresh() { if (xQueueReceive(msgQueue, &msg, 200)) { switch (msg) { case Display::Messages::UpdateBleConnection: - if (bleController.IsConnected()) + if (bleController.IsConnected()) { DisplayLogo(colorBlue); - else + } else { DisplayLogo(colorWhite); + } break; case Display::Messages::BleFirmwareUpdateStarted: DisplayLogo(colorGreen); diff --git a/src/displayapp/fonts/jetbrains_mono_42.c b/src/displayapp/fonts/jetbrains_mono_42.c new file mode 100644 index 00000000..6f25f5ab --- /dev/null +++ b/src/displayapp/fonts/jetbrains_mono_42.c @@ -0,0 +1,258 @@ +/******************************************************************************* + * Size: 42 px + * Bpp: 1 + * Opts: + ******************************************************************************/ + +#ifdef LV_LVGL_H_INCLUDE_SIMPLE +#include "lvgl.h" +#else +#include "lvgl/lvgl.h" +#endif + +#ifndef JETBRAINS_MONO_42 +#define JETBRAINS_MONO_42 1 +#endif + +#if JETBRAINS_MONO_42 + +/*----------------- + * BITMAPS + *----------------*/ + +/*Store the image of the glyphs*/ +static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = { + /* U+0025 "%" */ + 0x1f, 0x80, 0x7, 0x3f, 0xc0, 0xe, 0x7f, 0xe0, + 0x1c, 0xf0, 0xf0, 0x1c, 0xe0, 0x70, 0x38, 0xe0, + 0x70, 0x70, 0xe0, 0x70, 0x70, 0xe0, 0x70, 0xe0, + 0xe0, 0x71, 0xc0, 0xe0, 0x71, 0xc0, 0xf0, 0xf3, + 0x80, 0x7f, 0xe7, 0x0, 0x3f, 0xc7, 0x0, 0x1f, + 0x8e, 0x0, 0x0, 0x1c, 0x0, 0x0, 0x3c, 0x0, + 0x0, 0x38, 0x0, 0x0, 0x71, 0xf8, 0x0, 0xe3, + 0xfc, 0x0, 0xe7, 0xfe, 0x1, 0xcf, 0xf, 0x3, + 0x8e, 0x7, 0x3, 0x8e, 0x7, 0x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 0x0, + 0xf, 0xf0, 0x0, 0xff, 0x0, 0xf, 0xf8, 0x1, + 0xf7, 0x80, 0x1e, 0x7c, 0x3, 0xe3, 0xe0, 0x7e, + 0x3f, 0xff, 0xc1, 0xff, 0xfc, 0x7, 0xe7, 0x80, + 0x0, 0xf8, 0x0, 0xf, 0x0, 0x1, 0xe0, 0x0, + 0x1e, 0x0, 0x3, 0xc0, 0x0, 0x3c, 0x0, 0x7, + 0x80, 0x0, 0xf8, 0x0, 0xf, 0x0, 0x1, 0xe0, + 0x0, 0x1e, 0x0, 0x3, 0xc0, 0x0, + + /* U+003A ":" */ + 0x7d, 0xff, 0xff, 0xff, 0xef, 0x80, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, + 0xf7, 0xff, 0xff, 0xff, 0xbe +}; + + +/*--------------------- + * GLYPH DESCRIPTION + *--------------------*/ + +static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { + {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, + {.bitmap_index = 0, .adv_w = 403, .box_w = 24, .box_h = 31, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 93, .adv_w = 403, .box_w = 19, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, + {.bitmap_index = 167, .adv_w = 403, .box_w = 19, .box_h = 31, .ofs_x = 4, .ofs_y = 0}, + {.bitmap_index = 241, .adv_w = 403, .box_w = 19, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, + {.bitmap_index = 315, .adv_w = 403, .box_w = 19, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, + {.bitmap_index = 389, .adv_w = 403, .box_w = 18, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, + {.bitmap_index = 459, .adv_w = 403, .box_w = 18, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, + {.bitmap_index = 529, .adv_w = 403, .box_w = 20, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, + {.bitmap_index = 607, .adv_w = 403, .box_w = 20, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, + {.bitmap_index = 685, .adv_w = 403, .box_w = 20, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, + {.bitmap_index = 763, .adv_w = 403, .box_w = 20, .box_h = 31, .ofs_x = 3, .ofs_y = 0}, + {.bitmap_index = 841, .adv_w = 403, .box_w = 7, .box_h = 24, .ofs_x = 9, .ofs_y = 0} +}; + +/*--------------------- + * CHARACTER MAPPING + *--------------------*/ + + + +/*Collect the unicode lists and glyph_id offsets*/ +static const lv_font_fmt_txt_cmap_t cmaps[] = +{ + { + .range_start = 37, .range_length = 1, .glyph_id_start = 1, + .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY + }, + { + .range_start = 48, .range_length = 11, .glyph_id_start = 2, + .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY + } +}; + + + +/*-------------------- + * ALL CUSTOM DATA + *--------------------*/ + +#if LV_VERSION_CHECK(8, 0, 0) +/*Store all the custom data of the font*/ +static lv_font_fmt_txt_glyph_cache_t cache; +static const lv_font_fmt_txt_dsc_t font_dsc = { +#else +static lv_font_fmt_txt_dsc_t font_dsc = { +#endif + .glyph_bitmap = glyph_bitmap, + .glyph_dsc = glyph_dsc, + .cmaps = cmaps, + .kern_dsc = NULL, + .kern_scale = 0, + .cmap_num = 2, + .bpp = 1, + .kern_classes = 0, + .bitmap_format = 0, +#if LV_VERSION_CHECK(8, 0, 0) + .cache = &cache +#endif +}; + + +/*----------------- + * PUBLIC FONT + *----------------*/ + +/*Initialize a public general font descriptor*/ +#if LV_VERSION_CHECK(8, 0, 0) +const lv_font_t jetbrains_mono_42 = { +#else +lv_font_t jetbrains_mono_42 = { +#endif + .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ + .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ + .line_height = 31, /*The maximum line height required by the font*/ + .base_line = 0, /*Baseline measured from the bottom of the line*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -7, + .underline_thickness = 2, +#endif + .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ +}; + + + +#endif /*#if JETBRAINS_MONO_42*/ + diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp index 7e38b3f4..1eb36999 100644 --- a/src/displayapp/screens/ApplicationList.cpp +++ b/src/displayapp/screens/ApplicationList.cpp @@ -49,7 +49,7 @@ std::unique_ptr ApplicationList::CreateScreen1() { {Symbols::stopWatch, Apps::StopWatch}, {Symbols::music, Apps::Music}, {Symbols::map, Apps::Navigation}, - {Symbols::shoe, Apps::Motion}, + {Symbols::shoe, Apps::Steps}, {Symbols::heartBeat, Apps::HeartRate}, {"", Apps::None}, }}; @@ -62,7 +62,7 @@ std::unique_ptr ApplicationList::CreateScreen2() { {Symbols::paintbrush, Apps::Paint}, {Symbols::paddle, Apps::Paddle}, {"2", Apps::Twos}, - {"", Apps::None}, + {"M", Apps::Motion}, {"", Apps::None}, {"", Apps::None}, }}; diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index e0c1f62b..14299840 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -14,7 +14,6 @@ #include "../DisplayApp.h" #include "WatchFaceDigital.h" #include "WatchFaceAnalog.h" -#include "PineTimeStyle.h" using namespace Pinetime::Applications::Screens; @@ -43,9 +42,6 @@ Clock::Clock(DisplayApp* app, [this]() -> std::unique_ptr { return WatchFaceAnalogScreen(); }, - [this]() -> std::unique_ptr { - return PineTimeStyleScreen(); - }, // Examples for more watch faces //[this]() -> std::unique_ptr { return WatchFaceMinimalScreen(); }, //[this]() -> std::unique_ptr { return WatchFaceCustomScreen(); } @@ -84,16 +80,6 @@ std::unique_ptr Clock::WatchFaceAnalogScreen() { app, dateTimeController, batteryController, bleController, notificatioManager, settingsController); } -std::unique_ptr Clock::PineTimeStyleScreen() { - return std::make_unique(app, - dateTimeController, - batteryController, - bleController, - notificatioManager, - settingsController, - heartRateController); -} - /* // Examples for more watch faces std::unique_ptr Clock::WatchFaceMinimalScreen() { @@ -105,4 +91,4 @@ std::unique_ptr Clock::WatchFaceCustomScreen() { return std::make_unique(app, dateTimeController, batteryController, bleController, notificatioManager, settingsController); } -*/ +*/ \ No newline at end of file diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h index 920d58bb..9879985f 100644 --- a/src/displayapp/screens/Clock.h +++ b/src/displayapp/screens/Clock.h @@ -47,10 +47,9 @@ namespace Pinetime { Controllers::HeartRateController& heartRateController; Controllers::MotionController& motionController; - ScreenList<3> screens; + ScreenList<2> screens; std::unique_ptr WatchFaceDigitalScreen(); std::unique_ptr WatchFaceAnalogScreen(); - std::unique_ptr PineTimeStyleScreen(); // Examples for more watch faces // std::unique_ptr WatchFaceMinimalScreen(); diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp index 873a22f5..ad37a3df 100644 --- a/src/displayapp/screens/FirmwareValidation.cpp +++ b/src/displayapp/screens/FirmwareValidation.cpp @@ -27,6 +27,17 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app, sprintf(version, "%ld.%ld.%ld", Version::Major(), Version::Minor(), Version::Patch()); lv_label_set_text(labelVersionValue, version); + labelShortRefInfo = lv_label_create(lv_scr_act(), nullptr); + lv_obj_align(labelShortRefInfo, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 25); + lv_label_set_text(labelShortRefInfo, "ShortRef : "); + lv_label_set_align(labelShortRefInfo, LV_LABEL_ALIGN_LEFT); + + labelShortRefValue = lv_label_create(lv_scr_act(), nullptr); + lv_obj_align(labelShortRefValue, labelShortRefInfo, LV_ALIGN_OUT_RIGHT_MID, 0, 0); + lv_label_set_recolor(labelShortRefValue, true); + sprintf(shortref, "%s", Version::GitCommitHash()); + lv_label_set_text(labelShortRefValue, shortref); + labelIsValidated = lv_label_create(lv_scr_act(), nullptr); lv_obj_align(labelIsValidated, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 50); lv_label_set_recolor(labelIsValidated, true); diff --git a/src/displayapp/screens/FirmwareValidation.h b/src/displayapp/screens/FirmwareValidation.h index 67662fd9..303c2154 100644 --- a/src/displayapp/screens/FirmwareValidation.h +++ b/src/displayapp/screens/FirmwareValidation.h @@ -25,7 +25,10 @@ namespace Pinetime { lv_obj_t* labelVersionInfo; lv_obj_t* labelVersionValue; + lv_obj_t* labelShortRefInfo; + lv_obj_t* labelShortRefValue; char version[9]; + char shortref[9]; lv_obj_t* labelIsValidated; lv_obj_t* buttonValidate; lv_obj_t* labelButtonValidate; diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp index e7196267..a8bb3c18 100644 --- a/src/displayapp/screens/Motion.cpp +++ b/src/displayapp/screens/Motion.cpp @@ -3,8 +3,6 @@ #include "../DisplayApp.h" using namespace Pinetime::Applications::Screens; -extern lv_font_t jetbrains_mono_extrabold_compressed; -extern lv_font_t jetbrains_mono_bold_20; Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionController& motionController) : Screen(app), motionController {motionController} { @@ -29,13 +27,16 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr lv_chart_init_points(chart, ser3, 0); lv_chart_refresh(chart); /*Required after direct set*/ + label = lv_label_create(lv_scr_act(), NULL); + lv_label_set_text_fmt(label, "X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#", 0, 0, 0); + lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); + lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); + lv_label_set_recolor(label, true); + 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: "); + lv_label_set_text(labelStep, "Steps ---"); - labelStepValue = lv_label_create(lv_scr_act(), NULL); - lv_obj_align(labelStepValue, labelStep, LV_ALIGN_OUT_RIGHT_MID, 0, 0); - lv_label_set_text(labelStepValue, "-"); } Motion::~Motion() { @@ -47,8 +48,10 @@ bool Motion::Refresh() { lv_chart_set_next(chart, ser2, motionController.Y()); lv_chart_set_next(chart, ser3, motionController.Z()); - snprintf(nbStepsBuffer, nbStepsBufferSize, "%lu", motionController.NbSteps()); - lv_label_set_text(labelStepValue, nbStepsBuffer); + lv_label_set_text_fmt(labelStep, "Steps %lu", motionController.NbSteps()); + + lv_label_set_text_fmt(label, "X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#", motionController.X() / 0x10, 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 11007866..132b20ec 100644 --- a/src/displayapp/screens/Motion.h +++ b/src/displayapp/screens/Motion.h @@ -26,9 +26,9 @@ namespace Pinetime { lv_chart_series_t* ser1; lv_chart_series_t* ser2; lv_chart_series_t* ser3; + lv_obj_t* label; lv_obj_t* labelStep; - lv_obj_t* labelStepValue; static constexpr uint8_t nbStepsBufferSize = 9; char nbStepsBuffer[nbStepsBufferSize + 1]; bool running = true; diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index f0fd2f66..1f113750 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -176,7 +176,17 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x888888)); if (title == nullptr) title = "Notification"; + char* pchar; + pchar = strchr(title, '\n'); + while (pchar != nullptr) { + *pchar = ' '; + pchar = + pchar = strchr(pchar + 1, '\n'); + } lv_label_set_text(alert_type, title); + lv_label_set_long_mode(alert_type, LV_LABEL_LONG_SROLL_CIRC); + lv_label_set_anim_speed(alert_type, 3); + lv_obj_set_width(alert_type, 180); lv_obj_align(alert_type, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 16); ///////// diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp new file mode 100644 index 00000000..b485c975 --- /dev/null +++ b/src/displayapp/screens/Steps.cpp @@ -0,0 +1,72 @@ +#include "Steps.h" +#include +#include "../DisplayApp.h" +#include "Symbols.h" + +using namespace Pinetime::Applications::Screens; + +Steps::Steps( + Pinetime::Applications::DisplayApp *app, + Controllers::MotionController& motionController, + Controllers::Settings &settingsController) + : Screen(app), + motionController{motionController}, + settingsController{settingsController} { + + stepsArc = lv_arc_create(lv_scr_act(), nullptr); + + lv_obj_set_style_local_bg_opa(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, LV_OPA_0); + lv_obj_set_style_local_border_width(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 2); + lv_obj_set_style_local_radius(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0); + lv_obj_set_style_local_line_color(stepsArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, lv_color_hex(0x0000FF)); + lv_arc_set_end_angle(stepsArc, 200); + lv_obj_set_size(stepsArc, 220, 220); + lv_arc_set_range(stepsArc, 0, 500); + lv_obj_align(stepsArc, nullptr, LV_ALIGN_CENTER, 0, 0); + + stepsCount = motionController.NbSteps(); + + lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal())); + + lSteps = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); + lv_obj_set_style_local_text_font(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_label_set_text_fmt(lSteps, "%li", stepsCount); + lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20); + + lv_obj_t * lstepsL = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(lstepsL, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); + lv_label_set_text_static(lstepsL, "Steps"); + lv_obj_align(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); + + lv_obj_t * lstepsGoal = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(lstepsGoal, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN); + lv_label_set_text_fmt(lstepsGoal,"Goal\n%i", settingsController.GetStepsGoal()); + lv_label_set_align(lstepsGoal, LV_LABEL_ALIGN_CENTER); + lv_obj_align(lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 60); + + lv_obj_t * backgroundLabel = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + lv_obj_set_size(backgroundLabel, 240, 240); + lv_obj_set_pos(backgroundLabel, 0, 0); + lv_label_set_text_static(backgroundLabel, ""); + +} + +Steps::~Steps() { + lv_obj_clean(lv_scr_act()); +} + +bool 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 new file mode 100644 index 00000000..9c135e26 --- /dev/null +++ b/src/displayapp/screens/Steps.h @@ -0,0 +1,39 @@ +#pragma once + +#include +#include +#include "Screen.h" +#include + +namespace Pinetime { + + namespace Controllers { + class Settings; + } + + namespace Applications { + namespace Screens { + + class Steps : public Screen { + public: + Steps(DisplayApp* app, Controllers::MotionController& motionController, Controllers::Settings &settingsController); + ~Steps() override; + + bool Refresh() override; + + + private: + + Controllers::MotionController& motionController; + Controllers::Settings& settingsController; + + lv_obj_t * lSteps; + lv_obj_t * lStepsIcon; + lv_obj_t * stepsArc; + + uint32_t stepsCount; + + }; + } + } +} diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index e06981af..d7cd20c3 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -115,8 +115,9 @@ bool StopWatch::Refresh() { // Init state when an user first opens the app // and when a stop/reset button is pressed case States::Init: { - if (btnStopLap) { + if (btnStopLap != nullptr) { lv_obj_del(btnStopLap); + btnStopLap = nullptr; } // The initial default value lv_label_set_text(time, "00:00"); diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index f6e8d61a..e4ef6911 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -69,12 +69,14 @@ std::unique_ptr SystemInfo::CreateScreen1() { lv_label_set_text_fmt(label, "#FFFF00 InfiniTime#\n\n" "#444444 Version# %ld.%ld.%ld\n\n" + "#444444 Short Ref# %s\n\n" "#444444 Build date#\n" - "\t%s\n" - "\t%s\n", + "%s\n" + "%s\n", Version::Major(), Version::Minor(), Version::Patch(), + Version::GitCommitHash(), __DATE__, __TIME__); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); @@ -242,4 +244,4 @@ std::unique_ptr SystemInfo::CreateScreen5() { lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); return std::unique_ptr(new Screens::Label(4, 5, app, label)); -} \ No newline at end of file +} diff --git a/src/displayapp/screens/settings/SettingSteps.cpp b/src/displayapp/screens/settings/SettingSteps.cpp new file mode 100644 index 00000000..b7c024f1 --- /dev/null +++ b/src/displayapp/screens/settings/SettingSteps.cpp @@ -0,0 +1,98 @@ +#include "SettingSteps.h" +#include +#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) { + SettingSteps* screen = static_cast(obj->user_data); + screen->UpdateSelected(obj, event); + } +} + +SettingSteps::SettingSteps( + Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) : + Screen(app), + settingsController{settingsController} +{ + + lv_obj_t * container1 = lv_cont_create(lv_scr_act(), nullptr); + + //lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); + lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); + lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10); + lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); + lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_pos(container1, 30, 60); + lv_obj_set_width(container1, LV_HOR_RES - 50); + lv_obj_set_height(container1, LV_VER_RES - 60); + lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); + + lv_obj_t * title = lv_label_create(lv_scr_act(), NULL); + lv_label_set_text_static(title,"Daily steps goal"); + lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); + lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15); + + lv_obj_t * icon = lv_label_create(lv_scr_act(), NULL); + lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + + lv_label_set_text_static(icon, Symbols::shoe); + lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); + lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); + + + stepValue = lv_label_create(lv_scr_act(), NULL); + lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_label_set_text_fmt(stepValue,"%i", settingsController.GetStepsGoal()); + lv_label_set_align(stepValue, LV_LABEL_ALIGN_CENTER); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); + + btnPlus = lv_btn_create(lv_scr_act(), NULL); + btnPlus->user_data = this; + lv_obj_set_size(btnPlus, 80, 50); + lv_obj_align(btnPlus, lv_scr_act(), LV_ALIGN_CENTER, 55, 80); + lv_obj_set_style_local_value_str(btnPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+"); + lv_obj_set_event_cb(btnPlus, event_handler); + + btnMinus = lv_btn_create(lv_scr_act(), NULL); + btnMinus->user_data = this; + lv_obj_set_size(btnMinus, 80, 50); + lv_obj_set_event_cb(btnMinus, event_handler); + lv_obj_align(btnMinus, lv_scr_act(), LV_ALIGN_CENTER, -55, 80); + lv_obj_set_style_local_value_str(btnMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-"); + +} + +SettingSteps::~SettingSteps() { + lv_obj_clean(lv_scr_act()); + 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)) { + value += 1000; + if ( value <= 500000 ) { + settingsController.SetStepsGoal(value); + lv_label_set_text_fmt(stepValue,"%i", settingsController.GetStepsGoal()); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); + } + } + + if(object == btnMinus && (event == LV_EVENT_PRESSED)) { + value -= 1000; + if ( value >= 1000 ) { + settingsController.SetStepsGoal(value); + lv_label_set_text_fmt(stepValue,"%i", settingsController.GetStepsGoal()); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); + } + } + +} \ No newline at end of file diff --git a/src/displayapp/screens/settings/SettingSteps.h b/src/displayapp/screens/settings/SettingSteps.h new file mode 100644 index 00000000..0a4c2056 --- /dev/null +++ b/src/displayapp/screens/settings/SettingSteps.h @@ -0,0 +1,32 @@ +#pragma once + +#include +#include +#include "components/settings/Settings.h" +#include "displayapp/screens/Screen.h" + +namespace Pinetime { + + namespace Applications { + namespace Screens { + + 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: + + Controllers::Settings& settingsController; + + lv_obj_t * stepValue; + lv_obj_t * btnPlus; + lv_obj_t * btnMinus; + + }; + } + } +} diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp index 3914a048..457cebf6 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.cpp +++ b/src/displayapp/screens/settings/SettingWatchFace.cpp @@ -58,15 +58,6 @@ SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pine lv_checkbox_set_checked(cbOption[optionsTotal], true); } - optionsTotal++; - cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); - lv_checkbox_set_text_static(cbOption[optionsTotal], " PineTimeStyle"); - cbOption[optionsTotal]->user_data = this; - lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); - if (settingsController.GetClockFace() == 2) { - lv_checkbox_set_checked(cbOption[optionsTotal], true); - } - optionsTotal++; } @@ -90,4 +81,4 @@ void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) { } } } -} +} \ No newline at end of file diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h index 6f65d692..1930a228 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.h +++ b/src/displayapp/screens/settings/SettingWatchFace.h @@ -21,7 +21,7 @@ namespace Pinetime { private: Controllers::Settings& settingsController; uint8_t optionsTotal; - lv_obj_t* cbOption[3]; + lv_obj_t* cbOption[2]; }; } } diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp index e24be3d7..2c72c832 100644 --- a/src/displayapp/screens/settings/Settings.cpp +++ b/src/displayapp/screens/settings/Settings.cpp @@ -44,9 +44,7 @@ std::unique_ptr Settings::CreateScreen1() { {Symbols::clock, "Wake Up", Apps::SettingWakeUp}, {Symbols::clock, "Time format", Apps::SettingTimeFormat}, {Symbols::clock, "Watch face", Apps::SettingWatchFace}, - } - - }; + }}; return std::unique_ptr(new Screens::List(0, 2, app, settingsController, applications)); } @@ -54,13 +52,11 @@ std::unique_ptr Settings::CreateScreen1() { std::unique_ptr Settings::CreateScreen2() { std::array applications {{ + {Symbols::shoe, "Steps", Apps::SettingSteps}, {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}, {Symbols::check, "Firmware", Apps::FirmwareValidation}, {Symbols::list, "About", Apps::SysInfo}, - {"", "", Apps::None}, - } - - }; + }}; return std::unique_ptr(new Screens::List(1, 2, app, settingsController, applications)); } diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index e774091b..761baba2 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -415,8 +415,8 @@ typedef void* lv_indev_drv_user_data_t; /*Type of user data in the in #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(jetbrains_mono_bold_20) \ LV_FONT_DECLARE(jetbrains_mono_extrabold_compressed) \ + LV_FONT_DECLARE(jetbrains_mono_42) \ LV_FONT_DECLARE(jetbrains_mono_76) \ - LV_FONT_DECLARE(open_sans_light) \ LV_FONT_DECLARE(lv_font_sys_48) /* Enable it if you have fonts with a lot of characters. @@ -758,4 +758,4 @@ typedef void* lv_obj_user_data_t; /*--END OF LV_CONF_H--*/ -#endif /*LV_CONF_H*/ +#endif /*LV_CONF_H*/ \ No newline at end of file diff --git a/src/logging/NrfLogger.cpp b/src/logging/NrfLogger.cpp index 70a00e61..1c048f2c 100644 --- a/src/logging/NrfLogger.cpp +++ b/src/logging/NrfLogger.cpp @@ -12,8 +12,9 @@ void NrfLogger::Init() { NRF_LOG_DEFAULT_BACKENDS_INIT(); - if (pdPASS != xTaskCreate(NrfLogger::Process, "LOGGER", 200, this, 0, &m_logger_thread)) + if (pdPASS != xTaskCreate(NrfLogger::Process, "LOGGER", 200, this, 0, &m_logger_thread)) { APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); + } } void NrfLogger::Process(void*) { @@ -21,7 +22,7 @@ void NrfLogger::Process(void*) { // Suppress endless loop diagnostic #pragma clang diagnostic push #pragma ide diagnostic ignored "EndlessLoop" - while (1) { + while (true) { NRF_LOG_FLUSH(); vTaskDelay(100); // Not good for power consumption, it will wake up every 100ms... } -- cgit v1.2.3 From 108bbc3642f9e6ca614ab4b470eb8ae34e739ffe Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Tue, 18 May 2021 18:03:26 +0200 Subject: Fix it again.. --- src/CMakeLists.txt | 2 ++ src/displayapp/screens/Clock.cpp | 16 +++++++++++++++- src/displayapp/screens/Clock.h | 3 ++- src/displayapp/screens/settings/SettingWatchFace.cpp | 11 ++++++++++- src/libs/lv_conf.h | 3 ++- 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index acbfba18..5b83812d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -421,6 +421,7 @@ list(APPEND SOURCE_FILES displayapp/icons/bg_clock.c displayapp/screens/WatchFaceAnalog.cpp displayapp/screens/WatchFaceDigital.cpp + displayapp/screens/PineTimeStyle.cpp ## @@ -470,6 +471,7 @@ list(APPEND SOURCE_FILES displayapp/fonts/jetbrains_mono_76.c displayapp/fonts/jetbrains_mono_42.c displayapp/fonts/lv_font_sys_48.c + displayapp/fonts/open_sans_light.c displayapp/lv_pinetime_theme.c systemtask/SystemTask.cpp diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index 14299840..e0c1f62b 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -14,6 +14,7 @@ #include "../DisplayApp.h" #include "WatchFaceDigital.h" #include "WatchFaceAnalog.h" +#include "PineTimeStyle.h" using namespace Pinetime::Applications::Screens; @@ -42,6 +43,9 @@ Clock::Clock(DisplayApp* app, [this]() -> std::unique_ptr { return WatchFaceAnalogScreen(); }, + [this]() -> std::unique_ptr { + return PineTimeStyleScreen(); + }, // Examples for more watch faces //[this]() -> std::unique_ptr { return WatchFaceMinimalScreen(); }, //[this]() -> std::unique_ptr { return WatchFaceCustomScreen(); } @@ -80,6 +84,16 @@ std::unique_ptr Clock::WatchFaceAnalogScreen() { app, dateTimeController, batteryController, bleController, notificatioManager, settingsController); } +std::unique_ptr Clock::PineTimeStyleScreen() { + return std::make_unique(app, + dateTimeController, + batteryController, + bleController, + notificatioManager, + settingsController, + heartRateController); +} + /* // Examples for more watch faces std::unique_ptr Clock::WatchFaceMinimalScreen() { @@ -91,4 +105,4 @@ std::unique_ptr Clock::WatchFaceCustomScreen() { return std::make_unique(app, dateTimeController, batteryController, bleController, notificatioManager, settingsController); } -*/ \ No newline at end of file +*/ diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h index 9879985f..920d58bb 100644 --- a/src/displayapp/screens/Clock.h +++ b/src/displayapp/screens/Clock.h @@ -47,9 +47,10 @@ namespace Pinetime { Controllers::HeartRateController& heartRateController; Controllers::MotionController& motionController; - ScreenList<2> screens; + ScreenList<3> screens; std::unique_ptr WatchFaceDigitalScreen(); std::unique_ptr WatchFaceAnalogScreen(); + std::unique_ptr PineTimeStyleScreen(); // Examples for more watch faces // std::unique_ptr WatchFaceMinimalScreen(); diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp index 457cebf6..33d41416 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.cpp +++ b/src/displayapp/screens/settings/SettingWatchFace.cpp @@ -58,6 +58,15 @@ SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pine lv_checkbox_set_checked(cbOption[optionsTotal], true); } + optionsTotal++; + cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + lv_checkbox_set_text_static(cbOption[optionsTotal], " PineTimeStyle"); + cbOption[optionsTotal]->user_data = this; + lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + if (settingsController.GetClockFace() == 2) { + lv_checkbox_set_checked(cbOption[optionsTotal], true); + } + optionsTotal++; } @@ -81,4 +90,4 @@ void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) { } } } -} \ No newline at end of file +} diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index 761baba2..cabc1859 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -417,6 +417,7 @@ typedef void* lv_indev_drv_user_data_t; /*Type of user data in the in LV_FONT_DECLARE(jetbrains_mono_extrabold_compressed) \ LV_FONT_DECLARE(jetbrains_mono_42) \ LV_FONT_DECLARE(jetbrains_mono_76) \ + LV_FONT_DECLARE(open_sans_light) \ LV_FONT_DECLARE(lv_font_sys_48) /* Enable it if you have fonts with a lot of characters. @@ -758,4 +759,4 @@ typedef void* lv_obj_user_data_t; /*--END OF LV_CONF_H--*/ -#endif /*LV_CONF_H*/ \ No newline at end of file +#endif /*LV_CONF_H*/ -- cgit v1.2.3 From 5daaa5cf75b23e80776614af263c23e6433365e3 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Wed, 19 May 2021 11:03:33 +0200 Subject: Tidying/formatting fixes --- src/displayapp/screens/PineTimeStyle.cpp | 36 ++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index b249416a..10f2da66 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -15,6 +15,21 @@ #include "../DisplayApp.h" /* + * This file is part of the Infinitime distribution (https://github.com/JF002/Infinitime). + * Copyright (c) 2021 Kieran Cawthray. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * * PineTimeStyle watchface for Infinitime created by Kieran Cawthray * Based on WatchFaceDigital * Style/layout copied from TimeStyle for Pebble by Dan Tilden (github.com/tilden) @@ -38,7 +53,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, settingsController {settingsController}, heartRateController {heartRateController} { - /* 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; @@ -47,7 +62,7 @@ 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)); @@ -55,7 +70,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, 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); @@ -69,7 +84,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_label_set_text(timeDD2, "34"); lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5); - /*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)); @@ -77,7 +92,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, 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)); @@ -86,17 +101,14 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, batteryPlug = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - //lv_label_set_text(batteryPlug, Symbols::plug); lv_obj_align(batteryPlug, 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, BleIcon::GetIcon(false)); lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25); notificationIcon = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - //lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false)); lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 40); /* Calendar icon */ @@ -137,7 +149,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)); @@ -154,7 +166,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_label_set_text(dateMonth, "MAR"); lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32); - /*Display heartrate info*/ + /* Display heartrate info */ heartbeatIcon = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); @@ -208,10 +220,8 @@ bool PineTimeStyle::Refresh() { if (notificationState.Get() == true) { lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(true)); lv_obj_realign(notificationIcon); - //lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, -8, 25); } else { lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false)); - //lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25); } } @@ -248,7 +258,7 @@ bool PineTimeStyle::Refresh() { char hourStr[3]; char minStr[3]; - /*Display the time as 2 pairs of digits*/ + /* Display the time as 2 pairs of digits */ sprintf(hourStr, "%c%c", hoursChar[0], hoursChar[1]); lv_label_set_text(timeDD1, hourStr); -- cgit v1.2.3 From 249b6db6f5a5a7ac6cfaf96b1d8e59306ffe1333 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Wed, 19 May 2021 17:05:33 +0200 Subject: Remove newline modifications --- src/displayapp/screens/Clock.cpp | 2 +- src/displayapp/screens/PineTimeStyle.cpp | 2 +- src/displayapp/screens/settings/SettingWatchFace.cpp | 2 +- src/libs/lv_conf.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index e0c1f62b..4f0efd92 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -105,4 +105,4 @@ std::unique_ptr Clock::WatchFaceCustomScreen() { return std::make_unique(app, dateTimeController, batteryController, bleController, notificatioManager, settingsController); } -*/ +*/ \ No newline at end of file diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 10f2da66..f6597ca9 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -301,4 +301,4 @@ bool PineTimeStyle::Refresh() { } return running; -} +} \ No newline at end of file diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp index 33d41416..3e73489d 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.cpp +++ b/src/displayapp/screens/settings/SettingWatchFace.cpp @@ -90,4 +90,4 @@ void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) { } } } -} +} \ No newline at end of file diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index cabc1859..a03a4833 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -759,4 +759,4 @@ typedef void* lv_obj_user_data_t; /*--END OF LV_CONF_H--*/ -#endif /*LV_CONF_H*/ +#endif /*LV_CONF_H*/ \ No newline at end of file -- cgit v1.2.3 From 5c413016a7b9e78040fb8e5b48cd37b7963362df Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Wed, 19 May 2021 17:27:42 +0200 Subject: Move GPL license header --- src/displayapp/screens/PineTimeStyle.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index f6597ca9..787bb40a 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -1,19 +1,3 @@ -#include "PineTimeStyle.h" - -#include -#include -#include -#include "BatteryIcon.h" -#include "BleIcon.h" -#include "NotificationIcon.h" -#include "Symbols.h" -#include "components/battery/BatteryController.h" -#include "components/ble/BleController.h" -#include "components/ble/NotificationManager.h" -#include "components/heartrate/HeartRateController.h" -#include "components/settings/Settings.h" -#include "../DisplayApp.h" - /* * This file is part of the Infinitime distribution (https://github.com/JF002/Infinitime). * Copyright (c) 2021 Kieran Cawthray. @@ -35,6 +19,21 @@ * Style/layout copied from TimeStyle for Pebble by Dan Tilden (github.com/tilden) */ +#include "PineTimeStyle.h" +#include +#include +#include +#include "BatteryIcon.h" +#include "BleIcon.h" +#include "NotificationIcon.h" +#include "Symbols.h" +#include "components/battery/BatteryController.h" +#include "components/ble/BleController.h" +#include "components/ble/NotificationManager.h" +#include "components/heartrate/HeartRateController.h" +#include "components/settings/Settings.h" +#include "../DisplayApp.h" + using namespace Pinetime::Applications::Screens; PineTimeStyle::PineTimeStyle(DisplayApp* app, -- cgit v1.2.3 From 607af27ba8790f68d06d7cc855ef3058558defd7 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 20 Jun 2021 21:53:09 +0200 Subject: Add step count gauge - replaces heartrate in sidebar --- src/CMakeLists.txt | 2 ++ src/displayapp/screens/Clock.cpp | 2 +- src/displayapp/screens/PineTimeStyle.cpp | 56 ++++++++++++++++++-------------- src/displayapp/screens/PineTimeStyle.h | 9 ++--- 4 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 83f24394..aca86543 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -235,6 +235,7 @@ set(LVGL_SRC libs/lvgl/src/lv_widgets/lv_cont.h libs/lvgl/src/lv_widgets/lv_cpicker.h libs/lvgl/src/lv_widgets/lv_dropdown.h + libs/lvgl/src/lv_widgets/lv_gauge.h libs/lvgl/src/lv_widgets/lv_img.h libs/lvgl/src/lv_widgets/lv_imgbtn.h libs/lvgl/src/lv_widgets/lv_keyboard.h @@ -321,6 +322,7 @@ set(LVGL_SRC libs/lvgl/src/lv_widgets/lv_cont.c libs/lvgl/src/lv_widgets/lv_cpicker.c libs/lvgl/src/lv_widgets/lv_dropdown.c + libs/lvgl/src/lv_widgets/lv_gauge.c libs/lvgl/src/lv_widgets/lv_img.c libs/lvgl/src/lv_widgets/lv_imgbtn.c libs/lvgl/src/lv_widgets/lv_keyboard.c diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index 3b288d94..e0684976 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -87,7 +87,7 @@ std::unique_ptr Clock::PineTimeStyleScreen() { bleController, notificatioManager, settingsController, - heartRateController); + motionController); } /* diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 787bb40a..ab6e2a74 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -30,7 +30,7 @@ #include "components/battery/BatteryController.h" #include "components/ble/BleController.h" #include "components/ble/NotificationManager.h" -#include "components/heartrate/HeartRateController.h" +#include "components/motion/MotionController.h" #include "components/settings/Settings.h" #include "../DisplayApp.h" @@ -42,7 +42,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, Controllers::Ble& bleController, Controllers::NotificationManager& notificatioManager, Controllers::Settings& settingsController, - Controllers::HeartRateController& heartRateController) + Controllers::MotionController& motionController) : Screen(app), currentDateTime {{}}, dateTimeController {dateTimeController}, @@ -50,7 +50,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, bleController {bleController}, notificatioManager {notificatioManager}, settingsController {settingsController}, - heartRateController {heartRateController} { + motionController {motionController} { /* This sets the watchface number to return to after leaving the menu */ settingsController.SetClockFace(2); @@ -165,17 +165,29 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_label_set_text(dateMonth, "MAR"); lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32); - /* Display heartrate info */ - - heartbeatIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_label_set_text(heartbeatIcon, Symbols::heartBeat); - lv_obj_align(heartbeatIcon, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, -30); - - heartbeatValue = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_label_set_text(heartbeatValue, "---"); - lv_obj_align(heartbeatValue, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, -10); + // Step count gauge + static lv_color_t needle_colors[1]; + 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, (settingsController.GetStepsGoal() / 100)); + lv_gauge_set_range(stepGauge, 0, (settingsController.GetStepsGoal() / 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, 4); + 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); @@ -286,17 +298,11 @@ bool PineTimeStyle::Refresh() { } } - heartbeat = heartRateController.HeartRate(); - heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; - if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { - char heartbeatBuffer[4]; - if (heartbeatRunning.Get()) - sprintf(heartbeatBuffer, "%d", heartbeat.Get()); - else - sprintf(heartbeatBuffer, "---"); - - lv_label_set_text(heartbeatValue, heartbeatBuffer); - lv_obj_realign(heartbeatValue); + stepCount = motionController.NbSteps(); + motionSensorOk = motionController.IsSensorOk(); + if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) { + lv_gauge_set_value(stepGauge, 0, (stepCount.Get() / 100)); + lv_obj_realign(stepGauge); } return running; diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h index 55752412..4530bb5f 100644 --- a/src/displayapp/screens/PineTimeStyle.h +++ b/src/displayapp/screens/PineTimeStyle.h @@ -27,7 +27,7 @@ namespace Pinetime { Controllers::Ble& bleController, Controllers::NotificationManager& notificatioManager, Controllers::Settings& settingsController, - Controllers::HeartRateController& heartRateController); + Controllers::MotionController& motionController); ~PineTimeStyle() override; bool Refresh() override; @@ -45,8 +45,8 @@ namespace Pinetime { DirtyValue batteryPercentRemaining {}; DirtyValue bleState {}; DirtyValue> currentDateTime {}; - DirtyValue heartbeat {}; - DirtyValue heartbeatRunning {}; + DirtyValue motionSensorOk {}; + DirtyValue stepCount {}; DirtyValue notificationState {}; lv_obj_t* timebar; @@ -70,13 +70,14 @@ namespace Pinetime { lv_obj_t* heartbeatValue; lv_obj_t* heartbeatBpm; lv_obj_t* notificationIcon; + lv_obj_t* stepGauge; Controllers::DateTime& dateTimeController; Controllers::Battery& batteryController; Controllers::Ble& bleController; Controllers::NotificationManager& notificatioManager; Controllers::Settings& settingsController; - Controllers::HeartRateController& heartRateController; + Controllers::MotionController& motionController; }; } } -- cgit v1.2.3 From 266573deff61b25e924738bc046c03edfeeb0ef8 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 20 Jun 2021 21:57:28 +0200 Subject: Enable 12/24h functionality --- src/displayapp/screens/PineTimeStyle.cpp | 30 +++++++++++++++++++++++++++++- src/displayapp/screens/PineTimeStyle.h | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index ab6e2a74..6f7ec3a0 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -83,6 +83,12 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, 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_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 */ sidebar = lv_obj_create(lv_scr_act(), nullptr); @@ -257,7 +263,25 @@ bool PineTimeStyle::Refresh() { sprintf(minutesChar, "%02d", static_cast(minute)); char hoursChar[3]; - sprintf(hoursChar, "%02d", hour); + char ampmChar[5]; + + if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) { + sprintf(hoursChar, "%02d", hour); + } else { + if (hour == 0 && hour != 12) { + hour = 12; + sprintf(ampmChar, "A\nM"); + } else if (hour == 12 && hour != 0) { + hour = 12; + sprintf(ampmChar, "P\nM"); + } else if (hour < 12 && hour != 0) { + sprintf(ampmChar, "A\nM"); + } else if (hour > 12 && hour != 0) { + hour = hour - 12; + sprintf(ampmChar, "P\nM"); + } + sprintf(hoursChar, "%02d", hour); + } if (hoursChar[0] != displayedChar[0] || hoursChar[1] != displayedChar[1] || minutesChar[0] != displayedChar[2] || minutesChar[1] != displayedChar[3]) { @@ -269,6 +293,10 @@ bool PineTimeStyle::Refresh() { char hourStr[3]; char minStr[3]; + if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { + lv_label_set_text(timeAMPM, ampmChar); + } + /* Display the time as 2 pairs of digits */ sprintf(hourStr, "%c%c", hoursChar[0], hoursChar[1]); lv_label_set_text(timeDD1, hourStr); diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h index 4530bb5f..7c99c6a7 100644 --- a/src/displayapp/screens/PineTimeStyle.h +++ b/src/displayapp/screens/PineTimeStyle.h @@ -53,6 +53,7 @@ namespace Pinetime { 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; -- cgit v1.2.3 From be505fc15fef5d87c311a442f291dd1cbd86fd40 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Mon, 21 Jun 2021 20:06:47 +0200 Subject: Set step gauge outer to be white when step goal is reached --- src/displayapp/screens/PineTimeStyle.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 6f7ec3a0..0dc4117c 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -329,8 +329,12 @@ bool PineTimeStyle::Refresh() { stepCount = motionController.NbSteps(); motionSensorOk = motionController.IsSensorOk(); if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) { - lv_gauge_set_value(stepGauge, 0, (stepCount.Get() / 100)); - lv_obj_realign(stepGauge); + lv_gauge_set_value(stepGauge, 0, (stepCount.Get() / 100)); + lv_obj_realign(stepGauge); + if (stepCount.Get() > settingsController.GetStepsGoal()) { + lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + } } return running; -- cgit v1.2.3 From c3f854ba65967631282a719743f68943f4c6c86f Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Tue, 22 Jun 2021 21:32:27 +0200 Subject: Add font source file --- src/displayapp/fonts/open_sans_light.ttf | Bin 0 -> 222412 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/displayapp/fonts/open_sans_light.ttf diff --git a/src/displayapp/fonts/open_sans_light.ttf b/src/displayapp/fonts/open_sans_light.ttf new file mode 100644 index 00000000..0d381897 Binary files /dev/null and b/src/displayapp/fonts/open_sans_light.ttf differ -- cgit v1.2.3 From 14721e8f1ef3fd8ebfe2bf870416c7f343f83936 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Wed, 23 Jun 2021 22:14:34 +0200 Subject: Move static needle_colors array to member variable --- src/displayapp/screens/PineTimeStyle.cpp | 1 - src/displayapp/screens/PineTimeStyle.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 0dc4117c..678099c0 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -172,7 +172,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32); // Step count gauge - static lv_color_t needle_colors[1]; needle_colors[0] = LV_COLOR_WHITE; stepGauge = lv_gauge_create(lv_scr_act(), nullptr); lv_gauge_set_needle_count(stepGauge, 1, needle_colors); diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h index 7c99c6a7..70794cc5 100644 --- a/src/displayapp/screens/PineTimeStyle.h +++ b/src/displayapp/screens/PineTimeStyle.h @@ -72,6 +72,7 @@ namespace Pinetime { lv_obj_t* heartbeatBpm; lv_obj_t* notificationIcon; lv_obj_t* stepGauge; + lv_color_t needle_colors[1]; Controllers::DateTime& dateTimeController; Controllers::Battery& batteryController; -- cgit v1.2.3 From 38ab0add487183c2f7e0a1e545de49a8ad7b17e1 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Thu, 24 Jun 2021 19:15:23 +0200 Subject: PineTimeStyle color picker initial commit --- src/CMakeLists.txt | 1 + src/displayapp/Apps.h | 3 +- src/displayapp/DisplayApp.cpp | 5 + .../screens/settings/SettingPineTimeStyle.cpp | 302 +++++++++++++++++++++ .../screens/settings/SettingPineTimeStyle.h | 58 ++++ src/displayapp/screens/settings/Settings.cpp | 15 + src/displayapp/screens/settings/Settings.h | 3 +- 7 files changed, 385 insertions(+), 2 deletions(-) create mode 100644 src/displayapp/screens/settings/SettingPineTimeStyle.cpp create mode 100644 src/displayapp/screens/settings/SettingPineTimeStyle.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aca86543..caf015b0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -420,6 +420,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 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/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index de93428c..48a012a8 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" using namespace Pinetime::Applications; using namespace Pinetime::Applications::Display; @@ -323,6 +324,10 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) currentScreen = std::make_unique(this, settingsController); ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; + case Apps::SettingPineTimeStyle: + currentScreen = std::make_unique(this, settingsController); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + break; case Apps::BatteryInfo: currentScreen = std::make_unique(this, batteryController); ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp new file mode 100644 index 00000000..3aceeb71 --- /dev/null +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -0,0 +1,302 @@ +#include "SettingPineTimeStyle.h" +#include +#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(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, lv_color_hex(0x000000)); + 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, lv_color_hex(0x008080)); + 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_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_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, lv_color_hex(0x008080)); + 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, 4); + lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); + +// lv_style_copy(&style_button, &lv_style_plain_color); +// style_button.body.opa = LV_OPA_50; + btnNextTime = lv_btn_create(lv_scr_act(), nullptr); + btnNextTime->user_data = this; + lv_obj_set_size(btnNextTime, 50, 50); + lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_CENTER, 55, -80); + 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, 50, 50); + lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_CENTER, -55, -80); + 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, 50, 50); + lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_CENTER, 55, 0); + 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, 50, 50); + lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_CENTER, -55, 0); + 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, 50, 50); + lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_CENTER, 55, 80); + 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, 50, 50); + lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_CENTER, -55, 80); + lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); + lv_obj_set_event_cb(btnPrevBG, event_handler); + + 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, ""); + + +/* + + stepValue = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_label_set_text_fmt(stepValue,"%i", settingsController.GetStepsGoal()); + lv_label_set_align(stepValue, LV_LABEL_ALIGN_CENTER); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); + + btnPlus = lv_btn_create(lv_scr_act(), nullptr); + btnPlus->user_data = this; + lv_obj_set_size(btnPlus, 80, 50); + lv_obj_align(btnPlus, lv_scr_act(), LV_ALIGN_CENTER, 55, 80); + lv_obj_set_style_local_value_str(btnPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+"); + lv_obj_set_event_cb(btnPlus, event_handler); + + btnMinus = lv_btn_create(lv_scr_act(), nullptr); + btnMinus->user_data = this; + lv_obj_set_size(btnMinus, 80, 50); + lv_obj_set_event_cb(btnMinus, event_handler); + lv_obj_align(btnMinus, lv_scr_act(), LV_ALIGN_CENTER, -55, 80); + lv_obj_set_style_local_value_str(btnMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-"); +*/ +} + +SettingPineTimeStyle::~SettingPineTimeStyle() { + lv_obj_clean(lv_scr_act()); + settingsController.SaveSettings(); +} + +bool SettingPineTimeStyle::Refresh() { + return running; +} + +void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { + uint8_t value = 0; + lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, + LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, + LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, + LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, + LV_COLOR_ORANGE}; + + if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { + if ( value < 16 ) { + value += 1; + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + } + } + if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { + if ( value > 0 ) { + value -= 1; + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + } + } + if((object == btnNextTime) && (event == LV_EVENT_PRESSED)) { + if ( value < 16 ) { + value += 1; + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + } + } + if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) { + if ( value > 0 ) { + value -= 1; + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + } + } + if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) { + if ( value < 16 ) { + value += 1; + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + } + } + + if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) { + if ( value > 0 ) { + value -= 1; + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + } + } + + + +/* + uint32_t value = settingsController.GetStepsGoal(); + if(object == btnPlus && (event == LV_EVENT_PRESSED)) { + value += 1000; + if ( value <= 500000 ) { + settingsController.SetStepsGoal(value); + lv_label_set_text_fmt(stepValue,"%i", settingsController.GetStepsGoal()); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); + } + } + + if(object == btnMinus && (event == LV_EVENT_PRESSED)) { + value -= 1000; + if ( value >= 1000 ) { + settingsController.SetStepsGoal(value); + lv_label_set_text_fmt(stepValue,"%i", settingsController.GetStepsGoal()); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); + } + } +*/ +} \ No newline at end of file diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h new file mode 100644 index 00000000..5b5e61bf --- /dev/null +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h @@ -0,0 +1,58 @@ +#pragma once + +#include +#include +#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; + + bool Refresh() override; + void UpdateSelected(lv_obj_t *object, lv_event_t event); + + private: + + Controllers::Settings& settingsController; + + 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 * timeColor; + lv_obj_t * barColor; + lv_obj_t * bgColor; + 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]; + lv_color_t pts_colors[17]; + + }; + } + } +} diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp index e63a3584..73347804 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 { return CreateScreen2(); + }, + [this]() -> std::unique_ptr { + return CreateScreen3(); }}, Screens::ScreenListModes::UpDown} { } @@ -60,3 +63,15 @@ std::unique_ptr Settings::CreateScreen2() { return std::make_unique(1, 2, app, settingsController, applications); } + +std::unique_ptr Settings::CreateScreen3() { + + std::array applications {{ + {Symbols::paintbrush, "PTS Colors", Apps::SettingPineTimeStyle}, + {Symbols::none, "None", Apps::None}, + {Symbols::none, "None", Apps::None}, + {Symbols::none, "None", Apps::None}, + }}; + + return std::make_unique(2, 2, app, settingsController, applications); +} diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h index 711a6be6..12dd0514 100644 --- a/src/displayapp/screens/settings/Settings.h +++ b/src/displayapp/screens/settings/Settings.h @@ -21,10 +21,11 @@ namespace Pinetime { private: Controllers::Settings& settingsController; - ScreenList<2> screens; + ScreenList<3> screens; std::unique_ptr CreateScreen1(); std::unique_ptr CreateScreen2(); + std::unique_ptr CreateScreen3(); }; } } -- cgit v1.2.3 From 7edfc534819ba7b9a14523d84df62952852a0fe3 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Thu, 24 Jun 2021 21:49:04 +0200 Subject: PineTimeStyle color picker add settings integration --- src/components/settings/Settings.h | 31 +++++++ .../screens/settings/SettingPineTimeStyle.cpp | 98 ++++++++++++---------- 2 files changed, 84 insertions(+), 45 deletions(-) diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 4409425b..69e28e5b 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -27,6 +27,33 @@ namespace Pinetime { return settings.clockFace; }; + void SetPTSColorTime(uint8_t colorTime) { + if (colorTime != settings.PTSColorTime) + settingsChanged = true; + settings.PTSColorTime = colorTime; + }; + uint8_t GetPTSColorTime() const { + return settings.PTSColorTime; + }; + + void SetPTSColorBar(uint8_t colorBar) { + if (colorBar != settings.PTSColorBar) + settingsChanged = true; + settings.PTSColorBar = colorBar; + }; + uint8_t GetPTSColorBar() const { + return settings.PTSColorBar; + }; + + void SetPTSColorBG(uint8_t colorBG) { + if (colorBG != settings.PTSColorBG) + settingsChanged = true; + settings.PTSColorBG = colorBG; + }; + uint8_t GetPTSColorBG() const { + return settings.PTSColorBG; + }; + void SetAppMenu(uint8_t menu) { appMenu = menu; }; @@ -103,6 +130,10 @@ namespace Pinetime { uint8_t clockFace = 0; + uint8_t PTSColorTime = 11; + uint8_t PTSColorBar = 11; + uint8_t PTSColorBG = 3; + uint32_t stepsGoal = 10000; uint32_t screenTimeOut = 15000; diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 3aceeb71..3673e79c 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -12,6 +12,12 @@ namespace { } } +lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, + LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, + LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, + LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, + LV_COLOR_ORANGE}; + SettingPineTimeStyle::SettingPineTimeStyle( Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) : Screen(app), @@ -19,7 +25,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( { 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, LV_COLOR_BLACK); 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); @@ -28,18 +34,18 @@ SettingPineTimeStyle::SettingPineTimeStyle( 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, LV_COLOR_TEAL); 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, LV_COLOR_TEAL); 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, LV_COLOR_TEAL); 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); @@ -47,7 +53,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( /* 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, LV_COLOR_TEAL); 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); @@ -142,6 +148,13 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); 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, ""); + // lv_style_copy(&style_button, &lv_style_plain_color); // style_button.body.opa = LV_OPA_50; btnNextTime = lv_btn_create(lv_scr_act(), nullptr); @@ -186,14 +199,6 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); lv_obj_set_event_cb(btnPrevBG, event_handler); - 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, ""); - - /* stepValue = lv_label_create(lv_scr_act(), nullptr); @@ -228,52 +233,55 @@ bool SettingPineTimeStyle::Refresh() { } void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { - uint8_t value = 0; - lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, - LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, - LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, - LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, - LV_COLOR_ORANGE}; + uint8_t valueTime = settingsController.GetPTSColorTime(); + uint8_t valueBar = settingsController.GetPTSColorBar(); + uint8_t valueBG = settingsController.GetPTSColorBG(); - if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { - if ( value < 16 ) { - value += 1; - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + if((object == btnNextTime) && (event == LV_EVENT_PRESSED)) { + if ( valueTime < 17 ) { + valueTime += 1; + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } } - if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { - if ( value > 0 ) { - value -= 1; - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) { + if ( valueTime > 0 ) { + valueTime -= 1; + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } } - if((object == btnNextTime) && (event == LV_EVENT_PRESSED)) { - if ( value < 16 ) { - value += 1; - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { + if ( valueBar < 17 ) { + valueBar += 1; + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } } - if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) { - if ( value > 0 ) { - value -= 1; - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { + if ( valueBar > 0 ) { + valueBar -= 1; + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } } if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) { - if ( value < 16 ) { - value += 1; - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + if ( valueBG < 17 ) { + valueBG += 1; + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) { - if ( value > 0 ) { - value -= 1; - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[value]); + if ( valueBG > 0 ) { + valueBG -= 1; + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } -- cgit v1.2.3 From 8f16574992b1bb0f49b884f95cf9b7f5d709c6b6 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Thu, 24 Jun 2021 21:51:23 +0200 Subject: PineTimeStyle color picker tidying --- .../screens/settings/SettingPineTimeStyle.cpp | 59 ++-------------------- .../screens/settings/SettingPineTimeStyle.h | 2 - 2 files changed, 5 insertions(+), 56 deletions(-) diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 3673e79c..dcdd6700 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -30,7 +30,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( 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); @@ -50,7 +50,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( 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 */ + // 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_TEAL); @@ -58,7 +58,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( 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)); @@ -70,7 +70,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_label_set_text(bleIcon, Symbols::bluetooth); lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25); - /* 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)); @@ -108,7 +108,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( 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)); @@ -155,8 +155,6 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text(backgroundLabel, ""); -// lv_style_copy(&style_button, &lv_style_plain_color); -// style_button.body.opa = LV_OPA_50; btnNextTime = lv_btn_create(lv_scr_act(), nullptr); btnNextTime->user_data = this; lv_obj_set_size(btnNextTime, 50, 50); @@ -198,29 +196,6 @@ SettingPineTimeStyle::SettingPineTimeStyle( lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_CENTER, -55, 80); lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); lv_obj_set_event_cb(btnPrevBG, event_handler); - -/* - - stepValue = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); - lv_label_set_text_fmt(stepValue,"%i", settingsController.GetStepsGoal()); - lv_label_set_align(stepValue, LV_LABEL_ALIGN_CENTER); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); - - btnPlus = lv_btn_create(lv_scr_act(), nullptr); - btnPlus->user_data = this; - lv_obj_set_size(btnPlus, 80, 50); - lv_obj_align(btnPlus, lv_scr_act(), LV_ALIGN_CENTER, 55, 80); - lv_obj_set_style_local_value_str(btnPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+"); - lv_obj_set_event_cb(btnPlus, event_handler); - - btnMinus = lv_btn_create(lv_scr_act(), nullptr); - btnMinus->user_data = this; - lv_obj_set_size(btnMinus, 80, 50); - lv_obj_set_event_cb(btnMinus, event_handler); - lv_obj_align(btnMinus, lv_scr_act(), LV_ALIGN_CENTER, -55, 80); - lv_obj_set_style_local_value_str(btnMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-"); -*/ } SettingPineTimeStyle::~SettingPineTimeStyle() { @@ -276,7 +251,6 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } - if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) { if ( valueBG > 0 ) { valueBG -= 1; @@ -284,27 +258,4 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } - - - -/* - uint32_t value = settingsController.GetStepsGoal(); - if(object == btnPlus && (event == LV_EVENT_PRESSED)) { - value += 1000; - if ( value <= 500000 ) { - settingsController.SetStepsGoal(value); - lv_label_set_text_fmt(stepValue,"%i", settingsController.GetStepsGoal()); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); - } - } - - if(object == btnMinus && (event == LV_EVENT_PRESSED)) { - value -= 1000; - if ( value >= 1000 ) { - settingsController.SetStepsGoal(value); - lv_label_set_text_fmt(stepValue,"%i", settingsController.GetStepsGoal()); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); - } - } -*/ } \ No newline at end of file diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h index 5b5e61bf..b8ec9e9e 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.h +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h @@ -19,7 +19,6 @@ namespace Pinetime { void UpdateSelected(lv_obj_t *object, lv_event_t event); private: - Controllers::Settings& settingsController; lv_obj_t * btnNextTime; @@ -51,7 +50,6 @@ namespace Pinetime { lv_obj_t * stepGauge; lv_color_t needle_colors[1]; lv_color_t pts_colors[17]; - }; } } -- cgit v1.2.3 From 50b92e5dd6bd879b61e5038d3f064d486db864f6 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Fri, 25 Jun 2021 14:47:56 +0200 Subject: Move array to member variable, retrieve colors from settings for display --- .../screens/settings/SettingPineTimeStyle.cpp | 17 +++++------------ src/displayapp/screens/settings/SettingPineTimeStyle.h | 6 +++++- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index dcdd6700..bad0fec2 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -12,20 +12,13 @@ namespace { } } -lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, - LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, - LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, - LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, - LV_COLOR_ORANGE}; - 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, LV_COLOR_BLACK); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[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); @@ -34,18 +27,18 @@ SettingPineTimeStyle::SettingPineTimeStyle( 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_TEAL); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[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_TEAL); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[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_TEAL); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[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); @@ -53,7 +46,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( // 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_TEAL); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[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); diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h index b8ec9e9e..9b20f9fb 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.h +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h @@ -49,7 +49,11 @@ namespace Pinetime { lv_obj_t * calendarCrossBar2; lv_obj_t * stepGauge; lv_color_t needle_colors[1]; - lv_color_t pts_colors[17]; + lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, + LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, + LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, + LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, + LV_COLOR_ORANGE}; }; } } -- cgit v1.2.3 From 878dd1a7767bb4677ea629aef9d6fb98e2b2bc1a Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Fri, 25 Jun 2021 14:58:45 +0200 Subject: Use colors from settings for PineTimeStyle watchface --- src/displayapp/screens/PineTimeStyle.cpp | 10 +++++----- src/displayapp/screens/PineTimeStyle.h | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 678099c0..c75931c4 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -64,7 +64,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, /* 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, pts_colors[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); @@ -73,18 +73,18 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, timeDD1 = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080)); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[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, pts_colors[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, pts_colors[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); @@ -92,7 +92,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, /* 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, pts_colors[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); diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h index 70794cc5..97b39a01 100644 --- a/src/displayapp/screens/PineTimeStyle.h +++ b/src/displayapp/screens/PineTimeStyle.h @@ -73,6 +73,11 @@ namespace Pinetime { lv_obj_t* notificationIcon; lv_obj_t* stepGauge; lv_color_t needle_colors[1]; + lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, + LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, + LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, + LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, + LV_COLOR_ORANGE}; Controllers::DateTime& dateTimeController; Controllers::Battery& batteryController; -- cgit v1.2.3 From be22a9b1b8a3ca43cbf9e79d0a4f722d88d87ded Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Fri, 25 Jun 2021 15:09:18 +0200 Subject: Fix off-by-one error, reduce step gauge needle width --- src/displayapp/screens/PineTimeStyle.cpp | 2 +- src/displayapp/screens/settings/SettingPineTimeStyle.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index c75931c4..cbabca6f 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -191,7 +191,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); diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index bad0fec2..876d2b40 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -138,7 +138,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( 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); @@ -206,7 +206,7 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { uint8_t valueBG = settingsController.GetPTSColorBG(); if((object == btnNextTime) && (event == LV_EVENT_PRESSED)) { - if ( valueTime < 17 ) { + if ( valueTime < 16 ) { valueTime += 1; settingsController.SetPTSColorTime(valueTime); lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); @@ -224,7 +224,7 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { } } if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { - if ( valueBar < 17 ) { + if ( valueBar < 16 ) { valueBar += 1; settingsController.SetPTSColorBar(valueBar); lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); @@ -238,7 +238,7 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { } } if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) { - if ( valueBG < 17 ) { + if ( valueBG < 16 ) { valueBG += 1; settingsController.SetPTSColorBG(valueBG); lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); -- cgit v1.2.3 From f3b40cb7a62c4927fb9fe921fdaa3b38809163f5 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Fri, 25 Jun 2021 19:04:29 +0200 Subject: Make it loop around when you get to the end of the list of colors --- .../screens/settings/SettingPineTimeStyle.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 876d2b40..5e1396ad 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -212,6 +212,12 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + } else { + valueTime = 0; + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } } if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) { @@ -221,6 +227,12 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + } else { + valueTime = 16; + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } } if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { @@ -228,6 +240,10 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { valueBar += 1; settingsController.SetPTSColorBar(valueBar); lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); + } else { + valueBar = 0; + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } } if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { @@ -235,6 +251,10 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { valueBar -= 1; settingsController.SetPTSColorBar(valueBar); lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); + } else { + valueBar = 16; + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } } if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) { @@ -242,6 +262,10 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { valueBG += 1; settingsController.SetPTSColorBG(valueBG); lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); + } else { + valueBG = 0; + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) { @@ -249,6 +273,10 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { valueBG -= 1; settingsController.SetPTSColorBG(valueBG); lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); + } else { + valueBG = 16; + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } } \ No newline at end of file -- cgit v1.2.3 From 800daecf9038dc495327da71aff5dcf3cee82e40 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Fri, 25 Jun 2021 21:36:55 +0200 Subject: Add a check to set default colors if all colors are white --- src/displayapp/screens/PineTimeStyle.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index cbabca6f..ad1d2db0 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -207,6 +207,13 @@ PineTimeStyle::~PineTimeStyle() { } bool PineTimeStyle::Refresh() { + //Feels like a hack, but if all the colors are white, this is probably not what the user wants + if (settingsController.GetPTSColorTime() + settingsController.GetPTSColorBar() + settingsController.GetPTSColorBG() == 0) { + settingsController.SetPTSColorTime(11); + settingsController.SetPTSColorBar(11); + settingsController.SetPTSColorBG(3); + } + batteryPercentRemaining = batteryController.PercentRemaining(); if (batteryPercentRemaining.IsUpdated()) { auto batteryPercent = batteryPercentRemaining.Get(); -- cgit v1.2.3 From 6889cf1ed86f72f85a208961956ef6dff5972210 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Fri, 25 Jun 2021 21:55:51 +0200 Subject: Fix the fix, whoops --- src/displayapp/screens/PineTimeStyle.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index ad1d2db0..76db86e3 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -61,6 +61,13 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, displayedChar[3] = 0; displayedChar[4] = 0; + //Feels like a hack, but if all the colors are white, this is probably not what the user wants + if (settingsController.GetPTSColorTime() + settingsController.GetPTSColorBar() + settingsController.GetPTSColorBG() == 0) { + settingsController.SetPTSColorTime(11); + settingsController.SetPTSColorBar(11); + settingsController.SetPTSColorBG(3); + } + /* Create a 200px wide background rectangle */ timebar = lv_obj_create(lv_scr_act(), nullptr); @@ -207,13 +214,6 @@ PineTimeStyle::~PineTimeStyle() { } bool PineTimeStyle::Refresh() { - //Feels like a hack, but if all the colors are white, this is probably not what the user wants - if (settingsController.GetPTSColorTime() + settingsController.GetPTSColorBar() + settingsController.GetPTSColorBG() == 0) { - settingsController.SetPTSColorTime(11); - settingsController.SetPTSColorBar(11); - settingsController.SetPTSColorBG(3); - } - batteryPercentRemaining = batteryController.PercentRemaining(); if (batteryPercentRemaining.IsUpdated()) { auto batteryPercent = batteryPercentRemaining.Get(); -- cgit v1.2.3 From 660a8597f6edc66deec94782817613e1a4f84a6d Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 27 Jun 2021 15:24:17 +0200 Subject: Add reset button, reduce button opacity --- .../screens/settings/SettingPineTimeStyle.cpp | 48 ++++++++++++++++------ .../screens/settings/SettingPineTimeStyle.h | 1 + 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 5e1396ad..ae665464 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -150,45 +150,59 @@ SettingPineTimeStyle::SettingPineTimeStyle( btnNextTime = lv_btn_create(lv_scr_act(), nullptr); btnNextTime->user_data = this; - lv_obj_set_size(btnNextTime, 50, 50); - lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_CENTER, 55, -80); + 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, 50, 50); - lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_CENTER, -55, -80); + 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, 50, 50); - lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_CENTER, 55, 0); + 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, 50, 50); - lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_CENTER, -55, 0); + 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, 50, 50); - lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_CENTER, 55, 80); + 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, 50, 50); - lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_CENTER, -55, 80); + 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); } SettingPineTimeStyle::~SettingPineTimeStyle() { @@ -279,4 +293,14 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } } + if((object == btnReset) && (event == LV_EVENT_PRESSED)) { + settingsController.SetPTSColorTime(11); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); + settingsController.SetPTSColorBar(11); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); + settingsController.SetPTSColorBG(3); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[3]); + } } \ No newline at end of file diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h index 9b20f9fb..fe449b2e 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.h +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h @@ -27,6 +27,7 @@ namespace Pinetime { lv_obj_t * btnPrevBar; lv_obj_t * btnNextBG; lv_obj_t * btnPrevBG; + lv_obj_t * btnReset; lv_obj_t * timeColor; lv_obj_t * barColor; lv_obj_t * bgColor; -- cgit v1.2.3 From 9bd180896e16bf7451bf7063a646ce1d4b9e44f4 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Tue, 29 Jun 2021 21:12:39 +0200 Subject: Replace font file --- src/displayapp/fonts/open_sans_light.ttf | Bin 222412 -> 101696 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/displayapp/fonts/open_sans_light.ttf b/src/displayapp/fonts/open_sans_light.ttf index 0d381897..6580d3a1 100644 Binary files a/src/displayapp/fonts/open_sans_light.ttf and b/src/displayapp/fonts/open_sans_light.ttf differ -- cgit v1.2.3 From 2edf41be8eea79461a1f9b45a16d13f150c7e5d5 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Tue, 29 Jun 2021 21:15:39 +0200 Subject: Fix bad merge --- src/displayapp/screens/PineTimeStyle.cpp | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 57c0f3ba..76db86e3 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -61,7 +61,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, displayedChar[3] = 0; displayedChar[4] = 0; -<<<<<<< HEAD //Feels like a hack, but if all the colors are white, this is probably not what the user wants if (settingsController.GetPTSColorTime() + settingsController.GetPTSColorBar() + settingsController.GetPTSColorBG() == 0) { settingsController.SetPTSColorTime(11); @@ -73,12 +72,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, timebar = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBG()]); -======= - /* 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)); ->>>>>>> upstream/develop 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); @@ -87,30 +80,18 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, timeDD1 = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); -<<<<<<< HEAD lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]); -======= - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080)); ->>>>>>> upstream/develop 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); -<<<<<<< HEAD lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]); -======= - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080)); ->>>>>>> upstream/develop 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); -<<<<<<< HEAD lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]); -======= - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080)); ->>>>>>> upstream/develop 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); @@ -118,11 +99,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, /* Create a 40px wide bar down the right side of the screen */ sidebar = lv_obj_create(lv_scr_act(), nullptr); -<<<<<<< HEAD lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBar()]); -======= - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080)); ->>>>>>> upstream/develop 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); @@ -221,11 +198,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); -<<<<<<< HEAD lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3); -======= - lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); ->>>>>>> upstream/develop lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); backgroundLabel = lv_label_create(lv_scr_act(), nullptr); -- cgit v1.2.3 From f5639db8ed48a332eeeed48a359a3323b0537d39 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Tue, 6 Jul 2021 22:53:00 +0200 Subject: Change step gauge to use percentage of goal for progress --- src/displayapp/screens/PineTimeStyle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 76db86e3..b27bd9c7 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -186,8 +186,8 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, 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, (settingsController.GetStepsGoal() / 100)); - lv_gauge_set_range(stepGauge, 0, (settingsController.GetStepsGoal() / 100)); + 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); @@ -335,7 +335,7 @@ bool PineTimeStyle::Refresh() { stepCount = motionController.NbSteps(); motionSensorOk = motionController.IsSensorOk(); if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) { - lv_gauge_set_value(stepGauge, 0, (stepCount.Get() / 100)); + lv_gauge_set_value(stepGauge, 0, (stepCount.Get() / (settingsController.GetStepsGoal() / 100))); lv_obj_realign(stepGauge); if (stepCount.Get() > settingsController.GetStepsGoal()) { lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); -- cgit v1.2.3 From fe64176e7b8a0a7a9df733701d08762b60c2511f Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Thu, 15 Jul 2021 14:11:27 +0300 Subject: New touch handler, with issues --- src/CMakeLists.txt | 4 + src/displayapp/DisplayApp.cpp | 124 ++++++++++----------- src/displayapp/DisplayApp.h | 8 +- src/displayapp/LittleVgl.cpp | 9 +- src/displayapp/LittleVgl.h | 2 +- src/displayapp/Messages.h | 3 +- src/displayapp/screens/FirmwareValidation.cpp | 4 +- src/displayapp/screens/List.cpp | 2 +- src/displayapp/screens/Metronome.cpp | 3 - src/displayapp/screens/ScreenList.h | 2 +- src/displayapp/screens/StopWatch.cpp | 4 +- src/displayapp/screens/SystemInfo.cpp | 6 +- src/displayapp/screens/Tile.cpp | 10 +- src/displayapp/screens/Tile.h | 2 +- src/displayapp/screens/settings/QuickSettings.cpp | 6 +- src/displayapp/screens/settings/SettingDisplay.cpp | 4 +- src/drivers/Cst816s.cpp | 12 +- src/main.cpp | 11 +- src/systemtask/SystemTask.cpp | 1 - src/touchhandler/TouchHandler.cpp | 70 ++++++++++++ src/touchhandler/TouchHandler.h | 45 ++++++++ 21 files changed, 230 insertions(+), 102 deletions(-) create mode 100644 src/touchhandler/TouchHandler.cpp create mode 100644 src/touchhandler/TouchHandler.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 40e1f2a5..cbc8cadc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -495,6 +495,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 +554,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 @@ -660,6 +663,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/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 071af0c8..ca7e390f 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -66,7 +66,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}, @@ -79,7 +80,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd, settingsController {settingsController}, motorController {motorController}, motionController {motionController}, - timerController {timerController} { + timerController {timerController}, + touchHandler {touchHandler} { } void DisplayApp::Start() { @@ -176,33 +178,6 @@ void DisplayApp::Refresh() { LoadApp(Apps::Timer, DisplayApp::FullRefreshDirections::Down); } break; - case Messages::TouchEvent: { - if (state != States::Running) - break; - auto gesture = OnTouchEvent(); - if (!currentScreen->OnTouchEvent(gesture)) { - if (currentApp == Apps::Clock) { - switch (gesture) { - case TouchEvents::SwipeUp: - LoadApp(Apps::Launcher, DisplayApp::FullRefreshDirections::Up); - break; - case TouchEvents::SwipeDown: - LoadApp(Apps::Notifications, DisplayApp::FullRefreshDirections::Down); - break; - case TouchEvents::SwipeRight: - LoadApp(Apps::QuickSettings, DisplayApp::FullRefreshDirections::RightAnim); - break; - case TouchEvents::DoubleTap: - PushMessageToSystemTask(System::Messages::GoToSleep); - break; - default: - break; - } - } else if (returnTouchEvent == gesture) { - LoadApp(returnToApp, returnDirection); - } - } - } break; case Messages::ButtonPushed: if (currentApp == Apps::Clock) { PushMessageToSystemTask(System::Messages::GoToSleep); @@ -223,19 +198,42 @@ void DisplayApp::Refresh() { } } - if(nextApp != Apps::None) { - LoadApp(nextApp, nextDirection); - 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); + auto gesture = GetGesture(); + if (gesture != TouchEvents::None) { + if (!currentScreen->OnTouchEvent(gesture)) { + if (currentApp == Apps::Clock) { + switch (gesture) { + case TouchEvents::SwipeUp: + LoadApp(Apps::Launcher, DisplayApp::FullRefreshDirections::Up); + break; + case TouchEvents::SwipeDown: + LoadApp(Apps::Notifications, DisplayApp::FullRefreshDirections::Down); + break; + case TouchEvents::SwipeRight: + LoadApp(Apps::QuickSettings, DisplayApp::FullRefreshDirections::RightAnim); + break; + case TouchEvents::DoubleTap: + PushMessageToSystemTask(System::Messages::GoToSleep); + break; + default: + break; + } + } else if (returnTouchEvent == gesture) { + LoadApp(returnToApp, returnDirection); } + } else { + touchHandler.CancelTap(); } } + + if (touchMode == TouchModes::Polling) { + currentScreen->OnTouchEvent(touchHandler.GetX(), touchHandler.GetY()); + } + + if (nextApp != Apps::None) { + LoadApp(nextApp, nextDirection); + nextApp = Apps::None; + } } void DisplayApp::RunningState() { @@ -257,6 +255,7 @@ void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction } void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) { + touchHandler.CancelTap(); currentScreen.reset(nullptr); SetFullRefresh(direction); @@ -395,31 +394,28 @@ void DisplayApp::PushMessage(Messages msg) { } } -TouchEvents DisplayApp::OnTouchEvent() { - auto info = touchPanel.GetTouchInfo(); - if (info.isTouch) { - switch (info.gesture) { - case Pinetime::Drivers::Cst816S::Gestures::SingleTap: - if (touchMode == TouchModes::Gestures) { - lvgl.SetNewTapEvent(info.x, info.y); - } - 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 DisplayApp::GetGesture() { + auto gesture = touchHandler.GestureGet(); + 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; } diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index f4573ab7..74fc4456 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 { @@ -55,7 +57,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(Display::Messages msg); @@ -81,6 +84,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; @@ -102,7 +106,7 @@ namespace Pinetime { TouchModes touchMode = TouchModes::Gestures; - TouchEvents OnTouchEvent(); + TouchEvents GetGesture(); void RunningState(); void IdleState(); static void Process(void* instance); diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index c069afa2..d0c6161e 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -166,18 +166,17 @@ 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::SetNewTapEvent(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; } diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index 41f934a7..8d1ed56f 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 SetNewTapEvent(uint16_t x, uint16_t y, bool contact); private: void InitDisplay(); diff --git a/src/displayapp/Messages.h b/src/displayapp/Messages.h index ce65f846..3b8bad27 100644 --- a/src/displayapp/Messages.h +++ b/src/displayapp/Messages.h @@ -8,7 +8,6 @@ namespace Pinetime { UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, - TouchEvent, ButtonPushed, NewNotification, TimerDone, @@ -17,4 +16,4 @@ namespace Pinetime { }; } } -} \ No newline at end of file +} diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp index 1d05be8d..5bacb4e8 100644 --- a/src/displayapp/screens/FirmwareValidation.cpp +++ b/src/displayapp/screens/FirmwareValidation.cpp @@ -66,10 +66,10 @@ bool FirmwareValidation::Refresh() { } 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/List.cpp b/src/displayapp/screens/List.cpp index b4f4d2cf..1f92634a 100644 --- a/src/displayapp/screens/List.cpp +++ b/src/displayapp/screens/List.cpp @@ -108,7 +108,7 @@ bool List::Refresh() { } 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/Metronome.cpp b/src/displayapp/screens/Metronome.cpp index 7bfbccb7..15916b62 100644 --- a/src/displayapp/screens/Metronome.cpp +++ b/src/displayapp/screens/Metronome.cpp @@ -83,12 +83,9 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl lv_obj_set_height(playPause, 39); playPauseLabel = lv_label_create(playPause, nullptr); lv_label_set_text(playPauseLabel, Symbols::play); - - app->SetTouchMode(DisplayApp::TouchModes::Polling); } Metronome::~Metronome() { - app->SetTouchMode(DisplayApp::TouchModes::Gestures); systemTask.PushMessage(System::Messages::EnableSleeping); lv_obj_clean(lv_scr_act()); } diff --git a/src/displayapp/screens/ScreenList.h b/src/displayapp/screens/ScreenList.h index ea66bfb2..50d66328 100644 --- a/src/displayapp/screens/ScreenList.h +++ b/src/displayapp/screens/ScreenList.h @@ -110,4 +110,4 @@ namespace Pinetime { }; } } -} \ No newline at end of file +} diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index f4db5d6e..e3db6299 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -161,7 +161,7 @@ bool StopWatch::Refresh() { } void StopWatch::playPauseBtnEventHandler(lv_event_t event) { - if (event != LV_EVENT_PRESSED) { + if (event != LV_EVENT_CLICKED) { return; } if (currentState == States::Init) { @@ -174,7 +174,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 diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index f5bf0cc9..47a49180 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -210,7 +210,7 @@ bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) { } std::unique_ptr 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, 3); lv_table_set_row_cnt(infoTask, 8); @@ -223,9 +223,9 @@ std::unique_ptr SystemInfo::CreateScreen4() { lv_table_set_cell_value(infoTask, 0, 2, "Free"); lv_table_set_col_width(infoTask, 2, 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()); lv_table_set_cell_value(infoTask, i + 1, 1, tasksStatus[i].pcTaskName); diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index 3eb127cc..5a40e915 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -12,9 +12,7 @@ namespace { static void event_handler(lv_obj_t* obj, lv_event_t event) { Tile* screen = static_cast(obj->user_data); - uint32_t* eventDataPtr = (uint32_t*) lv_event_get_data(); - uint32_t eventData = *eventDataPtr; - screen->OnObjectEvent(obj, event, eventData); + screen->OnObjectEvent(obj, event); } } @@ -124,9 +122,9 @@ bool Tile::Refresh() { return running; } -void Tile::OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId) { - if (event == LV_EVENT_VALUE_CHANGED) { - app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up); +void Tile::OnObjectEvent(lv_obj_t* obj, lv_event_t event) { + if (event == LV_EVENT_CLICKED) { + app->StartApp(apps[lv_btnmatrix_get_active_btn(obj)], DisplayApp::FullRefreshDirections::Up); running = false; } } diff --git a/src/displayapp/screens/Tile.h b/src/displayapp/screens/Tile.h index 4ebd81cd..91ce9d01 100644 --- a/src/displayapp/screens/Tile.h +++ b/src/displayapp/screens/Tile.h @@ -32,7 +32,7 @@ namespace Pinetime { bool Refresh() override; void UpdateScreen(); - void OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId); + void OnObjectEvent(lv_obj_t* obj, lv_event_t event); private: Pinetime::Controllers::Battery& batteryController; diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp index acc2a27a..2da5ca27 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -125,12 +125,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()); @@ -147,7 +147,7 @@ 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); diff --git a/src/displayapp/screens/settings/SettingDisplay.cpp b/src/displayapp/screens/settings/SettingDisplay.cpp index 4954185d..aaf6a9f0 100644 --- a/src/displayapp/screens/settings/SettingDisplay.cpp +++ b/src/displayapp/screens/settings/SettingDisplay.cpp @@ -85,7 +85,7 @@ bool SettingDisplay::Refresh() { } 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 +110,4 @@ void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) { } } } -} \ No newline at end of file +} diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp index fd9792b3..adb984e0 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/Cst816s.cpp @@ -40,6 +40,16 @@ 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() { @@ -90,4 +100,4 @@ void Cst816S::Sleep() { void Cst816S::Wakeup() { Init(); NRF_LOG_INFO("[TOUCHPANEL] Wakeup"); -} \ No newline at end of file +} diff --git a/src/main.cpp b/src/main.cpp index ffbba5e7..f427db40 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,6 +43,7 @@ #include "drivers/TwiMaster.h" #include "drivers/Cst816s.h" #include "systemtask/SystemTask.h" +#include "touchhandler/TouchHandler.h" #if NRF_LOG_ENABLED #include "logging/NrfLogger.h" @@ -118,6 +119,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}; @@ -136,7 +138,8 @@ Pinetime::Applications::DisplayApp displayApp(lcd, settingsController, motorController, motionController, - timerController); + timerController, + touchHandler); Pinetime::System::SystemTask systemTask(spi, lcd, @@ -162,7 +165,7 @@ Pinetime::System::SystemTask systemTask(spi, void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { if (pin == pinTouchIrq) { - systemTask.OnTouchEvent(); + touchHandler.WakeUp(); return; } @@ -309,6 +312,10 @@ int main(void) { lvgl.Init(); systemTask.Start(); + + touchHandler.Register(&systemTask); + touchHandler.Start(); + nimble_port_init(); vTaskStartScheduler(); diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index d8b965b1..f6aee785 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -397,7 +397,6 @@ void SystemTask::OnTouchEvent() { return; if (!isSleeping) { PushMessage(Messages::OnTouchEvent); - displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent); } else if (!isWakingUp) { if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap) or settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) { diff --git a/src/touchhandler/TouchHandler.cpp b/src/touchhandler/TouchHandler.cpp new file mode 100644 index 00000000..a13d1af3 --- /dev/null +++ b/src/touchhandler/TouchHandler.cpp @@ -0,0 +1,70 @@ +#include "TouchHandler.h" + +using namespace Pinetime::Controllers; + +TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel, Components::LittleVgl& lvgl) + : touchPanel {touchPanel}, + lvgl {lvgl} { +} + +void TouchHandler::CancelTap() { + isCancelled = true; + lvgl.SetNewTapEvent(-1, -1, false); +} + +Pinetime::Drivers::Cst816S::Gestures TouchHandler::GestureGet() { + auto returnGesture = gesture; + gesture = Drivers::Cst816S::Gestures::None; + return returnGesture; +} + +void TouchHandler::Start() { + if (pdPASS != xTaskCreate(TouchHandler::Process, "Touch", 80, this, 0, &taskHandle)) { + APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); + } +} + +void TouchHandler::Process(void* instance) { + auto* app = static_cast(instance); + app->Work(); +} + +void TouchHandler::Work() { + Pinetime::Drivers::Cst816S::TouchInfos info; + while (true) { + vTaskSuspend(taskHandle); + info = touchPanel.GetTouchInfo(); + if (systemTask->IsSleeping()) { + systemTask->PushMessage(System::Messages::TouchWakeUp); + } else { + x = info.x; + y = info.y; + if (info.action == 0) { + lvgl.SetNewTapEvent(info.x, info.y, true); + } else if (info.action == 1) { + lvgl.SetNewTapEvent(info.x, info.y, false); + prevGesture = Pinetime::Drivers::Cst816S::Gestures::None; + isCancelled = false; + } else if (info.action == 2) { + if (!isCancelled) { + lvgl.SetNewTapEvent(info.x, info.y, true); + } + if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) { + if (prevGesture != info.gesture) { + prevGesture = info.gesture; + gesture = info.gesture; + } + } + } + systemTask->OnTouchEvent(); + } + } +} + +void TouchHandler::Register(Pinetime::System::SystemTask* systemTask) { + this->systemTask = systemTask; +} + +void TouchHandler::WakeUp() { + vTaskResume(taskHandle); +} diff --git a/src/touchhandler/TouchHandler.h b/src/touchhandler/TouchHandler.h new file mode 100644 index 00000000..7999e00a --- /dev/null +++ b/src/touchhandler/TouchHandler.h @@ -0,0 +1,45 @@ +#pragma once +#include "drivers/Cst816s.h" +#include "systemtask/SystemTask.h" +#include +#include + +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(); + void Register(Pinetime::System::SystemTask* systemTask); + void Start(); + void WakeUp(); + uint8_t GetX() const { + return x; + } + uint8_t GetY() const { + return y; + } + Drivers::Cst816S::Gestures GestureGet(); + private: + static void Process(void* instance); + void Work(); + Pinetime::System::SystemTask* systemTask = nullptr; + TaskHandle_t taskHandle; + Pinetime::Drivers::Cst816S& touchPanel; + Pinetime::Components::LittleVgl& lvgl; + Pinetime::Drivers::Cst816S::Gestures gesture; + Pinetime::Drivers::Cst816S::Gestures prevGesture; + bool isCancelled = false; + uint8_t x, y; + }; + } +} -- cgit v1.2.3 From 0d24d2b81e995d37bb7fb363df21a19b195107b8 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Thu, 15 Jul 2021 23:18:05 +0300 Subject: Quick fix --- src/drivers/Cst816s.cpp | 2 +- src/touchhandler/TouchHandler.cpp | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp index adb984e0..127fe1ec 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/Cst816s.cpp @@ -81,7 +81,7 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() { info.x = x; info.y = y; - info.action = action; + info.finger = nbTouchPoints; info.gesture = static_cast(touchData[gestureIndex]); return info; diff --git a/src/touchhandler/TouchHandler.cpp b/src/touchhandler/TouchHandler.cpp index a13d1af3..90b4d6da 100644 --- a/src/touchhandler/TouchHandler.cpp +++ b/src/touchhandler/TouchHandler.cpp @@ -39,13 +39,11 @@ void TouchHandler::Work() { } else { x = info.x; y = info.y; - if (info.action == 0) { - lvgl.SetNewTapEvent(info.x, info.y, true); - } else if (info.action == 1) { + if (info.finger == 0) { lvgl.SetNewTapEvent(info.x, info.y, false); prevGesture = Pinetime::Drivers::Cst816S::Gestures::None; isCancelled = false; - } else if (info.action == 2) { + } else if (info.finger == 1) { if (!isCancelled) { lvgl.SetNewTapEvent(info.x, info.y, true); } -- cgit v1.2.3 From 2a3e1263906d1145d6b539ff019362f0077d8097 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Fri, 16 Jul 2021 00:07:55 +0300 Subject: Fix most issues --- src/displayapp/DisplayApp.cpp | 11 ++--------- src/displayapp/DisplayApp.h | 4 ---- src/displayapp/LittleVgl.cpp | 2 +- src/displayapp/LittleVgl.h | 2 +- src/displayapp/screens/InfiniPaint.cpp | 3 --- src/displayapp/screens/Metronome.cpp | 2 +- src/displayapp/screens/Paddle.cpp | 4 ---- src/displayapp/screens/Screen.h | 1 + src/drivers/Cst816s.cpp | 26 +++++++++----------------- src/drivers/Cst816s.h | 26 ++++++++++++-------------- src/systemtask/SystemTask.cpp | 2 +- src/touchhandler/TouchHandler.cpp | 20 ++++++++++++-------- 12 files changed, 40 insertions(+), 63 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index ca7e390f..945f182a 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -226,9 +226,7 @@ void DisplayApp::Refresh() { } } - if (touchMode == TouchModes::Polling) { - currentScreen->OnTouchEvent(touchHandler.GetX(), touchHandler.GetY()); - } + currentScreen->OnTouchEvent(touchHandler.GetX(), touchHandler.GetY()); if (nextApp != Apps::None) { LoadApp(nextApp, nextDirection); @@ -367,6 +365,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) break; case Apps::Metronome: currentScreen = std::make_unique(this, motorController, *systemTask); + ReturnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::None); break; case Apps::Motion: currentScreen = std::make_unique(this, motionController); @@ -397,10 +396,8 @@ void DisplayApp::PushMessage(Messages msg) { TouchEvents DisplayApp::GetGesture() { auto gesture = touchHandler.GestureGet(); 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: @@ -445,10 +442,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 74fc4456..96951d1c 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -43,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, @@ -65,7 +64,6 @@ namespace Pinetime { void StartApp(Apps app, DisplayApp::FullRefreshDirections direction); void SetFullRefresh(FullRefreshDirections direction); - void SetTouchMode(TouchModes mode); void Register(Pinetime::System::SystemTask* systemTask); @@ -104,8 +102,6 @@ namespace Pinetime { FullRefreshDirections returnDirection = FullRefreshDirections::None; TouchEvents returnTouchEvent = TouchEvents::None; - TouchModes touchMode = TouchModes::Gestures; - TouchEvents GetGesture(); void RunningState(); void IdleState(); diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index d0c6161e..b5669713 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -166,7 +166,7 @@ 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, bool contact) { +void LittleVgl::SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) { tap_x = x; tap_y = y; tapped = contact; diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index 8d1ed56f..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, bool contact); + void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact); private: void InitDisplay(); diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp index 32240084..58bfa558 100644 --- a/src/displayapp/screens/InfiniPaint.cpp +++ b/src/displayapp/screens/InfiniPaint.cpp @@ -5,13 +5,10 @@ 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()); } diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp index 15916b62..3e3f478e 100644 --- a/src/displayapp/screens/Metronome.cpp +++ b/src/displayapp/screens/Metronome.cpp @@ -91,7 +91,7 @@ Metronome::~Metronome() { } bool Metronome::OnTouchEvent(Pinetime::Applications::TouchEvents event) { - return true; + return false; } bool Metronome::Refresh() { diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp index 5a939ac7..79e0c3d3 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); @@ -32,8 +30,6 @@ Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::Li } Paddle::~Paddle() { - // Reset the touchmode - app->SetTouchMode(DisplayApp::TouchModes::Gestures); lv_obj_clean(lv_scr_act()); } diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h index 8e49c9de..6567a20c 100644 --- a/src/displayapp/screens/Screen.h +++ b/src/displayapp/screens/Screen.h @@ -60,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/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp index 127fe1ec..b8f8e45d 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/Cst816s.cpp @@ -56,32 +56,24 @@ 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.finger = nbTouchPoints; + info.touching = (nbTouchPoints > 0); info.gesture = static_cast(touchData[gestureIndex]); return info; diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h index 14c296ea..26bdf4e0 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 = false; }; Cst816S(TwiMaster& twiMaster, uint8_t twiAddress); @@ -41,23 +38,24 @@ namespace Pinetime { 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/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index f6aee785..7277fc93 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -231,7 +231,7 @@ void SystemTask::Work() { twiMaster.Wakeup(); auto touchInfo = touchPanel.GetTouchInfo(); twiMaster.Sleep(); - if (touchInfo.isTouch and ((touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap and + if (touchInfo.isValid 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)))) { diff --git a/src/touchhandler/TouchHandler.cpp b/src/touchhandler/TouchHandler.cpp index 90b4d6da..c6f8629f 100644 --- a/src/touchhandler/TouchHandler.cpp +++ b/src/touchhandler/TouchHandler.cpp @@ -9,7 +9,7 @@ TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel, Components::LittleVgl& void TouchHandler::CancelTap() { isCancelled = true; - lvgl.SetNewTapEvent(-1, -1, false); + lvgl.SetNewTouchPoint(-1, -1, true); } Pinetime::Drivers::Cst816S::Gestures TouchHandler::GestureGet() { @@ -19,7 +19,7 @@ Pinetime::Drivers::Cst816S::Gestures TouchHandler::GestureGet() { } void TouchHandler::Start() { - if (pdPASS != xTaskCreate(TouchHandler::Process, "Touch", 80, this, 0, &taskHandle)) { + if (pdPASS != xTaskCreate(TouchHandler::Process, "Touch", 100, this, 0, &taskHandle)) { APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); } } @@ -39,13 +39,9 @@ void TouchHandler::Work() { } else { x = info.x; y = info.y; - if (info.finger == 0) { - lvgl.SetNewTapEvent(info.x, info.y, false); - prevGesture = Pinetime::Drivers::Cst816S::Gestures::None; - isCancelled = false; - } else if (info.finger == 1) { + if (info.touching) { if (!isCancelled) { - lvgl.SetNewTapEvent(info.x, info.y, true); + lvgl.SetNewTouchPoint(info.x, info.y, true); } if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) { if (prevGesture != info.gesture) { @@ -53,6 +49,14 @@ void TouchHandler::Work() { gesture = info.gesture; } } + } else { + if (isCancelled) { + lvgl.SetNewTouchPoint(-1, -1, false); + isCancelled = false; + } else { + lvgl.SetNewTouchPoint(info.x, info.y, false); + } + prevGesture = Pinetime::Drivers::Cst816S::Gestures::None; } systemTask->OnTouchEvent(); } -- cgit v1.2.3 From 93ccbf38e81b30165e49e897c01cac2eb54cc331 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Fri, 16 Jul 2021 01:49:20 +0300 Subject: Fix touch wakeup and code cleanup --- src/displayapp/LittleVgl.cpp | 21 --------------------- src/drivers/TwiMaster.cpp | 12 ++++++++---- src/drivers/TwiMaster.h | 3 ++- src/main.cpp | 4 +++- src/systemtask/SystemTask.cpp | 38 +++++++++++++++++++------------------- src/systemtask/SystemTask.h | 13 +++++++++---- src/touchhandler/TouchHandler.cpp | 5 ++--- 7 files changed, 43 insertions(+), 53 deletions(-) diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index b5669713..2bd5e57b 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -181,27 +181,6 @@ bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) { 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/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp index fc9edf81..456c3e64 100644 --- a/src/drivers/TwiMaster.cpp +++ b/src/drivers/TwiMaster.cpp @@ -12,9 +12,10 @@ TwiMaster::TwiMaster(const Modules module, const Parameters& params) : module {m } void TwiMaster::Init() { + sleeping = false; 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) | @@ -176,11 +177,14 @@ void TwiMaster::Sleep() { nrf_gpio_cfg_default(6); nrf_gpio_cfg_default(7); NRF_LOG_INFO("[TWIMASTER] Sleep"); + sleeping = true; } void TwiMaster::Wakeup() { - Init(); - NRF_LOG_INFO("[TWIMASTER] Wakeup"); + if (sleeping) { + Init(); + NRF_LOG_INFO("[TWIMASTER] Wakeup"); + } } /* Sometimes, the TWIM device just freeze and never set the event EVENTS_LASTTX. @@ -206,4 +210,4 @@ void TwiMaster::FixHwFreezed() { // 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..5748ec65 100644 --- a/src/drivers/TwiMaster.h +++ b/src/drivers/TwiMaster.h @@ -39,6 +39,7 @@ namespace Pinetime { uint8_t internalBuffer[maxDataSize + registerSize]; uint32_t txStartedCycleCount = 0; static constexpr uint32_t HwFreezedDelay {161000}; + bool sleeping; }; } -} \ No newline at end of file +} diff --git a/src/main.cpp b/src/main.cpp index f427db40..b8d4b023 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -161,10 +161,12 @@ 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) { + twiMaster.Wakeup(); touchHandler.WakeUp(); return; } diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 7277fc93..93d19863 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -60,7 +60,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}, @@ -72,18 +73,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() { @@ -105,11 +106,11 @@ void SystemTask::Work() { APP_GPIOTE_INIT(2); app_timer_init(); - + spi.Init(); spiNorFlash.Init(); spiNorFlash.Wakeup(); - + fs.Init(); nimbleController.Init(); @@ -228,14 +229,14 @@ void SystemTask::Work() { isWakingUp = false; break; case Messages::TouchWakeUp: { - twiMaster.Wakeup(); - auto touchInfo = touchPanel.GetTouchInfo(); - twiMaster.Sleep(); - if (touchInfo.isValid 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)))) { + auto gesture = touchHandler.GestureGet(); + if ((gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap && + settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) || + (gesture == Pinetime::Drivers::Cst816S::Gestures::SingleTap && + settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap))) { GoToRunning(); + } else { + twiMaster.Sleep(); } } break; case Messages::GoToSleep: @@ -311,7 +312,7 @@ void SystemTask::Work() { break; case Messages::OnChargingEvent: motorController.SetDuration(15); - // Battery level is updated on every message - there's no need to do anything + // Battery level is updated on every message - there's no need to do anything break; default: @@ -410,14 +411,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 f8cf6370..a7ee73ad 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -17,6 +17,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 +25,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 +40,9 @@ namespace Pinetime { class TwiMaster; class Hrs3300; } + namespace Controllers { + class TouchHandler; + } namespace System { class SystemTask { public: @@ -62,7 +66,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); @@ -91,7 +96,6 @@ namespace Pinetime { Pinetime::Components::LittleVgl& lvgl; Pinetime::Controllers::Battery& batteryController; - Pinetime::Controllers::Ble& bleController; Pinetime::Controllers::DateTime& dateTimeController; Pinetime::Controllers::TimerController& timerController; @@ -106,13 +110,14 @@ namespace Pinetime { Pinetime::Drivers::Bma421& motionSensor; Pinetime::Controllers::Settings& settingsController; Pinetime::Controllers::HeartRateController& heartRateController; - + Controllers::BrightnessController brightnessController; Pinetime::Controllers::MotionController& motionController; 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; diff --git a/src/touchhandler/TouchHandler.cpp b/src/touchhandler/TouchHandler.cpp index c6f8629f..86dc29f6 100644 --- a/src/touchhandler/TouchHandler.cpp +++ b/src/touchhandler/TouchHandler.cpp @@ -2,9 +2,7 @@ using namespace Pinetime::Controllers; -TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel, Components::LittleVgl& lvgl) - : touchPanel {touchPanel}, - lvgl {lvgl} { +TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel, Components::LittleVgl& lvgl) : touchPanel {touchPanel}, lvgl {lvgl} { } void TouchHandler::CancelTap() { @@ -35,6 +33,7 @@ void TouchHandler::Work() { vTaskSuspend(taskHandle); info = touchPanel.GetTouchInfo(); if (systemTask->IsSleeping()) { + gesture = info.gesture; systemTask->PushMessage(System::Messages::TouchWakeUp); } else { x = info.x; -- cgit v1.2.3 From baffa1594f9c1a03a95f0cc10955e3cf8bf880ce Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Fri, 16 Jul 2021 02:17:17 +0300 Subject: Fix gestures --- src/displayapp/screens/settings/QuickSettings.cpp | 11 ----------- src/displayapp/screens/settings/QuickSettings.h | 1 - src/touchhandler/TouchHandler.cpp | 20 +++++++++++++------- src/touchhandler/TouchHandler.h | 1 - 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp index 2da5ca27..076bea82 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -154,17 +154,6 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) { } } -bool QuickSettings::OnTouchEvent(Pinetime::Applications::TouchEvents event) { - switch (event) { - case Pinetime::Applications::TouchEvents::SwipeLeft: - running = false; - return false; - - default: - return true; - } -} - bool QuickSettings::Refresh() { return running; } diff --git a/src/displayapp/screens/settings/QuickSettings.h b/src/displayapp/screens/settings/QuickSettings.h index a14f46bf..e0fc0a87 100644 --- a/src/displayapp/screens/settings/QuickSettings.h +++ b/src/displayapp/screens/settings/QuickSettings.h @@ -29,7 +29,6 @@ namespace Pinetime { bool Refresh() override; - bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; void OnButtonEvent(lv_obj_t* object, lv_event_t event); void UpdateScreen(); diff --git a/src/touchhandler/TouchHandler.cpp b/src/touchhandler/TouchHandler.cpp index 86dc29f6..160b5e14 100644 --- a/src/touchhandler/TouchHandler.cpp +++ b/src/touchhandler/TouchHandler.cpp @@ -29,11 +29,23 @@ void TouchHandler::Process(void* instance) { void TouchHandler::Work() { Pinetime::Drivers::Cst816S::TouchInfos info; + Pinetime::Drivers::Cst816S::Gestures prevGesture = Pinetime::Drivers::Cst816S::Gestures::None; while (true) { vTaskSuspend(taskHandle); + info = touchPanel.GetTouchInfo(); + + if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) { + if (prevGesture != info.gesture) { + 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) { + prevGesture = info.gesture; + } + gesture = info.gesture; + } + } + if (systemTask->IsSleeping()) { - gesture = info.gesture; systemTask->PushMessage(System::Messages::TouchWakeUp); } else { x = info.x; @@ -42,12 +54,6 @@ void TouchHandler::Work() { if (!isCancelled) { lvgl.SetNewTouchPoint(info.x, info.y, true); } - if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) { - if (prevGesture != info.gesture) { - prevGesture = info.gesture; - gesture = info.gesture; - } - } } else { if (isCancelled) { lvgl.SetNewTouchPoint(-1, -1, false); diff --git a/src/touchhandler/TouchHandler.h b/src/touchhandler/TouchHandler.h index 7999e00a..37ef5af2 100644 --- a/src/touchhandler/TouchHandler.h +++ b/src/touchhandler/TouchHandler.h @@ -37,7 +37,6 @@ namespace Pinetime { Pinetime::Drivers::Cst816S& touchPanel; Pinetime::Components::LittleVgl& lvgl; Pinetime::Drivers::Cst816S::Gestures gesture; - Pinetime::Drivers::Cst816S::Gestures prevGesture; bool isCancelled = false; uint8_t x, y; }; -- cgit v1.2.3 From 329482f87308c185e970b141bcbfe9c83b46c4da Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Fri, 16 Jul 2021 11:55:29 +0300 Subject: Fix remaining known issues --- src/displayapp/DisplayApp.cpp | 4 +++- src/displayapp/screens/Tile.cpp | 3 ++- src/touchhandler/TouchHandler.cpp | 9 ++++----- src/touchhandler/TouchHandler.h | 11 ++++++++--- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 945f182a..1ff8d51d 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -226,7 +226,9 @@ void DisplayApp::Refresh() { } } - currentScreen->OnTouchEvent(touchHandler.GetX(), touchHandler.GetY()); + if (touchHandler.IsTouching()) { + currentScreen->OnTouchEvent(touchHandler.GetX(), touchHandler.GetY()); + } if (nextApp != Apps::None) { LoadApp(nextApp, nextDirection); diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index 5a40e915..8eb5eb0a 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -91,6 +91,7 @@ Tile::Tile(uint8_t screenID, lv_obj_set_style_local_bg_color(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DISABLED, lv_color_hex(0x111111)); 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); } @@ -123,7 +124,7 @@ bool Tile::Refresh() { } void Tile::OnObjectEvent(lv_obj_t* obj, lv_event_t event) { - if (event == LV_EVENT_CLICKED) { + if (event == LV_EVENT_VALUE_CHANGED) { app->StartApp(apps[lv_btnmatrix_get_active_btn(obj)], DisplayApp::FullRefreshDirections::Up); running = false; } diff --git a/src/touchhandler/TouchHandler.cpp b/src/touchhandler/TouchHandler.cpp index 160b5e14..0d0b8273 100644 --- a/src/touchhandler/TouchHandler.cpp +++ b/src/touchhandler/TouchHandler.cpp @@ -6,8 +6,10 @@ TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel, Components::LittleVgl& } void TouchHandler::CancelTap() { - isCancelled = true; - lvgl.SetNewTouchPoint(-1, -1, true); + if (info.touching) { + isCancelled = true; + lvgl.SetNewTouchPoint(-1, -1, true); + } } Pinetime::Drivers::Cst816S::Gestures TouchHandler::GestureGet() { @@ -28,7 +30,6 @@ void TouchHandler::Process(void* instance) { } void TouchHandler::Work() { - Pinetime::Drivers::Cst816S::TouchInfos info; Pinetime::Drivers::Cst816S::Gestures prevGesture = Pinetime::Drivers::Cst816S::Gestures::None; while (true) { vTaskSuspend(taskHandle); @@ -48,8 +49,6 @@ void TouchHandler::Work() { if (systemTask->IsSleeping()) { systemTask->PushMessage(System::Messages::TouchWakeUp); } else { - x = info.x; - y = info.y; if (info.touching) { if (!isCancelled) { lvgl.SetNewTouchPoint(info.x, info.y, true); diff --git a/src/touchhandler/TouchHandler.h b/src/touchhandler/TouchHandler.h index 37ef5af2..6b8189f5 100644 --- a/src/touchhandler/TouchHandler.h +++ b/src/touchhandler/TouchHandler.h @@ -22,23 +22,28 @@ namespace Pinetime { void Register(Pinetime::System::SystemTask* systemTask); void Start(); void WakeUp(); + + bool IsTouching() const { + return info.touching; + } uint8_t GetX() const { - return x; + return info.x; } uint8_t GetY() const { - return y; + return info.y; } Drivers::Cst816S::Gestures GestureGet(); private: static void Process(void* instance); void Work(); + + Pinetime::Drivers::Cst816S::TouchInfos info; Pinetime::System::SystemTask* systemTask = nullptr; TaskHandle_t taskHandle; Pinetime::Drivers::Cst816S& touchPanel; Pinetime::Components::LittleVgl& lvgl; Pinetime::Drivers::Cst816S::Gestures gesture; bool isCancelled = false; - uint8_t x, y; }; } } -- cgit v1.2.3 From 3e42297bd86fa20daaf7f59f6bc0a69de6cf9e53 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Sun, 18 Jul 2021 12:32:46 +0300 Subject: Update --- src/drivers/Cst816s.h | 2 +- src/main.cpp | 3 --- src/systemtask/SystemTask.cpp | 3 +++ src/touchhandler/TouchHandler.cpp | 44 ++++++++++++++++++++------------------- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h index 26bdf4e0..d4c17bb8 100644 --- a/src/drivers/Cst816s.h +++ b/src/drivers/Cst816s.h @@ -21,7 +21,7 @@ namespace Pinetime { uint16_t y = 0; Gestures gesture = Gestures::None; bool touching = false; - bool isValid = false; + bool isValid = true; }; Cst816S(TwiMaster& twiMaster, uint8_t twiAddress); diff --git a/src/main.cpp b/src/main.cpp index b8d4b023..62e4446f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -315,9 +315,6 @@ int main(void) { systemTask.Start(); - touchHandler.Register(&systemTask); - touchHandler.Start(); - nimble_port_init(); vTaskStartScheduler(); diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 93d19863..252d3cc3 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -144,6 +144,9 @@ void SystemTask::Work() { heartRateSensor.Disable(); heartRateApp.Start(); + touchHandler.Register(this); + touchHandler.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_output(15); nrf_gpio_pin_set(15); diff --git a/src/touchhandler/TouchHandler.cpp b/src/touchhandler/TouchHandler.cpp index 0d0b8273..187aa696 100644 --- a/src/touchhandler/TouchHandler.cpp +++ b/src/touchhandler/TouchHandler.cpp @@ -30,37 +30,39 @@ void TouchHandler::Process(void* instance) { } void TouchHandler::Work() { - Pinetime::Drivers::Cst816S::Gestures prevGesture = Pinetime::Drivers::Cst816S::Gestures::None; + bool slideReleased = true; while (true) { vTaskSuspend(taskHandle); info = touchPanel.GetTouchInfo(); - if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) { - if (prevGesture != info.gesture) { - 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) { - prevGesture = info.gesture; + if (info.isValid) { + if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) { + if (slideReleased) { + 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) { + slideReleased = false; + } + gesture = info.gesture; } - gesture = info.gesture; } - } - if (systemTask->IsSleeping()) { - systemTask->PushMessage(System::Messages::TouchWakeUp); - } else { - if (info.touching) { - if (!isCancelled) { - lvgl.SetNewTouchPoint(info.x, info.y, true); - } - } else { - if (isCancelled) { - lvgl.SetNewTouchPoint(-1, -1, false); - isCancelled = false; + if (!systemTask->IsSleeping()) { + if (info.touching) { + if (!isCancelled) { + lvgl.SetNewTouchPoint(info.x, info.y, true); + } } else { - lvgl.SetNewTouchPoint(info.x, info.y, false); + if (isCancelled) { + lvgl.SetNewTouchPoint(-1, -1, false); + isCancelled = false; + } else { + lvgl.SetNewTouchPoint(info.x, info.y, false); + } + slideReleased = true; } - prevGesture = Pinetime::Drivers::Cst816S::Gestures::None; } systemTask->OnTouchEvent(); } -- cgit v1.2.3 From dc2b5f0c6b387f674915d0dbe817b7ac2a821e07 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Mon, 19 Jul 2021 10:21:42 +0300 Subject: Restore Tile.cpp changes --- src/displayapp/screens/Tile.cpp | 8 +++++--- src/displayapp/screens/Tile.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index 8eb5eb0a..853fa7ec 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -12,7 +12,9 @@ namespace { static void event_handler(lv_obj_t* obj, lv_event_t event) { Tile* screen = static_cast(obj->user_data); - screen->OnObjectEvent(obj, event); + uint32_t* eventDataPtr = (uint32_t*) lv_event_get_data(); + uint32_t eventData = *eventDataPtr; + screen->OnObjectEvent(obj, event, eventData); } } @@ -123,9 +125,9 @@ bool Tile::Refresh() { return running; } -void Tile::OnObjectEvent(lv_obj_t* obj, lv_event_t event) { +void Tile::OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId) { if (event == LV_EVENT_VALUE_CHANGED) { - app->StartApp(apps[lv_btnmatrix_get_active_btn(obj)], DisplayApp::FullRefreshDirections::Up); + app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up); running = false; } } diff --git a/src/displayapp/screens/Tile.h b/src/displayapp/screens/Tile.h index 91ce9d01..4ebd81cd 100644 --- a/src/displayapp/screens/Tile.h +++ b/src/displayapp/screens/Tile.h @@ -32,7 +32,7 @@ namespace Pinetime { bool Refresh() override; void UpdateScreen(); - void OnObjectEvent(lv_obj_t* obj, lv_event_t event); + void OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId); private: Pinetime::Controllers::Battery& batteryController; -- cgit v1.2.3 From 97c761a5c74994ea1d9bef9c14e6e24afb9b4be2 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Mon, 19 Jul 2021 16:26:12 +0300 Subject: Refresh rework --- src/displayapp/DisplayApp.cpp | 2 +- src/displayapp/screens/ApplicationList.cpp | 6 --- src/displayapp/screens/ApplicationList.h | 3 +- src/displayapp/screens/BatteryInfo.cpp | 17 ++------ src/displayapp/screens/BatteryInfo.h | 6 +-- src/displayapp/screens/Brightness.cpp | 4 -- src/displayapp/screens/Brightness.h | 3 +- src/displayapp/screens/Clock.cpp | 7 +--- src/displayapp/screens/Clock.h | 2 - src/displayapp/screens/FirmwareUpdate.cpp | 15 ++++--- src/displayapp/screens/FirmwareUpdate.h | 6 ++- src/displayapp/screens/FirmwareValidation.cpp | 4 -- src/displayapp/screens/FirmwareValidation.h | 2 - src/displayapp/screens/FlashLight.cpp | 4 -- src/displayapp/screens/FlashLight.h | 2 - src/displayapp/screens/HeartRate.cpp | 7 ++-- src/displayapp/screens/HeartRate.h | 4 +- src/displayapp/screens/InfiniPaint.cpp | 4 -- src/displayapp/screens/InfiniPaint.h | 2 - src/displayapp/screens/Label.cpp | 4 -- src/displayapp/screens/Label.h | 4 +- src/displayapp/screens/List.cpp | 5 --- src/displayapp/screens/List.h | 2 - src/displayapp/screens/Meter.cpp | 8 ++-- src/displayapp/screens/Meter.h | 4 +- src/displayapp/screens/Metronome.cpp | 6 ++- src/displayapp/screens/Metronome.h | 4 +- src/displayapp/screens/Motion.cpp | 8 ++-- src/displayapp/screens/Motion.h | 6 ++- src/displayapp/screens/Music.cpp | 9 +++-- src/displayapp/screens/Music.h | 4 +- src/displayapp/screens/Navigation.cpp | 9 ++--- src/displayapp/screens/Navigation.h | 4 +- src/displayapp/screens/Notifications.cpp | 7 ++-- src/displayapp/screens/Notifications.h | 7 ++-- src/displayapp/screens/Paddle.cpp | 6 ++- src/displayapp/screens/Paddle.h | 4 +- src/displayapp/screens/PineTimeStyle.cpp | 10 +++-- src/displayapp/screens/PineTimeStyle.h | 4 +- src/displayapp/screens/Screen.cpp | 6 ++- src/displayapp/screens/Screen.h | 24 +++++------ src/displayapp/screens/ScreenList.h | 7 +--- src/displayapp/screens/Steps.cpp | 12 +++--- src/displayapp/screens/Steps.h | 25 ++++++------ src/displayapp/screens/StopWatch.cpp | 12 +++--- src/displayapp/screens/StopWatch.h | 5 ++- src/displayapp/screens/SystemInfo.cpp | 7 ---- src/displayapp/screens/SystemInfo.h | 3 +- src/displayapp/screens/Tile.cpp | 4 -- src/displayapp/screens/Tile.h | 1 - src/displayapp/screens/Timer.cpp | 46 ++++++++-------------- src/displayapp/screens/Timer.h | 35 ++++++++-------- src/displayapp/screens/Twos.cpp | 6 +-- src/displayapp/screens/Twos.h | 3 +- src/displayapp/screens/WatchFaceAnalog.cpp | 6 +-- src/displayapp/screens/WatchFaceAnalog.h | 4 +- src/displayapp/screens/WatchFaceDigital.cpp | 8 ++-- src/displayapp/screens/WatchFaceDigital.h | 4 +- src/displayapp/screens/settings/QuickSettings.cpp | 4 -- src/displayapp/screens/settings/QuickSettings.h | 2 - src/displayapp/screens/settings/SettingDisplay.cpp | 6 +-- src/displayapp/screens/settings/SettingDisplay.h | 1 - src/displayapp/screens/settings/SettingSteps.cpp | 7 +--- src/displayapp/screens/settings/SettingSteps.h | 23 +++++------ .../screens/settings/SettingTimeFormat.cpp | 6 +-- .../screens/settings/SettingTimeFormat.h | 1 - src/displayapp/screens/settings/SettingWakeUp.cpp | 4 -- src/displayapp/screens/settings/SettingWakeUp.h | 1 - .../screens/settings/SettingWatchFace.cpp | 6 +-- src/displayapp/screens/settings/SettingWatchFace.h | 1 - src/displayapp/screens/settings/Settings.cpp | 7 ---- src/displayapp/screens/settings/Settings.h | 2 - 72 files changed, 198 insertions(+), 306 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 071af0c8..450833f9 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -239,7 +239,7 @@ void DisplayApp::Refresh() { } void DisplayApp::RunningState() { - if (!currentScreen->Refresh()) { + if (!currentScreen->IsRunning()) { LoadApp(returnToApp, returnDirection); } lv_task_handler(); diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp index 78c7cd9a..67b67a53 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..91c26512 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(task->user_data); - user_data->UpdateScreen(); -} - BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Battery& batteryController) : Screen(app), batteryController {batteryController} { @@ -49,16 +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() { +void BatteryInfo::Refresh() { batteryController.Update(); @@ -85,7 +80,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 e0684976..e3af5e47 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -55,11 +55,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); } @@ -101,4 +96,4 @@ std::unique_ptr Clock::WatchFaceCustomScreen() { return std::make_unique(app, dateTimeController, batteryController, bleController, notificatioManager, settingsController); } -*/ \ No newline at end of file +*/ diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h index a48feea1..500672a7 100644 --- a/src/displayapp/screens/Clock.h +++ b/src/displayapp/screens/Clock.h @@ -34,8 +34,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 4086b152..11ac7bcb 100644 --- a/src/displayapp/screens/FirmwareUpdate.cpp +++ b/src/displayapp/screens/FirmwareUpdate.cpp @@ -30,36 +30,40 @@ FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp* app, Pinetime lv_label_set_text(percentLabel, ""); 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); } 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: case Pinetime::Controllers::Ble::FirmwareUpdateStates::Running: if (state != States::Running) state = States::Running; - return DisplayProgression(); + DisplayProgression(); + return; case Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated: if (state != States::Validated) { UpdateValidated(); state = States::Validated; } - return running; + return; case Pinetime::Controllers::Ble::FirmwareUpdateStates::Error: if (state != States::Error) { UpdateError(); state = States::Error; } - return running; + return; } } -bool FirmwareUpdate::DisplayProgression() const { +void FirmwareUpdate::DisplayProgression() const { float current = bleController.FirmwareUpdateCurrentBytes() / 1024.0f; float total = bleController.FirmwareUpdateTotalBytes() / 1024.0f; int16_t pc = (current / total) * 100.0f; @@ -67,7 +71,6 @@ bool FirmwareUpdate::DisplayProgression() const { lv_label_set_text(percentLabel, percentStr); lv_bar_set_value(bar1, pc, LV_ANIM_OFF); - return running; } void FirmwareUpdate::UpdateValidated() { diff --git a/src/displayapp/screens/FirmwareUpdate.h b/src/displayapp/screens/FirmwareUpdate.h index f4d34df0..12cd4aea 100644 --- a/src/displayapp/screens/FirmwareUpdate.h +++ b/src/displayapp/screens/FirmwareUpdate.h @@ -15,7 +15,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 }; @@ -27,11 +27,13 @@ namespace Pinetime { States state; - bool DisplayProgression() const; + void DisplayProgression() const; void UpdateValidated(); void UpdateError(); + + lv_task_t* taskRefresh; }; } } diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp index 1d05be8d..7ad45fac 100644 --- a/src/displayapp/screens/FirmwareValidation.cpp +++ b/src/displayapp/screens/FirmwareValidation.cpp @@ -61,10 +61,6 @@ 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) { validator.Validate(); 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 7db2c6c8..eebb776c 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 true; } 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..4dde81a4 100644 --- a/src/displayapp/screens/InfiniPaint.cpp +++ b/src/displayapp/screens/InfiniPaint.cpp @@ -15,10 +15,6 @@ InfiniPaint::~InfiniPaint() { 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 0132dbd2..8b079d99 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 62b80bec..7e86c83d 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: bool running = true; @@ -25,4 +23,4 @@ namespace Pinetime { }; } } -} \ No newline at end of file +} diff --git a/src/displayapp/screens/List.cpp b/src/displayapp/screens/List.cpp index b4f4d2cf..efc505c2 100644 --- a/src/displayapp/screens/List.cpp +++ b/src/displayapp/screens/List.cpp @@ -102,11 +102,6 @@ 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) { for (int i = 0; i < MAXLISTITEMS; i++) { 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); ~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 7bfbccb7..06cd7efb 100644 --- a/src/displayapp/screens/Metronome.cpp +++ b/src/displayapp/screens/Metronome.cpp @@ -85,9 +85,12 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl lv_label_set_text(playPauseLabel, Symbols::play); app->SetTouchMode(DisplayApp::TouchModes::Polling); + + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); } Metronome::~Metronome() { + lv_task_del(taskRefresh); app->SetTouchMode(DisplayApp::TouchModes::Gestures); systemTask.PushMessage(System::Messages::EnableSleeping); lv_obj_clean(lv_scr_act()); @@ -97,7 +100,7 @@ bool Metronome::OnTouchEvent(Pinetime::Applications::TouchEvents event) { return true; } -bool Metronome::Refresh() { +void Metronome::Refresh() { switch (currentState) { case States::Stopped: { break; @@ -117,7 +120,6 @@ bool Metronome::Refresh() { break; } } - 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 3a1f1084..d83dc741 100644 --- a/src/displayapp/screens/Metronome.h +++ b/src/displayapp/screens/Metronome.h @@ -11,7 +11,7 @@ namespace Pinetime::Applications::Screens { public: Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask); ~Metronome() override; - bool Refresh() override; + void Refresh() override; bool OnTouchEvent(TouchEvents event) override; void OnEvent(lv_obj_t* obj, lv_event_t event); enum class States { Running, Stopped }; @@ -30,5 +30,7 @@ namespace Pinetime::Applications::Screens { lv_obj_t *bpmArc, *bpmTap, *bpmValue, *bpmLegend; lv_obj_t *bpbDropdown, *bpbLegend; lv_obj_t *playPause, *playPauseLabel; + + lv_task_t* taskRefresh; }; } diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp index a8bb3c18..108b942d 100644 --- a/src/displayapp/screens/Motion.cpp +++ b/src/displayapp/screens/Motion.cpp @@ -32,18 +32,20 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); lv_label_set_recolor(label, true); - + 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()); @@ -52,8 +54,6 @@ bool Motion::Refresh() { lv_label_set_text_fmt(label, "X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#", motionController.X() / 0x10, motionController.Y() / 0x10, motionController.Z() / 0x10); lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); - - return running; } bool Motion::OnButtonPushed() { diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h index 132b20ec..3f91ecee 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; bool OnButtonPushed() override; private: @@ -32,7 +32,9 @@ namespace Pinetime { static constexpr uint8_t nbStepsBufferSize = 9; char nbStepsBuffer[nbStepsBufferSize + 1]; bool running = true; + + lv_task_t* taskRefresh; }; } } -} \ No newline at end of file +} diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp index 9f10f508..beb96fae 100644 --- a/src/displayapp/screens/Music.cpp +++ b/src/displayapp/screens/Music.cpp @@ -146,13 +146,16 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus frameB = false; musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN); + + taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this); } Music::~Music() { + lv_task_del(taskRefresh); lv_obj_clean(lv_scr_act()); } -bool Music::Refresh() { +void Music::Refresh() { if (artist != musicService.getArtist()) { artist = musicService.getArtist(); currentLength = 0; @@ -216,8 +219,6 @@ bool Music::Refresh() { } else { lv_label_set_text(txtPlayPause, Symbols::play); } - - return running; } void Music::UpdateLength() { @@ -303,4 +304,4 @@ bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) { return true; } } -} \ No newline at end of file +} diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h index ef8f1fec..a2d138b1 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); @@ -78,6 +78,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 38b12420..33e50cc3 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -47,13 +47,16 @@ Notifications::Notifications(DisplayApp* app, timeoutTickCountStart = xTaskGetTickCount(); 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); lv_obj_clean(lv_scr_act()); } -bool Notifications::Refresh() { +void Notifications::Refresh() { if (mode == Modes::Preview) { auto tick = xTaskGetTickCount(); int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240)); @@ -63,8 +66,6 @@ bool Notifications::Refresh() { timeoutLinePoints[1].x = pos; lv_line_set_points(timeoutLine, timeoutLinePoints, 2); } - - return running; } bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 51ca81da..6d47e232 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -22,7 +22,7 @@ namespace Pinetime { Modes mode); ~Notifications() override; - bool Refresh() override; + void Refresh() override; bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; class NotificationItem { @@ -35,9 +35,6 @@ namespace Pinetime { Modes mode, Pinetime::Controllers::AlertNotificationService& alertNotificationService); ~NotificationItem(); - bool Refresh() { - return false; - } void OnAcceptIncomingCall(lv_event_t event); void OnMuteIncomingCall(lv_event_t event); void OnRejectIncomingCall(lv_event_t event); @@ -78,6 +75,8 @@ namespace Pinetime { lv_obj_t* timeoutLine; 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..87fc8725 100644 --- a/src/displayapp/screens/Paddle.cpp +++ b/src/displayapp/screens/Paddle.cpp @@ -29,15 +29,18 @@ 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, 20, LV_TASK_PRIO_MID, this); } Paddle::~Paddle() { + lv_task_del(taskRefresh); // Reset the touchmode app->SetTouchMode(DisplayApp::TouchModes::Gestures); lv_obj_clean(lv_scr_act()); } -bool Paddle::Refresh() { +void Paddle::Refresh() { ballX += dx; ballY += dy; @@ -69,7 +72,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 591f3a49..c595223a 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -200,13 +200,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(); @@ -335,6 +339,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 3b4ded1e..88180c5e 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; void OnObjectEvent(lv_obj_t* pObj, lv_event_t i); @@ -80,6 +80,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(task->user_data)->Refresh(); +} diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h index 8e49c9de..30de2adc 100644 --- a/src/displayapp/screens/Screen.h +++ b/src/displayapp/screens/Screen.h @@ -2,6 +2,7 @@ #include #include "../TouchEvents.h" +#include namespace Pinetime { namespace Applications { @@ -34,25 +35,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() { 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 6aabd30e..a096bbcd 100644 --- a/src/displayapp/screens/Steps.cpp +++ b/src/displayapp/screens/Steps.cpp @@ -50,20 +50,20 @@ Steps::Steps( 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; + lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal())); } 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..74b49db1 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, 20, 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,7 +159,6 @@ 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) { @@ -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 f5bf0cc9..78399b74 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -63,13 +63,6 @@ SystemInfo::~SystemInfo() { lv_obj_clean(lv_scr_act()); } -bool SystemInfo::Refresh() { - if (running) { - screens.Refresh(); - } - return running; -} - bool SystemInfo::OnButtonPushed() { running = false; return true; diff --git a/src/displayapp/screens/SystemInfo.h b/src/displayapp/screens/SystemInfo.h index 9d471f61..5b1b4ee5 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 OnButtonPushed() override; bool OnTouchEvent(TouchEvents event) override; @@ -56,4 +55,4 @@ namespace Pinetime { }; } } -} \ No newline at end of file +} diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index 3eb127cc..d2ab9b4a 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -120,10 +120,6 @@ void Tile::UpdateScreen() { lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining())); } -bool Tile::Refresh() { - return running; -} - void Tile::OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId) { if (event == LV_EVENT_VALUE_CHANGED) { app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up); diff --git a/src/displayapp/screens/Tile.h b/src/displayapp/screens/Tile.h index 4ebd81cd..5de5b04b 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 OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId); diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp index 99e979ba..ae6ed30e 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(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, 20, 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> 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 f1889379..b6720bd1 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -119,10 +119,12 @@ 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, 20, 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); @@ -176,7 +178,7 @@ void WatchFaceAnalog::UpdateClock() { } } -bool WatchFaceAnalog::Refresh() { +void WatchFaceAnalog::Refresh() { batteryPercentRemaining = batteryController.PercentRemaining(); if (batteryPercentRemaining.IsUpdated()) { auto batteryPercent = batteryPercentRemaining.Get(); @@ -211,6 +213,4 @@ bool WatchFaceAnalog::Refresh() { currentDay = day; } } - - return true; } diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h index ac7f0ac5..c9b19b4d 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; @@ -83,6 +83,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 f1285eaf..9b6aee23 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -100,13 +100,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, 20, 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(); @@ -240,6 +244,4 @@ bool WatchFaceDigital::Refresh() { lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2); 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 76c8d3dc..02ec93cb 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; void OnObjectEvent(lv_obj_t* pObj, lv_event_t i); @@ -75,6 +75,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 acc2a27a..abee1688 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -164,7 +164,3 @@ bool QuickSettings::OnTouchEvent(Pinetime::Applications::TouchEvents event) { return true; } } - -bool QuickSettings::Refresh() { - return running; -} diff --git a/src/displayapp/screens/settings/QuickSettings.h b/src/displayapp/screens/settings/QuickSettings.h index a14f46bf..7757f28f 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; - bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; void OnButtonEvent(lv_obj_t* object, lv_event_t event); diff --git a/src/displayapp/screens/settings/SettingDisplay.cpp b/src/displayapp/screens/settings/SettingDisplay.cpp index 4954185d..7b31c47c 100644 --- a/src/displayapp/screens/settings/SettingDisplay.cpp +++ b/src/displayapp/screens/settings/SettingDisplay.cpp @@ -80,10 +80,6 @@ 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) { for (int i = 0; i < optionsTotal; i++) { @@ -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/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 0e080353..646afe6b 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 3e73489d..1d27acd9 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++) { @@ -90,4 +86,4 @@ void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) { } } } -} \ No newline at end of file +} 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 e63a3584..c7995742 100644 --- a/src/displayapp/screens/settings/Settings.cpp +++ b/src/displayapp/screens/settings/Settings.cpp @@ -26,13 +26,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); } diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h index 711a6be6..02ccff69 100644 --- a/src/displayapp/screens/settings/Settings.h +++ b/src/displayapp/screens/settings/Settings.h @@ -14,8 +14,6 @@ namespace Pinetime { Settings(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); ~Settings() override; - bool Refresh() override; - bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; private: -- cgit v1.2.3 From 331fc2be6931238960c894d0a926f673607455fc Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Mon, 19 Jul 2021 17:06:20 +0300 Subject: Set remaining default periods to LV_DISP_DEF_REFR_PERIOD --- src/displayapp/screens/Music.cpp | 2 +- src/displayapp/screens/Paddle.cpp | 2 +- src/displayapp/screens/StopWatch.cpp | 2 +- src/displayapp/screens/Timer.cpp | 2 +- src/displayapp/screens/WatchFaceAnalog.cpp | 2 +- src/displayapp/screens/WatchFaceDigital.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp index beb96fae..2d228772 100644 --- a/src/displayapp/screens/Music.cpp +++ b/src/displayapp/screens/Music.cpp @@ -147,7 +147,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN); - taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this); + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); } Music::~Music() { diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp index 87fc8725..d43173dc 100644 --- a/src/displayapp/screens/Paddle.cpp +++ b/src/displayapp/screens/Paddle.cpp @@ -30,7 +30,7 @@ Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::Li 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, 20, LV_TASK_PRIO_MID, this); + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); } Paddle::~Paddle() { diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index 74b49db1..0d4feb20 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -101,7 +101,7 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask) lv_obj_align(lapTwoText, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 50, 55); lv_label_set_text(lapTwoText, ""); - taskRefresh = lv_task_create(RefreshTaskCallback, 20, LV_TASK_PRIO_MID, this); + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); } StopWatch::~StopWatch() { diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp index ae6ed30e..ff3099d5 100644 --- a/src/displayapp/screens/Timer.cpp +++ b/src/displayapp/screens/Timer.cpp @@ -74,7 +74,7 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController) createButtons(); } - taskRefresh = lv_task_create(RefreshTaskCallback, 20, LV_TASK_PRIO_MID, this); + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); } Timer::~Timer() { diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp index b6720bd1..95c3fe46 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -119,7 +119,7 @@ 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, 20, LV_TASK_PRIO_MID, this); + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); UpdateClock(); } diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 9b6aee23..e66e7aa9 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -101,7 +101,7 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app, lv_label_set_text(stepIcon, Symbols::shoe); lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); - taskRefresh = lv_task_create(RefreshTaskCallback, 20, LV_TASK_PRIO_MID, this); + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); Refresh(); } -- cgit v1.2.3 From 5e4d3c87e92b8f2dd1020577f3ebad93322b0f6f Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Thu, 22 Jul 2021 15:37:34 +0200 Subject: Remove .gitignore --- .gitignore | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 2f9ac181..00000000 --- a/.gitignore +++ /dev/null @@ -1,41 +0,0 @@ -.idea/ -# Python virtual environment for DFU images -.venv/ - -# CMake -cmake-build-* -cmake-* -CMakeFiles -**/CMakeCache.txt -cmake_install.cmake -Makefile -build -tools - -# Resulting binary files -*.a -*.so -*.s -*.hex -*.bin -!bootloader/bootloader-5.0.4.bin -*.map -*.out -pinetime*.cbp - -# InfiniTime's files -core -sdk -src/Version.h -docker/post_build.sh -Testing/Temporary/ - -# Linux -**/.directory -**/*.swp - -# OSX/MacOS -**/.DS_Store - -# Windows -**/thumbs.db \ No newline at end of file -- cgit v1.2.3 From 547b5a869911bc98e08df05dc56de7ae830f7eeb Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Fri, 23 Jul 2021 15:06:08 +0200 Subject: Restore .gitignore --- .gitignore | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..2f9ac181 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +.idea/ +# Python virtual environment for DFU images +.venv/ + +# CMake +cmake-build-* +cmake-* +CMakeFiles +**/CMakeCache.txt +cmake_install.cmake +Makefile +build +tools + +# Resulting binary files +*.a +*.so +*.s +*.hex +*.bin +!bootloader/bootloader-5.0.4.bin +*.map +*.out +pinetime*.cbp + +# InfiniTime's files +core +sdk +src/Version.h +docker/post_build.sh +Testing/Temporary/ + +# Linux +**/.directory +**/*.swp + +# OSX/MacOS +**/.DS_Store + +# Windows +**/thumbs.db \ No newline at end of file -- cgit v1.2.3 From b3e3d75d0fd077cd4341092f57403b6b3e17c7fd Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sat, 24 Jul 2021 14:25:27 +0200 Subject: Add extra screen in settings to show scrollbar correctly --- src/displayapp/screens/settings/Settings.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp index 73347804..43f60a31 100644 --- a/src/displayapp/screens/settings/Settings.cpp +++ b/src/displayapp/screens/settings/Settings.cpp @@ -49,7 +49,7 @@ std::unique_ptr Settings::CreateScreen1() { {Symbols::clock, "Watch face", Apps::SettingWatchFace}, }}; - return std::make_unique(0, 2, app, settingsController, applications); + return std::make_unique(0, 3, app, settingsController, applications); } std::unique_ptr Settings::CreateScreen2() { @@ -61,7 +61,7 @@ std::unique_ptr Settings::CreateScreen2() { {Symbols::list, "About", Apps::SysInfo}, }}; - return std::make_unique(1, 2, app, settingsController, applications); + return std::make_unique(1, 3, app, settingsController, applications); } std::unique_ptr Settings::CreateScreen3() { @@ -73,5 +73,5 @@ std::unique_ptr Settings::CreateScreen3() { {Symbols::none, "None", Apps::None}, }}; - return std::make_unique(2, 2, app, settingsController, applications); + return std::make_unique(2, 3, app, settingsController, applications); } -- cgit v1.2.3 From e6bc485679022c51486ac3a28b8473b95ff0d115 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 25 Jul 2021 22:18:39 +0200 Subject: Increment settings value, remove old hacky fix --- src/components/settings/Settings.h | 2 +- src/displayapp/screens/PineTimeStyle.cpp | 28 ++++++++-------------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index cddef635..40cafe9a 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -154,7 +154,7 @@ 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; diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index b27bd9c7..afce698c 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -52,7 +52,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, 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; @@ -61,14 +61,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, displayedChar[3] = 0; displayedChar[4] = 0; - //Feels like a hack, but if all the colors are white, this is probably not what the user wants - if (settingsController.GetPTSColorTime() + settingsController.GetPTSColorBar() + settingsController.GetPTSColorBG() == 0) { - settingsController.SetPTSColorTime(11); - settingsController.SetPTSColorBar(11); - settingsController.SetPTSColorBG(3); - } - - /* 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, pts_colors[settingsController.GetPTSColorBG()]); @@ -76,8 +69,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, 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, pts_colors[settingsController.GetPTSColorTime()]); @@ -96,16 +88,14 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, 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, pts_colors[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); @@ -123,8 +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); @@ -161,8 +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"); @@ -303,7 +291,7 @@ bool PineTimeStyle::Refresh() { lv_label_set_text(timeAMPM, ampmChar); } - /* Display the time as 2 pairs of digits */ + // Display the time as 2 pairs of digits sprintf(hourStr, "%c%c", hoursChar[0], hoursChar[1]); lv_label_set_text(timeDD1, hourStr); -- cgit v1.2.3 From 28abeae21bb370c45d26912bba4737a1cc6ddca7 Mon Sep 17 00:00:00 2001 From: hubmartin Date: Mon, 2 Aug 2021 21:37:48 +0200 Subject: DRAFT: Put gpio pins to separate file --- src/CMakeLists.txt | 1 + src/components/battery/BatteryController.h | 3 ++- src/drivers/Cst816s.h | 3 ++- src/drivers/PinMap.h | 25 +++++++++++++++++++++++++ src/systemtask/SystemTask.h | 3 ++- 5 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 src/drivers/PinMap.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 40e1f2a5..24b5ae4a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -615,6 +615,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 diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h index 1333ad0e..cd66ff8f 100644 --- a/src/components/battery/BatteryController.h +++ b/src/components/battery/BatteryController.h @@ -3,6 +3,7 @@ #include #include #include +#include namespace Pinetime { namespace Controllers { @@ -72,7 +73,7 @@ namespace Pinetime { static constexpr uint8_t percentRemainingSamples = 5; CircBuffer percentRemainingBuffer {}; - static constexpr uint32_t chargingPin = 12; + static constexpr uint32_t chargingPin = PINMAP_CHARGING_PIN; static constexpr uint32_t powerPresentPin = 19; static constexpr nrf_saadc_input_t batteryVoltageAdcInput = NRF_SAADC_INPUT_AIN7; uint16_t voltage = 0; diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h index 14c296ea..fa53907a 100644 --- a/src/drivers/Cst816s.h +++ b/src/drivers/Cst816s.h @@ -1,6 +1,7 @@ #pragma once #include "TwiMaster.h" +#include namespace Pinetime { namespace Drivers { @@ -40,7 +41,7 @@ namespace Pinetime { private: static constexpr uint8_t pinIrq = 28; - static constexpr uint8_t pinReset = 10; + static constexpr uint8_t pinReset = PINMAP_CST816S_RESET_PIN; static constexpr uint8_t lastTouchId = 0x0f; static constexpr uint8_t touchPointNumIndex = 2; static constexpr uint8_t touchMiscIndex = 8; diff --git a/src/drivers/PinMap.h b/src/drivers/PinMap.h new file mode 100644 index 00000000..61bb10e4 --- /dev/null +++ b/src/drivers/PinMap.h @@ -0,0 +1,25 @@ +#pragma once + +#ifdef WATCH_P8 + +// BatteryController.h +#define PINMAP_CHARGING_PIN 19 + +// Cst816s.h +#define PINMAP_CST816S_RESET_PIN 13 + +// SystemTask.h +#define PINMAP_BUTTON_PIN 17 + +#else + +// BatteryController.h +#define PINMAP_CHARGING_PIN 12 + +// Cst816s.h +#define PINMAP_CST816S_RESET_PIN 10 + +// SystemTask.h +#define PINMAP_BUTTON_PIN 13 + +#endif \ No newline at end of file diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index ba434298..2756f774 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "SystemMonitor.h" @@ -120,7 +121,7 @@ namespace Pinetime { 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 pinButton = PINMAP_BUTTON_PIN; static constexpr uint8_t pinTouchIrq = 28; static constexpr uint8_t pinPowerPresentIrq = 19; -- cgit v1.2.3 From f244c960d3848096b60f735e705819f05a0459d7 Mon Sep 17 00:00:00 2001 From: Martin Hub Date: Tue, 3 Aug 2021 17:41:34 +0200 Subject: Update ota-gadgetbridge-nrfconnect.md --- doc/gettingStarted/ota-gadgetbridge-nrfconnect.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md b/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md index 1187a9b7..2f2dd55e 100644 --- a/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md +++ b/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md @@ -88,6 +88,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. -- cgit v1.2.3 From 2992f4afd286d26068bba0afdd9337ab6d96aa15 Mon Sep 17 00:00:00 2001 From: Martin Hub Date: Tue, 3 Aug 2021 17:56:02 +0200 Subject: Add FW validation note after DFU flash --- doc/gettingStarted/ota-gadgetbridge-nrfconnect.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md b/doc/gettingStarted/ota-gadgetbridge-nrfconnect.md index 1187a9b7..86bbab86 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 -- cgit v1.2.3 From c30e54c7b743f7c6364d35412d74ba9be8dc3c04 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Tue, 3 Aug 2021 19:49:54 +0300 Subject: Make it easier for new people to find instructions --- README.md | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index d9de4002..af91616c 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,15 @@ -# PineTime +## New to 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. + - [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) # InfiniTime +[![Build PineTime Firmware](https://github.com/JF002/InfiniTime/workflows/Build%20PineTime%20Firmware/badge.svg?branch=master)](https://github.com/JF002/InfiniTime/actions) + ![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**; @@ -75,11 +70,6 @@ As of now, here is the list of achievements of this project: ## 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) -- cgit v1.2.3 From 285ac9e4c86f6f1fb96130d2df038fff7ec49ad5 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Tue, 3 Aug 2021 19:51:58 +0300 Subject: Move getting started slightly lower --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index af91616c..a6f0d3a6 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,3 @@ -## 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) - # InfiniTime [![Build PineTime Firmware](https://github.com/JF002/InfiniTime/workflows/Build%20PineTime%20Firmware/badge.svg?branch=master)](https://github.com/JF002/InfiniTime/actions) @@ -17,6 +12,11 @@ The goal of this project is to design an open-source firmware for the [Pinetime - 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") -- cgit v1.2.3 From b7aa04e1f55096d754a7cc291f02f3430f5a3cd9 Mon Sep 17 00:00:00 2001 From: hubmartin Date: Tue, 3 Aug 2021 20:32:23 +0200 Subject: PinMap with namespace and constexpr --- src/components/battery/BatteryController.cpp | 6 ++-- src/components/battery/BatteryController.h | 2 -- src/components/brightness/BrightnessController.cpp | 32 +++++++++---------- src/components/brightness/BrightnessController.h | 3 -- src/components/motor/MotorController.cpp | 9 +++--- src/components/motor/MotorController.h | 1 - src/drivers/Cst816s.cpp | 13 ++++---- src/drivers/Cst816s.h | 3 -- src/drivers/PinMap.h | 37 ++++++++++++++++++++++ src/main.cpp | 29 ++++++----------- src/recoveryLoader.cpp | 19 ++++------- src/systemtask/SystemTask.cpp | 20 ++++++------ src/systemtask/SystemTask.h | 9 ------ 13 files changed, 96 insertions(+), 87 deletions(-) diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index fa476ea3..d543ccd9 100644 --- a/src/components/battery/BatteryController.cpp +++ b/src/components/battery/BatteryController.cpp @@ -12,12 +12,12 @@ Battery::Battery() { } void Battery::Init() { - nrf_gpio_cfg_input(chargingPin, static_cast GPIO_PIN_CNF_PULL_Pullup); + nrf_gpio_cfg_input(PinMap::Charging, static_cast GPIO_PIN_CNF_PULL_Pullup); } 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; diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h index cd66ff8f..993ef6c5 100644 --- a/src/components/battery/BatteryController.h +++ b/src/components/battery/BatteryController.h @@ -73,8 +73,6 @@ namespace Pinetime { static constexpr uint8_t percentRemainingSamples = 5; CircBuffer percentRemainingBuffer {}; - static constexpr uint32_t chargingPin = PINMAP_CHARGING_PIN; - static constexpr uint32_t powerPresentPin = 19; static constexpr nrf_saadc_input_t batteryVoltageAdcInput = NRF_SAADC_INPUT_AIN7; uint16_t voltage = 0; int percentRemaining = -1; diff --git a/src/components/brightness/BrightnessController.cpp b/src/components/brightness/BrightnessController.cpp index 8ad987d1..350dfeeb 100644 --- a/src/components/brightness/BrightnessController.cpp +++ b/src/components/brightness/BrightnessController.cpp @@ -1,13 +1,13 @@ #include "BrightnessController.h" #include #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::LcdBacklight1); + nrf_gpio_cfg_output(PinMap::LcdBacklight2); + nrf_gpio_cfg_output(PinMap::LcdBacklight3); 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::LcdBacklight1); + nrf_gpio_pin_clear(PinMap::LcdBacklight2); + nrf_gpio_pin_clear(PinMap::LcdBacklight3); break; case Levels::Medium: - nrf_gpio_pin_clear(pinLcdBacklight1); - nrf_gpio_pin_clear(pinLcdBacklight2); - nrf_gpio_pin_set(pinLcdBacklight3); + nrf_gpio_pin_clear(PinMap::LcdBacklight1); + nrf_gpio_pin_clear(PinMap::LcdBacklight2); + nrf_gpio_pin_set(PinMap::LcdBacklight3); break; case Levels::Low: - nrf_gpio_pin_clear(pinLcdBacklight1); - nrf_gpio_pin_set(pinLcdBacklight2); - nrf_gpio_pin_set(pinLcdBacklight3); + nrf_gpio_pin_clear(PinMap::LcdBacklight1); + nrf_gpio_pin_set(PinMap::LcdBacklight2); + nrf_gpio_pin_set(PinMap::LcdBacklight3); break; case Levels::Off: - nrf_gpio_pin_set(pinLcdBacklight1); - nrf_gpio_pin_set(pinLcdBacklight2); - nrf_gpio_pin_set(pinLcdBacklight3); + nrf_gpio_pin_set(PinMap::LcdBacklight1); + nrf_gpio_pin_set(PinMap::LcdBacklight2); + nrf_gpio_pin_set(PinMap::LcdBacklight3); 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 3afa0ced..1f209368 100644 --- a/src/components/motor/MotorController.cpp +++ b/src/components/motor/MotorController.cpp @@ -2,6 +2,7 @@ #include #include "systemtask/SystemTask.h" #include "app_timer.h" +#include "drivers/PinMap.h" APP_TIMER_DEF(vibTimer); @@ -11,8 +12,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_create(&vibTimer, APP_TIMER_MODE_SINGLE_SHOT, vibrate); } @@ -21,11 +22,11 @@ void MotorController::SetDuration(uint8_t motorDuration) { if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) return; - nrf_gpio_pin_clear(pinMotor); + nrf_gpio_pin_clear(PinMap::Motor); /* Start timer for motorDuration miliseconds and timer triggers vibrate() when it finishes*/ app_timer_start(vibTimer, APP_TIMER_TICKS(motorDuration), NULL); } void MotorController::vibrate(void* p_context) { - nrf_gpio_pin_set(pinMotor); + nrf_gpio_pin_set(PinMap::Motor); } \ No newline at end of file diff --git a/src/components/motor/MotorController.h b/src/components/motor/MotorController.h index df61af78..00cd1937 100644 --- a/src/components/motor/MotorController.h +++ b/src/components/motor/MotorController.h @@ -6,7 +6,6 @@ namespace Pinetime { namespace Controllers { - static constexpr uint8_t pinMotor = 16; class MotorController { public: diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp index fd9792b3..b039ab0f 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/Cst816s.cpp @@ -3,6 +3,7 @@ #include #include #include +#include "drivers/PinMap.h" using namespace Pinetime::Drivers; @@ -18,12 +19,12 @@ Cst816S::Cst816S(TwiMaster& twiMaster, uint8_t twiAddress) : twiMaster {twiMaste } void Cst816S::Init() { - nrf_gpio_cfg_output(pinReset); - nrf_gpio_pin_set(pinReset); + nrf_gpio_cfg_output(PinMap::Cst816sReset); + nrf_gpio_pin_set(PinMap::Cst816sReset); vTaskDelay(50); - 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); // Wake the touchpanel up @@ -78,9 +79,9 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() { } 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); diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h index fa53907a..b6215104 100644 --- a/src/drivers/Cst816s.h +++ b/src/drivers/Cst816s.h @@ -1,7 +1,6 @@ #pragma once #include "TwiMaster.h" -#include namespace Pinetime { namespace Drivers { @@ -40,8 +39,6 @@ namespace Pinetime { void Wakeup(); private: - static constexpr uint8_t pinIrq = 28; - static constexpr uint8_t pinReset = PINMAP_CST816S_RESET_PIN; static constexpr uint8_t lastTouchId = 0x0f; static constexpr uint8_t touchPointNumIndex = 2; static constexpr uint8_t touchMiscIndex = 8; diff --git a/src/drivers/PinMap.h b/src/drivers/PinMap.h index 61bb10e4..117cf11f 100644 --- a/src/drivers/PinMap.h +++ b/src/drivers/PinMap.h @@ -1,5 +1,42 @@ #pragma once +namespace Pinetime { + namespace PinMap { + #define WATCH_P8 + #ifdef WATCH_P8 + static constexpr uint8_t Charging = 19; + static constexpr uint8_t Cst816sReset = 13; + static constexpr uint8_t Button = 17; + #else + 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 LcdBacklight1 = 14; + static constexpr uint8_t LcdBacklight2 = 22; + static constexpr uint8_t LcdBacklight3 = 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; + + } +} + + #ifdef WATCH_P8 // BatteryController.h diff --git a/src/main.cpp b/src/main.cpp index ffbba5e7..408ce437 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,6 +42,7 @@ #include "drivers/St7789.h" #include "drivers/TwiMaster.h" #include "drivers/Cst816s.h" +#include "drivers/PinMap.h" #include "systemtask/SystemTask.h" #if NRF_LOG_ENABLED @@ -52,14 +53,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; @@ -68,14 +61,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::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 @@ -83,7 +76,7 @@ Pinetime::Drivers::SpiNorFlash spiNorFlash {flashSpi}; // 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::Parameters {MaxTwiFrequencyWithoutHardwareBug, Pinetime::PinMap::TwiSda, Pinetime::PinMap::TwiScl}}; Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress}; #ifdef PINETIME_IS_RECOVERY static constexpr bool isFactory = true; @@ -106,8 +99,6 @@ 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; Pinetime::Controllers::HeartRateController heartRateController; Pinetime::Applications::HeartRateTask heartRateApp(heartRateSensor, heartRateController); @@ -161,14 +152,14 @@ Pinetime::System::SystemTask systemTask(spi, fs); 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; 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 #include #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/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 8915ce74..e03a57bd 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 using namespace Pinetime::System; @@ -149,7 +151,7 @@ void SystemTask::Work() { 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 +162,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,19 +172,19 @@ 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); @@ -354,7 +356,7 @@ void SystemTask::Work() { 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 diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index 2756f774..e4da6b1a 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -116,15 +116,6 @@ namespace Pinetime { Pinetime::Controllers::FS& fs; 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 = PINMAP_BUTTON_PIN; - static constexpr uint8_t pinTouchIrq = 28; - static constexpr uint8_t pinPowerPresentIrq = 19; - static void Process(void* instance); void Work(); void ReloadIdleTimer(); -- cgit v1.2.3 From b3e6da75148fcb54fdb5fe02f6bdc7d7d3905e98 Mon Sep 17 00:00:00 2001 From: hubmartin Date: Tue, 3 Aug 2021 20:40:27 +0200 Subject: Cleanup, set Pinetime as default --- src/components/battery/BatteryController.cpp | 1 + src/components/battery/BatteryController.h | 1 - src/drivers/PinMap.h | 58 ++++++++-------------------- 3 files changed, 18 insertions(+), 42 deletions(-) diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index d543ccd9..e2fce7f3 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 #include #include diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h index 993ef6c5..5c7fa1f4 100644 --- a/src/components/battery/BatteryController.h +++ b/src/components/battery/BatteryController.h @@ -3,7 +3,6 @@ #include #include #include -#include namespace Pinetime { namespace Controllers { diff --git a/src/drivers/PinMap.h b/src/drivers/PinMap.h index 117cf11f..c8b091f1 100644 --- a/src/drivers/PinMap.h +++ b/src/drivers/PinMap.h @@ -2,61 +2,37 @@ namespace Pinetime { namespace PinMap { - #define WATCH_P8 + #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 Cst816sIrq = 28; + static constexpr uint8_t PowerPresent = 19; - static constexpr uint8_t Motor = 16; + static constexpr uint8_t Motor = 16; - static constexpr uint8_t LcdBacklight1 = 14; - static constexpr uint8_t LcdBacklight2 = 22; - static constexpr uint8_t LcdBacklight3 = 23; + static constexpr uint8_t LcdBacklight1 = 14; + static constexpr uint8_t LcdBacklight2 = 22; + static constexpr uint8_t LcdBacklight3 = 23; - static constexpr uint8_t SpiSck = 2; - static constexpr uint8_t SpiMosi = 3; - static constexpr uint8_t SpiMiso = 4; + 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; + 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; } } - - -#ifdef WATCH_P8 - -// BatteryController.h -#define PINMAP_CHARGING_PIN 19 - -// Cst816s.h -#define PINMAP_CST816S_RESET_PIN 13 - -// SystemTask.h -#define PINMAP_BUTTON_PIN 17 - -#else - -// BatteryController.h -#define PINMAP_CHARGING_PIN 12 - -// Cst816s.h -#define PINMAP_CST816S_RESET_PIN 10 - -// SystemTask.h -#define PINMAP_BUTTON_PIN 13 - -#endif \ No newline at end of file -- cgit v1.2.3 From abd8f343e48bdfa1dc4c8604d843a5c2d8071bc0 Mon Sep 17 00:00:00 2001 From: hubmartin Date: Wed, 4 Aug 2021 14:43:04 +0200 Subject: Rename backlight level pins --- src/components/brightness/BrightnessController.cpp | 30 +++++++++++----------- src/drivers/PinMap.h | 6 ++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/brightness/BrightnessController.cpp b/src/components/brightness/BrightnessController.cpp index 350dfeeb..6c524679 100644 --- a/src/components/brightness/BrightnessController.cpp +++ b/src/components/brightness/BrightnessController.cpp @@ -5,9 +5,9 @@ using namespace Pinetime::Controllers; void BrightnessController::Init() { - nrf_gpio_cfg_output(PinMap::LcdBacklight1); - nrf_gpio_cfg_output(PinMap::LcdBacklight2); - nrf_gpio_cfg_output(PinMap::LcdBacklight3); + 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(PinMap::LcdBacklight1); - nrf_gpio_pin_clear(PinMap::LcdBacklight2); - nrf_gpio_pin_clear(PinMap::LcdBacklight3); + 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(PinMap::LcdBacklight1); - nrf_gpio_pin_clear(PinMap::LcdBacklight2); - nrf_gpio_pin_set(PinMap::LcdBacklight3); + 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(PinMap::LcdBacklight1); - nrf_gpio_pin_set(PinMap::LcdBacklight2); - nrf_gpio_pin_set(PinMap::LcdBacklight3); + 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(PinMap::LcdBacklight1); - nrf_gpio_pin_set(PinMap::LcdBacklight2); - nrf_gpio_pin_set(PinMap::LcdBacklight3); + nrf_gpio_pin_set(PinMap::LcdBacklightLow); + nrf_gpio_pin_set(PinMap::LcdBacklightMedium); + nrf_gpio_pin_set(PinMap::LcdBacklightHigh); break; } } diff --git a/src/drivers/PinMap.h b/src/drivers/PinMap.h index c8b091f1..57964020 100644 --- a/src/drivers/PinMap.h +++ b/src/drivers/PinMap.h @@ -20,9 +20,9 @@ namespace Pinetime { static constexpr uint8_t Motor = 16; - static constexpr uint8_t LcdBacklight1 = 14; - static constexpr uint8_t LcdBacklight2 = 22; - static constexpr uint8_t LcdBacklight3 = 23; + 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; -- cgit v1.2.3 From baa7e1bf12b58224e9461a5a605dcebabcf9504e Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Mon, 9 Aug 2021 17:45:24 +0300 Subject: Optimize twiMaster --- src/drivers/TwiMaster.cpp | 39 ++++++++++++++++++--------------------- src/drivers/TwiMaster.h | 4 +++- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp index fc9edf81..e4c03d5b 100644 --- a/src/drivers/TwiMaster.cpp +++ b/src/drivers/TwiMaster.cpp @@ -9,21 +9,25 @@ using namespace Pinetime::Drivers; // TODO use DMA/IRQ TwiMaster::TwiMaster(const Modules module, const Parameters& params) : module {module}, params {params} { + mutex = xSemaphoreCreateBinary(); } -void TwiMaster::Init() { - if(mutex == nullptr) - mutex = xSemaphoreCreateBinary(); - +void TwiMaster::ConfigurePins() const { 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); + (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | + (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_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[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); + (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | + (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | + (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) | + (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos); +} + +void TwiMaster::Init() { + ConfigurePins(); switch (module) { case Modules::TWIM1: @@ -179,7 +183,8 @@ void TwiMaster::Sleep() { } void TwiMaster::Wakeup() { - Init(); + ConfigurePins(); + twiBaseAddress->ENABLE = (TWIM_ENABLE_ENABLE_Enabled << TWIM_ENABLE_ENABLE_Pos); NRF_LOG_INFO("[TWIMASTER] Wakeup"); } @@ -194,16 +199,8 @@ void TwiMaster::FixHwFreezed() { 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); - - 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); + ConfigurePins(); // 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..b8d36d59 100644 --- a/src/drivers/TwiMaster.h +++ b/src/drivers/TwiMaster.h @@ -26,6 +26,8 @@ namespace Pinetime { void Sleep(); void Wakeup(); + void ConfigurePins() const; + private: 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); @@ -41,4 +43,4 @@ namespace Pinetime { static constexpr uint32_t HwFreezedDelay {161000}; }; } -} \ No newline at end of file +} -- cgit v1.2.3 From d35a54c060700e537d3e39723b7ee9b1d71b36d8 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Mon, 9 Aug 2021 21:49:35 +0300 Subject: Try to fix bootloop --- src/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index ffbba5e7..a18c3942 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,7 @@ #include #include #include +#include // nimble #define min // workaround: nimble's min/max macros conflict with libstdc++ @@ -300,6 +301,14 @@ int main(void) { nrf_drv_clock_init(); + // Unblock i2c? + nrf_gpio_cfg_output(pinTwiScl); + for (uint8_t i = 0; i < 16; i++) { + nrf_gpio_pin_toggle(pinTwiScl); + nrf_delay_us(5); + } + nrf_gpio_cfg_default(pinTwiScl); + debounceTimer = xTimerCreate("debounceTimer", 200, pdFALSE, (void*) 0, DebounceTimerCallback); debounceChargeTimer = xTimerCreate("debounceTimerCharge", 200, pdFALSE, (void*) 0, DebounceTimerChargeCallback); -- cgit v1.2.3 From ff81a72533e479388d49334d0ec3e0635b6e7f40 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Mon, 9 Aug 2021 22:07:06 +0300 Subject: Better pin configuration --- src/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a18c3942..39d8906c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -302,7 +302,12 @@ int main(void) { nrf_drv_clock_init(); // Unblock i2c? - nrf_gpio_cfg_output(pinTwiScl); + nrf_gpio_cfg(pinTwiScl, + NRF_GPIO_PIN_DIR_OUTPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_NOPULL, + NRF_GPIO_PIN_S0D1, + NRF_GPIO_PIN_NOSENSE); for (uint8_t i = 0; i < 16; i++) { nrf_gpio_pin_toggle(pinTwiScl); nrf_delay_us(5); -- cgit v1.2.3 From 5eb56d9a06652cb10358ecba051bbfe8ec2957a7 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Mon, 9 Aug 2021 22:11:35 +0300 Subject: Set pin before loop --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index 39d8906c..d301be67 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -308,6 +308,7 @@ int main(void) { NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_S0D1, NRF_GPIO_PIN_NOSENSE); + nrf_gpio_pin_set(pinTwiScl); for (uint8_t i = 0; i < 16; i++) { nrf_gpio_pin_toggle(pinTwiScl); nrf_delay_us(5); -- cgit v1.2.3 From 2194a339cf55772c944fc1302ca740805d931983 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Tue, 10 Aug 2021 11:26:43 +0300 Subject: Only enable the bus when needed --- src/drivers/TwiMaster.cpp | 6 ++++-- src/systemtask/SystemTask.cpp | 9 --------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp index e4c03d5b..34aac07f 100644 --- a/src/drivers/TwiMaster.cpp +++ b/src/drivers/TwiMaster.cpp @@ -72,8 +72,10 @@ void TwiMaster::Init() { 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, ®isterAddress, 1, false); ret = Read(deviceAddress, data, size, true); + Sleep(); xSemaphoreGive(mutex); return ret; } @@ -81,9 +83,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; } @@ -179,13 +183,11 @@ void TwiMaster::Sleep() { } nrf_gpio_cfg_default(6); nrf_gpio_cfg_default(7); - NRF_LOG_INFO("[TWIMASTER] Sleep"); } void TwiMaster::Wakeup() { ConfigurePins(); twiBaseAddress->ENABLE = (TWIM_ENABLE_ENABLE_Enabled << TWIM_ENABLE_ENABLE_Pos); - NRF_LOG_INFO("[TWIMASTER] Wakeup"); } /* Sometimes, the TWIM device just freeze and never set the event EVENTS_LASTTX. diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 8915ce74..4316330f 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -219,7 +219,6 @@ 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)) { @@ -240,9 +239,7 @@ void SystemTask::Work() { 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 @@ -315,7 +312,6 @@ void SystemTask::Work() { if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) { touchPanel.Sleep(); } - twiMaster.Sleep(); isSleeping = true; isGoingToSleep = false; @@ -367,17 +363,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); -- cgit v1.2.3 From 90ea1071d1df4bf80f2a7d62467aca44c8a63d75 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Tue, 10 Aug 2021 11:52:20 +0300 Subject: Explicitly disable pullup --- src/drivers/TwiMaster.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp index 34aac07f..52f93d85 100644 --- a/src/drivers/TwiMaster.cpp +++ b/src/drivers/TwiMaster.cpp @@ -16,12 +16,14 @@ void TwiMaster::ConfigurePins() const { NRF_GPIO->PIN_CNF[params.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[params.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); } -- cgit v1.2.3 From 7e92577c14895f57f5adda27ad54adbbc4b7ffe9 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Tue, 10 Aug 2021 21:02:51 +0300 Subject: Revert "Merge branch 'unblock_i2c' into develop" This reverts commit 275a84b3238874d213271f4287e6c1c5bfcb4353, reversing changes made to 9fb37550886f09f6510e99a5b452262c53c3987c. --- src/main.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9a5b0cfe..62e4446f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,6 @@ #include #include #include -#include // nimble #define min // workaround: nimble's min/max macros conflict with libstdc++ @@ -306,20 +305,6 @@ int main(void) { nrf_drv_clock_init(); - // Unblock i2c? - nrf_gpio_cfg(pinTwiScl, - 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); - for (uint8_t i = 0; i < 16; i++) { - nrf_gpio_pin_toggle(pinTwiScl); - nrf_delay_us(5); - } - nrf_gpio_cfg_default(pinTwiScl); - debounceTimer = xTimerCreate("debounceTimer", 200, pdFALSE, (void*) 0, DebounceTimerCallback); debounceChargeTimer = xTimerCreate("debounceTimerCharge", 200, pdFALSE, (void*) 0, DebounceTimerChargeCallback); -- cgit v1.2.3 From 8a694adb0979339664da0af6d51c480d26c5527b Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Tue, 10 Aug 2021 22:03:34 +0300 Subject: Rework TouchHandler into not a task --- src/drivers/TwiMaster.cpp | 12 ++---- src/drivers/TwiMaster.h | 3 +- src/main.cpp | 3 +- src/systemtask/SystemTask.cpp | 8 ++-- src/touchhandler/TouchHandler.cpp | 80 ++++++++++++++++----------------------- src/touchhandler/TouchHandler.h | 9 ++--- 6 files changed, 47 insertions(+), 68 deletions(-) diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp index 456c3e64..fc9edf81 100644 --- a/src/drivers/TwiMaster.cpp +++ b/src/drivers/TwiMaster.cpp @@ -12,10 +12,9 @@ TwiMaster::TwiMaster(const Modules module, const Parameters& params) : module {m } void TwiMaster::Init() { - sleeping = false; 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) | @@ -177,14 +176,11 @@ void TwiMaster::Sleep() { nrf_gpio_cfg_default(6); nrf_gpio_cfg_default(7); NRF_LOG_INFO("[TWIMASTER] Sleep"); - sleeping = true; } void TwiMaster::Wakeup() { - if (sleeping) { - Init(); - NRF_LOG_INFO("[TWIMASTER] Wakeup"); - } + Init(); + NRF_LOG_INFO("[TWIMASTER] Wakeup"); } /* Sometimes, the TWIM device just freeze and never set the event EVENTS_LASTTX. @@ -210,4 +206,4 @@ void TwiMaster::FixHwFreezed() { // 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 5748ec65..6175b99b 100644 --- a/src/drivers/TwiMaster.h +++ b/src/drivers/TwiMaster.h @@ -39,7 +39,6 @@ namespace Pinetime { uint8_t internalBuffer[maxDataSize + registerSize]; uint32_t txStartedCycleCount = 0; static constexpr uint32_t HwFreezedDelay {161000}; - bool sleeping; }; } -} +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 62e4446f..dffec28a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -166,8 +166,7 @@ Pinetime::System::SystemTask systemTask(spi, void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { if (pin == pinTouchIrq) { - twiMaster.Wakeup(); - touchHandler.WakeUp(); + systemTask.OnTouchEvent(); return; } diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 7ba7cf69..5f363130 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -150,9 +150,6 @@ void SystemTask::Work() { heartRateSensor.Disable(); heartRateApp.Start(); - touchHandler.Register(this); - touchHandler.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_output(15); nrf_gpio_pin_set(15); @@ -244,6 +241,8 @@ void SystemTask::Work() { isDimmed = false; break; case Messages::TouchWakeUp: { + twiMaster.Wakeup(); + touchHandler.GetNewTouchInfo(); auto gesture = touchHandler.GestureGet(); if ((gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap && settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) || @@ -299,6 +298,9 @@ void SystemTask::Work() { xTimerStart(dimTimer, 0); break; case Messages::OnTouchEvent: + if (touchHandler.GetNewTouchInfo()) { + touchHandler.UpdateLvglTouchPoint(); + } ReloadIdleTimer(); break; case Messages::OnButtonEvent: diff --git a/src/touchhandler/TouchHandler.cpp b/src/touchhandler/TouchHandler.cpp index 187aa696..c1a3c0d0 100644 --- a/src/touchhandler/TouchHandler.cpp +++ b/src/touchhandler/TouchHandler.cpp @@ -18,61 +18,47 @@ Pinetime::Drivers::Cst816S::Gestures TouchHandler::GestureGet() { return returnGesture; } -void TouchHandler::Start() { - if (pdPASS != xTaskCreate(TouchHandler::Process, "Touch", 100, this, 0, &taskHandle)) { - APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); - } -} - -void TouchHandler::Process(void* instance) { - auto* app = static_cast(instance); - app->Work(); -} - -void TouchHandler::Work() { - bool slideReleased = true; - while (true) { - vTaskSuspend(taskHandle); +bool TouchHandler::GetNewTouchInfo() { + info = touchPanel.GetTouchInfo(); - info = touchPanel.GetTouchInfo(); - - if (info.isValid) { - if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) { - if (slideReleased) { - 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) { - slideReleased = false; - } - gesture = info.gesture; - } - } + if (!info.isValid) { + return false; + } - if (!systemTask->IsSleeping()) { + if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) { + if (slideReleased) { + 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) { 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); - } - slideReleased = true; + gesture = info.gesture; + slideReleased = false; } + } else { + gesture = info.gesture; } - systemTask->OnTouchEvent(); } } -} -void TouchHandler::Register(Pinetime::System::SystemTask* systemTask) { - this->systemTask = systemTask; + if (!info.touching) { + slideReleased = true; + } + + return true; } -void TouchHandler::WakeUp() { - vTaskResume(taskHandle); +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 index 6b8189f5..38cb36cb 100644 --- a/src/touchhandler/TouchHandler.h +++ b/src/touchhandler/TouchHandler.h @@ -19,9 +19,9 @@ namespace Pinetime { public: explicit TouchHandler(Drivers::Cst816S&, Components::LittleVgl&); void CancelTap(); + bool GetNewTouchInfo(); + void UpdateLvglTouchPoint(); void Register(Pinetime::System::SystemTask* systemTask); - void Start(); - void WakeUp(); bool IsTouching() const { return info.touching; @@ -34,16 +34,13 @@ namespace Pinetime { } Drivers::Cst816S::Gestures GestureGet(); private: - static void Process(void* instance); - void Work(); Pinetime::Drivers::Cst816S::TouchInfos info; - Pinetime::System::SystemTask* systemTask = nullptr; - TaskHandle_t taskHandle; Pinetime::Drivers::Cst816S& touchPanel; Pinetime::Components::LittleVgl& lvgl; Pinetime::Drivers::Cst816S::Gestures gesture; bool isCancelled = false; + bool slideReleased = true; }; } } -- cgit v1.2.3 From 6776776421bd73c8e8f927af3ffc45ce77fe0e0d Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Tue, 10 Aug 2021 22:18:21 +0300 Subject: Make diff smaller and revert some changes in DisplayApp --- src/displayapp/DisplayApp.cpp | 117 ++++++++++++++++++++++-------------------- src/displayapp/Messages.h | 1 + src/systemtask/SystemTask.cpp | 1 + 3 files changed, 62 insertions(+), 57 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index b4fc885b..e26a96f2 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -52,6 +52,28 @@ namespace { static inline bool in_isr(void) { return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0; } + + 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; + } + } } DisplayApp::DisplayApp(Drivers::St7789& lcd, @@ -185,6 +207,41 @@ void DisplayApp::Refresh() { LoadApp(Apps::Timer, DisplayApp::FullRefreshDirections::Down); } break; + case Messages::TouchEvent: { + if (state != States::Running) { + break; + } + auto gesture = ConvertGesture(touchHandler.GestureGet()); + if (gesture == TouchEvents::None) { + break; + } + if (!currentScreen->OnTouchEvent(gesture)) { + if (currentApp == Apps::Clock) { + switch (gesture) { + case TouchEvents::SwipeUp: + LoadApp(Apps::Launcher, DisplayApp::FullRefreshDirections::Up); + break; + case TouchEvents::SwipeDown: + LoadApp(Apps::Notifications, DisplayApp::FullRefreshDirections::Down); + break; + case TouchEvents::SwipeRight: + LoadApp(Apps::QuickSettings, DisplayApp::FullRefreshDirections::RightAnim); + break; + case TouchEvents::DoubleTap: + PushMessageToSystemTask(System::Messages::GoToSleep); + break; + default: + break; + } + } else if (returnTouchEvent == gesture) { + LoadApp(returnToApp, returnDirection); + brightnessController.Set(settingsController.GetBrightness()); + brightnessController.Backup(); + } + } else { + touchHandler.CancelTap(); + } + } break; case Messages::ButtonPushed: if (currentApp == Apps::Clock) { PushMessageToSystemTask(System::Messages::GoToSleep); @@ -207,44 +264,14 @@ void DisplayApp::Refresh() { } } - auto gesture = GetGesture(); - if (gesture != TouchEvents::None) { - if (!currentScreen->OnTouchEvent(gesture)) { - if (currentApp == Apps::Clock) { - switch (gesture) { - case TouchEvents::SwipeUp: - LoadApp(Apps::Launcher, DisplayApp::FullRefreshDirections::Up); - break; - case TouchEvents::SwipeDown: - LoadApp(Apps::Notifications, DisplayApp::FullRefreshDirections::Down); - break; - case TouchEvents::SwipeRight: - LoadApp(Apps::QuickSettings, DisplayApp::FullRefreshDirections::RightAnim); - break; - case TouchEvents::DoubleTap: - PushMessageToSystemTask(System::Messages::GoToSleep); - break; - default: - break; - } - } else if (returnTouchEvent == gesture) { - LoadApp(returnToApp, returnDirection); - brightnessController.Set(settingsController.GetBrightness()); - brightnessController.Backup(); - } - } else { - touchHandler.CancelTap(); - } + if (nextApp != Apps::None) { + LoadApp(nextApp, nextDirection); + nextApp = Apps::None; } if (touchHandler.IsTouching()) { currentScreen->OnTouchEvent(touchHandler.GetX(), touchHandler.GetY()); } - - if (nextApp != Apps::None) { - LoadApp(nextApp, nextDirection); - nextApp = Apps::None; - } } void DisplayApp::RunningState() { @@ -407,30 +434,6 @@ void DisplayApp::PushMessage(Messages msg) { } } -TouchEvents DisplayApp::GetGesture() { - auto gesture = touchHandler.GestureGet(); - 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; -} - void DisplayApp::SetFullRefresh(DisplayApp::FullRefreshDirections direction) { switch (direction) { case DisplayApp::FullRefreshDirections::Down: diff --git a/src/displayapp/Messages.h b/src/displayapp/Messages.h index 26480987..322505e6 100644 --- a/src/displayapp/Messages.h +++ b/src/displayapp/Messages.h @@ -8,6 +8,7 @@ namespace Pinetime { UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, + TouchEvent, ButtonPushed, NewNotification, TimerDone, diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 5f363130..3ee26c5f 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -302,6 +302,7 @@ void SystemTask::Work() { touchHandler.UpdateLvglTouchPoint(); } ReloadIdleTimer(); + displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent); break; case Messages::OnButtonEvent: ReloadIdleTimer(); -- cgit v1.2.3 From cd7ca458fa959ba6d60b2cf107b198e462315abd Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Tue, 10 Aug 2021 22:37:41 +0300 Subject: Remove leftover --- src/touchhandler/TouchHandler.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/touchhandler/TouchHandler.h b/src/touchhandler/TouchHandler.h index 38cb36cb..e2140cae 100644 --- a/src/touchhandler/TouchHandler.h +++ b/src/touchhandler/TouchHandler.h @@ -21,7 +21,6 @@ namespace Pinetime { void CancelTap(); bool GetNewTouchInfo(); void UpdateLvglTouchPoint(); - void Register(Pinetime::System::SystemTask* systemTask); bool IsTouching() const { return info.touching; -- cgit v1.2.3 From fe33c756b7326cbf0a6c70822b70cff4dc2e3401 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Wed, 11 Aug 2021 18:31:40 +0300 Subject: Fix longpress gesture --- src/touchhandler/TouchHandler.cpp | 9 +++++---- src/touchhandler/TouchHandler.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/touchhandler/TouchHandler.cpp b/src/touchhandler/TouchHandler.cpp index c1a3c0d0..735b311a 100644 --- a/src/touchhandler/TouchHandler.cpp +++ b/src/touchhandler/TouchHandler.cpp @@ -26,14 +26,15 @@ bool TouchHandler::GetNewTouchInfo() { } if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) { - if (slideReleased) { + 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::SlideRight || + info.gesture == Pinetime::Drivers::Cst816S::Gestures::LongPress) { if (info.touching) { gesture = info.gesture; - slideReleased = false; + gestureReleased = false; } } else { gesture = info.gesture; @@ -42,7 +43,7 @@ bool TouchHandler::GetNewTouchInfo() { } if (!info.touching) { - slideReleased = true; + gestureReleased = true; } return true; diff --git a/src/touchhandler/TouchHandler.h b/src/touchhandler/TouchHandler.h index e2140cae..f5442939 100644 --- a/src/touchhandler/TouchHandler.h +++ b/src/touchhandler/TouchHandler.h @@ -39,7 +39,7 @@ namespace Pinetime { Pinetime::Components::LittleVgl& lvgl; Pinetime::Drivers::Cst816S::Gestures gesture; bool isCancelled = false; - bool slideReleased = true; + bool gestureReleased = true; }; } } -- cgit v1.2.3 From 1d341a7aeb16acb45f25b16590630efd655ecd30 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Thu, 12 Aug 2021 14:06:58 +0300 Subject: Don't reconfigure pins --- src/drivers/TwiMaster.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp index 52f93d85..429a6eb7 100644 --- a/src/drivers/TwiMaster.cpp +++ b/src/drivers/TwiMaster.cpp @@ -180,15 +180,10 @@ 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); + twiBaseAddress->ENABLE = (TWIM_ENABLE_ENABLE_Disabled << TWIM_ENABLE_ENABLE_Pos); } void TwiMaster::Wakeup() { - ConfigurePins(); twiBaseAddress->ENABLE = (TWIM_ENABLE_ENABLE_Enabled << TWIM_ENABLE_ENABLE_Pos); } -- cgit v1.2.3 From 6bffc7d52840affc5c037d1bb783172b99d4731a Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Thu, 12 Aug 2021 21:28:41 +0200 Subject: Tidying --- src/displayapp/screens/PineTimeStyle.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 04128b21..6b0cc59a 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -62,7 +62,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, displayedChar[4] = 0; //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, pts_colors[settingsController.GetPTSColorBG()]); lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); -- cgit v1.2.3 From fbb4e8c6ae461697e7151927205ce134eb26de53 Mon Sep 17 00:00:00 2001 From: mabuch Date: Sat, 14 Aug 2021 14:47:00 +0200 Subject: fix Github Action build Firmware --- .github/workflows/main.yml | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4a71b7e0..f25fd311 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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,16 @@ 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.5.0 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 + + # cbor is a dependency that is not currently included in mcuboot requirements.txt + - name: Install imgtool dependencies (cbor) + run: | + pip3 install --user cbor - name: Install adafruit-nrfutil run: | @@ -99,6 +105,8 @@ jobs: - name: Checkout source files uses: actions/checkout@v2 + with: + submodules: recursive - name: Show files run: set ; pwd ; ls -l @@ -110,7 +118,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 +133,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 -- cgit v1.2.3 From 23bde0d18e99a344b95b5f1507350e186659eec2 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Sat, 14 Aug 2021 21:18:11 +0300 Subject: Make battery reading periodic. Add events. Disable pullup --- src/components/battery/BatteryController.cpp | 11 +++++---- src/components/battery/BatteryController.h | 7 +++--- src/displayapp/DisplayApp.cpp | 3 --- src/displayapp/Messages.h | 1 - src/displayapp/screens/BatteryInfo.cpp | 3 --- src/systemtask/Messages.h | 4 +++- src/systemtask/SystemTask.cpp | 35 ++++++++++++++++------------ src/systemtask/SystemTask.h | 6 +++-- 8 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index f8a64ecd..aa038c5d 100644 --- a/src/components/battery/BatteryController.cpp +++ b/src/components/battery/BatteryController.cpp @@ -9,10 +9,7 @@ Battery* Battery::instance = nullptr; Battery::Battery() { instance = this; -} - -void Battery::Init() { - nrf_gpio_cfg_input(chargingPin, static_cast GPIO_PIN_CNF_PULL_Pullup); + nrf_gpio_cfg_input(chargingPin, static_cast GPIO_PIN_CNF_PULL_Disabled); } void Battery::Update() { @@ -75,5 +72,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..ad304eba 100644 --- a/src/components/battery/BatteryController.h +++ b/src/components/battery/BatteryController.h @@ -1,8 +1,7 @@ #pragma once #include #include -#include -#include +#include 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; @@ -49,6 +48,8 @@ namespace Pinetime { static void AdcCallbackStatic(nrfx_saadc_evt_t const* event); bool isReading = false; + + Pinetime::System::SystemTask* systemTask = nullptr; }; } } diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index d4a73f5e..c6e94668 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -194,9 +194,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; 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/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp index 0ab47ebf..31cde071 100644 --- a/src/displayapp/screens/BatteryInfo.cpp +++ b/src/displayapp/screens/BatteryInfo.cpp @@ -59,9 +59,6 @@ BatteryInfo::~BatteryInfo() { } void BatteryInfo::UpdateScreen() { - - batteryController.Update(); - batteryPercent = batteryController.PercentRemaining(); batteryVoltage = batteryController.Voltage(); 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 8915ce74..7ef6fc61 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -47,6 +47,11 @@ void IdleTimerCallback(TimerHandle_t xTimer) { sysTask->OnIdle(); } +void MeasureBatteryTimerCallback(TimerHandle_t xTimer) { + auto* sysTask = static_cast(pvTimerGetTimerID(xTimer)); + sysTask->PushMessage(Pinetime::System::Messages::MeasureBatteryTimerExpired); +} + SystemTask::SystemTask(Drivers::SpiMaster& spi, Drivers::St7789& lcd, Pinetime::Drivers::SpiNorFlash& spiNorFlash, @@ -126,7 +131,8 @@ void SystemTask::Work() { twiMaster.Init(); touchPanel.Init(); dateTimeController.Register(this); - batteryController.Init(); + batteryController.Register(this); + batteryController.Update(); motorController.Init(); motionSensor.SoftReset(); timerController.Register(this); @@ -143,8 +149,6 @@ void SystemTask::Work() { displayApp.Register(this); displayApp.Start(); - displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel); - heartRateSensor.Init(); heartRateSensor.Disable(); heartRateApp.Start(); @@ -187,7 +191,9 @@ void SystemTask::Work() { 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 +203,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(msg); switch (message) { case Messages::EnableSleeping: @@ -232,7 +233,6 @@ void SystemTask::Work() { lcd.Wakeup(); displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToRunning); - displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel); heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::WakeUp); isSleeping = false; @@ -326,8 +326,18 @@ void SystemTask::Work() { stepCounterMustBeReset = true; break; case Messages::OnChargingEvent: + batteryController.Update(); motorController.SetDuration(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: @@ -346,11 +356,6 @@ void SystemTask::Work() { } } - 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); diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index ba434298..14c7ec71 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -131,13 +131,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 monitor; -- cgit v1.2.3 From 40afae3833efd2220bac168467d82e3ca6c350be Mon Sep 17 00:00:00 2001 From: mabuch Date: Sat, 14 Aug 2021 20:46:29 +0200 Subject: Github Action - update mcuboot version --- .github/workflows/main.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f25fd311..4744eaef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -83,17 +83,12 @@ 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/mcu-tools/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 - # cbor is a dependency that is not currently included in mcuboot requirements.txt - - name: Install imgtool dependencies (cbor) - run: | - pip3 install --user cbor - - name: Install adafruit-nrfutil run: | pip3 install --user wheel -- cgit v1.2.3 From 477ff32edc3bc0997f45d943f90f68f8f0608468 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 15 Aug 2021 10:41:00 +0200 Subject: Add randomise button to color picker --- .../screens/settings/SettingPineTimeStyle.cpp | 21 +++++++++++++++++++++ .../screens/settings/SettingPineTimeStyle.h | 1 + 2 files changed, 22 insertions(+) diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index ae665464..a32ce34d 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -203,6 +203,14 @@ SettingPineTimeStyle::SettingPineTimeStyle( 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() { @@ -303,4 +311,17 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { settingsController.SetPTSColorBG(3); lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[3]); } + if((object == btnRandom) && (event == LV_EVENT_PRESSED)) { + uint8_t randTime = rand() % 17; + uint8_t randBar = rand() % 17; + uint8_t randBG = rand() % 17; + settingsController.SetPTSColorTime(randTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); + settingsController.SetPTSColorBar(randBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBar]); + settingsController.SetPTSColorBG(randBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBG]); + } } \ No newline at end of file diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h index fe449b2e..1a01ebbb 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.h +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h @@ -28,6 +28,7 @@ namespace Pinetime { lv_obj_t * btnNextBG; lv_obj_t * btnPrevBG; lv_obj_t * btnReset; + lv_obj_t * btnRandom; lv_obj_t * timeColor; lv_obj_t * barColor; lv_obj_t * bgColor; -- cgit v1.2.3 From c0bb88799c2de0ab8de5d38b3eb511f4f80029d7 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 15 Aug 2021 12:33:32 +0200 Subject: Add check for randomise button in case colors clash --- src/displayapp/screens/settings/SettingPineTimeStyle.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index a32ce34d..007c1cff 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -315,6 +315,11 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { 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) || (randBar == 3)) { + randBG += 1; + randBar = randTime; + } settingsController.SetPTSColorTime(randTime); lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); -- cgit v1.2.3 From 16ea069d55e4bcbba097cf499901eddf1a3828db Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 15 Aug 2021 14:05:21 +0200 Subject: Remove duplicate code, minor fixes --- .../screens/settings/SettingPineTimeStyle.cpp | 52 ++++++++-------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 007c1cff..dfa806a3 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -230,76 +230,60 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { if((object == btnNextTime) && (event == LV_EVENT_PRESSED)) { if ( valueTime < 16 ) { valueTime += 1; - settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } else { valueTime = 0; - settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) { if ( valueTime > 0 ) { valueTime -= 1; - settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } else { valueTime = 16; - settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { if ( valueBar < 16 ) { valueBar += 1; - settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } else { valueBar = 0; - settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { if ( valueBar > 0 ) { valueBar -= 1; - settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } else { valueBar = 16; - settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) { if ( valueBG < 16 ) { valueBG += 1; - settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } else { valueBG = 0; - settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) { if ( valueBG > 0 ) { valueBG -= 1; - settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } else { valueBG = 16; - settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } if((object == btnReset) && (event == LV_EVENT_PRESSED)) { settingsController.SetPTSColorTime(11); @@ -316,8 +300,10 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { 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) || (randBar == 3)) { + if (randTime == randBG) { randBG += 1; + } + if (randBar == 3) { randBar = randTime; } settingsController.SetPTSColorTime(randTime); -- cgit v1.2.3 From 5789f1527c5c8d1c31e78a6a88c6a2b6158eb671 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 15 Aug 2021 14:42:30 +0200 Subject: Avoid setting the sidebar black --- src/displayapp/screens/settings/SettingPineTimeStyle.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index dfa806a3..96b87800 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -252,6 +252,8 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { if ( valueBar < 16 ) { valueBar += 1; + // Avoid setting the sidebar black + if ( valueBar == 3 ) { valueBar += 1; } } else { valueBar = 0; } @@ -261,6 +263,8 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { if ( valueBar > 0 ) { valueBar -= 1; + // Avoid setting the sidebar black + if ( valueBar == 3 ) { valueBar -= 1; } } else { valueBar = 16; } -- cgit v1.2.3 From 639fd3a9bd9f4a1ada36a4b812b7199543d47457 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 15 Aug 2021 15:00:54 +0200 Subject: More tidying following review --- .../screens/settings/SettingPineTimeStyle.cpp | 173 +++++++++++---------- 1 file changed, 88 insertions(+), 85 deletions(-) diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 96b87800..979e4b66 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -6,17 +6,14 @@ using namespace Pinetime::Applications::Screens; namespace { - static void event_handler(lv_obj_t * obj, lv_event_t event) { - SettingPineTimeStyle* screen = static_cast(obj->user_data); + static void event_handler(lv_obj_t* obj, lv_event_t event) { + SettingPineTimeStyle* screen = static_cast(obj->user_data); screen->UpdateSelected(obj, event); } } -SettingPineTimeStyle::SettingPineTimeStyle( - Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) : - Screen(app), - settingsController{settingsController} -{ +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, pts_colors[settingsController.GetPTSColorBG()]); lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); @@ -140,7 +137,7 @@ SettingPineTimeStyle::SettingPineTimeStyle( 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); @@ -222,74 +219,79 @@ bool SettingPineTimeStyle::Refresh() { return running; } -void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { +void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) { uint8_t valueTime = settingsController.GetPTSColorTime(); uint8_t valueBar = settingsController.GetPTSColorBar(); uint8_t valueBG = settingsController.GetPTSColorBG(); - - if((object == btnNextTime) && (event == LV_EVENT_PRESSED)) { - if ( valueTime < 16 ) { - valueTime += 1; - } else { - valueTime = 0; + + if (event == LV_EVENT_CLICKED) { + if (object == btnNextTime) { + if (valueTime < 16) { + valueTime += 1; + } else { + valueTime = 0; + } + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } - settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - } - if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) { - if ( valueTime > 0 ) { - valueTime -= 1; - } else { - valueTime = 16; + if (object == btnPrevTime) { + if (valueTime > 0) { + valueTime -= 1; + } else { + valueTime = 16; + } + settingsController.SetPTSColorTime(valueTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); } - settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - } - if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) { - if ( valueBar < 16 ) { - valueBar += 1; - // Avoid setting the sidebar black - if ( valueBar == 3 ) { valueBar += 1; } - } else { - valueBar = 0; + if (object == btnNextBar) { + if (valueBar < 16) { + valueBar += 1; + // Avoid setting the sidebar black + if (valueBar == 3) { + valueBar += 1; + } + } else { + valueBar = 0; + } + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } - settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); - } - if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) { - if ( valueBar > 0 ) { - valueBar -= 1; - // Avoid setting the sidebar black - if ( valueBar == 3 ) { valueBar -= 1; } - } else { - valueBar = 16; + if (object == btnPrevBar) { + if (valueBar > 0) { + valueBar -= 1; + // Avoid setting the sidebar black + if (valueBar == 3) { + valueBar -= 1; + } + } else { + valueBar = 16; + } + settingsController.SetPTSColorBar(valueBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); } - settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]); - } - if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) { - if ( valueBG < 16 ) { - valueBG += 1; - } else { - valueBG = 0; + if (object == btnNextBG) { + if (valueBG < 16) { + valueBG += 1; + } else { + valueBG = 0; + } + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } - settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); - } - if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) { - if ( valueBG > 0 ) { - valueBG -= 1; - } else { - valueBG = 16; + if (object == btnPrevBG) { + if (valueBG > 0) { + valueBG -= 1; + } else { + valueBG = 16; + } + settingsController.SetPTSColorBG(valueBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); } - settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); - } - if((object == btnReset) && (event == LV_EVENT_PRESSED)) { + if (object == btnReset) { settingsController.SetPTSColorTime(11); lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); @@ -298,25 +300,26 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) { lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); settingsController.SetPTSColorBG(3); lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[3]); - } - if((object == btnRandom) && (event == LV_EVENT_PRESSED)) { - 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 = randTime; + 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 = randTime; + } + settingsController.SetPTSColorTime(randTime); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); + settingsController.SetPTSColorBar(randBar); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBar]); + settingsController.SetPTSColorBG(randBG); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBG]); } - settingsController.SetPTSColorTime(randTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); - settingsController.SetPTSColorBar(randBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBar]); - settingsController.SetPTSColorBG(randBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBG]); } } \ No newline at end of file -- cgit v1.2.3 From 9851ed33d84aa242dfb98c2c3714a20ddbc53f45 Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Sun, 15 Aug 2021 15:28:40 +0200 Subject: Fix potential edge case of sidebar being set black --- src/displayapp/screens/settings/SettingPineTimeStyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 979e4b66..e125c8a2 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -310,7 +310,7 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) { randBG += 1; } if (randBar == 3) { - randBar = randTime; + randBar -= 1; } settingsController.SetPTSColorTime(randTime); lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); -- cgit v1.2.3 From 81a36dc31ed22237e3cc06c8f4ba2a5cbcf07f8e Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Mon, 16 Aug 2021 18:26:10 +0300 Subject: Simplify parameters and cleanup --- src/drivers/TwiMaster.cpp | 43 ++++++++++--------------------------------- src/drivers/TwiMaster.h | 19 +++++++------------ src/main.cpp | 5 ++--- 3 files changed, 19 insertions(+), 48 deletions(-) diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp index 429a6eb7..f17d7168 100644 --- a/src/drivers/TwiMaster.cpp +++ b/src/drivers/TwiMaster.cpp @@ -8,19 +8,20 @@ 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} { mutex = xSemaphoreCreateBinary(); } void TwiMaster::ConfigurePins() const { - NRF_GPIO->PIN_CNF[params.pinScl] = + 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[params.pinSda] = + 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) | @@ -31,28 +32,12 @@ void TwiMaster::ConfigurePins() const { void TwiMaster::Init() { ConfigurePins(); - switch (module) { - case Modules::TWIM1: - twiBaseAddress = NRF_TWIM1; - break; - default: - return; - } + twiBaseAddress = module; - switch (static_cast(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; - } + twiBaseAddress->FREQUENCY = frequency; - twiBaseAddress->PSEL.SCL = params.pinScl; - twiBaseAddress->PSEL.SDA = params.pinSda; + twiBaseAddress->PSEL.SCL = pinScl; + twiBaseAddress->PSEL.SDA = pinSda; twiBaseAddress->EVENTS_LASTRX = 0; twiBaseAddress->EVENTS_STOPPED = 0; twiBaseAddress->EVENTS_LASTTX = 0; @@ -63,12 +48,6 @@ 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); } @@ -194,12 +173,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; - ConfigurePins(); + Sleep(); - // Re-enable I²C twiBaseAddress->ENABLE = twi_state; } diff --git a/src/drivers/TwiMaster.h b/src/drivers/TwiMaster.h index b8d36d59..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); @@ -26,16 +19,18 @@ namespace Pinetime { void Sleep(); void Wakeup(); - void ConfigurePins() const; - private: 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]; diff --git a/src/main.cpp b/src/main.cpp index ffbba5e7..4e94ab19 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -81,9 +81,8 @@ 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}}; +//static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000}; +Pinetime::Drivers::TwiMaster twiMaster {NRF_TWIM1, TWI_FREQUENCY_FREQUENCY_K250, pinTwiSda, pinTwiScl}; Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress}; #ifdef PINETIME_IS_RECOVERY static constexpr bool isFactory = true; -- cgit v1.2.3 From 40392d7b9199c87de9784cacb1dee5476e5a5b6f Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Wed, 18 Aug 2021 21:40:27 +0300 Subject: Use highest frequency and move mutex creation to Init --- src/drivers/TwiMaster.cpp | 5 ++++- src/main.cpp | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp index f17d7168..76009278 100644 --- a/src/drivers/TwiMaster.cpp +++ b/src/drivers/TwiMaster.cpp @@ -10,7 +10,6 @@ using namespace Pinetime::Drivers; TwiMaster::TwiMaster(NRF_TWIM_Type* module, uint32_t frequency, uint8_t pinSda, uint8_t pinScl) : module {module}, frequency {frequency}, pinSda {pinSda}, pinScl {pinScl} { - mutex = xSemaphoreCreateBinary(); } void TwiMaster::ConfigurePins() const { @@ -30,6 +29,10 @@ void TwiMaster::ConfigurePins() const { } void TwiMaster::Init() { + if (mutex == nullptr) { + mutex = xSemaphoreCreateBinary(); + } + ConfigurePins(); twiBaseAddress = module; diff --git a/src/main.cpp b/src/main.cpp index 4e94ab19..524035fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -81,8 +81,8 @@ 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 {NRF_TWIM1, TWI_FREQUENCY_FREQUENCY_K250, pinTwiSda, pinTwiScl}; +static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000}; +Pinetime::Drivers::TwiMaster twiMaster {NRF_TWIM1, MaxTwiFrequencyWithoutHardwareBug, pinTwiSda, pinTwiScl}; Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress}; #ifdef PINETIME_IS_RECOVERY static constexpr bool isFactory = true; -- cgit v1.2.3 From 2b30ff4fc6a1835bdc5a94f8754cfd366885c4c0 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Thu, 19 Aug 2021 11:12:34 +0300 Subject: Remove unused variables --- src/displayapp/DisplayApp.cpp | 3 --- src/displayapp/screens/Notifications.cpp | 2 +- src/displayapp/screens/Notifications.h | 8 -------- src/main.cpp | 7 +------ 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 5150162a..e79fa61a 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -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; diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index c061c146..c95edb45 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -150,7 +150,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..ff999343 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -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; diff --git a/src/main.cpp b/src/main.cpp index d301be67..d420fcdf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -87,16 +87,13 @@ Pinetime::Drivers::TwiMaster twiMaster {Pinetime::Drivers::TwiMaster::Modules::T Pinetime::Drivers::TwiMaster::Parameters {MaxTwiFrequencyWithoutHardwareBug, pinTwiSda, pinTwiScl}}; 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,8 +102,6 @@ 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; -- cgit v1.2.3 From 51c5257548efe678ec8e18d8cdea2476672f1238 Mon Sep 17 00:00:00 2001 From: hubmartin Date: Sun, 22 Aug 2021 22:17:57 +0200 Subject: Update startup SCL toggling pinmap definitions --- src/main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7131c680..4d16a6d5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -45,6 +45,7 @@ #include "drivers/Cst816s.h" #include "drivers/PinMap.h" #include "systemtask/SystemTask.h" +#include "drivers/PinMap.h" #if NRF_LOG_ENABLED #include "logging/NrfLogger.h" @@ -293,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); -- cgit v1.2.3 From d7293a44dfa6de8cb6ad25c259d33ca07bde3426 Mon Sep 17 00:00:00 2001 From: Fabien Benetou Date: Thu, 26 Aug 2021 15:11:20 +0200 Subject: Infini-iOS --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6549ece9..86f1b9dd 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ 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/) -- cgit v1.2.3 From b45d7c372d960051d048e4123335af6dacf88297 Mon Sep 17 00:00:00 2001 From: Colin Kinloch Date: Thu, 26 Aug 2021 19:42:02 +0100 Subject: Correct change test for wake up mode setting --- src/components/settings/Settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 93d6d217..0ff1cb8a 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -78,7 +78,7 @@ namespace Pinetime { }; void setWakeUpMode(WakeUpMode wakeUp, bool enabled) { - if (!isWakeUpModeOn(wakeUp)) { + if (enabled != isWakeUpModeOn(wakeUp)) { settingsChanged = true; } settings.wakeUpMode.set(static_cast(wakeUp), enabled); -- cgit v1.2.3 From 0313277ae604bb46987cdfbef123b7edfeb8ab9e Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sat, 28 Aug 2021 15:10:14 +0200 Subject: Fix touchinfo typo in SystemTask. --- src/systemtask/SystemTask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 08e21999..03bf6706 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -241,7 +241,7 @@ void SystemTask::Work() { break; case Messages::TouchWakeUp: { auto touchInfo = touchPanel.GetTouchInfo(); - if (touchInfo.isTouch and ((touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap and + if (touchInfo.touching 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)))) { -- cgit v1.2.3 From fab49f8557ef8ff38fe4f607e33b18fb5a1aeb9a Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sat, 28 Aug 2021 15:23:13 +0200 Subject: Fix recovery firmware since last changes in DisplayApp. --- src/displayapp/DisplayAppRecovery.cpp | 4 +++- src/displayapp/DisplayAppRecovery.h | 6 +++++- src/displayapp/DummyLittleVgl.h | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/displayapp/DisplayAppRecovery.cpp b/src/displayapp/DisplayAppRecovery.cpp index fd517b11..17612ef0 100644 --- a/src/displayapp/DisplayAppRecovery.cpp +++ b/src/displayapp/DisplayAppRecovery.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "displayapp/icons/infinitime/infinitime-nb.c" using namespace Pinetime::Applications; @@ -19,7 +20,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..8b2bc7f5 100644 --- a/src/displayapp/DisplayAppRecovery.h +++ b/src/displayapp/DisplayAppRecovery.h @@ -29,6 +29,9 @@ namespace Pinetime { namespace System { class SystemTask; }; + namespace Controllers { + class TouchHandler; + } namespace Applications { class DisplayApp { public: @@ -44,7 +47,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) { + + } }; } } -- cgit v1.2.3 From 31bc47d1cb397f5de0275d0d95aac7ca29cc7392 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sat, 28 Aug 2021 21:02:11 +0200 Subject: Settings : use enums instead of ints to store colors. Group all PTS settings into a struct. PTS/SettingsPTS : Convert to/from LVGL color and Settings::Color, add functions to reduce code duplication. Adapt SettingPineTimeStyle with the last Screen Interface --- src/CMakeLists.txt | 2 + src/components/settings/Settings.h | 46 ++++--- src/displayapp/Colors.cpp | 27 ++++ src/displayapp/Colors.h | 10 ++ src/displayapp/screens/PineTimeStyle.cpp | 11 +- src/displayapp/screens/PineTimeStyle.h | 5 - .../screens/settings/SettingPineTimeStyle.cpp | 147 ++++++++++----------- .../screens/settings/SettingPineTimeStyle.h | 12 +- 8 files changed, 144 insertions(+), 116 deletions(-) create mode 100644 src/displayapp/Colors.cpp create mode 100644 src/displayapp/Colors.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 69c19367..a7242903 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -418,6 +418,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 @@ -611,6 +612,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 diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 40cafe9a..a294ab78 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,37 +41,38 @@ namespace Pinetime { return settings.clockFace; }; - void SetPTSColorTime(uint8_t colorTime) { - if (colorTime != settings.PTSColorTime) + void SetPTSColorTime(Colors colorTime) { + if (colorTime != settings.PTS.ColorTime) settingsChanged = true; - settings.PTSColorTime = colorTime; + settings.PTS.ColorTime = colorTime; }; - uint8_t GetPTSColorTime() const { - return settings.PTSColorTime; + Colors GetPTSColorTime() const { + return settings.PTS.ColorTime; }; - void SetPTSColorBar(uint8_t colorBar) { - if (colorBar != settings.PTSColorBar) + void SetPTSColorBar(Colors colorBar) { + if (colorBar != settings.PTS.ColorBar) settingsChanged = true; - settings.PTSColorBar = colorBar; + settings.PTS.ColorBar = colorBar; }; - uint8_t GetPTSColorBar() const { - return settings.PTSColorBar; + Colors GetPTSColorBar() const { + return settings.PTS.ColorBar; }; - void SetPTSColorBG(uint8_t colorBG) { - if (colorBG != settings.PTSColorBG) + void SetPTSColorBG(Colors colorBG) { + if (colorBG != settings.PTS.ColorBG) settingsChanged = true; - settings.PTSColorBG = colorBG; + settings.PTS.ColorBG = colorBG; }; - uint8_t GetPTSColorBG() const { - return settings.PTSColorBG; + Colors GetPTSColorBG() const { + return settings.PTS.ColorBG; }; void SetAppMenu(uint8_t menu) { appMenu = menu; }; - uint8_t GetAppMenu() { + + uint8_t GetAppMenu() const { return appMenu; }; @@ -156,7 +165,6 @@ namespace Pinetime { static constexpr uint32_t settingsVersion = 0x0002; struct SettingsData { - uint32_t version = settingsVersion; uint32_t stepsGoal = 10000; uint32_t screenTimeOut = 15000; @@ -166,9 +174,7 @@ namespace Pinetime { uint8_t clockFace = 0; - uint8_t PTSColorTime = 11; - uint8_t PTSColorBar = 11; - uint8_t PTSColorBG = 3; + PineTimeStyle PTS; std::bitset<3> wakeUpMode {0}; 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 +#include + +namespace Pinetime { + namespace Applications { + lv_color_t Convert(Controllers::Settings::Colors color); + } +} \ No newline at end of file diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 772e4612..7a712f43 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "BatteryIcon.h" #include "BleIcon.h" #include "NotificationIcon.h" @@ -63,7 +64,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, //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, pts_colors[settingsController.GetPTSColorBG()]); + 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); @@ -71,25 +72,25 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, // 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, pts_colors[settingsController.GetPTSColorTime()]); + 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, pts_colors[settingsController.GetPTSColorTime()]); + 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, pts_colors[settingsController.GetPTSColorTime()]); + 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 sidebar = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBar()]); + 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); diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h index 16b6de19..cb74ead5 100644 --- a/src/displayapp/screens/PineTimeStyle.h +++ b/src/displayapp/screens/PineTimeStyle.h @@ -68,11 +68,6 @@ namespace Pinetime { lv_obj_t* notificationIcon; lv_obj_t* stepGauge; lv_color_t needle_colors[1]; - lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, - LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, - LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, - LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, - LV_COLOR_ORANGE}; Controllers::DateTime& dateTimeController; Controllers::Battery& batteryController; diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index e125c8a2..c9af19b6 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -1,5 +1,6 @@ #include "SettingPineTimeStyle.h" #include +#include #include "displayapp/DisplayApp.h" #include "displayapp/screens/Symbols.h" @@ -15,7 +16,7 @@ namespace { 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, pts_colors[settingsController.GetPTSColorBG()]); + 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); @@ -24,18 +25,18 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a 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, pts_colors[settingsController.GetPTSColorTime()]); + 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, pts_colors[settingsController.GetPTSColorTime()]); + 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, pts_colors[settingsController.GetPTSColorTime()]); + 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); @@ -43,7 +44,7 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a // 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, pts_colors[settingsController.GetPTSColorBar()]); + 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); @@ -215,91 +216,60 @@ SettingPineTimeStyle::~SettingPineTimeStyle() { settingsController.SaveSettings(); } -bool SettingPineTimeStyle::Refresh() { - return running; -} - void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) { - uint8_t valueTime = settingsController.GetPTSColorTime(); - uint8_t valueBar = settingsController.GetPTSColorBar(); - uint8_t valueBG = settingsController.GetPTSColorBG(); + auto valueTime = settingsController.GetPTSColorTime(); + auto valueBar = settingsController.GetPTSColorBar(); + auto valueBG = settingsController.GetPTSColorBG(); if (event == LV_EVENT_CLICKED) { if (object == btnNextTime) { - if (valueTime < 16) { - valueTime += 1; - } else { - valueTime = 0; - } + valueTime = GetNext(valueTime); + settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); } if (object == btnPrevTime) { - if (valueTime > 0) { - valueTime -= 1; - } else { - valueTime = 16; - } + valueTime = GetPrevious(valueTime); settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); } if (object == btnNextBar) { - if (valueBar < 16) { - valueBar += 1; - // Avoid setting the sidebar black - if (valueBar == 3) { - valueBar += 1; - } - } else { - valueBar = 0; - } + 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, pts_colors[valueBar]); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar)); } if (object == btnPrevBar) { - if (valueBar > 0) { - valueBar -= 1; - // Avoid setting the sidebar black - if (valueBar == 3) { - valueBar -= 1; - } - } else { - valueBar = 16; - } + 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, pts_colors[valueBar]); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar)); } if (object == btnNextBG) { - if (valueBG < 16) { - valueBG += 1; - } else { - valueBG = 0; - } + valueBG = GetNext(valueBG); settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG)); } if (object == btnPrevBG) { - if (valueBG > 0) { - valueBG -= 1; - } else { - valueBG = 16; - } + valueBG = GetPrevious(valueBG); settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG)); } if (object == btnReset) { - settingsController.SetPTSColorTime(11); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); - settingsController.SetPTSColorBar(11); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]); - settingsController.SetPTSColorBG(3); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[3]); + 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; @@ -312,14 +282,37 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) { if (randBar == 3) { randBar -= 1; } - settingsController.SetPTSColorTime(randTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]); - settingsController.SetPTSColorBar(randBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBar]); - settingsController.SetPTSColorBG(randBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBG]); + settingsController.SetPTSColorTime(static_cast(randTime)); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randTime))); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randTime))); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randTime))); + settingsController.SetPTSColorBar(static_cast(randBar)); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randBar))); + settingsController.SetPTSColorBG(static_cast(randBG)); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randBG))); } } -} \ No newline at end of file +} + +Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) { + auto colorAsInt = static_cast(color); + Pinetime::Controllers::Settings::Colors nextColor; + if (colorAsInt < 16) { + nextColor = static_cast(colorAsInt + 1); + } else { + nextColor = static_cast(0); + } + return nextColor; +} + +Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) { + auto colorAsInt = static_cast(color); + Pinetime::Controllers::Settings::Colors prevColor; + + if (colorAsInt > 0) { + prevColor = static_cast(colorAsInt - 1); + } else { + prevColor = static_cast(16); + } + return prevColor; +} diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h index 1a01ebbb..397bd86d 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.h +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h @@ -15,12 +15,14 @@ namespace Pinetime { SettingPineTimeStyle(DisplayApp* app, Pinetime::Controllers::Settings &settingsController); ~SettingPineTimeStyle() override; - bool Refresh() 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; @@ -29,9 +31,6 @@ namespace Pinetime { lv_obj_t * btnPrevBG; lv_obj_t * btnReset; lv_obj_t * btnRandom; - lv_obj_t * timeColor; - lv_obj_t * barColor; - lv_obj_t * bgColor; lv_obj_t * timebar; lv_obj_t * sidebar; lv_obj_t * timeDD1; @@ -51,11 +50,6 @@ namespace Pinetime { lv_obj_t * calendarCrossBar2; lv_obj_t * stepGauge; lv_color_t needle_colors[1]; - lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK, - LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE, - LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL, - LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE, - LV_COLOR_ORANGE}; }; } } -- cgit v1.2.3 From 6c023785e53c507f7cb20703f5f3a221ea095068 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sat, 28 Aug 2021 21:30:31 +0200 Subject: Fix wake on tap/double tap. --- src/systemtask/SystemTask.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 03bf6706..0617b0ce 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -240,12 +240,14 @@ void SystemTask::Work() { isDimmed = false; break; case Messages::TouchWakeUp: { - auto touchInfo = touchPanel.GetTouchInfo(); - if (touchInfo.touching 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: -- cgit v1.2.3 From be31f417db1937032ae440e1cf68cb2971284713 Mon Sep 17 00:00:00 2001 From: "James A. Jerkins" Date: Sun, 29 Aug 2021 15:50:04 -0500 Subject: WIP Refactor ble advertising Refactor ble advertising based on ble standards and conventions. Changes are based on the bleprph example code, bluetooth docs, and nimble docs. --- src/CMakeLists.txt | 11 ++-- src/components/ble/NimbleController.cpp | 98 +++++++++++++++++++-------------- src/components/ble/NimbleController.h | 2 + src/systemtask/SystemTask.cpp | 2 - 4 files changed, 67 insertions(+), 46 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f72f50c9..c7eda52d 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 diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index 5eb227bf..4de8fff9 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -42,6 +42,19 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask, serviceDiscovery({¤tTimeClient, &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(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; @@ -104,9 +124,6 @@ void NimbleController::StartAdvertising() { adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN; 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,27 +133,24 @@ 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, 5000, &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: { NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_CONNECT"); @@ -145,18 +159,19 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { if (event->connect.status != 0) { /* Connection failed; resume advertising. */ - StartAdvertising(); bleController.Disconnect(); + 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; + 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(); @@ -165,15 +180,18 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { bleController.Disconnect(); 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 +201,11 @@ 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; + break; case BLE_GAP_EVENT_REPEAT_PAIRING: { /* We already have a bond with the peer, but it is attempting to @@ -217,8 +236,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: diff --git a/src/components/ble/NimbleController.h b/src/components/ble/NimbleController.h index 0cfe983c..078d6158 100644 --- a/src/components/ble/NimbleController.h +++ b/src/components/ble/NimbleController.h @@ -101,5 +101,7 @@ namespace Pinetime { ServiceDiscovery serviceDiscovery; }; + + static NimbleController* nptr; } } diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 3553f449..2dff9254 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -120,7 +120,6 @@ void SystemTask::Work() { fs.Init(); nimbleController.Init(); - nimbleController.StartAdvertising(); lcd.Init(); twiMaster.Init(); @@ -226,7 +225,6 @@ void SystemTask::Work() { touchPanel.Wakeup(); } - nimbleController.StartAdvertising(); xTimerStart(dimTimer, 0); spiNorFlash.Wakeup(); lcd.Wakeup(); -- cgit v1.2.3 From 00a3f84ea764e5da5d982e7603ece1e574306850 Mon Sep 17 00:00:00 2001 From: "James A. Jerkins" Date: Mon, 30 Aug 2021 23:17:16 -0500 Subject: Completely reset connection state on fail --- src/components/ble/NimbleController.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index 4de8fff9..8b4f3ea8 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -159,6 +159,9 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { if (event->connect.status != 0) { /* Connection failed; resume advertising. */ + currentTimeClient.Reset(); + alertNotificationClient.Reset(); + connectionHandle = BLE_HS_CONN_HANDLE_NONE; bleController.Disconnect(); StartAdvertising(); } else { -- cgit v1.2.3 From 1635bfafb3fe9dce1ab05102d1bfeac1eca81c66 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Tue, 31 Aug 2021 21:56:21 +0200 Subject: Fix notifications that wouldn't auto close when the timeout elapsed (in preview mode). --- src/displayapp/screens/Notifications.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index fd0b86da..22eb290e 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -73,7 +73,6 @@ void Notifications::Refresh() { timeoutLinePoints[1].x = pos; lv_line_set_points(timeoutLine, timeoutLinePoints, 2); } - running = currentItem->IsRunning(); } bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { -- cgit v1.2.3 From d69a8e84fa1906a661738ea034eae5f5f37c25bf Mon Sep 17 00:00:00 2001 From: "James A. Jerkins" Date: Wed, 1 Sep 2021 22:48:01 -0500 Subject: Fix race condition, connect->disconnect->discovery --- src/components/ble/NimbleController.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index 8b4f3ea8..0f486095 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -250,7 +250,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() { -- cgit v1.2.3 From 3e1fe687b82d4df237b7b355fa31cb88713193fc Mon Sep 17 00:00:00 2001 From: "James A. Jerkins" Date: Wed, 1 Sep 2021 22:50:56 -0500 Subject: Fix styles issues - no change to functionality --- src/components/ble/NimbleController.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index 0f486095..8e0fe756 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -151,7 +151,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { 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. */ @@ -170,7 +170,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { systemTask.PushMessage(Pinetime::System::Messages::BleConnected); // Service discovery is deferred via systemtask } - } break; + break; case BLE_GAP_EVENT_DISCONNECT: NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_DISCONNECT"); @@ -207,7 +207,8 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { 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); + 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: { @@ -224,8 +225,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { /* Return BLE_GAP_REPEAT_PAIRING_RETRY to indicate that the host should * continue with the pairing operation. */ - } - return BLE_GAP_REPEAT_PAIRING_RETRY; + } return BLE_GAP_REPEAT_PAIRING_RETRY; case BLE_GAP_EVENT_NOTIFY_RX: { /* Peer sent us a notification or indication. */ @@ -260,7 +260,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); } } -- cgit v1.2.3 From 6f9f0e8b0e42a5526d47ca664534fb6b0ccb6ace Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Thu, 2 Sep 2021 20:32:50 +0200 Subject: Set version to 1.4.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b442fc11..cc41a087 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) -- cgit v1.2.3 From bd1a571399923014c6411dc7f4677078ee54d0f5 Mon Sep 17 00:00:00 2001 From: Itai Nelken <70802936+Itai-Nelken@users.noreply.github.com> Date: Thu, 2 Sep 2021 23:20:25 +0300 Subject: Update Settings.cpp --- src/displayapp/screens/settings/Settings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp index f82b03c1..e3319f03 100644 --- a/src/displayapp/screens/settings/Settings.cpp +++ b/src/displayapp/screens/settings/Settings.cpp @@ -50,8 +50,8 @@ std::unique_ptr Settings::CreateScreen2() { std::array applications {{ {Symbols::shoe, "Steps", Apps::SettingSteps}, {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}, + {Symbols::paintbrush, "PTS Colors", Apps::SettingPineTimeStyle}, {Symbols::check, "Firmware", Apps::FirmwareValidation}, - {Symbols::list, "About", Apps::SysInfo}, }}; return std::make_unique(1, 3, app, settingsController, applications); @@ -60,7 +60,7 @@ std::unique_ptr Settings::CreateScreen2() { std::unique_ptr Settings::CreateScreen3() { std::array applications {{ - {Symbols::paintbrush, "PTS Colors", Apps::SettingPineTimeStyle}, + {Symbols::list, "About", Apps::SysInfo}, {Symbols::none, "None", Apps::None}, {Symbols::none, "None", Apps::None}, {Symbols::none, "None", Apps::None}, -- cgit v1.2.3 From c32ba844e04017a3fd31444c384deb3542bd76be Mon Sep 17 00:00:00 2001 From: "James A. Jerkins" Date: Sat, 4 Sep 2021 15:26:50 -0500 Subject: Linear decrease of advert rate to conserve battery Start advertising aggressively when powered on then slow down linearly over 75 seconds. This will conserve battery by not advertising rapidly the whole time we are seeking a connection. The slowest rate is approximately once every 4.5 seconds to balance responsiveness and battery life. We use a fixed advertising duration of 5 seconds and start with a 62.5 ms advertising interval. Every 5 seconds (the advertising duration) we step up to a larger advertising interval (slower advertising). We continue to increase the advertising interval linearly for 75 seconds from the start of advertising. At 75 seconds we have an advertising interval of 4.44 seconds which we keep until connected. A reboot will restart the sequence. When we receive a disconnect event we restart the sequence with fast advertising and then slow down as described above. Note that we are not using the BLE high duty cycle setting to change the advertising rate. The rate is managed by repeatedly setting the minimum and maximum intervals. The linear rate of decrease and the slowest interval size were determined experimentally by the author. The 5.3 Core spec suggests that you not advertise slower than once every 1.2 seconds to preserve responsiveness but we ignored that suggestion. --- src/components/ble/NimbleController.cpp | 5 +++++ src/components/ble/NimbleController.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index 8e0fe756..bebca2d3 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -122,6 +122,8 @@ void NimbleController::StartAdvertising() { adv_params.conn_mode = BLE_GAP_CONN_MODE_UND; adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN; + adv_params.itvl_min = advInterval; + adv_params.itvl_max = advInterval + 100; fields.flags = BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP; fields.uuids128 = &dfuServiceUuid; @@ -148,6 +150,8 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { case BLE_GAP_EVENT_ADV_COMPLETE: NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_ADV_COMPLETE"); NRF_LOG_INFO("reason=%d; status=%d", event->adv_complete.reason, event->connect.status); + if (advInterval < 7100) + advInterval += 500; StartAdvertising(); break; @@ -181,6 +185,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { alertNotificationClient.Reset(); connectionHandle = BLE_HS_CONN_HANDLE_NONE; bleController.Disconnect(); + advInterval = 100; StartAdvertising(); break; diff --git a/src/components/ble/NimbleController.h b/src/components/ble/NimbleController.h index 078d6158..79761108 100644 --- a/src/components/ble/NimbleController.h +++ b/src/components/ble/NimbleController.h @@ -94,6 +94,7 @@ namespace Pinetime { uint8_t addrType; // 1 = Random, 0 = PUBLIC uint16_t connectionHandle = BLE_HS_CONN_HANDLE_NONE; + uint16_t advInterval = 100; // multiplied by 0.625ms, must be in 32..16384 ble_uuid128_t dfuServiceUuid { .u {.type = BLE_UUID_TYPE_128}, -- cgit v1.2.3 From 4820b2ffe8be0b8d1abefd307a4c0fe6d4d41a73 Mon Sep 17 00:00:00 2001 From: "James A. Jerkins" Date: Sun, 5 Sep 2021 15:52:01 -0500 Subject: Revert "Linear decrease of advert rate to conserve battery" This reverts commit c32ba844e04017a3fd31444c384deb3542bd76be. --- src/components/ble/NimbleController.cpp | 5 ----- src/components/ble/NimbleController.h | 1 - 2 files changed, 6 deletions(-) diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index bebca2d3..8e0fe756 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -122,8 +122,6 @@ void NimbleController::StartAdvertising() { adv_params.conn_mode = BLE_GAP_CONN_MODE_UND; adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN; - adv_params.itvl_min = advInterval; - adv_params.itvl_max = advInterval + 100; fields.flags = BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP; fields.uuids128 = &dfuServiceUuid; @@ -150,8 +148,6 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { case BLE_GAP_EVENT_ADV_COMPLETE: NRF_LOG_INFO("Advertising event : BLE_GAP_EVENT_ADV_COMPLETE"); NRF_LOG_INFO("reason=%d; status=%d", event->adv_complete.reason, event->connect.status); - if (advInterval < 7100) - advInterval += 500; StartAdvertising(); break; @@ -185,7 +181,6 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { alertNotificationClient.Reset(); connectionHandle = BLE_HS_CONN_HANDLE_NONE; bleController.Disconnect(); - advInterval = 100; StartAdvertising(); break; diff --git a/src/components/ble/NimbleController.h b/src/components/ble/NimbleController.h index 79761108..078d6158 100644 --- a/src/components/ble/NimbleController.h +++ b/src/components/ble/NimbleController.h @@ -94,7 +94,6 @@ namespace Pinetime { uint8_t addrType; // 1 = Random, 0 = PUBLIC uint16_t connectionHandle = BLE_HS_CONN_HANDLE_NONE; - uint16_t advInterval = 100; // multiplied by 0.625ms, must be in 32..16384 ble_uuid128_t dfuServiceUuid { .u {.type = BLE_UUID_TYPE_128}, -- cgit v1.2.3 From 22571d4b384e40d647cd994202956f08ed32d925 Mon Sep 17 00:00:00 2001 From: "James A. Jerkins" Date: Sun, 5 Sep 2021 15:53:20 -0500 Subject: Advertise fast for at least 30 secs then slow down On power up, advertise aggressively for at least 30 seconds then switch to a longer interval to conserve battery life. This fast/slow pattern is designed to balance connection response time and battery life. When a disconnect event is received restart the fast/slow pattern. When a failed connect event is received, restart the fast/slow pattern. When the screen is activated and ble is not connected, restart the fast/slow pattern. This pattern is consistent with Apple's BLE developer standards (QA 1931). --- src/components/ble/NimbleController.cpp | 13 ++++++++++++- src/components/ble/NimbleController.h | 5 +++++ src/systemtask/SystemTask.cpp | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index 8e0fe756..226f6694 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -122,6 +122,15 @@ 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 = &dfuServiceUuid; @@ -139,7 +148,7 @@ void NimbleController::StartAdvertising() { rc = ble_gap_adv_rsp_set_fields(&rsp_fields); ASSERT(rc == 0); - rc = ble_gap_adv_start(addrType, NULL, 5000, &adv_params, GAPEventCallback, this); + rc = ble_gap_adv_start(addrType, NULL, 2000, &adv_params, GAPEventCallback, this); ASSERT(rc == 0); } @@ -163,6 +172,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { alertNotificationClient.Reset(); connectionHandle = BLE_HS_CONN_HANDLE_NONE; bleController.Disconnect(); + fastAdvCount = 0; StartAdvertising(); } else { connectionHandle = event->connect.conn_handle; @@ -181,6 +191,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { alertNotificationClient.Reset(); connectionHandle = BLE_HS_CONN_HANDLE_NONE; bleController.Disconnect(); + fastAdvCount = 0; StartAdvertising(); break; diff --git a/src/components/ble/NimbleController.h b/src/components/ble/NimbleController.h index 078d6158..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}, diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 2dff9254..41f346ae 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -233,6 +233,9 @@ void SystemTask::Work() { 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; -- cgit v1.2.3 From 3cc00771fa6528433b2ec4d787dc6bfefd948390 Mon Sep 17 00:00:00 2001 From: NeroBurner Date: Fri, 10 Sep 2021 23:42:49 +0200 Subject: Run CI on master and develop branch The documentation https://github.com/JF002/InfiniTime/blob/develop/doc/contribute.md#how-to-submit-a-pull-request- tells us to make pull requests against `develop` branch. Update the CI to run on those pull requests to have a check if the PR breaks something unintentionally. --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4744eaef..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: -- cgit v1.2.3 From e614af1c4a53e943256b3b2acee4bfe7d7204bbf Mon Sep 17 00:00:00 2001 From: hubmartin Date: Mon, 13 Sep 2021 11:41:51 +0200 Subject: Add WATCH_COLMI_P8 option to cmake & docs --- CMakeLists.txt | 9 +++++++++ doc/buildAndProgram.md | 1 + 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc41a087..f2402e57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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/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. -- cgit v1.2.3 From 84a93b54410681ce1aaae80ba7a7e6d3300dcfa1 Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Tue, 14 Sep 2021 04:02:53 +1000 Subject: docs: Fix a few typos (#606) * docs: Fix a few typos There are small typos in: - doc/versioning.md - src/components/ble/NimbleController.cpp - src/libs/mynewt-nimble/CODING_STANDARDS.md - src/libs/mynewt-nimble/docs/btshell/btshell_GAP.rst - src/systemtask/SystemTask.cpp Fixes: - Should read `milliseconds` rather than `miliseconds`. - Should read `unnecessary` rather than `uncesseray`. - Should read `target` rather than `tharget`. - Should read `project` rather than `projct`. - Should read `preferred` rather than `prefered`. - Should read `functioning` rather than `functionning`. - Should read `forever` rather than `forver`. - Should read `existing` rather than `exisiting`. --- cmake-nRF5x/readme.md | 2 +- doc/versioning.md | 2 +- src/components/ble/NimbleController.cpp | 2 +- src/systemtask/SystemTask.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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/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/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index 5eb227bf..bde9b076 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -126,7 +126,7 @@ void NimbleController::StartAdvertising() { // 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 + // I remove the assert to prevent this unnecessary 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. } diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index d9434b34..690a453d 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -350,7 +350,7 @@ 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--; -- cgit v1.2.3 From 6356c7f276d09ab32d6f1c1338dac0b00a602232 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Mon, 13 Sep 2021 20:35:51 +0200 Subject: Fix DisplayAppRecovery : fix include error by forward declaring Controllers in header file. --- src/displayapp/DisplayAppRecovery.cpp | 1 + src/displayapp/DisplayAppRecovery.h | 32 +++++++++++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/displayapp/DisplayAppRecovery.cpp b/src/displayapp/DisplayAppRecovery.cpp index 17612ef0..7a202629 100644 --- a/src/displayapp/DisplayAppRecovery.cpp +++ b/src/displayapp/DisplayAppRecovery.cpp @@ -5,6 +5,7 @@ #include #include #include "displayapp/icons/infinitime/infinitime-nb.c" +#include "components/ble/BleController.h" using namespace Pinetime::Applications; diff --git a/src/displayapp/DisplayAppRecovery.h b/src/displayapp/DisplayAppRecovery.h index 8b2bc7f5..4184ea49 100644 --- a/src/displayapp/DisplayAppRecovery.h +++ b/src/displayapp/DisplayAppRecovery.h @@ -6,32 +6,38 @@ #include #include #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 #include -#include -#include #include -#include #include "TouchEvents.h" #include "Apps.h" #include "Messages.h" #include "DummyLittleVgl.h" -#include "components/timer/TimerController.h" namespace Pinetime { - namespace System { - class SystemTask; - }; + 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: -- cgit v1.2.3 From f89780f3323042ce9a83f78aa9017c56f0fb62e9 Mon Sep 17 00:00:00 2001 From: Reinhold Gschweicher Date: Mon, 13 Sep 2021 22:32:22 +0200 Subject: Remove unused include in MotoController.h Remove the unused include `app_timer.h` in `MotorController.h` --- src/components/motor/MotorController.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/motor/MotorController.h b/src/components/motor/MotorController.h index 1d8fcc95..cf78088e 100644 --- a/src/components/motor/MotorController.h +++ b/src/components/motor/MotorController.h @@ -1,7 +1,6 @@ #pragma once #include -#include "app_timer.h" #include "components/settings/Settings.h" namespace Pinetime { -- cgit v1.2.3