From 378fa6b4016b65e2d7b128fdc3ce89c4ca779a4d Mon Sep 17 00:00:00 2001 From: Kieran Cawthray Date: Tue, 18 May 2021 15:23:26 +0200 Subject: Reset --- src/displayapp/screens/settings/Settings.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/displayapp/screens/settings/Settings.cpp') 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)); } -- 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 (limited to 'src/displayapp/screens/settings/Settings.cpp') 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, 0x7, 0xe, 0x7, + 0xe, 0xe, 0x7, 0xe, 0xe, 0x7, 0x1c, 0xe, + 0x7, 0x38, 0xf, 0xf, 0x38, 0x7, 0xfe, 0x70, + 0x3, 0xfc, 0xe0, 0x1, 0xf8, + + /* U+0030 "0" */ + 0x3, 0xf8, 0x1, 0xff, 0xc0, 0xff, 0xfe, 0x1f, + 0x7, 0xc7, 0xc0, 0x7c, 0xf0, 0x7, 0xbc, 0x0, + 0x7f, 0x80, 0xf, 0xf0, 0x1, 0xfe, 0x0, 0x3f, + 0xc0, 0x7, 0xf8, 0x0, 0xff, 0xe, 0x1f, 0xe3, + 0xe3, 0xfc, 0x7c, 0x7f, 0x8f, 0x8f, 0xf0, 0xe1, + 0xfe, 0x0, 0x3f, 0xc0, 0x7, 0xf8, 0x0, 0xff, + 0x0, 0x1f, 0xe0, 0x3, 0xfc, 0x0, 0x7f, 0x80, + 0xf, 0xf0, 0x1, 0xef, 0x0, 0x79, 0xf0, 0x1f, + 0x1f, 0x7, 0xc3, 0xff, 0xf8, 0x1f, 0xfc, 0x0, + 0xfe, 0x0, + + /* U+0031 "1" */ + 0x3, 0xf0, 0x0, 0xfe, 0x0, 0x3f, 0xc0, 0x1f, + 0xf8, 0x7, 0xcf, 0x1, 0xf1, 0xe0, 0x3c, 0x3c, + 0x7, 0x7, 0x80, 0x80, 0xf0, 0x0, 0x1e, 0x0, + 0x3, 0xc0, 0x0, 0x78, 0x0, 0xf, 0x0, 0x1, + 0xe0, 0x0, 0x3c, 0x0, 0x7, 0x80, 0x0, 0xf0, + 0x0, 0x1e, 0x0, 0x3, 0xc0, 0x0, 0x78, 0x0, + 0xf, 0x0, 0x1, 0xe0, 0x0, 0x3c, 0x0, 0x7, + 0x80, 0x0, 0xf0, 0x0, 0x1e, 0x0, 0x3, 0xc0, + 0x0, 0x78, 0xf, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf8, + + /* U+0032 "2" */ + 0x3, 0xf8, 0x1, 0xff, 0xc0, 0x7f, 0xfe, 0x1f, + 0x7, 0xc7, 0xc0, 0x3c, 0xf0, 0x7, 0xbc, 0x0, + 0x7f, 0x80, 0xf, 0xf0, 0x1, 0xe0, 0x0, 0x3c, + 0x0, 0x7, 0x80, 0x1, 0xf0, 0x0, 0x3c, 0x0, + 0xf, 0x80, 0x1, 0xe0, 0x0, 0x7c, 0x0, 0x1f, + 0x0, 0x7, 0xc0, 0x1, 0xf0, 0x0, 0x7e, 0x0, + 0xf, 0x80, 0x3, 0xe0, 0x0, 0xf8, 0x0, 0x3e, + 0x0, 0xf, 0x80, 0x3, 0xe0, 0x0, 0xf8, 0x0, + 0x3e, 0x0, 0x7, 0xff, 0xfe, 0xff, 0xff, 0xdf, + 0xff, 0xf8, + + /* U+0033 "3" */ + 0x7f, 0xff, 0x8f, 0xff, 0xf1, 0xff, 0xfe, 0x0, + 0x3, 0xc0, 0x0, 0xf0, 0x0, 0x3c, 0x0, 0xf, + 0x0, 0x3, 0xc0, 0x0, 0xf0, 0x0, 0x3e, 0x0, + 0x7, 0x80, 0x1, 0xfe, 0x0, 0x3f, 0xf0, 0x7, + 0xff, 0x0, 0x3, 0xf0, 0x0, 0x1e, 0x0, 0x3, + 0xc0, 0x0, 0x3c, 0x0, 0x7, 0x80, 0x0, 0xf0, + 0x0, 0x1e, 0x0, 0x3, 0xfc, 0x0, 0x7f, 0x80, + 0xf, 0xf0, 0x1, 0xef, 0x0, 0x79, 0xf0, 0x1f, + 0x1f, 0x7, 0xc3, 0xff, 0xf0, 0x1f, 0xfc, 0x0, + 0xfe, 0x0, + + /* U+0034 "4" */ + 0x0, 0x1e, 0x0, 0xf, 0x80, 0x3, 0xc0, 0x1, + 0xe0, 0x0, 0x78, 0x0, 0x3c, 0x0, 0x1f, 0x0, + 0x7, 0x80, 0x3, 0xc0, 0x1, 0xf0, 0x0, 0x78, + 0x0, 0x3e, 0x0, 0xf, 0x0, 0x7, 0x80, 0xf3, + 0xe0, 0x3c, 0xf0, 0xf, 0x7c, 0x3, 0xde, 0x0, + 0xff, 0x0, 0x3f, 0xc0, 0xf, 0xf0, 0x3, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, 0x3, + 0xc0, 0x0, 0xf0, 0x0, 0x3c, 0x0, 0xf, 0x0, + 0x3, 0xc0, 0x0, 0xf0, 0x0, 0x3c, + + /* U+0035 "5" */ + 0x7f, 0xff, 0x9f, 0xff, 0xe7, 0xff, 0xf9, 0xe0, + 0x0, 0x78, 0x0, 0x1e, 0x0, 0x7, 0x80, 0x1, + 0xe0, 0x0, 0x78, 0x0, 0x1e, 0x0, 0x7, 0x8f, + 0x81, 0xef, 0xf8, 0x7f, 0xff, 0x1f, 0x87, 0xe7, + 0xc0, 0x79, 0xe0, 0x1f, 0x0, 0x3, 0xc0, 0x0, + 0xf0, 0x0, 0x3c, 0x0, 0xf, 0x0, 0x3, 0xc0, + 0x0, 0xf0, 0x0, 0x3c, 0x0, 0xf, 0xf0, 0x3, + 0xde, 0x1, 0xe7, 0x80, 0x78, 0xf8, 0x7e, 0x3f, + 0xff, 0x3, 0xff, 0x80, 0x3f, 0x0, + + /* U+0036 "6" */ + 0x0, 0x3c, 0x0, 0x7, 0x80, 0x0, 0x78, 0x0, + 0xf, 0x0, 0x1, 0xe0, 0x0, 0x1e, 0x0, 0x3, + 0xc0, 0x0, 0x3c, 0x0, 0x7, 0x80, 0x0, 0x70, + 0x0, 0xf, 0x0, 0x1, 0xe7, 0xc0, 0x1f, 0xff, + 0x3, 0xff, 0xfc, 0x3f, 0xf, 0xc7, 0xc0, 0x3e, + 0x78, 0x1, 0xe7, 0x80, 0x1f, 0xf0, 0x0, 0xff, + 0x0, 0xf, 0xf0, 0x0, 0xff, 0x0, 0xf, 0xf0, + 0x0, 0xff, 0x0, 0xf, 0xf8, 0x1, 0xe7, 0x80, + 0x1e, 0x7c, 0x3, 0xe3, 0xf0, 0xfc, 0x1f, 0xff, + 0x80, 0xff, 0xf0, 0x1, 0xf8, 0x0, + + /* U+0037 "7" */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x0, 0x1e, 0xf0, 0x1, 0xef, 0x0, 0x1e, 0xf0, + 0x3, 0xcf, 0x0, 0x3c, 0x0, 0x3, 0x80, 0x0, + 0x78, 0x0, 0x7, 0x80, 0x0, 0xf0, 0x0, 0xf, + 0x0, 0x0, 0xf0, 0x0, 0x1e, 0x0, 0x1, 0xe0, + 0x0, 0x3c, 0x0, 0x3, 0xc0, 0x0, 0x3c, 0x0, + 0x7, 0x80, 0x0, 0x78, 0x0, 0x7, 0x80, 0x0, + 0xf0, 0x0, 0xf, 0x0, 0x1, 0xe0, 0x0, 0x1e, + 0x0, 0x1, 0xe0, 0x0, 0x3c, 0x0, 0x3, 0xc0, + 0x0, 0x7c, 0x0, 0x7, 0x80, 0x0, + + /* U+0038 "8" */ + 0x1, 0xf8, 0x0, 0xff, 0xf0, 0x1f, 0xff, 0x83, + 0xf0, 0xfc, 0x3c, 0x3, 0xc7, 0xc0, 0x3e, 0x78, + 0x1, 0xe7, 0x80, 0x1e, 0x78, 0x1, 0xe7, 0x80, + 0x1e, 0x3c, 0x3, 0xc3, 0xe0, 0x7c, 0x1f, 0xf, + 0x80, 0xff, 0xf0, 0x3, 0xfc, 0x0, 0x7f, 0xe0, + 0xf, 0xff, 0x3, 0xe0, 0x7c, 0x3c, 0x3, 0xc7, + 0x80, 0x1e, 0xf0, 0x0, 0xff, 0x0, 0xf, 0xf0, + 0x0, 0xff, 0x0, 0xf, 0xf0, 0x0, 0xff, 0x80, + 0x1f, 0x7c, 0x3, 0xe7, 0xe0, 0x7e, 0x3f, 0xff, + 0xc0, 0xff, 0xf0, 0x3, 0xfc, 0x0, + + /* U+0039 "9" */ + 0x3, 0xf8, 0x0, 0xff, 0xf0, 0x1f, 0xff, 0x83, + 0xe0, 0xfc, 0x7c, 0x3, 0xe7, 0x80, 0x1e, 0xf8, + 0x1, 0xff, 0x0, 0xf, 0xf0, 0x0, 0xff, 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 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 (limited to 'src/displayapp/screens/settings/Settings.cpp') 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 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(-) (limited to 'src/displayapp/screens/settings/Settings.cpp') 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 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(-) (limited to 'src/displayapp/screens/settings/Settings.cpp') 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