summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt14
-rw-r--r--README.md2
-rwxr-xr-xcmake-nRF5x/CMake_nRF5x.cmake15
-rw-r--r--doc/MemoryAnalysis.md299
-rw-r--r--doc/buildWithDocker.md2
-rw-r--r--doc/companionapps/Amazfish.md3
-rw-r--r--doc/companionapps/Gadgetbridge.md2
-rw-r--r--doc/filesInReleaseNotes.md12
-rw-r--r--doc/memoryAnalysis/linkermapviz.pngbin0 -> 55661 bytes
-rw-r--r--doc/memoryAnalysis/mapfile.pngbin0 -> 111302 bytes
-rw-r--r--doc/memoryAnalysis/puncover-all-symbols.pngbin0 -> 78193 bytes
-rw-r--r--doc/memoryAnalysis/puncover.pngbin0 -> 217193 bytes
-rw-r--r--docker/.gitpod.Dockerfile3
-rw-r--r--docker/Dockerfile3
-rw-r--r--src/CMakeLists.txt89
-rw-r--r--src/FreeRTOS/port_cmsis.c39
-rw-r--r--src/FreeRTOSConfig.h2
-rw-r--r--src/Version.h.in2
-rw-r--r--src/components/battery/BatteryController.cpp1
-rw-r--r--src/components/ble/AlertNotificationClient.cpp2
-rw-r--r--src/components/ble/AlertNotificationService.cpp2
-rw-r--r--src/components/ble/DfuService.cpp6
-rw-r--r--src/components/ble/ImmediateAlertService.cpp2
-rw-r--r--src/components/ble/NimbleController.cpp2
-rw-r--r--src/components/datetime/DateTimeController.cpp10
-rw-r--r--src/components/datetime/DateTimeController.h6
-rw-r--r--src/components/heartrate/HeartRateController.cpp3
-rw-r--r--src/components/heartrate/HeartRateController.h4
-rw-r--r--src/components/heartrate/Ppg.cpp11
-rw-r--r--src/components/heartrate/Ppg.h3
-rw-r--r--src/components/motor/MotorController.cpp1
-rw-r--r--src/components/timer/TimerController.cpp69
-rw-r--r--src/components/timer/TimerController.h37
-rw-r--r--src/displayapp/Apps.h1
-rw-r--r--src/displayapp/DisplayApp.cpp87
-rw-r--r--src/displayapp/DisplayApp.h15
-rw-r--r--src/displayapp/DisplayAppRecovery.cpp15
-rw-r--r--src/displayapp/DisplayAppRecovery.h8
-rw-r--r--src/displayapp/LittleVgl.cpp4
-rw-r--r--src/displayapp/LittleVgl.h2
-rw-r--r--src/displayapp/Messages.h1
-rw-r--r--src/displayapp/fonts/README.md2
-rw-r--r--src/displayapp/fonts/jetbrains_mono_bold_20.c36
-rw-r--r--src/displayapp/screens/ApplicationList.cpp2
-rw-r--r--src/displayapp/screens/FirmwareValidation.cpp11
-rw-r--r--src/displayapp/screens/FirmwareValidation.h3
-rw-r--r--src/displayapp/screens/FlashLight.cpp4
-rw-r--r--src/displayapp/screens/HeartRate.cpp8
-rw-r--r--src/displayapp/screens/Navigation.cpp137
-rw-r--r--src/displayapp/screens/Navigation.h101
-rw-r--r--src/displayapp/screens/Notifications.cpp9
-rw-r--r--src/displayapp/screens/ScreenList.h13
-rw-r--r--src/displayapp/screens/Symbols.h1
-rw-r--r--src/displayapp/screens/SystemInfo.cpp18
-rw-r--r--src/displayapp/screens/SystemInfo.h3
-rw-r--r--src/displayapp/screens/Timer.cpp173
-rw-r--r--src/displayapp/screens/Timer.h42
-rw-r--r--src/displayapp/screens/settings/QuickSettings.cpp4
-rw-r--r--src/displayapp/screens/settings/Settings.cpp4
-rw-r--r--src/displayapp/screens/settings/Settings.h1
-rw-r--r--src/drivers/Bma421.cpp2
-rw-r--r--src/drivers/SpiMaster.cpp16
-rw-r--r--src/drivers/SpiMaster.h3
-rw-r--r--src/drivers/TwiMaster.cpp4
-rw-r--r--src/drivers/TwiMaster.h2
-rw-r--r--src/heartratetask/HeartRateTask.cpp7
-rw-r--r--src/main.cpp85
-rw-r--r--src/systemtask/Messages.h26
-rw-r--r--src/systemtask/SystemTask.cpp136
-rw-r--r--src/systemtask/SystemTask.h52
70 files changed, 1214 insertions, 470 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f7770136..1a488eaa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
-project(pinetime VERSION 1.0.0 LANGUAGES C CXX ASM)
+project(pinetime VERSION 1.1.0 LANGUAGES C CXX ASM)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 14)
@@ -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 396d7462..755f1905 100644
--- a/README.md
+++ b/README.md
@@ -62,7 +62,7 @@ As of now, here is the list of achievements of this project:
* Firmware validation
* System information
- Supported by 3 companion apps (development is in progress):
- * [Gadgetbridge](https://codeberg.org/Freeyourgadget/Gadgetbridge/) (on Android)
+ * [Gadgetbridge](https://codeberg.org/Freeyourgadget/Gadgetbridge/) (on Android via F-Droid)
* [Amazfish](https://openrepos.net/content/piggz/amazfish) (on SailfishOS and Linux)
* [Siglo](https://github.com/alexr4535/siglo) (on Linux)
* **[Experimental]** [WebBLEWatch](https://hubmartin.github.io/WebBLEWatch/) Synchronize time directly from your web browser. [video](https://youtu.be/IakiuhVDdrY)
diff --git a/cmake-nRF5x/CMake_nRF5x.cmake b/cmake-nRF5x/CMake_nRF5x.cmake
index ead7b9f6..c7d0a68b 100755
--- a/cmake-nRF5x/CMake_nRF5x.cmake
+++ b/cmake-nRF5x/CMake_nRF5x.cmake
@@ -74,21 +74,6 @@ macro(nRF5x_setup)
)
endif ()
- set(COMMON_FLAGS "-MP -MD -mthumb -mabi=aapcs -Wall -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums ${CPU_FLAGS} -Wreturn-type -Werror=return-type")
-
- # compiler/assambler/linker flags
- set(CMAKE_C_FLAGS "${COMMON_FLAGS}")
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3")
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")
- set(CMAKE_CXX_FLAGS "${COMMON_FLAGS}")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
- set(CMAKE_ASM_FLAGS "-MP -MD -x assembler-with-cpp")
- set(CMAKE_EXE_LINKER_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} ${CPU_FLAGS} -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm")
- # note: we must override the default cmake linker flags so that CMAKE_C_FLAGS are not added implicitly
- set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_COMPILER} <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
- set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_C_COMPILER} <LINK_FLAGS> <OBJECTS> -lstdc++ -o <TARGET> <LINK_LIBRARIES>")
-
# basic board definitions and drivers
include_directories(
"${NRF5_SDK_PATH}/components"
diff --git a/doc/MemoryAnalysis.md b/doc/MemoryAnalysis.md
index 95bd611c..3251c98d 100644
--- a/doc/MemoryAnalysis.md
+++ b/doc/MemoryAnalysis.md
@@ -1,78 +1,289 @@
# Memory analysis
-## FreeRTOS heap and task stack
-FreeRTOS statically allocate its own heap buffer in a global variable named `ucHeap`. This is an array of *uint8_t*. Its size is specified by the definition `configTOTAL_HEAP_SIZE` in *FreeRTOSConfig.h*
-FreeRTOS uses this buffer to allocate memory for tasks stack and all the RTOS object created during runtime (timers, mutexes,...).
+The PineTime is equipped with the following memories:
+ - The internal RAM : **64KB**
+ - The internal Flash : **512KB**
+ - The external (SPI) Flash : **4MB**
-The function `xPortGetFreeHeapSize()` returns the amount of memory available in this *ucHeap* buffer. If this value reaches 0, FreeRTOS runs out of memory.
+Note that the NRF52832 cannot execute code stored in the external flash : we need to store the whole firmware in the internal flash memory, and use the external one to store graphicals assets, fonts...
+
+This document describes how the RAM and Flash memories are used in InfiniTime and how to analyze and monitor their usage. It was written in the context of [this memory analysis effort](https://github.com/JF002/InfiniTime/issues/313).
+
+## Code sections
+A binary is composed of multiple sections. Most of the time, these sections are : .text, .rodata, .data and .bss but more sections can be defined in the linker script.
+
+Here is a small description of these sections and where they end up in memory:
+
+ - **TEXT** = code (FLASH)
+ - **RODATA** = constants (FLASH)
+ - **DATA** = initialized variables (FLASH + RAM)
+ - **BSS** = uninitialized variables (RAM)
+
+
+## Internal FLASH
+The internal flash memory stores the whole firmware: code, variable that are not default-initialized, constants...
+
+The content of the flash memory can be easily analyzed thanks to the MAP file generated by the compiler. This file lists all the symbols from the program along with their size and location (section and addresses) in RAM and FLASH.
+
+![Map file](./memoryAnalysis/mapfile.png)
+
+As you can see on the picture above, this file contains a lot of information and is not easily readable by a human being. Fortunately, you can easily find tools that parse and display the content of the MAP file in a more understandable way.
+
+In this analysis, I used [Linkermapviz](https://github.com/PromyLOPh/linkermapviz).
+
+### Linkermapviz
+
+[Linkermapviz](https://github.com/PromyLOPh/linkermapviz) parses the MAP file and displays its content in a graphical way into an HTML page:
+
+![linkermapviz](./memoryAnalysis/linkermapviz.png)
+
+Using this tool, you can easily see the size of each symbol relative to the other one, and check what is using most of the space,...
+
+Also, as Linkermapviz is written in Python, you can easily modify it to adapt it to your firmware, export data in another format,... For example, [I modified it to parse the contents of the MAP file and export it in a CSV file](https://github.com/JF002/InfiniTime/issues/313#issuecomment-842338620). I could later on open this file in LibreOffice Calc and use sort/filter functionality to search for specific symbols in specific files...
+
+### Puncover
+[Puncover](https://github.com/HBehrens/puncover) is another useful tools that analyses the binary file generated by the compiler (the .out file that contains all debug information). It provides valuable information about the symbols (data and code): name, position, size, max stack of each functions, callers, callees...
+![Puncover](./memoryAnalysis/puncover.png)
+
+Puncover is really easy to install:
+ - clone the repo and cd into the cloned directory
+ - setup a venv
+ - `python -m virtualenv venv`
+ - `source venv/bin/activate`
+ - Install : `pip install .`
+ - Run : `puncover --gcc_tools_base=/path/to/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi- --elf_file /path/to/build/directory/src/pinetime-app-1.1.0.out --src_root /path/to/sources --build_dir /path/to/build/directory`
+ - Replace
+ * `/path/to/gcc-arm-none-eabi-9-2020-q2-update/bin` with the path to your gcc-arm-none-eabi toolchain
+ * `/path/to/build/directory/src/pinetime-app-1.1.0.out` with the path to the binary generated by GCC (.out file)
+ * `/path/to/sources` with the path to the root folder of the sources (checkout directory)
+ * `/path/to/build/directory` with the path to the build directory
+ - Launch a browser at http://localhost:5000/
+
+### Analysis
+Using the MAP file and tools, we can easily see what symbols are using most of the FLASH memory space. In this case, with no surprise, fonts and graphics are the biggest flash space consumer.
+
+![Puncover](./memoryAnalysis/puncover-all-symbols.png)
+
+This way, you can easily check what needs to be optimized : we should find a way to store big static data (like fonts and graphics) in the external flash memory, for example.
+
+It's always a good idea to check the flash memory space when working on the project : this way, you can easily check that your developments are using a reasonable amount of space.
+
+### Links
+ - Analysis with linkermapviz : https://github.com/JF002/InfiniTime/issues/313#issuecomment-842338620
+ - Analysis with Puncover : https://github.com/JF002/InfiniTime/issues/313#issuecomment-847311392
+
+## RAM
+RAM memory contains all the data that can be modified at run-time: variables, stack, heap...
+
+### Data
+RAM memory can be *statically* allocated, meaning that the size and position of the data are known at compile-time:
+
+You can easily analyze the memory used by variables declared in the global scope using the MAP. You'll find them in the .BSS or .DATA sections. Linkermapviz and Puncover can be used to analyze their memory usage.
+
+Variables declared in the scope of a function will be allocated on the stack. It means that the stack usage will vary according to the state of the program, and cannot be easily analyzed at compile time.
```
-NRF_LOG_INFO("Free heap : %d", xPortGetFreeHeapSize());
+uint8_t buffer[1024]
+
+int main() {
+ int a;
+}
```
+#### Analysis
+In Infinitime 1.1, the biggest buffers are the buffers allocated for LVGL (14KB) and the one for FreeRTOS (16KB). Nimble also allocated 9KB of RAM.
-The function `uxTaskGetSystemState()` fetches some information about the running tasks like its name and the minimum amount of stack space that has remained for the task since the task was created:
+### Stack
+The stack will be used for everything except tasks, which have their own stack allocated by FreeRTOS. The stack is 8192B and is allocated in the [linker script](https://github.com/JF002/InfiniTime/blob/develop/nrf_common.ld#L148).
+An easy way to monitor its usage is by filling the section with a known pattern at boot time, then use the firmware and dump the memory. You can then check the maximum stack usage by checking the address from the beginning of the stack that were overwritten.
+
+#### Fill the stack section by a known pattern:
+Edit <NRFSDK>/modules/nrfx/mdk/gcc_startup_nrf52.S and add the following code after the copy of the data from read only memory to RAM at around line 243:
```
-TaskStatus_t tasksStatus[10]
-auto nb = uxTaskGetSystemState(tasksStatus, 10, NULL);
-for (int i = 0; i < nb; i++) {
- NRF_LOG_INFO("Task [%s] - %d", tasksStatus[i].pcTaskName, tasksStatus[i].usStackHighWaterMark);
-```
+/* Loop to copy data from read only memory to RAM.
+ * The ranges of copy from/to are specified by following symbols:
+ * __etext: LMA of start of the section to copy from. Usually end of text
+ * __data_start__: VMA of start of the section to copy to.
+ * __bss_start__: VMA of end of the section to copy to. Normally __data_end__ is used, but by using __bss_start__
+ * the user can add their own initialized data section before BSS section with the INTERT AFTER command.
+ *
+ * All addresses must be aligned to 4 bytes boundary.
+ */
+ ldr r1, =__etext
+ ldr r2, =__data_start__
+ ldr r3, =__bss_start__
+
+ subs r3, r3, r2
+ ble .L_loop1_done
+.L_loop1:
+ subs r3, r3, #4
+ ldr r0, [r1,r3]
+ str r0, [r2,r3]
+ bgt .L_loop1
-## Global heap
-Heap is used for **dynamic memory allocation (malloc() / new)**. NRF SDK defaults the heap size to 8KB. The size of the heap can be specified by defining `__HEAP_SIZE=8192` in *src/CMakeLists.txt*:
+.L_loop1_done:
+
+/* Add this code to fill the stack section with 0xFFEEDDBB */
+ldr r0, =__StackLimit
+ ldr r1, =8192
+ldr r2, =0xFFEEDDBB
+.L_fill:
+str r2, [r0]
+adds r0, 4
+subs r1, 4
+bne .L_fill
+/* -- */
+```
+
+#### Dump RAM memory and check usage
+Dumping the content of the ram is easy using JLink debugger and `nrfjprog`:
+
+```
+nrfjprog --readram ram.bin
```
-add_definitions(-D__HEAP_SIZE=8192)
-```
-You can trace the dynamic memory allocation by using the flag `--wrap` of the linker. When this flag is enabled, the linker will replace the calls to a specific function by a call to __wrap_the_function(). For example, if you specify `-Wl,-wrap,malloc` in the linker flags, the linker will replace all calls to `void* malloc(size_t)` by calls to `void* __wrap_malloc(size_t)`. This is a function you'll have to define in your code. In this function, you can call `__real_malloc()` to call the actual `malloc()' function.
+You can then display the file using objdump:
-This technic allows you to wrap all calls to malloc() with you own code.
+```
+hexdump ram.bin -v | less
+```
-In *src/CMakeLists.txt*:
+The stack is positionned at the end of the RAM -> 0xFFFF. Its size is 8192 bytes, so the end of the stack is at 0xE000.
+On the following dump, the maximum stack usage is 520 bytes (0xFFFF - 0xFDF8):
```
-set_target_properties(${EXECUTABLE_NAME} PROPERTIES
- ...
- LINK_FLAGS "-Wl,-wrap,malloc ..."
- ...
- )
+000fdb0 ddbb ffee ddbb ffee ddbb ffee ddbb ffee
+000fdc0 ddbb ffee ddbb ffee ddbb ffee ddbb ffee
+000fdd0 ddbb ffee ddbb ffee ddbb ffee ddbb ffee
+000fde0 ddbb ffee ddbb ffee ddbb ffee ddbb ffee
+000fdf0 ddbb ffee ddbb ffee ffff ffff c24b 0003
+000fe00 ffff ffff ffff ffff ffff ffff 0000 0000
+000fe10 0018 0000 0000 0000 0000 0000 fe58 2000
+000fe20 0000 0000 0000 00ff ddbb 00ff 0018 0000
+000fe30 929c 2000 0000 0000 0018 0000 0000 0000
+000fe40 92c4 2000 0458 2000 0000 0000 80e7 0003
+000fe50 0000 0000 8cd9 0003 ddbb ffee ddbb ffee
+000fe60 00dc 2000 92c4 2000 0005 0000 929c 2000
+000fe70 007f 0000 feb0 2000 92c4 2000 feb8 2000
+000fe80 ddbb ffee 0005 0000 929c 2000 0000 0000
+000fe90 aca0 2000 0000 0000 0028 0000 418b 0005
+000fea0 02f4 2000 001f 0000 0000 0000 0013 0000
+000feb0 b5a8 2000 2199 0005 b5a8 2000 2201 0005
+000fec0 b5a8 2000 001e 0000 0000 0000 0013 0000
+000fed0 b5b0 2000 0fe0 0006 b5a8 2000 0000 0000
+000fee0 0013 0000 2319 0005 0013 0000 0000 0000
+000fef0 0000 0000 3b1c 2000 3b1c 2000 d0e3 0000
+000ff00 4b70 2000 54ac 2000 4b70 2000 ffff ffff
+000ff10 0000 0000 1379 0003 6578 2000 0d75 0003
+000ff20 6578 2000 ffff ffff 0000 0000 1379 0003
+000ff30 000c 0000 cfeb 0002 39a1 2000 a824 2000
+000ff40 0015 0000 cfeb 0002 39a1 2000 a824 2000
+000ff50 39a1 2000 0015 0000 001b 0000 b4b9 0002
+000ff60 0000 0000 a9f4 2000 4b70 2000 0d75 0003
+000ff70 4b70 2000 ffff ffff 0000 0000 1379 0003
+000ff80 ed00 e000 a820 2000 1000 4001 7fc0 2000
+000ff90 7f64 2000 75a7 0001 a884 2000 7b04 2000
+000ffa0 a8c0 2000 0000 0000 0000 0000 0000 0000
+000ffb0 7fc0 2000 7f64 2000 8024 2000 a5a5 a5a5
+000ffc0 ed00 e000 3fd5 0001 0000 0000 72c0 2000
+000ffd0 0000 0000 72e4 2000 3f65 0001 7f64 2000
+000ffe0 0000 2001 0000 0000 ef30 e000 0010 0000
+000fff0 7fc0 2000 4217 0001 3f0a 0001 0000 6100
+```
+
+#### Analysis
+According to my experimentations, we don't use the stack that much, and 8192 bytes is probably way too big for InfiniTime!
+
+#### Links
+ - https://github.com/JF002/InfiniTime/issues/313#issuecomment-851035070
+### Heap
+The heap is declared in the [linker script](https://github.com/JF002/InfiniTime/blob/develop/nrf_common.ld#L136) and its current size is 8192 bytes. The heap is used for dynamic memory allocation(`malloc()`, `new`...).
+
+Heap monitoring is not easy, but it seems that we can use the following code to know the current usage of the heap:
+
+```
+auto m = mallinfo();
+NRF_LOG_INFO("heap : %d", m.uordblks);
```
-In *main.cpp*:
+#### Analysis
+According to my experimentation, InfiniTime uses ~6000bytes of heap most of the time. Except when the Navigation app is launched, where the heap usage increases to... more than 9500 bytes (meaning that the heap overflows and could potentially corrupt the stack!!!). This is a bug that should be fixed in #362.
+
+To know exactly what's consuming heap memory, you can `wrap` functions like `malloc()` into your own functions. In this wrapper, you can add logging code or put breakpoints:
+
+- Add ` -Wl,-wrap,malloc` to the cmake variable `LINK_FLAGS` of the target you want to debug (pinetime-app, most probably)
+- Add the following code in `main.cpp`
```
-uint32_t totalMalloc = 0;
extern "C" {
- extern void* __real_malloc(size_t s);
- void *__wrap_malloc(size_t s) {
- totalMalloc += s;
- return __real_malloc(s);
- }
+void *__real_malloc (size_t);
+void* __wrap_malloc(size_t size) {
+ return __real_malloc(size);
}
+}
+```
+Now, your function `__wrap_malloc()` will be called instead of `malloc()`. You can call the actual malloc from the stdlib by calling `__real_malloc()`.
+
+Using this technique, I was able to trace all malloc calls at boot (boot -> digital watchface):
+
+- system task = 3464 bytes (SystemTask could potentially be declared as a global variable to avoid heap allocation here)
+- string music = 31 (maybe we should not use std::string when not needed, as it does heap allocation)
+- ble_att_svr_start = 1720
+- ble gatts start = 40 + 88
+- ble ll task = 24
+- display app = 104
+- digital clock = 96 + 152
+- hr task = 304
+
+#### Links
+ - https://github.com/JF002/InfiniTime/issues/313#issuecomment-851035625
+ - https://www.embedded.com/mastering-stack-and-heap-for-system-reliability-part-1-calculating-stack-size/
+ - https://www.embedded.com/mastering-stack-and-heap-for-system-reliability-part-2-properly-allocating-stacks/
+ - https://www.embedded.com/mastering-stack-and-heap-for-system-reliability-part-3-avoiding-heap-errors/
+
+## LVGL
+I did a deep analysis of the usage of the buffer dedicated for lvgl (managed by lv_mem).
+This buffer is used by lvgl to allocated memory for drivers (display/touch), screens, themes, and all widgets created by the apps.
+
+The usage of this buffer can be monitored using this code :
+
```
-This function sums all the memory that is allocated during the runtime. You can monitor or log this value. You can also place breakpoints in this function to determine where the dynamic memory allocation occurs in your code.
+lv_mem_monitor_t mon;
+lv_mem_monitor(&mon);
+NRF_LOG_INFO("\t Free %d / %d -- max %d", mon.free_size, mon.total_size, mon.max_used);
+```
+
+The most interesting metric is `mon.max_used` which specifies the maximum number of bytes that were used from this buffer since the initialization of lvgl.
+According to my measurements, initializing the theme, display/touch driver and screens cost **4752** bytes!
+Then, initializing the digital clock face costs **1541 bytes**.
+For example a simple lv_label needs **~140 bytes** of memory.
+
+I tried to monitor this max value while going through all the apps of InfiniTime 1.1 : the max value I've seen is **5660 bytes**. It means that we could probably **reduce the size of the buffer from 14KB to 6 - 10 KB** (we have to take the fragmentation of the memory into account).
+### Links
+ - https://github.com/JF002/InfiniTime/issues/313#issuecomment-850890064
+
+
+## FreeRTOS heap and task stack
+FreeRTOS statically allocate its own heap buffer in a global variable named `ucHeap`. This is an array of *uint8_t*. Its size is specified by the definition `configTOTAL_HEAP_SIZE` in *FreeRTOSConfig.h*
+FreeRTOS uses this buffer to allocate memory for tasks stack and all the RTOS object created during runtime (timers, mutexes...).
+The function `xPortGetFreeHeapSize()` returns the amount of memory available in this *ucHeap* buffer. If this value reaches 0, FreeRTOS runs out of memory.
-# Global stack
-The stack is used to allocate memory used by functions : **parameters and local variables**. NRF SDK defaults the heap size to 8KB. The size of the heap can be specified by defining `__STACK_SIZE=8192` in *src/CMakeLists.txt*:
-
```
-add_definitions(-D__STACK_SIZE=8192)
-```
+NRF_LOG_INFO("Free heap : %d", xPortGetFreeHeapSize());
+```
-*NOTE*: FreeRTOS uses its own stack buffer. Thus, the global stack is only used for main() and IRQ handlers. It should be possible to reduce its size to a much lower value.
-**NOTE**: [?] How to track the global stack usage?
+The function `uxTaskGetSystemState()` fetches some information about the running tasks like its name and the minimum amount of stack space that has remained for the task since the task was created:
-#LittleVGL buffer
-*TODO*
+```
+TaskStatus_t tasksStatus[10]
+auto nb = uxTaskGetSystemState(tasksStatus, 10, NULL);
+for (int i = 0; i < nb; i++) {
+ NRF_LOG_INFO("Task [%s] - %d", tasksStatus[i].pcTaskName, tasksStatus[i].usStackHighWaterMark);
+```
-#NimBLE buffers
-*TODO*
-#Tools
- - https://github.com/eliotstock/memory : display the memory usage (FLASH/RAM) using the .map file from GCC.
diff --git a/doc/buildWithDocker.md b/doc/buildWithDocker.md
index 7a2f3727..17fb53d9 100644
--- a/doc/buildWithDocker.md
+++ b/doc/buildWithDocker.md
@@ -13,7 +13,7 @@ Based on Ubuntu 18.04 with the following build dependencies:
The `infinitime-build` image contains all the dependencies you need. The default `CMD` will compile sources found in `/sources`, so you need only mount your code.
-This example will build the firmware, generate the MCUBoot image and generate the DFU file. Outputs will be written to **<project_root>/build/output**:
+This example will build the firmware, generate the MCUBoot image and generate the DFU file. For cloning the repo, see [these instructions](../doc/buildAndProgram.md#clone-the-repo). Outputs will be written to **<project_root>/build/output**:
```bash
cd <project_root> # e.g. cd ./work/Pinetime
diff --git a/doc/companionapps/Amazfish.md b/doc/companionapps/Amazfish.md
index eb9daa04..90ad20c2 100644
--- a/doc/companionapps/Amazfish.md
+++ b/doc/companionapps/Amazfish.md
@@ -8,8 +8,9 @@ The following features are implemented:
- Time synchronization
- Notifications
- Music control
+ - Navigation with Puremaps
## Demo
[This video](https://seafile.codingfield.com/f/21c5d023452740279e36/) shows how to connect to the Pinetime and control the playback of the music on the phone.
Amazfish and Sailfish OS are running on the [Pinephone](https://www.pine64.org/pinephone/), another awesome device from Pine64.
- \ No newline at end of file
+
diff --git a/doc/companionapps/Gadgetbridge.md b/doc/companionapps/Gadgetbridge.md
index 1a25069c..974e2828 100644
--- a/doc/companionapps/Gadgetbridge.md
+++ b/doc/companionapps/Gadgetbridge.md
@@ -1,7 +1,7 @@
# Integration with Gadgetbridge
[Gadgetbridge](https://gadgetbridge.org/) is an Android application that supports many smartwatches and fitness trackers.
-The integration of InfiniTime (previously Pinetime-JF) is now merged into the master branch (https://codeberg.org/Freeyourgadget/Gadgetbridge/).
+The integration of InfiniTime (previously Pinetime-JF) is now merged into the master branch (https://codeberg.org/Freeyourgadget/Gadgetbridge/) and initial support is available [starting with version 0.47](https://codeberg.org/Freeyourgadget/Gadgetbridge/src/branch/master/CHANGELOG.md). Note that the official version is only available on F-Droid (as of May 2021), and the unofficial fork available on the Play Store is outdated and does not support Infinitime.
## Features
The following features are implemented:
diff --git a/doc/filesInReleaseNotes.md b/doc/filesInReleaseNotes.md
index f48a0c10..78c20b51 100644
--- a/doc/filesInReleaseNotes.md
+++ b/doc/filesInReleaseNotes.md
@@ -1,16 +1,16 @@
# Using the releases
-For each new *stable* version of Pinetime, a [release note](https://github.com/JF002/InfiniTime/releases) is created. It contains a description of the main changes in the release and some files you can use to flash the firmware in your Pinetime.
+For each new *stable* version of IniniTime, a [release note](https://github.com/JF002/InfiniTime/releases) is created. It contains a description of the main changes in the release and some files you can use to flash the firmware to your Pinetime.
This page describes the files from the release notes and how to use them.
-**NOTE :** the files included in different could be different. This page describes the release note of [version 0.7.1](https://github.com/JF002/InfiniTime/releases/tag/0.7.1), which is the version that'll probably be pre-programmed at the factory for the next batch of Pinetime devkits.
+**NOTE :** the files included in different Releases could be different. This page describes the release notes of [version 0.7.1](https://github.com/JF002/InfiniTime/releases/tag/0.7.1), which is the version that is pre-programmed for the last batches of pinetimes but will be replaced with [1.0.0](https://github.com/jF002/infiniTime/releases/tag/1.0.0) around june 2021.
-## Files included in the release note
+## Files included in the release notes
### Standalone firmware
-This firmware is standalone, meaning that it does not need a bootloader to actually run. It is intended to be flash at offset 0, meaning it will erase any bootloader that might be present in memory.
+This firmware is standalone, meaning that it does not need a bootloader to actually run. It is intended to be flashed at offset 0, meaning it will erase any bootloader that might be present in memory.
- - **pinetime-app.out** : Output file of GCC containing debug symbols, useful is you want to debug the firmware using GDB.
+ - **pinetime-app.out** : Output file of GCC containing debug symbols, useful if you want to debug the firmware using GDB.
- **pinetime-app.hex** : Firmware in Intel HEX file format. Easier to use because it contains the offset in memory where it must be flashed, you don't need to specify it.
- **pintime-app.bin** : Firmware in binary format. When programming it, you have to specify the offset (0x00) in memory where it must be flashed.
- **pinetime-app.map** : Map file containing all the symbols, addresses in memory,...
@@ -38,7 +38,7 @@ This firmware is a small utility firmware that writes the boot graphic in the ex
### Firmware with bootloader
This firmware is intended to be used with our [MCUBoot-based bootloader](../bootloader/README.md).
- - **pinetime-mcuboot-app-image.hex** : Firmware wrapped into an MCUBoot image. This is **the** file that must be flashed **@ 0x8000** into flash memory. If the [bootloader](../bootloader/README.md) has been successfully programmed, it should run this firmware after the next reset.
+ - **pinetime-mcuboot-app-image.hex**: Firmware wrapped into an MCUBoot image. This is **the** file that must be flashed at **0x8000** into the flash memory. If the [bootloader](../bootloader/README.md) has been successfully programmed, it should run this firmware after the next reset.
The following files are not directly usable by the bootloader:
diff --git a/doc/memoryAnalysis/linkermapviz.png b/doc/memoryAnalysis/linkermapviz.png
new file mode 100644
index 00000000..8edfc8f9
--- /dev/null
+++ b/doc/memoryAnalysis/linkermapviz.png
Binary files differ
diff --git a/doc/memoryAnalysis/mapfile.png b/doc/memoryAnalysis/mapfile.png
new file mode 100644
index 00000000..0badd104
--- /dev/null
+++ b/doc/memoryAnalysis/mapfile.png
Binary files differ
diff --git a/doc/memoryAnalysis/puncover-all-symbols.png b/doc/memoryAnalysis/puncover-all-symbols.png
new file mode 100644
index 00000000..6a984248
--- /dev/null
+++ b/doc/memoryAnalysis/puncover-all-symbols.png
Binary files differ
diff --git a/doc/memoryAnalysis/puncover.png b/doc/memoryAnalysis/puncover.png
new file mode 100644
index 00000000..b32e1784
--- /dev/null
+++ b/doc/memoryAnalysis/puncover.png
Binary files 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 acbfba18..c72f7c9c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -407,6 +407,7 @@ list(APPEND SOURCE_FILES
displayapp/screens/List.cpp
displayapp/screens/BatteryInfo.cpp
displayapp/screens/Steps.cpp
+ displayapp/screens/Timer.cpp
## Settings
displayapp/screens/settings/QuickSettings.cpp
@@ -459,6 +460,7 @@ list(APPEND SOURCE_FILES
components/firmwarevalidator/FirmwareValidator.cpp
components/motor/MotorController.cpp
components/settings/Settings.cpp
+ components/timer/TimerController.cpp
drivers/Cst816s.cpp
FreeRTOS/port.c
FreeRTOS/port_cmsis_systick.c
@@ -520,6 +522,7 @@ list(APPEND RECOVERY_SOURCE_FILES
components/ble/HeartRateService.cpp
components/firmwarevalidator/FirmwareValidator.cpp
components/settings/Settings.cpp
+ components/timer/TimerController.cpp
drivers/Cst816s.cpp
FreeRTOS/port.c
FreeRTOS/port_cmsis_systick.c
@@ -590,6 +593,7 @@ set(INCLUDE_FILES
displayapp/screens/Notifications.h
displayapp/screens/HeartRate.h
displayapp/screens/Motion.h
+ displayapp/screens/Timer.h
drivers/St7789.h
drivers/SpiNorFlash.h
drivers/SpiMaster.h
@@ -619,6 +623,7 @@ set(INCLUDE_FILES
components/ble/BleClient.h
components/ble/HeartRateService.h
components/settings/Settings.h
+ components/timer/TimerController.h
drivers/Cst816s.h
FreeRTOS/portmacro.h
FreeRTOS/portmacro_cmsis.h
@@ -739,16 +744,18 @@ link_directories(
)
-set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -Wno-unknown-pragmas -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wreturn-type -Werror=return-type)
+set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -Wno-unknown-pragmas -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wreturn-type -Werror=return-type -fstack-usage -fno-exceptions -fno-non-call-exceptions)
add_definitions(-DCONFIG_GPIO_AS_PINRESET)
-add_definitions(-DDEBUG)
add_definitions(-DNIMBLE_CFG_CONTROLLER)
add_definitions(-DOS_CPUTIME_FREQ)
add_definitions(-DNRF52 -DNRF52832 -DNRF52832_XXAA -DNRF52_PAN_74 -DNRF52_PAN_64 -DNRF52_PAN_12 -DNRF52_PAN_58 -DNRF52_PAN_54 -DNRF52_PAN_31 -DNRF52_PAN_51 -DNRF52_PAN_36 -DNRF52_PAN_15 -DNRF52_PAN_20 -DNRF52_PAN_55 -DBOARD_PCA10040)
add_definitions(-DFREERTOS)
-add_definitions(-DDEBUG_NRF_USER)
-add_definitions(-D__STACK_SIZE=8192)
-add_definitions(-D__HEAP_SIZE=8192)
+add_definitions(-D__STACK_SIZE=1024)
+add_definitions(-D__HEAP_SIZE=4096)
+
+# NOTE : Add the following defines to enable debug mode of the NRF SDK:
+#add_definitions(-DDEBUG)
+#add_definitions(-DDEBUG_NRF_USER)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
@@ -759,10 +766,10 @@ add_library(nrf-sdk STATIC ${SDK_SOURCE_FILES})
target_include_directories(nrf-sdk SYSTEM PUBLIC . ../)
target_include_directories(nrf-sdk SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
target_compile_options(nrf-sdk PRIVATE
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -fno-rtti>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os -fno-rtti>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -x assembler-with-cpp>
)
@@ -771,10 +778,10 @@ add_library(nimble STATIC ${NIMBLE_SRC} ${TINYCRYPT_SRC})
target_include_directories(nimble SYSTEM PUBLIC . ../)
target_include_directories(nimble SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
target_compile_options(nimble PRIVATE
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os -Wno-unused-but-set-variable -Wno-maybe-uninitialized>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-rtti>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-rtti>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -x assembler-with-cpp>
)
@@ -783,10 +790,10 @@ add_library(lvgl STATIC ${LVGL_SRC})
target_include_directories(lvgl SYSTEM PUBLIC . ../)
target_include_directories(lvgl SYSTEM PUBLIC ${INCLUDES_FROM_LIBS})
target_compile_options(lvgl PRIVATE
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3 -fno-rtti>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os -fno-rtti>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -x assembler-with-cpp>
)
@@ -798,10 +805,10 @@ add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES})
set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FILE_NAME})
target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl)
target_compile_options(${EXECUTABLE_NAME} PUBLIC
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3 -fno-rtti>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os -fno-rtti>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -x assembler-with-cpp>
)
@@ -828,10 +835,10 @@ add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES})
target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl)
set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_FILE_NAME})
target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3 -fno-rtti>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os -fno-rtti>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -x assembler-with-cpp>
)
@@ -865,10 +872,10 @@ target_link_libraries(${EXECUTABLE_RECOVERY_NAME} nimble nrf-sdk)
set_target_properties(${EXECUTABLE_RECOVERY_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_FILE_NAME})
target_compile_definitions(${EXECUTABLE_RECOVERY_NAME} PUBLIC "PINETIME_IS_RECOVERY")
target_compile_options(${EXECUTABLE_RECOVERY_NAME} PUBLIC
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3 -fno-rtti>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os -fno-rtti>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -x assembler-with-cpp>
)
@@ -895,10 +902,10 @@ target_link_libraries(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} nimble nrf-sdk)
set_target_properties(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME})
target_compile_definitions(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC "PINETIME_IS_RECOVERY")
target_compile_options(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3 -fno-rtti>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os -fno-rtti>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -x assembler-with-cpp>
)
@@ -932,10 +939,10 @@ add_executable(${EXECUTABLE_RECOVERYLOADER_NAME} ${RECOVERYLOADER_SOURCE_FILES})
target_link_libraries(${EXECUTABLE_RECOVERYLOADER_NAME} nrf-sdk)
set_target_properties(${EXECUTABLE_RECOVERYLOADER_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERYLOADER_FILE_NAME})
target_compile_options(${EXECUTABLE_RECOVERYLOADER_NAME} PUBLIC
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3 -fno-rtti>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os -fno-rtti>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -x assembler-with-cpp>
)
target_include_directories(${EXECUTABLE_RECOVERYLOADER_NAME} PUBLIC
@@ -965,10 +972,10 @@ add_executable(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} ${RECOVERYLOADER_SOURCE
target_link_libraries(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} nrf-sdk)
set_target_properties(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME})
target_compile_options(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PUBLIC
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3 -fno-rtti>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os -fno-rtti>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -x assembler-with-cpp>
)
target_include_directories(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PUBLIC
diff --git a/src/FreeRTOS/port_cmsis.c b/src/FreeRTOS/port_cmsis.c
index d8850b52..0ccf2e27 100644
--- a/src/FreeRTOS/port_cmsis.c
+++ b/src/FreeRTOS/port_cmsis.c
@@ -294,6 +294,25 @@ static void vPortEnableVFP( void )
}
/*-----------------------------------------------------------*/
+uint32_t ulSetInterruptMaskFromISR( void )
+{
+ __asm volatile (
+ " mrs r0, PRIMASK \n"
+ " cpsid i \n"
+ " bx lr "
+ ::: "memory"
+ );
+}
+
+void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask )
+{
+ __asm volatile (
+ " msr PRIMASK, r0 \n"
+ " bx lr "
+ ::: "memory"
+ );
+}
+
#if ( configASSERT_DEFINED == 1 )
void vPortValidateInterruptPriority( void )
@@ -354,24 +373,4 @@ static void vPortEnableVFP( void )
configASSERT( NVIC_GetPriorityGrouping() <= ulMaxPRIGROUPValue );
}
-uint32_t ulSetInterruptMaskFromISR( void )
-{
- __asm volatile (
- " mrs r0, PRIMASK \n"
- " cpsid i \n"
- " bx lr "
- ::: "memory"
- );
-}
-/*-----------------------------------------------------------*/
-
-void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask )
-{
- __asm volatile (
- " msr PRIMASK, r0 \n"
- " bx lr "
- ::: "memory"
- );
-}
-
#endif /* configASSERT_DEFINED */
diff --git a/src/FreeRTOSConfig.h b/src/FreeRTOSConfig.h
index 15185766..07c152dc 100644
--- a/src/FreeRTOSConfig.h
+++ b/src/FreeRTOSConfig.h
@@ -62,7 +62,7 @@
#define configTICK_RATE_HZ 1024
#define configMAX_PRIORITIES (3)
#define configMINIMAL_STACK_SIZE (120)
-#define configTOTAL_HEAP_SIZE (1024 * 16)
+#define configTOTAL_HEAP_SIZE (1024 * 17)
#define configMAX_TASK_NAME_LEN (4)
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
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/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp
index b39efefb..bc146457 100644
--- a/src/components/battery/BatteryController.cpp
+++ b/src/components/battery/BatteryController.cpp
@@ -15,7 +15,6 @@ Battery::Battery() {
void Battery::Init() {
nrf_gpio_cfg_input(chargingPin, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup);
- nrf_gpio_cfg_input(powerPresentPin, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup);
}
void Battery::Update() {
diff --git a/src/components/ble/AlertNotificationClient.cpp b/src/components/ble/AlertNotificationClient.cpp
index 6043a129..c3d1d69a 100644
--- a/src/components/ble/AlertNotificationClient.cpp
+++ b/src/components/ble/AlertNotificationClient.cpp
@@ -159,7 +159,7 @@ void AlertNotificationClient::OnNotification(ble_gap_event* event) {
notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
notificationManager.Push(std::move(notif));
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification);
+ systemTask.PushMessage(Pinetime::System::Messages::OnNewNotification);
}
}
diff --git a/src/components/ble/AlertNotificationService.cpp b/src/components/ble/AlertNotificationService.cpp
index e9f5941e..d5fc7f65 100644
--- a/src/components/ble/AlertNotificationService.cpp
+++ b/src/components/ble/AlertNotificationService.cpp
@@ -79,7 +79,7 @@ int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle
break;
}
- auto event = Pinetime::System::SystemTask::Messages::OnNewNotification;
+ auto event = Pinetime::System::Messages::OnNewNotification;
notificationManager.Push(std::move(notif));
systemTask.PushMessage(event);
}
diff --git a/src/components/ble/DfuService.cpp b/src/components/ble/DfuService.cpp
index 2031668e..cec194cc 100644
--- a/src/components/ble/DfuService.cpp
+++ b/src/components/ble/DfuService.cpp
@@ -205,7 +205,7 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) {
bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Running);
bleController.FirmwareUpdateTotalBytes(0xffffffffu);
bleController.FirmwareUpdateCurrentBytes(0);
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleFirmwareUpdateStarted);
+ systemTask.PushMessage(Pinetime::System::Messages::BleFirmwareUpdateStarted);
return 0;
} else {
NRF_LOG_INFO("[DFU] -> Start DFU, mode %d not supported!", imageType);
@@ -279,7 +279,7 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) {
}
NRF_LOG_INFO("[DFU] -> Activate image and reset!");
bleController.StopFirmwareUpdate();
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleFirmwareUpdateFinished);
+ systemTask.PushMessage(Pinetime::System::Messages::BleFirmwareUpdateFinished);
Reset();
bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated);
return 0;
@@ -304,7 +304,7 @@ void DfuService::Reset() {
notificationManager.Reset();
bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error);
bleController.StopFirmwareUpdate();
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleFirmwareUpdateFinished);
+ systemTask.PushMessage(Pinetime::System::Messages::BleFirmwareUpdateFinished);
}
DfuService::NotificationManager::NotificationManager() {
diff --git a/src/components/ble/ImmediateAlertService.cpp b/src/components/ble/ImmediateAlertService.cpp
index fd6430af..820d3b6e 100644
--- a/src/components/ble/ImmediateAlertService.cpp
+++ b/src/components/ble/ImmediateAlertService.cpp
@@ -67,7 +67,7 @@ int ImmediateAlertService::OnAlertLevelChanged(uint16_t connectionHandle, uint16
notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
notificationManager.Push(std::move(notif));
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification);
+ systemTask.PushMessage(Pinetime::System::Messages::OnNewNotification);
}
}
diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp
index 67a6d691..2c1d0f99 100644
--- a/src/components/ble/NimbleController.cpp
+++ b/src/components/ble/NimbleController.cpp
@@ -149,7 +149,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
bleController.Disconnect();
} else {
bleController.Connect();
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleConnected);
+ systemTask.PushMessage(Pinetime::System::Messages::BleConnected);
connectionHandle = event->connect.conn_handle;
// Service discovery is deffered via systemtask
}
diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp
index 4f9302eb..28a70abc 100644
--- a/src/components/datetime/DateTimeController.cpp
+++ b/src/components/datetime/DateTimeController.cpp
@@ -5,9 +5,6 @@
using namespace Pinetime::Controllers;
-DateTime::DateTime(System::SystemTask& systemTask) : systemTask {systemTask} {
-}
-
void DateTime::SetTime(
uint16_t year, uint8_t month, uint8_t day, uint8_t dayOfWeek, uint8_t hour, uint8_t minute, uint8_t second, uint32_t systickCounter) {
std::tm tm = {
@@ -70,7 +67,8 @@ void DateTime::UpdateTime(uint32_t systickCounter) {
// Notify new day to SystemTask
if (hour == 0 and not isMidnightAlreadyNotified) {
isMidnightAlreadyNotified = true;
- systemTask.PushMessage(System::SystemTask::Messages::OnNewDay);
+ if(systemTask != nullptr)
+ systemTask->PushMessage(System::Messages::OnNewDay);
} else if (hour != 0) {
isMidnightAlreadyNotified = false;
}
@@ -104,6 +102,10 @@ const char* DateTime::DayOfWeekShortToStringLow() {
return DateTime::DaysStringShortLow[(uint8_t) dayOfWeek];
}
+void DateTime::Register(Pinetime::System::SystemTask* systemTask) {
+ this->systemTask = systemTask;
+}
+
char const* DateTime::DaysStringLow[] = {"--", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
char const* DateTime::DaysStringShortLow[] = {"--", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
diff --git a/src/components/datetime/DateTimeController.h b/src/components/datetime/DateTimeController.h
index d0ae727e..265d6e9d 100644
--- a/src/components/datetime/DateTimeController.h
+++ b/src/components/datetime/DateTimeController.h
@@ -27,8 +27,6 @@ namespace Pinetime {
December
};
- DateTime(System::SystemTask& systemTask);
-
void SetTime(uint16_t year,
uint8_t month,
uint8_t day,
@@ -75,8 +73,9 @@ namespace Pinetime {
return uptime;
}
+ void Register(System::SystemTask* systemTask);
+
private:
- System::SystemTask& systemTask;
uint16_t year = 0;
Months month = Months::Unknown;
uint8_t day = 0;
@@ -90,6 +89,7 @@ namespace Pinetime {
std::chrono::seconds uptime {0};
bool isMidnightAlreadyNotified = false;
+ System::SystemTask* systemTask = nullptr;
static char const* DaysString[];
static char const* DaysStringShort[];
diff --git a/src/components/heartrate/HeartRateController.cpp b/src/components/heartrate/HeartRateController.cpp
index e84d665a..716813b3 100644
--- a/src/components/heartrate/HeartRateController.cpp
+++ b/src/components/heartrate/HeartRateController.cpp
@@ -4,9 +4,6 @@
using namespace Pinetime::Controllers;
-HeartRateController::HeartRateController(Pinetime::System::SystemTask& systemTask) : systemTask {systemTask} {
-}
-
void HeartRateController::Update(HeartRateController::States newState, uint8_t heartRate) {
this->state = newState;
if (this->heartRate != heartRate) {
diff --git a/src/components/heartrate/HeartRateController.h b/src/components/heartrate/HeartRateController.h
index d3a8460d..a63f1a70 100644
--- a/src/components/heartrate/HeartRateController.h
+++ b/src/components/heartrate/HeartRateController.h
@@ -15,8 +15,7 @@ namespace Pinetime {
public:
enum class States { Stopped, NotEnoughData, NoTouch, Running };
- explicit HeartRateController(System::SystemTask& systemTask);
-
+ HeartRateController() = default;
void Start();
void Stop();
void Update(States newState, uint8_t heartRate);
@@ -32,7 +31,6 @@ namespace Pinetime {
void SetService(Pinetime::Controllers::HeartRateService* service);
private:
- System::SystemTask& systemTask;
Applications::HeartRateTask* task = nullptr;
States state = States::Stopped;
uint8_t heartRate = 0;
diff --git a/src/components/heartrate/Ppg.cpp b/src/components/heartrate/Ppg.cpp
index da0789e0..fcba3815 100644
--- a/src/components/heartrate/Ppg.cpp
+++ b/src/components/heartrate/Ppg.cpp
@@ -38,9 +38,8 @@ namespace {
}
}
-Ppg::Ppg(float spl)
- : offset {spl},
- hpf {0.87033078, -1.74066156, 0.87033078, -1.72377617, 0.75754694},
+Ppg::Ppg()
+ : hpf {0.87033078, -1.74066156, 0.87033078, -1.72377617, 0.75754694},
agc {20, 0.971, 2},
lpf {0.11595249, 0.23190498, 0.11595249, -0.72168143, 0.18549138} {
}
@@ -67,13 +66,7 @@ float Ppg::HeartRate() {
dataIndex = 0;
return hr;
}
-
-int cccount = 0;
float Ppg::ProcessHeartRate() {
-
- if (cccount > 2)
- asm("nop");
- cccount++;
auto t0 = Trough(data.data(), dataIndex, 7, 48);
if (t0 < 0)
return 0;
diff --git a/src/components/heartrate/Ppg.h b/src/components/heartrate/Ppg.h
index ee07dfcf..00014162 100644
--- a/src/components/heartrate/Ppg.h
+++ b/src/components/heartrate/Ppg.h
@@ -8,8 +8,7 @@ namespace Pinetime {
namespace Controllers {
class Ppg {
public:
- explicit Ppg(float spl);
-
+ Ppg();
int8_t Preprocess(float spl);
float HeartRate();
diff --git a/src/components/motor/MotorController.cpp b/src/components/motor/MotorController.cpp
index a834ab6b..3afa0ced 100644
--- a/src/components/motor/MotorController.cpp
+++ b/src/components/motor/MotorController.cpp
@@ -13,7 +13,6 @@ MotorController::MotorController(Controllers::Settings& settingsController) : se
void MotorController::Init() {
nrf_gpio_cfg_output(pinMotor);
nrf_gpio_pin_set(pinMotor);
- app_timer_init();
app_timer_create(&vibTimer, APP_TIMER_MODE_SINGLE_SHOT, vibrate);
}
diff --git a/src/components/timer/TimerController.cpp b/src/components/timer/TimerController.cpp
new file mode 100644
index 00000000..8d5f5c33
--- /dev/null
+++ b/src/components/timer/TimerController.cpp
@@ -0,0 +1,69 @@
+//
+// Created by florian on 16.05.21.
+//
+
+#include "TimerController.h"
+#include "systemtask/SystemTask.h"
+#include "app_timer.h"
+#include "task.h"
+
+using namespace Pinetime::Controllers;
+
+
+APP_TIMER_DEF(timerAppTimer);
+
+namespace {
+ void TimerEnd(void* p_context) {
+ auto* controller = static_cast<Pinetime::Controllers::TimerController*> (p_context);
+ if(controller != nullptr)
+ controller->OnTimerEnd();
+ }
+}
+
+
+void TimerController::Init() {
+ app_timer_create(&timerAppTimer, APP_TIMER_MODE_SINGLE_SHOT, TimerEnd);
+}
+
+void TimerController::StartTimer(uint32_t duration) {
+ app_timer_stop(timerAppTimer);
+ auto currentTicks = xTaskGetTickCount();
+ app_timer_start(timerAppTimer, APP_TIMER_TICKS(duration), this);
+ endTicks = currentTicks + APP_TIMER_TICKS(duration);
+ timerRunning = true;
+}
+
+uint32_t TimerController::GetTimeRemaining() {
+ if (!timerRunning) {
+ return 0;
+ }
+ auto currentTicks = xTaskGetTickCount();
+
+ TickType_t deltaTicks = 0;
+ if (currentTicks > endTicks) {
+ deltaTicks = 0xffffffff - currentTicks;
+ deltaTicks += (endTicks + 1);
+ } else {
+ deltaTicks = endTicks - currentTicks;
+ }
+
+ return (static_cast<TickType_t>(deltaTicks) / static_cast<TickType_t>(configTICK_RATE_HZ)) * 1000;
+}
+
+void TimerController::StopTimer() {
+ app_timer_stop(timerAppTimer);
+ timerRunning = false;
+}
+
+bool TimerController::IsRunning() {
+ return timerRunning;
+}
+void TimerController::OnTimerEnd() {
+ timerRunning = false;
+ if(systemTask != nullptr)
+ systemTask->PushMessage(System::Messages::OnTimerDone);
+}
+
+void TimerController::Register(Pinetime::System::SystemTask* systemTask) {
+ this->systemTask = systemTask;
+}
diff --git a/src/components/timer/TimerController.h b/src/components/timer/TimerController.h
new file mode 100644
index 00000000..fa7bc90d
--- /dev/null
+++ b/src/components/timer/TimerController.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include <cstdint>
+#include "app_timer.h"
+#include "portmacro_cmsis.h"
+
+namespace Pinetime {
+ namespace System {
+ class SystemTask;
+ }
+ namespace Controllers {
+
+ class TimerController {
+ public:
+ TimerController() = default;
+
+ void Init();
+
+ void StartTimer(uint32_t duration);
+
+ void StopTimer();
+
+ uint32_t GetTimeRemaining();
+
+ bool IsRunning();
+
+ void OnTimerEnd();
+
+ void Register(System::SystemTask* systemTask);
+
+ private:
+ System::SystemTask* systemTask = nullptr;
+ TickType_t endTicks;
+ bool timerRunning = false;
+ };
+ }
+} \ No newline at end of file
diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h
index 09a20181..2df517f8 100644
--- a/src/displayapp/Apps.h
+++ b/src/displayapp/Apps.h
@@ -11,6 +11,7 @@ namespace Pinetime {
FirmwareValidation,
NotificationsPreview,
Notifications,
+ Timer,
FlashLight,
BatteryInfo,
Music,
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index a6c4a3ec..01e26e22 100644
--- a/src/displayapp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -2,6 +2,7 @@
#include <libraries/log/nrf_log.h>
#include <displayapp/screens/HeartRate.h>
#include <displayapp/screens/Motion.h>
+#include <displayapp/screens/Timer.h>
#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
#include "components/datetime/DateTimeController.h"
@@ -31,6 +32,7 @@
#include "drivers/St7789.h"
#include "drivers/Watchdog.h"
#include "systemtask/SystemTask.h"
+#include "systemtask/Messages.h"
#include "displayapp/screens/settings/QuickSettings.h"
#include "displayapp/screens/settings/Settings.h"
@@ -43,6 +45,12 @@
using namespace Pinetime::Applications;
using namespace Pinetime::Applications::Display;
+namespace {
+ static inline bool in_isr(void) {
+ return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
+ }
+}
+
DisplayApp::DisplayApp(Drivers::St7789& lcd,
Components::LittleVgl& lvgl,
Drivers::Cst816S& touchPanel,
@@ -50,12 +58,12 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController,
Drivers::WatchdogView& watchdog,
- System::SystemTask& systemTask,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::HeartRateController& heartRateController,
Controllers::Settings& settingsController,
Pinetime::Controllers::MotorController& motorController,
- Pinetime::Controllers::MotionController& motionController)
+ Pinetime::Controllers::MotionController& motionController,
+ Pinetime::Controllers::TimerController& timerController)
: lcd {lcd},
lvgl {lvgl},
touchPanel {touchPanel},
@@ -63,18 +71,20 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
bleController {bleController},
dateTimeController {dateTimeController},
watchdog {watchdog},
- systemTask {systemTask},
notificationManager {notificationManager},
heartRateController {heartRateController},
settingsController {settingsController},
motorController {motorController},
- motionController {motionController} {
+ motionController {motionController},
+ timerController {timerController} {
+}
+
+void DisplayApp::Start() {
msgQueue = xQueueCreate(queueSize, itemSize);
+
// Start clock when smartwatch boots
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None);
-}
-void DisplayApp::Start() {
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) {
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
@@ -127,7 +137,7 @@ void DisplayApp::Refresh() {
vTaskDelay(100);
}
lcd.DisplayOff();
- systemTask.PushMessage(System::SystemTask::Messages::OnDisplayTaskSleeping);
+ PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping);
state = States::Idle;
break;
case Messages::GoToRunning:
@@ -136,7 +146,7 @@ void DisplayApp::Refresh() {
state = States::Running;
break;
case Messages::UpdateTimeOut:
- systemTask.PushMessage(System::SystemTask::Messages::UpdateTimeOut);
+ PushMessageToSystemTask(System::Messages::UpdateTimeOut);
break;
case Messages::UpdateBleConnection:
// clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected :
@@ -148,6 +158,14 @@ void DisplayApp::Refresh() {
case Messages::NewNotification:
LoadApp(Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down);
break;
+ case Messages::TimerDone:
+ if (currentApp == Apps::Timer) {
+ auto *timer = static_cast<Screens::Timer*>(currentScreen.get());
+ timer->setDone();
+ } else {
+ LoadApp(Apps::Timer, DisplayApp::FullRefreshDirections::Down);
+ }
+ break;
case Messages::TouchEvent: {
if (state != States::Running)
break;
@@ -165,7 +183,7 @@ void DisplayApp::Refresh() {
LoadApp(Apps::QuickSettings, DisplayApp::FullRefreshDirections::RightAnim);
break;
case TouchEvents::DoubleTap:
- systemTask.PushMessage(System::SystemTask::Messages::GoToSleep);
+ PushMessageToSystemTask(System::Messages::GoToSleep);
break;
default:
break;
@@ -177,7 +195,7 @@ void DisplayApp::Refresh() {
} break;
case Messages::ButtonPushed:
if (currentApp == Apps::Clock) {
- systemTask.PushMessage(System::SystemTask::Messages::GoToSleep);
+ PushMessageToSystemTask(System::Messages::GoToSleep);
} else {
if (!currentScreen->OnButtonPushed()) {
LoadApp(returnToApp, returnDirection);
@@ -195,6 +213,11 @@ void DisplayApp::Refresh() {
}
}
+ if(nextApp != Apps::None) {
+ LoadApp(nextApp, nextDirection);
+ nextApp = Apps::None;
+ }
+
if (state != States::Idle && touchMode == TouchModes::Polling) {
auto info = touchPanel.GetTouchInfo();
if (info.action == 2) { // 2 = contact
@@ -213,7 +236,8 @@ void DisplayApp::RunningState() {
}
void DisplayApp::StartApp(Apps app, DisplayApp::FullRefreshDirections direction) {
- LoadApp(app, direction);
+ nextApp = app;
+ nextDirection = direction;
}
void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent) {
@@ -256,14 +280,17 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
case Apps::Notifications:
currentScreen = std::make_unique<Screens::Notifications>(
- this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Normal);
+ this, notificationManager, systemTask->nimble().alertService(), Screens::Notifications::Modes::Normal);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break;
case Apps::NotificationsPreview:
currentScreen = std::make_unique<Screens::Notifications>(
- this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Preview);
+ this, notificationManager, systemTask->nimble().alertService(), Screens::Notifications::Modes::Preview);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break;
+ case Apps::Timer:
+ currentScreen = std::make_unique<Screens::Timer>(this, timerController);
+ break;
// Settings
case Apps::QuickSettings:
@@ -304,10 +331,8 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
std::make_unique<Screens::SystemInfo>(this, dateTimeController, batteryController, brightnessController, bleController, watchdog);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
- //
-
case Apps::FlashLight:
- currentScreen = std::make_unique<Screens::FlashLight>(this, systemTask, brightnessController);
+ currentScreen = std::make_unique<Screens::FlashLight>(this, *systemTask, brightnessController);
ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None);
break;
case Apps::StopWatch:
@@ -323,13 +348,13 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
currentScreen = std::make_unique<Screens::Paddle>(this, lvgl);
break;
case Apps::Music:
- currentScreen = std::make_unique<Screens::Music>(this, systemTask.nimble().music());
+ currentScreen = std::make_unique<Screens::Music>(this, systemTask->nimble().music());
break;
case Apps::Navigation:
- currentScreen = std::make_unique<Screens::Navigation>(this, systemTask.nimble().navigation());
+ currentScreen = std::make_unique<Screens::Navigation>(this, systemTask->nimble().navigation());
break;
case Apps::HeartRate:
- currentScreen = std::make_unique<Screens::HeartRate>(this, heartRateController, systemTask);
+ currentScreen = std::make_unique<Screens::HeartRate>(this, heartRateController, *systemTask);
break;
case Apps::Motion:
currentScreen = std::make_unique<Screens::Motion>(this, motionController);
@@ -345,12 +370,15 @@ void DisplayApp::IdleState() {
}
void DisplayApp::PushMessage(Messages msg) {
- BaseType_t xHigherPriorityTaskWoken;
- xHigherPriorityTaskWoken = pdFALSE;
- xQueueSendFromISR(msgQueue, &msg, &xHigherPriorityTaskWoken);
- if (xHigherPriorityTaskWoken) {
- /* Actual macro used here is port specific. */
- // TODO : should I do something here?
+ if(in_isr()) {
+ BaseType_t xHigherPriorityTaskWoken;
+ xHigherPriorityTaskWoken = pdFALSE;
+ xQueueSendFromISR(msgQueue, &msg, &xHigherPriorityTaskWoken);
+ if (xHigherPriorityTaskWoken) {
+ portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
+ }
+ } else {
+ xQueueSend(msgQueue, &msg, portMAX_DELAY);
}
}
@@ -411,3 +439,12 @@ void DisplayApp::SetFullRefresh(DisplayApp::FullRefreshDirections direction) {
void DisplayApp::SetTouchMode(DisplayApp::TouchModes mode) {
touchMode = mode;
}
+
+void DisplayApp::PushMessageToSystemTask(Pinetime::System::Messages message) {
+ if(systemTask != nullptr)
+ systemTask->PushMessage(message);
+}
+
+void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) {
+ this->systemTask = systemTask;
+}
diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h
index ffe27cf1..73a7cc36 100644
--- a/src/displayapp/DisplayApp.h
+++ b/src/displayapp/DisplayApp.h
@@ -4,6 +4,7 @@
#include <queue.h>
#include <task.h>
#include <memory>
+#include <systemtask/Messages.h>
#include "Apps.h"
#include "LittleVgl.h"
#include "TouchEvents.h"
@@ -12,6 +13,7 @@
#include "components/firmwarevalidator/FirmwareValidator.h"
#include "components/settings/Settings.h"
#include "displayapp/screens/Screen.h"
+#include "components/timer/TimerController.h"
#include "Messages.h"
namespace Pinetime {
@@ -48,12 +50,12 @@ namespace Pinetime {
Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController,
Drivers::WatchdogView& watchdog,
- System::SystemTask& systemTask,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::HeartRateController& heartRateController,
Controllers::Settings& settingsController,
Pinetime::Controllers::MotorController& motorController,
- Pinetime::Controllers::MotionController& motionController);
+ Pinetime::Controllers::MotionController& motionController,
+ Pinetime::Controllers::TimerController& timerController);
void Start();
void PushMessage(Display::Messages msg);
@@ -62,6 +64,8 @@ namespace Pinetime {
void SetFullRefresh(FullRefreshDirections direction);
void SetTouchMode(TouchModes mode);
+ void Register(Pinetime::System::SystemTask* systemTask);
+
private:
Pinetime::Drivers::St7789& lcd;
Pinetime::Components::LittleVgl& lvgl;
@@ -70,12 +74,13 @@ namespace Pinetime {
Pinetime::Controllers::Ble& bleController;
Pinetime::Controllers::DateTime& dateTimeController;
Pinetime::Drivers::WatchdogView& watchdog;
- Pinetime::System::SystemTask& systemTask;
+ Pinetime::System::SystemTask* systemTask = nullptr;
Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::HeartRateController& heartRateController;
Pinetime::Controllers::Settings& settingsController;
Pinetime::Controllers::MotorController& motorController;
Pinetime::Controllers::MotionController& motionController;
+ Pinetime::Controllers::TimerController& timerController;
Pinetime::Controllers::FirmwareValidator validator;
Controllers::BrightnessController brightnessController;
@@ -105,6 +110,10 @@ namespace Pinetime {
void Refresh();
void ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent);
void LoadApp(Apps app, DisplayApp::FullRefreshDirections direction);
+ void PushMessageToSystemTask(Pinetime::System::Messages message);
+
+ Apps nextApp = Apps::None;
+ DisplayApp::FullRefreshDirections nextDirection;
};
}
}
diff --git a/src/displayapp/DisplayAppRecovery.cpp b/src/displayapp/DisplayAppRecovery.cpp
index a132a47c..fd517b11 100644
--- a/src/displayapp/DisplayAppRecovery.cpp
+++ b/src/displayapp/DisplayAppRecovery.cpp
@@ -14,17 +14,18 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController,
Drivers::WatchdogView& watchdog,
- System::SystemTask& systemTask,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::HeartRateController& heartRateController,
- Pinetime::Controllers::Settings& settingsController,
+ Controllers::Settings& settingsController,
Pinetime::Controllers::MotorController& motorController,
- Pinetime::Controllers::MotionController& motionController)
+ Pinetime::Controllers::MotionController& motionController,
+ Pinetime::Controllers::TimerController& timerController)
: lcd {lcd}, bleController {bleController} {
- msgQueue = xQueueCreate(queueSize, itemSize);
+
}
void DisplayApp::Start() {
+ msgQueue = xQueueCreate(queueSize, itemSize);
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 512, this, 0, &taskHandle))
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
@@ -112,4 +113,8 @@ void DisplayApp::PushMessage(Display::Messages msg) {
/* Actual macro used here is port specific. */
// TODO : should I do something here?
}
-} \ No newline at end of file
+}
+
+void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) {
+
+}
diff --git a/src/displayapp/DisplayAppRecovery.h b/src/displayapp/DisplayAppRecovery.h
index 30b8e0a1..638c0071 100644
--- a/src/displayapp/DisplayAppRecovery.h
+++ b/src/displayapp/DisplayAppRecovery.h
@@ -23,6 +23,7 @@
#include "Apps.h"
#include "Messages.h"
#include "DummyLittleVgl.h"
+#include "components/timer/TimerController.h"
namespace Pinetime {
namespace System {
@@ -38,14 +39,15 @@ namespace Pinetime {
Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController,
Drivers::WatchdogView& watchdog,
- System::SystemTask& systemTask,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::HeartRateController& heartRateController,
- Pinetime::Controllers::Settings& settingsController,
+ Controllers::Settings& settingsController,
Pinetime::Controllers::MotorController& motorController,
- Pinetime::Controllers::MotionController& motionController);
+ Pinetime::Controllers::MotionController& motionController,
+ Pinetime::Controllers::TimerController& timerController);
void Start();
void PushMessage(Pinetime::Applications::Display::Messages msg);
+ void Register(Pinetime::System::SystemTask* systemTask);
private:
TaskHandle_t taskHandle;
diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp
index 36df51b4..c069afa2 100644
--- a/src/displayapp/LittleVgl.cpp
+++ b/src/displayapp/LittleVgl.cpp
@@ -23,6 +23,10 @@ bool touchpad_read(lv_indev_drv_t* indev_drv, lv_indev_data_t* data) {
LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel)
: lcd {lcd}, touchPanel {touchPanel}, previousClick {0, 0} {
+
+}
+
+void LittleVgl::Init() {
lv_init();
InitTheme();
InitDisplay();
diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h
index 7f7b76e0..41f934a7 100644
--- a/src/displayapp/LittleVgl.h
+++ b/src/displayapp/LittleVgl.h
@@ -19,6 +19,8 @@ namespace Pinetime {
LittleVgl(LittleVgl&&) = delete;
LittleVgl& operator=(LittleVgl&&) = delete;
+ void Init();
+
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p);
bool GetTouchPadInfo(lv_indev_data_t* ptr);
void SetFullRefresh(FullRefreshDirections direction);
diff --git a/src/displayapp/Messages.h b/src/displayapp/Messages.h
index 81871c54..ce65f846 100644
--- a/src/displayapp/Messages.h
+++ b/src/displayapp/Messages.h
@@ -11,6 +11,7 @@ namespace Pinetime {
TouchEvent,
ButtonPushed,
NewNotification,
+ TimerDone,
BleFirmwareUpdateStarted,
UpdateTimeOut
};
diff --git a/src/displayapp/fonts/README.md b/src/displayapp/fonts/README.md
index f43e9c52..183ad7e4 100644
--- a/src/displayapp/fonts/README.md
+++ b/src/displayapp/fonts/README.md
@@ -12,7 +12,7 @@
* Do not enable font compression and horizontal subpixel hinting
* Load the file `JetBrainsMono-Bold.tff` and specify the following range : `0x20-0x7f, 0x410-0x44f`
* Add a 2nd font, load the file `FontAwesome5-Solid+Brands+Regular.woff` and specify the following
- range : `0xf293, 0xf294, 0xf244, 0xf240, 0xf242, 0xf243, 0xf241, 0xf54b, 0xf21e, 0xf1e6, 0xf54b, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf069, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf029, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024`
+ range : `0xf293, 0xf294, 0xf244, 0xf240, 0xf242, 0xf243, 0xf241, 0xf54b, 0xf21e, 0xf1e6, 0xf54b, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf069, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf029, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252`
* Click on Convert, and download the file `jetbrains_mono_bold_20.c` and copy it in `src/DisplayApp/Fonts`
Add new symbols:
diff --git a/src/displayapp/fonts/jetbrains_mono_bold_20.c b/src/displayapp/fonts/jetbrains_mono_bold_20.c
index f4050db8..9174ff48 100644
--- a/src/displayapp/fonts/jetbrains_mono_bold_20.c
+++ b/src/displayapp/fonts/jetbrains_mono_bold_20.c
@@ -900,6 +900,13 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t gylph_bitmap[] = {
0x7, 0xe0, 0x0, 0x7, 0xf0, 0x0, 0x3, 0xff,
0xff, 0xff, 0xcf, 0xff, 0xff, 0xe0,
+ /* U+F252 "" */
+ 0xff, 0xff, 0xff, 0xfd, 0x80, 0x33, 0x80, 0xe7,
+ 0xff, 0xc7, 0xff, 0xf, 0xfe, 0xf, 0xf8, 0xf,
+ 0xe0, 0xf, 0x80, 0x7f, 0xc0, 0xe3, 0x83, 0x83,
+ 0x86, 0x3, 0x1f, 0xff, 0x3f, 0xfe, 0x7f, 0xfd,
+ 0xff, 0xff, 0xff, 0xf8,
+
/* U+F293 "" */
0x7, 0xe0, 0x3f, 0xe0, 0xfb, 0xe3, 0xf3, 0xe7,
0xe3, 0xdf, 0xd3, 0xf9, 0xb3, 0xf9, 0x4f, 0xf8,
@@ -1184,17 +1191,18 @@ static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
{.bitmap_index = 3380, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
{.bitmap_index = 3418, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
{.bitmap_index = 3456, .adv_w = 400, .box_w = 25, .box_h = 12, .ofs_x = 0, .ofs_y = 1},
- {.bitmap_index = 3494, .adv_w = 280, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 3532, .adv_w = 200, .box_w = 11, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 3561, .adv_w = 280, .box_w = 16, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 3599, .adv_w = 400, .box_w = 25, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 3665, .adv_w = 360, .box_w = 23, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 3714, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 3764, .adv_w = 400, .box_w = 25, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 3824, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 3877, .adv_w = 360, .box_w = 22, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 3932, .adv_w = 360, .box_w = 22, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 3985, .adv_w = 320, .box_w = 20, .box_h = 15, .ofs_x = 0, .ofs_y = 0}
+ {.bitmap_index = 3494, .adv_w = 240, .box_w = 15, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 3530, .adv_w = 280, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 3568, .adv_w = 200, .box_w = 11, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 3597, .adv_w = 280, .box_w = 16, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 3635, .adv_w = 400, .box_w = 25, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 3701, .adv_w = 360, .box_w = 23, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 3750, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 3800, .adv_w = 400, .box_w = 25, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 3860, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 3913, .adv_w = 360, .box_w = 22, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 3968, .adv_w = 360, .box_w = 22, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 4021, .adv_w = 320, .box_w = 20, .box_h = 15, .ofs_x = 0, .ofs_y = 0}
};
/*---------------------
@@ -1205,8 +1213,8 @@ static const uint16_t unicode_list_2[] = {
0x0, 0x16, 0x23, 0x26, 0x27, 0x28, 0x39, 0x47,
0x4a, 0x4b, 0x4c, 0x50, 0x68, 0x94, 0x128, 0x184,
0x1e5, 0x1fb, 0x21d, 0x23f, 0x240, 0x241, 0x242, 0x243,
- 0x292, 0x293, 0x2f1, 0x3dc, 0x3fc, 0x45c, 0x54a, 0x55f,
- 0x59e, 0x59f, 0x6a8
+ 0x251, 0x292, 0x293, 0x2f1, 0x3dc, 0x3fc, 0x45c, 0x54a,
+ 0x55f, 0x59e, 0x59f, 0x6a8
};
/*Collect the unicode lists and glyph_id offsets*/
@@ -1222,7 +1230,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
},
{
.range_start = 61441, .range_length = 1705, .glyph_id_start = 160,
- .unicode_list = unicode_list_2, .glyph_id_ofs_list = NULL, .list_length = 35, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
+ .unicode_list = unicode_list_2, .glyph_id_ofs_list = NULL, .list_length = 36, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
}
};
diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp
index 1eb36999..d599f5cc 100644
--- a/src/displayapp/screens/ApplicationList.cpp
+++ b/src/displayapp/screens/ApplicationList.cpp
@@ -51,7 +51,7 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen1() {
{Symbols::map, Apps::Navigation},
{Symbols::shoe, Apps::Steps},
{Symbols::heartBeat, Apps::HeartRate},
- {"", Apps::None},
+ {Symbols::hourGlass, Apps::Timer},
}};
return std::make_unique<Screens::Tile>(0, 2, app, settingsController, batteryController, dateTimeController, applications);
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/FlashLight.cpp b/src/displayapp/screens/FlashLight.cpp
index 4568db40..7db2c6c8 100644
--- a/src/displayapp/screens/FlashLight.cpp
+++ b/src/displayapp/screens/FlashLight.cpp
@@ -39,14 +39,14 @@ FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
backgroundAction->user_data = this;
lv_obj_set_event_cb(backgroundAction, event_handler);
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::DisableSleeping);
+ systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
}
FlashLight::~FlashLight() {
lv_obj_clean(lv_scr_act());
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
brightness.Restore();
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::EnableSleeping);
+ systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
}
void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) {
diff --git a/src/displayapp/screens/HeartRate.cpp b/src/displayapp/screens/HeartRate.cpp
index 90f6bc26..5689b63e 100644
--- a/src/displayapp/screens/HeartRate.cpp
+++ b/src/displayapp/screens/HeartRate.cpp
@@ -63,12 +63,12 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
label_startStop = lv_label_create(btn_startStop, nullptr);
UpdateStartStopButton(isHrRunning);
if (isHrRunning)
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::DisableSleeping);
+ systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
}
HeartRate::~HeartRate() {
lv_obj_clean(lv_scr_act());
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::EnableSleeping);
+ systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
}
bool HeartRate::Refresh() {
@@ -95,12 +95,12 @@ void HeartRate::OnStartStopEvent(lv_event_t event) {
if (heartRateController.State() == Controllers::HeartRateController::States::Stopped) {
heartRateController.Start();
UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped);
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::DisableSleeping);
+ systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
} else {
heartRateController.Stop();
UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped);
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::EnableSleeping);
+ systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
}
}
diff --git a/src/displayapp/screens/Navigation.cpp b/src/displayapp/screens/Navigation.cpp
index b5ce8b83..79b04e21 100644
--- a/src/displayapp/screens/Navigation.cpp
+++ b/src/displayapp/screens/Navigation.cpp
@@ -24,6 +24,106 @@ using namespace Pinetime::Applications::Screens;
LV_FONT_DECLARE(lv_font_navi_80)
+namespace {
+ constexpr std::array<std::pair<const char*, const char*>, 86> m_iconMap = {{
+ {"arrive-left", "\xEE\xA4\x81"},
+ {"arrive-right", "\xEE\xA4\x82"},
+ {"arrive-straight", "\xEE\xA4\x80"},
+ {"arrive", "\xEE\xA4\x80"},
+ {"close", "\xEE\xA4\x83"},
+ {"continue-left", "\xEE\xA4\x85"},
+ {"continue-right", "\xEE\xA4\x86"},
+ {"continue-slight-left", "\xEE\xA4\x87"},
+ {"continue-slight-right", "\xEE\xA4\x88"},
+ {"continue-straight", "\xEE\xA4\x84"},
+ {"continue-uturn", "\xEE\xA4\x89"},
+ {"continue", "\xEE\xA4\x84"},
+ {"depart-left", "\xEE\xA4\x8B"},
+ {"depart-right", "\xEE\xA4\x8C"},
+ {"depart-straight", "\xEE\xA4\x8A"},
+ {"end-of-road-left", "\xEE\xA4\x8D"},
+ {"end-of-road-right", "\xEE\xA4\x8E"},
+ {"ferry", "\xEE\xA4\x8F"},
+ {"flag", "\xEE\xA4\x90"},
+ {"fork-left", "\xEE\xA4\x92"},
+ {"fork-right", "\xEE\xA4\x93"},
+ {"fork-slight-left", "\xEE\xA4\x94"},
+ {"fork-slight-right", "\xEE\xA4\x95"},
+ {"fork-straight", "\xEE\xA4\x96"},
+ {"invalid", "\xEE\xA4\x84"},
+ {"invalid-left", "\xEE\xA4\x85"},
+ {"invalid-right", "\xEE\xA4\x86"},
+ {"invalid-slight-left", "\xEE\xA4\x87"},
+ {"invalid-slight-right", "\xEE\xA4\x88"},
+ {"invalid-straight", "\xEE\xA4\x84"},
+ {"invalid-uturn", "\xEE\xA4\x89"},
+ {"merge-left", "\xEE\xA4\x97"},
+ {"merge-right", "\xEE\xA4\x98"},
+ {"merge-slight-left", "\xEE\xA4\x99"},
+ {"merge-slight-right", "\xEE\xA4\x9A"},
+ {"merge-straight", "\xEE\xA4\x84"},
+ {"new-name-left", "\xEE\xA4\x85"},
+ {"new-name-right", "\xEE\xA4\x86"},
+ {"new-name-sharp-left", "\xEE\xA4\x9B"},
+ {"new-name-sharp-right", "\xEE\xA4\x9C"},
+ {"new-name-slight-left", "\xEE\xA4\x87"},
+ {"new-name-slight-right", "\xEE\xA4\x88"},
+ {"new-name-straight", "\xEE\xA4\x84"},
+ {"notification-left", "\xEE\xA4\x85"},
+ {"notification-right", "\xEE\xA4\x86"},
+ {"notification-sharp-left", "\xEE\xA4\x9B"},
+ {"notification-sharp-right", "\xEE\xA4\xA5"},
+ {"notification-slight-left", "\xEE\xA4\x87"},
+ {"notification-slight-right", "\xEE\xA4\x88"},
+ {"notification-straight", "\xEE\xA4\x84"},
+ {"off-ramp-left", "\xEE\xA4\x9D"},
+ {"off-ramp-right", "\xEE\xA4\x9E"},
+ {"off-ramp-slight-left", "\xEE\xA4\x9F"},
+ {"off-ramp-slight-right", "\xEE\xA4\xA0"},
+ {"on-ramp-left", "\xEE\xA4\x85"},
+ {"on-ramp-right", "\xEE\xA4\x86"},
+ {"on-ramp-sharp-left", "\xEE\xA4\x9B"},
+ {"on-ramp-sharp-right", "\xEE\xA4\xA5"},
+ {"on-ramp-slight-left", "\xEE\xA4\x87"},
+ {"on-ramp-slight-right", "\xEE\xA4\x88"},
+ {"on-ramp-straight", "\xEE\xA4\x84"},
+ {"rotary", "\xEE\xA4\xA1"},
+ {"rotary-left", "\xEE\xA4\xA2"},
+ {"rotary-right", "\xEE\xA4\xA3"},
+ {"rotary-sharp-left", "\xEE\xA4\xA4"},
+ {"rotary-sharp-right", "\xEE\xA4\xA5"},
+ {"rotary-slight-left", "\xEE\xA4\xA6"},
+ {"rotary-slight-right", "\xEE\xA4\xA7"},
+ {"rotary-straight", "\xEE\xA4\xA8"},
+ {"roundabout", "\xEE\xA4\xA1"},
+ {"roundabout-left", "\xEE\xA4\xA2"},
+ {"roundabout-right", "\xEE\xA4\xA3"},
+ {"roundabout-sharp-left", "\xEE\xA4\xA4"},
+ {"roundabout-sharp-right", "\xEE\xA4\xA5"},
+ {"roundabout-slight-left", "\xEE\xA4\xA6"},
+ {"roundabout-slight-right", "\xEE\xA4\xA7"},
+ {"roundabout-straight", "\xEE\xA4\xA8"},
+ {"turn-left", "\xEE\xA4\x85"},
+ {"turn-right", "\xEE\xA4\x86"},
+ {"turn-sharp-left", "\xEE\xA4\x9B"},
+ {"turn-sharp-right", "\xEE\xA4\xA5"},
+ {"turn-slight-left", "\xEE\xA4\x87"},
+ {"turn-slight-right", "\xEE\xA4\x88"},
+ {"turn-straight", "\xEE\xA4\x84"},
+ {"updown", "\xEE\xA4\xA9"},
+ {"uturn", "\xEE\xA4\x89"},
+ }};
+
+ const char* iconForName(const std::string& icon) {
+ for (auto iter : m_iconMap) {
+ if (iter.first == icon) {
+ return iter.second;
+ }
+ }
+ return "\xEE\xA4\x90";
+ }
+}
+
/**
* Navigation watchapp
*
@@ -68,27 +168,25 @@ Navigation::~Navigation() {
}
bool Navigation::Refresh() {
-
- if (m_flag != navService.getFlag()) {
- m_flag = navService.getFlag();
- lv_label_set_text(imgFlag, iconForName(m_flag));
- // lv_img_set_src_arr(imgFlag, iconForName(m_flag));
+ if (flag != navService.getFlag()) {
+ flag = navService.getFlag();
+ lv_label_set_text(imgFlag, iconForName(flag));
}
- if (m_narrative != navService.getNarrative()) {
- m_narrative = navService.getNarrative();
- lv_label_set_text(txtNarrative, m_narrative.data());
+ if (narrative != navService.getNarrative()) {
+ narrative = navService.getNarrative();
+ lv_label_set_text(txtNarrative, narrative.data());
}
- if (m_manDist != navService.getManDist()) {
- m_manDist = navService.getManDist();
- lv_label_set_text(txtManDist, m_manDist.data());
+ if (manDist != navService.getManDist()) {
+ manDist = navService.getManDist();
+ lv_label_set_text(txtManDist, manDist.data());
}
- if (m_progress != navService.getProgress()) {
- m_progress = navService.getProgress();
- lv_bar_set_value(barProgress, m_progress, LV_ANIM_OFF);
- if (m_progress > 90) {
+ if (progress != navService.getProgress()) {
+ progress = navService.getProgress();
+ lv_bar_set_value(barProgress, progress, LV_ANIM_OFF);
+ if (progress > 90) {
lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED);
} else {
lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
@@ -98,11 +196,4 @@ bool Navigation::Refresh() {
return running;
}
-const char* Navigation::iconForName(std::string icon) {
- for (auto iter : m_iconMap) {
- if (iter.first == icon) {
- return iter.second;
- }
- }
- return "\xEE\xA4\x90";
-}
+
diff --git a/src/displayapp/screens/Navigation.h b/src/displayapp/screens/Navigation.h
index 46816c33..eb7e00c4 100644
--- a/src/displayapp/screens/Navigation.h
+++ b/src/displayapp/screens/Navigation.h
@@ -45,103 +45,10 @@ namespace Pinetime {
Pinetime::Controllers::NavigationService& navService;
- std::string m_flag;
- std::string m_narrative;
- std::string m_manDist;
- int m_progress;
-
- /** Watchapp */
-
- const char* iconForName(std::string icon);
-
- std::array<std::pair<std::string, const char*>, 89> m_iconMap = {{
- {"arrive-left", "\xEE\xA4\x81"},
- {"arrive-right", "\xEE\xA4\x82"},
- {"arrive-straight", "\xEE\xA4\x80"},
- {"arrive", "\xEE\xA4\x80"},
- {"close", "\xEE\xA4\x83"},
- {"continue-left", "\xEE\xA4\x85"},
- {"continue-right", "\xEE\xA4\x86"},
- {"continue-slight-left", "\xEE\xA4\x87"},
- {"continue-slight-right", "\xEE\xA4\x88"},
- {"continue-straight", "\xEE\xA4\x84"},
- {"continue-uturn", "\xEE\xA4\x89"},
- {"continue", "\xEE\xA4\x84"},
- {"depart-left", "\xEE\xA4\x8B"},
- {"depart-right", "\xEE\xA4\x8C"},
- {"depart-straight", "\xEE\xA4\x8A"},
- {"end-of-road-left", "\xEE\xA4\x8D"},
- {"end-of-road-right", "\xEE\xA4\x8E"},
- {"ferry", "\xEE\xA4\x8F"},
- {"flag", "\xEE\xA4\x90"},
- {"fork-left", "\xEE\xA4\x92"},
- {"fork-right", "\xEE\xA4\x93"},
- {"fork-slight-left", "\xEE\xA4\x94"},
- {"fork-slight-right", "\xEE\xA4\x95"},
- {"fork-straight", "\xEE\xA4\x96"},
- {"invalid", "\xEE\xA4\x84"},
- {"invalid-left", "\xEE\xA4\x85"},
- {"invalid-right", "\xEE\xA4\x86"},
- {"invalid-slight-left", "\xEE\xA4\x87"},
- {"invalid-slight-right", "\xEE\xA4\x88"},
- {"invalid-straight", "\xEE\xA4\x84"},
- {"invalid-uturn", "\xEE\xA4\x89"},
- {"merge-left", "\xEE\xA4\x97"},
- {"merge-right", "\xEE\xA4\x98"},
- {"merge-slight-left", "\xEE\xA4\x99"},
- {"merge-slight-right", "\xEE\xA4\x9A"},
- {"merge-straight", "\xEE\xA4\x84"},
- {"new-name-left", "\xEE\xA4\x85"},
- {"new-name-right", "\xEE\xA4\x86"},
- {"new-name-sharp-left", "\xEE\xA4\x9B"},
- {"new-name-sharp-right", "\xEE\xA4\x9C"},
- {"new-name-slight-left", "\xEE\xA4\x87"},
- {"new-name-slight-right", "\xEE\xA4\x88"},
- {"new-name-straight", "\xEE\xA4\x84"},
- {"notification-left", "\xEE\xA4\x85"},
- {"notification-right", "\xEE\xA4\x86"},
- {"notification-sharp-left", "\xEE\xA4\x9B"},
- {"notification-sharp-right", "\xEE\xA4\xA5"},
- {"notification-slight-left", "\xEE\xA4\x87"},
- {"notification-slight-right", "\xEE\xA4\x88"},
- {"notification-straight", "\xEE\xA4\x84"},
- {"off-ramp-left", "\xEE\xA4\x9D"},
- {"off-ramp-right", "\xEE\xA4\x9E"},
- {"off-ramp-slight-left", "\xEE\xA4\x9F"},
- {"off-ramp-slight-right", "\xEE\xA4\xA0"},
- {"on-ramp-left", "\xEE\xA4\x85"},
- {"on-ramp-right", "\xEE\xA4\x86"},
- {"on-ramp-sharp-left", "\xEE\xA4\x9B"},
- {"on-ramp-sharp-right", "\xEE\xA4\xA5"},
- {"on-ramp-slight-left", "\xEE\xA4\x87"},
- {"on-ramp-slight-right", "\xEE\xA4\x88"},
- {"on-ramp-straight", "\xEE\xA4\x84"},
- {"rotary", "\xEE\xA4\xA1"},
- {"rotary-left", "\xEE\xA4\xA2"},
- {"rotary-right", "\xEE\xA4\xA3"},
- {"rotary-sharp-left", "\xEE\xA4\xA4"},
- {"rotary-sharp-right", "\xEE\xA4\xA5"},
- {"rotary-slight-left", "\xEE\xA4\xA6"},
- {"rotary-slight-right", "\xEE\xA4\xA7"},
- {"rotary-straight", "\xEE\xA4\xA8"},
- {"roundabout", "\xEE\xA4\xA1"},
- {"roundabout-left", "\xEE\xA4\xA2"},
- {"roundabout-right", "\xEE\xA4\xA3"},
- {"roundabout-sharp-left", "\xEE\xA4\xA4"},
- {"roundabout-sharp-right", "\xEE\xA4\xA5"},
- {"roundabout-slight-left", "\xEE\xA4\xA6"},
- {"roundabout-slight-right", "\xEE\xA4\xA7"},
- {"roundabout-straight", "\xEE\xA4\xA8"},
- {"turn-left", "\xEE\xA4\x85"},
- {"turn-right", "\xEE\xA4\x86"},
- {"turn-sharp-left", "\xEE\xA4\x9B"},
- {"turn-sharp-right", "\xEE\xA4\xA5"},
- {"turn-slight-left", "\xEE\xA4\x87"},
- {"turn-slight-right", "\xEE\xA4\x88"},
- {"turn-straight", "\xEE\xA4\x84"},
- {"updown", "\xEE\xA4\xA9"},
- {"uturn", "\xEE\xA4\x89"},
- }};
+ std::string flag;
+ std::string narrative;
+ std::string manDist;
+ int progress;
};
}
}
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index f0fd2f66..1a1729ea 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -176,7 +176,16 @@ 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 = 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/ScreenList.h b/src/displayapp/screens/ScreenList.h
index 73ea4610..ea66bfb2 100644
--- a/src/displayapp/screens/ScreenList.h
+++ b/src/displayapp/screens/ScreenList.h
@@ -15,12 +15,17 @@ namespace Pinetime {
public:
ScreenList(DisplayApp* app,
uint8_t initScreen,
- std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens,
+ const std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens,
ScreenListModes mode)
- : Screen(app), initScreen {initScreen}, screens {std::move(screens)}, mode {mode}, current {this->screens[initScreen]()} {
- screenIndex = initScreen;
+ : Screen(app), initScreen {initScreen}, screens {std::move(screens)}, mode {mode}, screenIndex{initScreen}, current {this->screens[initScreen]()} {
+
}
+ ScreenList(const ScreenList&) = delete;
+ ScreenList& operator=(const ScreenList&) = delete;
+ ScreenList(ScreenList&&) = delete;
+ ScreenList& operator=(ScreenList&&) = delete;
+
~ScreenList() override {
lv_obj_clean(lv_scr_act());
}
@@ -97,7 +102,7 @@ namespace Pinetime {
private:
uint8_t initScreen = 0;
- std::array<std::function<std::unique_ptr<Screen>()>, N> screens;
+ const std::array<std::function<std::unique_ptr<Screen>()>, N> screens;
ScreenListModes mode = ScreenListModes::UpDown;
uint8_t screenIndex = 0;
diff --git a/src/displayapp/screens/Symbols.h b/src/displayapp/screens/Symbols.h
index e60825c1..8d55f693 100644
--- a/src/displayapp/screens/Symbols.h
+++ b/src/displayapp/screens/Symbols.h
@@ -38,6 +38,7 @@ namespace Pinetime {
static constexpr const char* pause = "\xEF\x81\x8C";
static constexpr const char* stop = "\xEF\x81\x8D";
static constexpr const char* stopWatch = "\xEF\x8B\xB2";
+ static constexpr const char* hourGlass = "\xEF\x89\x92";
static constexpr const char* lapsFlag = "\xEF\x80\xA4";
// lv_font_sys_48.c
diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp
index ab349d7b..9ff28288 100644
--- a/src/displayapp/screens/SystemInfo.cpp
+++ b/src/displayapp/screens/SystemInfo.cpp
@@ -69,17 +69,19 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
lv_label_set_text_fmt(label,
"#FFFF00 InfiniTime#\n\n"
"#444444 Version# %ld.%ld.%ld\n\n"
+ "#444444 Short Ref# %s\n\n"
"#444444 Build date#\n"
"%s\n"
"%s\n",
Version::Major(),
Version::Minor(),
Version::Patch(),
+ Version::GitCommitHash(),
__DATE__,
__TIME__);
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<Screen>(new Screens::Label(0, 5, app, label));
+ return std::make_unique<Screens::Label>(0, 5, app, label);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
@@ -159,7 +161,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
brightnessController.ToString(),
resetReason);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
- return std::unique_ptr<Screen>(new Screens::Label(1, 4, app, label));
+ return std::make_unique<Screens::Label>(1, 5, app, label);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
@@ -173,8 +175,9 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
"#444444 BLE MAC#\n"
" %02x:%02x:%02x:%02x:%02x:%02x"
"\n"
- "#444444 Memory#\n"
+ "#444444 LVGL Memory#\n"
" #444444 used# %d (%d%%)\n"
+ " #444444 max used# %d\n"
" #444444 frag# %d%%\n"
" #444444 free# %d"
"\n"
@@ -187,14 +190,15 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
bleAddr[0],
(int) mon.total_size - mon.free_size,
mon.used_pct,
+ mon.max_used,
mon.frag_pct,
(int) mon.free_biggest_size,
0);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
- return std::unique_ptr<Screen>(new Screens::Label(2, 5, app, label));
+ return std::make_unique<Screens::Label>(2, 5, app, label);
}
-bool sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
+bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
return lhs.xTaskNumber < rhs.xTaskNumber;
}
@@ -225,7 +229,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
lv_table_set_cell_value(infoTask, i + 1, 2, std::to_string(tasksStatus[i].usStackHighWaterMark).c_str());
}
}
- return std::unique_ptr<Screen>(new Screens::Label(3, 5, app, infoTask));
+ return std::make_unique<Screens::Label>(3, 5, app, infoTask);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
@@ -241,5 +245,5 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
"#FFFF00 JF002/InfiniTime#");
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<Screen>(new Screens::Label(4, 5, app, label));
+ return std::make_unique<Screens::Label>(4, 5, app, label);
}
diff --git a/src/displayapp/screens/SystemInfo.h b/src/displayapp/screens/SystemInfo.h
index c0c65554..c61a07a2 100644
--- a/src/displayapp/screens/SystemInfo.h
+++ b/src/displayapp/screens/SystemInfo.h
@@ -43,6 +43,9 @@ namespace Pinetime {
Pinetime::Drivers::WatchdogView& watchdog;
ScreenList<5> screens;
+
+ static bool sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs);
+
std::unique_ptr<Screen> CreateScreen1();
std::unique_ptr<Screen> CreateScreen2();
std::unique_ptr<Screen> CreateScreen3();
diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp
new file mode 100644
index 00000000..260a17ef
--- /dev/null
+++ b/src/displayapp/screens/Timer.cpp
@@ -0,0 +1,173 @@
+#include "Timer.h"
+
+#include "Screen.h"
+#include "Symbols.h"
+#include "lvgl/lvgl.h"
+
+
+using namespace Pinetime::Applications::Screens;
+
+
+static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
+ Timer* screen = static_cast<Timer*>(obj->user_data);
+ screen->OnButtonEvent(obj, event);
+}
+
+void Timer::createButtons() {
+ btnMinutesUp = lv_btn_create(lv_scr_act(), nullptr);
+ btnMinutesUp->user_data = this;
+ lv_obj_set_event_cb(btnMinutesUp, btnEventHandler);
+ lv_obj_align(btnMinutesUp, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, -80);
+ lv_obj_set_height(btnMinutesUp, 40);
+ 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);
+ lv_obj_align(btnMinutesDown, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, +40);
+ lv_obj_set_height(btnMinutesDown, 40);
+ 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);
+ lv_obj_align(btnSecondsUp, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 10, -80);
+ lv_obj_set_height(btnSecondsUp, 40);
+ 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);
+ lv_obj_align(btnSecondsDown, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 10, +40);
+ lv_obj_set_height(btnSecondsDown, 40);
+ 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} {
+
+ 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, "%02d:%02d", 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);
+ lv_obj_align(btnPlayPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, -10);
+ lv_obj_set_height(btnPlayPause, 40);
+ txtPlayPause = lv_label_create(btnPlayPause, nullptr);
+ if (timerController.IsRunning()) {
+ lv_label_set_text(txtPlayPause, Symbols::pause);
+ } else {
+ lv_label_set_text(txtPlayPause, Symbols::play);
+ createButtons();
+ }
+
+}
+
+Timer::~Timer() {
+ lv_obj_clean(lv_scr_act());
+
+}
+
+bool Timer::Refresh() {
+ if (timerController.IsRunning()) {
+ uint32_t seconds = timerController.GetTimeRemaining() / 1000;
+ lv_label_set_text_fmt(time, "%02d:%02d", seconds / 60, seconds % 60);
+ }
+ return running;
+}
+
+void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
+ if (event == LV_EVENT_CLICKED) {
+ if (obj == btnPlayPause) {
+ if (timerController.IsRunning()) {
+ lv_label_set_text(txtPlayPause, Symbols::play);
+ uint32_t seconds = timerController.GetTimeRemaining() / 1000;
+ minutesToSet = seconds / 60;
+ 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);
+ btnSecondsUp = nullptr;
+ lv_obj_del(btnMinutesDown);
+ btnMinutesDown = nullptr;
+ lv_obj_del(btnMinutesUp);
+ btnMinutesUp = nullptr;
+
+ }
+ } else {
+ if (!timerController.IsRunning()) {
+ if (obj == btnMinutesUp) {
+ if (minutesToSet >= 59) {
+ minutesToSet = 0;
+ } else {
+ minutesToSet++;
+ }
+ lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
+
+ } else if (obj == btnMinutesDown) {
+ if (minutesToSet == 0) {
+ minutesToSet = 59;
+ } else {
+ minutesToSet--;
+ }
+ lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
+
+ } else if (obj == btnSecondsUp) {
+ if (secondsToSet >= 59) {
+ secondsToSet = 0;
+ } else {
+ secondsToSet++;
+ }
+ lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
+
+ } else if (obj == btnSecondsDown) {
+ if (secondsToSet == 0) {
+ secondsToSet = 59;
+ } else {
+ 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
new file mode 100644
index 00000000..0d66f2d4
--- /dev/null
+++ b/src/displayapp/screens/Timer.h
@@ -0,0 +1,42 @@
+#pragma once
+
+#include "Screen.h"
+#include "components/datetime/DateTimeController.h"
+#include "systemtask/SystemTask.h"
+#include "../LittleVgl.h"
+
+#include "components/timer/TimerController.h"
+
+namespace Pinetime::Applications::Screens {
+
+
+ class Timer : public Screen {
+ public:
+
+ enum class Modes {
+ Normal, Done
+ };
+
+ Timer(DisplayApp* app, Controllers::TimerController& timerController);
+
+ ~Timer() override;
+
+ bool 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;
+ };
+} \ No newline at end of file
diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp
index 3994794d..5db7468c 100644
--- a/src/displayapp/screens/settings/QuickSettings.cpp
+++ b/src/displayapp/screens/settings/QuickSettings.cpp
@@ -7,12 +7,12 @@ using namespace Pinetime::Applications::Screens;
namespace {
static void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) {
- QuickSettings* screen = static_cast<QuickSettings*>(obj->user_data);
+ auto* screen = static_cast<QuickSettings*>(obj->user_data);
screen->OnButtonEvent(obj, event);
}
static void lv_update_task(struct _lv_task_t* task) {
- auto user_data = static_cast<QuickSettings*>(task->user_data);
+ auto* user_data = static_cast<QuickSettings*>(task->user_data);
user_data->UpdateScreen();
}
}
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp
index 2c72c832..e63a3584 100644
--- a/src/displayapp/screens/settings/Settings.cpp
+++ b/src/displayapp/screens/settings/Settings.cpp
@@ -46,7 +46,7 @@ std::unique_ptr<Screen> Settings::CreateScreen1() {
{Symbols::clock, "Watch face", Apps::SettingWatchFace},
}};
- return std::unique_ptr<Screen>(new Screens::List(0, 2, app, settingsController, applications));
+ return std::make_unique<Screens::List>(0, 2, app, settingsController, applications);
}
std::unique_ptr<Screen> Settings::CreateScreen2() {
@@ -58,5 +58,5 @@ std::unique_ptr<Screen> Settings::CreateScreen2() {
{Symbols::list, "About", Apps::SysInfo},
}};
- return std::unique_ptr<Screen>(new Screens::List(1, 2, app, settingsController, applications));
+ return std::make_unique<Screens::List>(1, 2, app, settingsController, applications);
}
diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h
index 7e332dfe..711a6be6 100644
--- a/src/displayapp/screens/settings/Settings.h
+++ b/src/displayapp/screens/settings/Settings.h
@@ -16,7 +16,6 @@ namespace Pinetime {
bool Refresh() override;
- void OnButtonEvent(lv_obj_t* object, lv_event_t event);
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
private:
diff --git a/src/drivers/Bma421.cpp b/src/drivers/Bma421.cpp
index 925b66c7..35b2c105 100644
--- a/src/drivers/Bma421.cpp
+++ b/src/drivers/Bma421.cpp
@@ -103,8 +103,6 @@ Bma421::Values Bma421::Process() {
uint8_t activity = 0;
bma423_activity_output(&activity, &bma);
- NRF_LOG_INFO("MOTION : %d - %d/%d/%d", steps, data.x, data.y, data.z);
-
// X and Y axis are swapped because of the way the sensor is mounted in the PineTime
return {steps, data.y, data.x, data.z};
}
diff --git a/src/drivers/SpiMaster.cpp b/src/drivers/SpiMaster.cpp
index 34fcc08a..c45e1294 100644
--- a/src/drivers/SpiMaster.cpp
+++ b/src/drivers/SpiMaster.cpp
@@ -7,11 +7,14 @@
using namespace Pinetime::Drivers;
SpiMaster::SpiMaster(const SpiMaster::SpiModule spi, const SpiMaster::Parameters& params) : spi {spi}, params {params} {
- mutex = xSemaphoreCreateBinary();
- ASSERT(mutex != NULL);
}
bool SpiMaster::Init() {
+ if(mutex == nullptr) {
+ mutex = xSemaphoreCreateBinary();
+ ASSERT(mutex != nullptr);
+ }
+
/* Configure GPIO pins used for pselsck, pselmosi, pselmiso and pselss for SPI0 */
nrf_gpio_pin_set(params.pinSCK);
nrf_gpio_cfg_output(params.pinSCK);
@@ -53,6 +56,7 @@ bool SpiMaster::Init() {
break;
case BitOrder::Lsb_Msb:
regConfig = 1;
+ break;
default:
return false;
}
@@ -132,17 +136,17 @@ void SpiMaster::OnEndEvent() {
spiBaseAddress->TASKS_START = 1;
} else {
+ BaseType_t xHigherPriorityTaskWoken = pdFALSE;
if (taskToNotify != nullptr) {
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
vTaskNotifyGiveFromISR(taskToNotify, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
nrf_gpio_pin_set(this->pinCsn);
currentBufferAddr = 0;
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
- xSemaphoreGiveFromISR(mutex, &xHigherPriorityTaskWoken);
- portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
+ BaseType_t xHigherPriorityTaskWoken2 = pdFALSE;
+ xSemaphoreGiveFromISR(mutex, &xHigherPriorityTaskWoken2);
+ portYIELD_FROM_ISR(xHigherPriorityTaskWoken | xHigherPriorityTaskWoken2);
}
}
diff --git a/src/drivers/SpiMaster.h b/src/drivers/SpiMaster.h
index dfc195b7..5ea624f2 100644
--- a/src/drivers/SpiMaster.h
+++ b/src/drivers/SpiMaster.h
@@ -10,7 +10,6 @@ namespace Pinetime {
namespace Drivers {
class SpiMaster {
public:
- ;
enum class SpiModule : uint8_t { SPI0, SPI1 };
enum class BitOrder : uint8_t { Msb_Lsb, Lsb_Msb };
enum class Modes : uint8_t { Mode0, Mode1, Mode2, Mode3 };
@@ -60,7 +59,7 @@ namespace Pinetime {
volatile uint32_t currentBufferAddr = 0;
volatile size_t currentBufferSize = 0;
volatile TaskHandle_t taskToNotify;
- SemaphoreHandle_t mutex;
+ SemaphoreHandle_t mutex = nullptr;
};
}
}
diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp
index 7b6582dd..fc9edf81 100644
--- a/src/drivers/TwiMaster.cpp
+++ b/src/drivers/TwiMaster.cpp
@@ -9,10 +9,12 @@ using namespace Pinetime::Drivers;
// TODO use DMA/IRQ
TwiMaster::TwiMaster(const Modules module, const Parameters& params) : module {module}, params {params} {
- mutex = xSemaphoreCreateBinary();
}
void TwiMaster::Init() {
+ if(mutex == nullptr)
+ mutex = xSemaphoreCreateBinary();
+
NRF_GPIO->PIN_CNF[params.pinScl] =
((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
diff --git a/src/drivers/TwiMaster.h b/src/drivers/TwiMaster.h
index 1c0648a2..6175b99b 100644
--- a/src/drivers/TwiMaster.h
+++ b/src/drivers/TwiMaster.h
@@ -31,7 +31,7 @@ namespace Pinetime {
ErrorCodes Write(uint8_t deviceAddress, const uint8_t* data, size_t size, bool stop);
void FixHwFreezed();
NRF_TWIM_Type* twiBaseAddress;
- SemaphoreHandle_t mutex;
+ SemaphoreHandle_t mutex = nullptr;
const Modules module;
const Parameters params;
static constexpr uint8_t maxDataSize {16};
diff --git a/src/heartratetask/HeartRateTask.cpp b/src/heartratetask/HeartRateTask.cpp
index 36c8cc18..fddc05d7 100644
--- a/src/heartratetask/HeartRateTask.cpp
+++ b/src/heartratetask/HeartRateTask.cpp
@@ -6,12 +6,13 @@
using namespace Pinetime::Applications;
HeartRateTask::HeartRateTask(Drivers::Hrs3300& heartRateSensor, Controllers::HeartRateController& controller)
- : heartRateSensor {heartRateSensor}, controller {controller}, ppg {static_cast<float>(heartRateSensor.ReadHrs())} {
- messageQueue = xQueueCreate(10, 1);
- controller.SetHeartRateTask(this);
+ : heartRateSensor {heartRateSensor}, controller {controller}, ppg{} {
}
void HeartRateTask::Start() {
+ messageQueue = xQueueCreate(10, 1);
+ controller.SetHeartRateTask(this);
+
if (pdPASS != xTaskCreate(HeartRateTask::Process, "Heartrate", 500, this, 0, &taskHandle))
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
diff --git a/src/main.cpp b/src/main.cpp
index 04cef6b5..4c2c5de8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -33,7 +33,7 @@
#include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
#include "components/datetime/DateTimeController.h"
-#include "components/settings/Settings.h"
+#include "components/heartrate/HeartRateController.h"
#include "drivers/Spi.h"
#include "drivers/SpiMaster.h"
#include "drivers/SpiNorFlash.h"
@@ -50,8 +50,6 @@ Pinetime::Logging::NrfLogger logger;
Pinetime::Logging::DummyLogger logger;
#endif
-#include <memory>
-
static constexpr uint8_t pinSpiSck = 2;
static constexpr uint8_t pinSpiMosi = 3;
static constexpr uint8_t pinSpiMiso = 4;
@@ -101,24 +99,77 @@ Pinetime::Drivers::Bma421 motionSensor {twiMaster, motionSensorTwiAddress};
Pinetime::Drivers::Hrs3300 heartRateSensor {twiMaster, heartRateSensorTwiAddress};
TimerHandle_t debounceTimer;
+TimerHandle_t debounceChargeTimer;
Pinetime::Controllers::Battery batteryController;
Pinetime::Controllers::Ble bleController;
void ble_manager_set_ble_connection_callback(void (*connection)());
void ble_manager_set_ble_disconnection_callback(void (*disconnection)());
static constexpr uint8_t pinTouchIrq = 28;
-std::unique_ptr<Pinetime::System::SystemTask> systemTask;
+static constexpr uint8_t pinPowerPresentIrq = 19;
Pinetime::Controllers::Settings settingsController {spiNorFlash};
Pinetime::Controllers::MotorController motorController {settingsController};
+Pinetime::Controllers::HeartRateController heartRateController;
+Pinetime::Applications::HeartRateTask heartRateApp(heartRateSensor, heartRateController);
+
+Pinetime::Controllers::DateTime dateTimeController;
+Pinetime::Drivers::Watchdog watchdog;
+Pinetime::Drivers::WatchdogView watchdogView(watchdog);
+Pinetime::Controllers::NotificationManager notificationManager;
+Pinetime::Controllers::MotionController motionController;
+Pinetime::Controllers::TimerController timerController;
+
+Pinetime::Applications::DisplayApp displayApp(lcd,
+ lvgl,
+ touchPanel,
+ batteryController,
+ bleController,
+ dateTimeController,
+ watchdogView,
+ notificationManager,
+ heartRateController,
+ settingsController,
+ motorController,
+ motionController,
+ timerController);
+
+Pinetime::System::SystemTask systemTask(spi,
+ lcd,
+ spiNorFlash,
+ twiMaster,
+ touchPanel,
+ lvgl,
+ batteryController,
+ bleController,
+ dateTimeController,
+ timerController,
+ watchdog,
+ notificationManager,
+ motorController,
+ heartRateSensor,
+ motionController,
+ motionSensor,
+ settingsController,
+ heartRateController,
+ displayApp,
+ heartRateApp);
+
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
if (pin == pinTouchIrq) {
- systemTask->OnTouchEvent();
+ systemTask.OnTouchEvent();
return;
}
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
+
+ if (pin == pinPowerPresentIrq and action == NRF_GPIOTE_POLARITY_TOGGLE) {
+ xTimerStartFromISR(debounceChargeTimer, &xHigherPriorityTaskWoken);
+ portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
+ return;
+ }
+
xTimerStartFromISR(debounceTimer, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
@@ -130,9 +181,14 @@ void vApplicationIdleHook(void) {
}
}
+void DebounceTimerChargeCallback(TimerHandle_t xTimer) {
+ xTimerStop(xTimer, 0);
+ systemTask.PushMessage(Pinetime::System::Messages::OnChargingEvent);
+}
+
void DebounceTimerCallback(TimerHandle_t xTimer) {
xTimerStop(xTimer, 0);
- systemTask->OnButtonPushed();
+ systemTask.OnButtonPushed();
}
void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void) {
@@ -248,20 +304,11 @@ int main(void) {
nrf_drv_clock_init();
debounceTimer = xTimerCreate("debounceTimer", 200, pdFALSE, (void*) 0, DebounceTimerCallback);
+ debounceChargeTimer = xTimerCreate("debounceTimerCharge", 200, pdFALSE, (void*) 0, DebounceTimerChargeCallback);
+
+ lvgl.Init();
- systemTask = std::make_unique<Pinetime::System::SystemTask>(spi,
- lcd,
- spiNorFlash,
- twiMaster,
- touchPanel,
- lvgl,
- batteryController,
- bleController,
- motorController,
- heartRateSensor,
- motionSensor,
- settingsController);
- systemTask->Start();
+ systemTask.Start();
nimble_port_init();
vTaskStartScheduler();
diff --git a/src/systemtask/Messages.h b/src/systemtask/Messages.h
new file mode 100644
index 00000000..3a195e2d
--- /dev/null
+++ b/src/systemtask/Messages.h
@@ -0,0 +1,26 @@
+#pragma once
+
+namespace Pinetime {
+ namespace System {
+ enum class Messages {
+ GoToSleep,
+ GoToRunning,
+ TouchWakeUp,
+ OnNewTime,
+ OnNewNotification,
+ OnTimerDone,
+ OnNewCall,
+ BleConnected,
+ UpdateTimeOut,
+ BleFirmwareUpdateStarted,
+ BleFirmwareUpdateFinished,
+ OnTouchEvent,
+ OnButtonEvent,
+ OnDisplayTaskSleeping,
+ EnableSleeping,
+ DisableSleeping,
+ OnNewDay,
+ OnChargingEvent
+ };
+ }
+}
diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp
index 6d695e2c..38e9793c 100644
--- a/src/systemtask/SystemTask.cpp
+++ b/src/systemtask/SystemTask.cpp
@@ -27,6 +27,12 @@
using namespace Pinetime::System;
+namespace {
+ static inline bool in_isr(void) {
+ return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
+ }
+}
+
void IdleTimerCallback(TimerHandle_t xTimer) {
NRF_LOG_INFO("IdleTimerCallback");
@@ -42,10 +48,18 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi,
Components::LittleVgl& lvgl,
Controllers::Battery& batteryController,
Controllers::Ble& bleController,
+ Controllers::DateTime& dateTimeController,
+ Controllers::TimerController& timerController,
+ Drivers::Watchdog& watchdog,
+ Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Drivers::Hrs3300& heartRateSensor,
+ Pinetime::Controllers::MotionController& motionController,
Pinetime::Drivers::Bma421& motionSensor,
- Controllers::Settings& settingsController)
+ Controllers::Settings& settingsController,
+ Pinetime::Controllers::HeartRateController& heartRateController,
+ Pinetime::Applications::DisplayApp& displayApp,
+ Pinetime::Applications::HeartRateTask& heartRateApp)
: spi {spi},
lcd {lcd},
spiNorFlash {spiNorFlash},
@@ -53,20 +67,25 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi,
touchPanel {touchPanel},
lvgl {lvgl},
batteryController {batteryController},
- heartRateController {*this},
bleController {bleController},
- dateTimeController {*this},
- watchdog {},
- watchdogView {watchdog},
+ dateTimeController {dateTimeController},
+ timerController {timerController},
+ watchdog {watchdog},
+ notificationManager{notificationManager},
motorController {motorController},
heartRateSensor {heartRateSensor},
motionSensor {motionSensor},
settingsController {settingsController},
- nimbleController(*this, bleController, dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController) {
- systemTasksMsgQueue = xQueueCreate(10, 1);
+ heartRateController{heartRateController},
+ nimbleController(*this, bleController, dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController),
+ motionController{motionController},
+ displayApp{displayApp},
+ heartRateApp(heartRateApp) {
+
}
void SystemTask::Start() {
+ systemTasksMsgQueue = xQueueCreate(10, 1);
if (pdPASS != xTaskCreate(SystemTask::Process, "MAIN", 350, this, 0, &taskHandle))
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
@@ -83,6 +102,8 @@ void SystemTask::Work() {
NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::Watchdog::ResetReasonToString(watchdog.ResetReason()));
APP_GPIOTE_INIT(2);
+ app_timer_init();
+
spi.Init();
spiNorFlash.Init();
spiNorFlash.Wakeup();
@@ -93,9 +114,12 @@ void SystemTask::Work() {
twiMaster.Init();
touchPanel.Init();
+ dateTimeController.Register(this);
batteryController.Init();
motorController.Init();
motionSensor.SoftReset();
+ timerController.Register(this);
+ timerController.Init();
// Reset the TWI device because the motion sensor chip most probably crashed it...
twiMaster.Sleep();
@@ -104,27 +128,14 @@ void SystemTask::Work() {
motionSensor.Init();
settingsController.Init();
- displayApp = std::make_unique<Pinetime::Applications::DisplayApp>(lcd,
- lvgl,
- touchPanel,
- batteryController,
- bleController,
- dateTimeController,
- watchdogView,
- *this,
- notificationManager,
- heartRateController,
- settingsController,
- motorController,
- motionController);
- displayApp->Start();
-
- displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel);
+ displayApp.Register(this);
+ displayApp.Start();
+
+ displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel);
heartRateSensor.Init();
heartRateSensor.Disable();
- heartRateApp = std::make_unique<Pinetime::Applications::HeartRateTask>(heartRateSensor, heartRateController);
- heartRateApp->Start();
+ heartRateApp.Start();
nrf_gpio_cfg_sense_input(pinButton, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_High);
nrf_gpio_cfg_output(15);
@@ -149,6 +160,19 @@ void SystemTask::Work() {
nrfx_gpiote_in_init(pinTouchIrq, &pinConfig, nrfx_gpiote_evt_handler);
+ pinConfig.sense = NRF_GPIOTE_POLARITY_TOGGLE;
+ pinConfig.pull = NRF_GPIO_PIN_NOPULL;
+ pinConfig.is_watcher = false;
+ pinConfig.hi_accuracy = false;
+ pinConfig.skip_gpio_setup = true;
+ nrfx_gpiote_in_init(pinPowerPresentIrq, &pinConfig, nrfx_gpiote_evt_handler);
+
+ if (nrf_gpio_pin_read(pinPowerPresentIrq)) {
+ nrf_gpio_cfg_sense_input(pinPowerPresentIrq, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
+ } else {
+ nrf_gpio_cfg_sense_input(pinPowerPresentIrq, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
+ }
+
idleTimer = xTimerCreate("idleTimer", pdMS_TO_TICKS(settingsController.GetScreenTimeOut()), pdFALSE, this, IdleTimerCallback);
xTimerStart(idleTimer, 0);
@@ -161,12 +185,9 @@ void SystemTask::Work() {
uint8_t msg;
if (xQueueReceive(systemTasksMsgQueue, &msg, 100)) {
- // call the battery controller or use the MSG in DisplayApp to get the battery status ???
- // it is necessary to validate which is the most efficient
batteryController.Update();
- // displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel);
- // analyze a more efficient way to do this refreshment
- // this and the UpdateMotion(); can be called on a timer to be independent of the main process ???
+ // the battery does not emit events when changing charge levels, so we piggyback
+ // on any system event to read and update the current values
Messages message = static_cast<Messages>(msg);
switch (message) {
@@ -193,9 +214,9 @@ void SystemTask::Work() {
spiNorFlash.Wakeup();
lcd.Wakeup();
- displayApp->PushMessage(Pinetime::Applications::Display::Messages::GoToRunning);
- displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel);
- heartRateApp->PushMessage(Pinetime::Applications::HeartRateTask::Messages::WakeUp);
+ displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToRunning);
+ displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel);
+ heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::WakeUp);
isSleeping = false;
isWakingUp = false;
@@ -215,18 +236,26 @@ void SystemTask::Work() {
isGoingToSleep = true;
NRF_LOG_INFO("[systemtask] Going to sleep");
xTimerStop(idleTimer, 0);
- displayApp->PushMessage(Pinetime::Applications::Display::Messages::GoToSleep);
- heartRateApp->PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep);
+ displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToSleep);
+ heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep);
break;
case Messages::OnNewTime:
ReloadIdleTimer();
- displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
+ displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
break;
case Messages::OnNewNotification:
- if (isSleeping && !isWakingUp)
+ if (isSleeping && !isWakingUp) {
GoToRunning();
+ }
+ motorController.SetDuration(35);
+ displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
+ break;
+ case Messages::OnTimerDone:
+ if (isSleeping && !isWakingUp) {
+ GoToRunning();
+ }
motorController.SetDuration(35);
- displayApp->PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
+ displayApp.PushMessage(Pinetime::Applications::Display::Messages::TimerDone);
break;
case Messages::BleConnected:
ReloadIdleTimer();
@@ -237,7 +266,7 @@ void SystemTask::Work() {
doNotGoToSleep = true;
if (isSleeping && !isWakingUp)
GoToRunning();
- displayApp->PushMessage(Pinetime::Applications::Display::Messages::BleFirmwareUpdateStarted);
+ displayApp.PushMessage(Pinetime::Applications::Display::Messages::BleFirmwareUpdateStarted);
break;
case Messages::BleFirmwareUpdateFinished:
doNotGoToSleep = false;
@@ -274,6 +303,11 @@ void SystemTask::Work() {
// Remember we'll have to reset the counter next time we're awake
stepCounterMustBeReset = true;
break;
+ case Messages::OnChargingEvent:
+ motorController.SetDuration(15);
+ // Battery level is updated on every message - there's no need to do anything
+ break;
+
default:
break;
}
@@ -331,7 +365,7 @@ void SystemTask::OnButtonPushed() {
if (!isSleeping) {
NRF_LOG_INFO("[systemtask] Button pushed");
PushMessage(Messages::OnButtonEvent);
- displayApp->PushMessage(Pinetime::Applications::Display::Messages::ButtonPushed);
+ displayApp.PushMessage(Pinetime::Applications::Display::Messages::ButtonPushed);
} else {
if (!isWakingUp) {
NRF_LOG_INFO("[systemtask] Button pushed, waking up");
@@ -352,7 +386,7 @@ void SystemTask::OnTouchEvent() {
return;
if (!isSleeping) {
PushMessage(Messages::OnTouchEvent);
- displayApp->PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
+ displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
} else if (!isWakingUp) {
if (settingsController.getWakeUpMode() == Pinetime::Controllers::Settings::WakeUpMode::None or
settingsController.getWakeUpMode() == Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist)
@@ -361,16 +395,22 @@ void SystemTask::OnTouchEvent() {
}
}
-void SystemTask::PushMessage(SystemTask::Messages msg) {
+void SystemTask::PushMessage(System::Messages msg) {
if (msg == Messages::GoToSleep) {
isGoingToSleep = true;
}
- BaseType_t xHigherPriorityTaskWoken;
- xHigherPriorityTaskWoken = pdFALSE;
- xQueueSendFromISR(systemTasksMsgQueue, &msg, &xHigherPriorityTaskWoken);
- if (xHigherPriorityTaskWoken) {
- /* Actual macro used here is port specific. */
- // TODO: should I do something here?
+
+ if(in_isr()) {
+ BaseType_t xHigherPriorityTaskWoken;
+ xHigherPriorityTaskWoken = pdFALSE;
+ xQueueSendFromISR(systemTasksMsgQueue, &msg, &xHigherPriorityTaskWoken);
+ if (xHigherPriorityTaskWoken) {
+ /* Actual macro used here is port specific. */
+ portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
+
+ }
+ } else {
+ xQueueSend(systemTasksMsgQueue, &msg, portMAX_DELAY);
}
}
diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h
index e65fbea0..fa6a949c 100644
--- a/src/systemtask/SystemTask.h
+++ b/src/systemtask/SystemTask.h
@@ -6,7 +6,6 @@
#include <task.h>
#include <timers.h>
#include <heartratetask/HeartRateTask.h>
-#include <components/heartrate/HeartRateController.h>
#include <components/settings/Settings.h>
#include <drivers/Bma421.h>
#include <components/motion/MotionController.h>
@@ -16,6 +15,7 @@
#include "components/ble/NimbleController.h"
#include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
+#include "components/timer/TimerController.h"
#ifdef PINETIME_IS_RECOVERY
#include "displayapp/DisplayAppRecovery.h"
#include "displayapp/DummyLittleVgl.h"
@@ -26,6 +26,7 @@
#endif
#include "drivers/Watchdog.h"
+#include "Messages.h"
namespace Pinetime {
namespace Drivers {
@@ -39,25 +40,6 @@ namespace Pinetime {
namespace System {
class SystemTask {
public:
- enum class Messages {
- GoToSleep,
- GoToRunning,
- TouchWakeUp,
- OnNewTime,
- OnNewNotification,
- OnNewCall,
- BleConnected,
- UpdateTimeOut,
- BleFirmwareUpdateStarted,
- BleFirmwareUpdateFinished,
- OnTouchEvent,
- OnButtonEvent,
- OnDisplayTaskSleeping,
- EnableSleeping,
- DisableSleeping,
- OnNewDay
- };
-
SystemTask(Drivers::SpiMaster& spi,
Drivers::St7789& lcd,
Pinetime::Drivers::SpiNorFlash& spiNorFlash,
@@ -66,10 +48,18 @@ namespace Pinetime {
Components::LittleVgl& lvgl,
Controllers::Battery& batteryController,
Controllers::Ble& bleController,
+ Controllers::DateTime& dateTimeController,
+ Controllers::TimerController& timerController,
+ Drivers::Watchdog& watchdog,
+ Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Drivers::Hrs3300& heartRateSensor,
+ Pinetime::Controllers::MotionController& motionController,
Pinetime::Drivers::Bma421& motionSensor,
- Controllers::Settings& settingsController);
+ Controllers::Settings& settingsController,
+ Pinetime::Controllers::HeartRateController& heartRateController,
+ Pinetime::Applications::DisplayApp& displayApp,
+ Pinetime::Applications::HeartRateTask& heartRateApp);
void Start();
void PushMessage(Messages msg);
@@ -93,26 +83,29 @@ namespace Pinetime {
Pinetime::Drivers::Cst816S& touchPanel;
Pinetime::Components::LittleVgl& lvgl;
Pinetime::Controllers::Battery& batteryController;
- std::unique_ptr<Pinetime::Applications::DisplayApp> displayApp;
- Pinetime::Controllers::HeartRateController heartRateController;
- std::unique_ptr<Pinetime::Applications::HeartRateTask> heartRateApp;
+
Pinetime::Controllers::Ble& bleController;
- Pinetime::Controllers::DateTime dateTimeController;
+ Pinetime::Controllers::DateTime& dateTimeController;
+ Pinetime::Controllers::TimerController& timerController;
QueueHandle_t systemTasksMsgQueue;
std::atomic<bool> isSleeping {false};
std::atomic<bool> isGoingToSleep {false};
std::atomic<bool> isWakingUp {false};
- Pinetime::Drivers::Watchdog watchdog;
- Pinetime::Drivers::WatchdogView watchdogView;
- Pinetime::Controllers::NotificationManager notificationManager;
+ Pinetime::Drivers::Watchdog& watchdog;
+ Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::MotorController& motorController;
Pinetime::Drivers::Hrs3300& heartRateSensor;
Pinetime::Drivers::Bma421& motionSensor;
Pinetime::Controllers::Settings& settingsController;
+ Pinetime::Controllers::HeartRateController& heartRateController;
Pinetime::Controllers::NimbleController nimbleController;
Controllers::BrightnessController brightnessController;
- Pinetime::Controllers::MotionController motionController;
+ Pinetime::Controllers::MotionController& motionController;
+
+ Pinetime::Applications::DisplayApp& displayApp;
+ Pinetime::Applications::HeartRateTask& heartRateApp;
+
static constexpr uint8_t pinSpiSck = 2;
static constexpr uint8_t pinSpiMosi = 3;
@@ -121,6 +114,7 @@ namespace Pinetime {
static constexpr uint8_t pinLcdDataCommand = 18;
static constexpr uint8_t pinButton = 13;
static constexpr uint8_t pinTouchIrq = 28;
+ static constexpr uint8_t pinPowerPresentIrq = 19;
static void Process(void* instance);
void Work();