Merge remote-tracking branch 'upstream/develop' into pts-settings
This commit is contained in:
commit
ff1fce18d6
56 changed files with 1073 additions and 260 deletions
|
@ -55,7 +55,7 @@ RUN unzip -q /tmp/nRF5_SDK_15.3.0_59ac345 -d /opt
|
||||||
RUN rm /tmp/nRF5_SDK_15.3.0_59ac345
|
RUN rm /tmp/nRF5_SDK_15.3.0_59ac345
|
||||||
# McuBoot
|
# McuBoot
|
||||||
# RUN bash -c "source /opt/build.sh; GetMcuBoot;"
|
# RUN bash -c "source /opt/build.sh; GetMcuBoot;"
|
||||||
RUN git clone https://github.com/JuulLabs-OSS/mcuboot.git
|
RUN git clone https://github.com/mcu-tools/mcuboot.git
|
||||||
RUN pip3 install -r ./mcuboot/scripts/requirements.txt
|
RUN pip3 install -r ./mcuboot/scripts/requirements.txt
|
||||||
|
|
||||||
RUN adduser infinitime
|
RUN adduser infinitime
|
||||||
|
|
|
@ -43,7 +43,7 @@ GetGcc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
GetMcuBoot() {
|
GetMcuBoot() {
|
||||||
git clone https://github.com/JuulLabs-OSS/mcuboot.git "$TOOLS_DIR/mcuboot"
|
git clone https://github.com/mcu-tools/mcuboot.git "$TOOLS_DIR/mcuboot"
|
||||||
pip3 install -r "$TOOLS_DIR/mcuboot/scripts/requirements.txt"
|
pip3 install -r "$TOOLS_DIR/mcuboot/scripts/requirements.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
59
.github/ISSUE_TEMPLATE/bug-report.yaml
vendored
Normal file
59
.github/ISSUE_TEMPLATE/bug-report.yaml
vendored
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
name: Bug Report
|
||||||
|
description: File a bug report
|
||||||
|
title: "[Bug]: "
|
||||||
|
labels: ["bug"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
**Thanks for taking the time to fill out this bug report!**
|
||||||
|
*Please, before opening a bug report, check if similar issues already exist. In that case, use those issues to provide your feedback instead.*
|
||||||
|
- type: checkboxes
|
||||||
|
attributes:
|
||||||
|
options:
|
||||||
|
- label: I searched for similar bug reports and found none was relevant.
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: desc-brief
|
||||||
|
attributes:
|
||||||
|
label: What happened?
|
||||||
|
description: A one-line description of the bug.
|
||||||
|
placeholder: "Ex. I woke up as a Kafkian insect this morning."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: desc-expected
|
||||||
|
attributes:
|
||||||
|
label: What should happen instead?
|
||||||
|
description: The behaviour you were expecting to see.
|
||||||
|
placeholder: "Ex. I was expecting to wake up as a human."
|
||||||
|
- type: textarea
|
||||||
|
id: desc-steps
|
||||||
|
attributes:
|
||||||
|
label: Reproduction steps
|
||||||
|
description: "How do you trigger this bug? Please walk us through it step by step."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: desc-long
|
||||||
|
attributes:
|
||||||
|
label: More details?
|
||||||
|
description: Give us more details about the bug and any personal attempts you made to fix it.
|
||||||
|
placeholder: Tell us more!
|
||||||
|
- type: input
|
||||||
|
id: version
|
||||||
|
attributes:
|
||||||
|
label: Version
|
||||||
|
description: |
|
||||||
|
What [version of the firmware](https://github.com/JF002/InfiniTime/blob/develop/doc/gettingStarted/gettingStarted-1.0.md#how-to-check-the-version-of-infinitime-and-the-bootloader) are you running?
|
||||||
|
If you are running an older version, please consider [updating to the latest firmware](https://github.com/JF002/InfiniTime/blob/develop/doc/gettingStarted/gettingStarted-1.0.md#how-to-update-your-pinetime).
|
||||||
|
If you are running directly from git, specify the branch or the commit hash directly.
|
||||||
|
placeholder: "Ex. v1.6.0 or develop or fc922b60"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: companion-app
|
||||||
|
attributes:
|
||||||
|
label: Companion app
|
||||||
|
description: Which companion app are you using (if relevant)?
|
||||||
|
placeholder: "Ex. Gadgetbridge v0.60.0, Siglo v0.9.4"
|
41
.github/ISSUE_TEMPLATE/feature-request.yaml
vendored
Normal file
41
.github/ISSUE_TEMPLATE/feature-request.yaml
vendored
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
name: Feature Request
|
||||||
|
description: File a feature request
|
||||||
|
title: ""
|
||||||
|
labels: ["feature request"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
**Thanks for taking the time to fill out this feature request!**
|
||||||
|
*Please, before opening a feature request, check if similar issues already exist. In that case, use those issues to provide your feedback instead.*
|
||||||
|
- type: checkboxes
|
||||||
|
attributes:
|
||||||
|
options:
|
||||||
|
- label: I searched for similar feature request and found none was relevant.
|
||||||
|
required: true
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
**Note:** keep in mind that, while InfiniTime is usable, it is still under heavy development and as such it is continuously evolving.
|
||||||
|
Some features you want to see implemented might not be compatible with the current state of the project, or might not even be suitable to include *in the firmware* of the watch.
|
||||||
|
- type: input
|
||||||
|
id: desc-brief
|
||||||
|
attributes:
|
||||||
|
label: Pitch us your idea!
|
||||||
|
description: A one-line elevator pitch of the feature you'd like to see implemented.
|
||||||
|
placeholder: "Ex. My dog wants InfiniTime on its smart collar."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: desc-long
|
||||||
|
attributes:
|
||||||
|
label: Description
|
||||||
|
description: |
|
||||||
|
Give us a detailed description of the feature you are proposing. Mockups or a description of the possible use cases are highly appreciated.
|
||||||
|
Tell us why this should be included in the firmware.
|
||||||
|
placeholder: "Ex. Here is a drawing of my dog wearing an InfiniTime collar and smiling."
|
||||||
|
- type: markdown
|
||||||
|
id: companion-app
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
If this requires features missing from other software (for example a companion app), please take care of opening any relevant feature request over there as well.
|
|
@ -1,6 +1,6 @@
|
||||||
# InfiniTime
|
# InfiniTime
|
||||||
|
|
||||||
[![Build PineTime Firmware](https://github.com/JF002/InfiniTime/workflows/Build%20PineTime%20Firmware/badge.svg?branch=master)](https://github.com/JF002/InfiniTime/actions)
|
[![Build PineTime Firmware](https://github.com/InfiniTimeOrg/InfiniTime/workflows/Build%20PineTime%20Firmware/badge.svg?branch=master)](https://github.com/InfiniTimeOrg/InfiniTime/actions)
|
||||||
|
|
||||||
![InfiniTime logo](images/infinitime-logo.jpg "InfiniTime Logo")
|
![InfiniTime logo](images/infinitime-logo.jpg "InfiniTime Logo")
|
||||||
|
|
||||||
|
@ -72,7 +72,8 @@ As of now, here is the list of achievements of this project:
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
### Develop
|
### Develop
|
||||||
|
- [Rough structure of the code](doc/code/Intro.md)
|
||||||
|
- [How to implement an application](doc/code/Apps.md)
|
||||||
- [Generate the fonts and symbols](src/displayapp/fonts/README.md)
|
- [Generate the fonts and symbols](src/displayapp/fonts/README.md)
|
||||||
- [Creating a stopwatch in Pinetime(article)](https://pankajraghav.com/2021/04/03/PINETIME-STOPCLOCK.html)
|
- [Creating a stopwatch in Pinetime(article)](https://pankajraghav.com/2021/04/03/PINETIME-STOPCLOCK.html)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# About this bootloader
|
# About this bootloader
|
||||||
The [bootloader](https://github.com/lupyuen/pinetime-rust-mynewt/tree/master/libs/pinetime_boot/src) is mostly developed by [Lup Yuen](https://github.com/lupyuen). It is based on [MCUBoot](https://juullabs-oss.github.io/mcuboot/) and [Mynewt](https://mynewt.apache.org/).
|
The [bootloader](https://github.com/lupyuen/pinetime-rust-mynewt/tree/master/libs/pinetime_boot/src) is mostly developed by [Lup Yuen](https://github.com/lupyuen). It is based on [MCUBoot](https://www.mcuboot.com) and [Mynewt](https://mynewt.apache.org/).
|
||||||
|
|
||||||
The goal of this project is to provide a common bootloader for multiple (all?) Pinetime projects. It allows to upgrade the current bootloader and even replace the current application by another one that supports the same bootloader.
|
The goal of this project is to provide a common bootloader for multiple (all?) Pinetime projects. It allows to upgrade the current bootloader and even replace the current application by another one that supports the same bootloader.
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ make pinetime-mcuboot-app
|
||||||
|
|
||||||
The binary is located in *<build directory>/src/pinetime-mcuboot-app.bin*.
|
The binary is located in *<build directory>/src/pinetime-mcuboot-app.bin*.
|
||||||
|
|
||||||
It must me converted into a MCUBoot image using *imgtool.py* from [MCUBoot](https://github.com/JuulLabs-OSS/mcuboot/tree/master/scripts). Simply checkout the project and run the script <mcuboot root>/scripts/imgtool.py with the following command line:
|
It must me converted into a MCUBoot image using *imgtool.py* from [MCUBoot](https://github.com/mcu-tools/mcuboot/tree/master/scripts). Simply checkout the project and run the script <mcuboot root>/scripts/imgtool.py with the following command line:
|
||||||
|
|
||||||
`
|
`
|
||||||
imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header <build directory>/src/pinetime-mcuboot-app.bin image.bin
|
imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header <build directory>/src/pinetime-mcuboot-app.bin image.bin
|
||||||
|
|
|
@ -6,7 +6,7 @@ The PineTime is equipped with the following memories:
|
||||||
|
|
||||||
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...
|
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).
|
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/InfiniTimeOrg/InfiniTime/issues/313).
|
||||||
|
|
||||||
## Code sections
|
## 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.
|
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.
|
||||||
|
@ -38,7 +38,7 @@ In this analysis, I used [Linkermapviz](https://github.com/PromyLOPh/linkermapvi
|
||||||
|
|
||||||
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,...
|
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...
|
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/InfiniTimeOrg/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
|
||||||
[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](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...
|
||||||
|
@ -69,8 +69,8 @@ This way, you can easily check what needs to be optimized : we should find a way
|
||||||
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.
|
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
|
### Links
|
||||||
- Analysis with linkermapviz : https://github.com/JF002/InfiniTime/issues/313#issuecomment-842338620
|
- Analysis with linkermapviz : https://github.com/InfiniTimeOrg/InfiniTime/issues/313#issuecomment-842338620
|
||||||
- Analysis with Puncover : https://github.com/JF002/InfiniTime/issues/313#issuecomment-847311392
|
- Analysis with Puncover : https://github.com/InfiniTimeOrg/InfiniTime/issues/313#issuecomment-847311392
|
||||||
|
|
||||||
## RAM
|
## RAM
|
||||||
RAM memory contains all the data that can be modified at run-time: variables, stack, heap...
|
RAM memory contains all the data that can be modified at run-time: variables, stack, heap...
|
||||||
|
@ -93,7 +93,7 @@ int main() {
|
||||||
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.
|
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.
|
||||||
|
|
||||||
### Stack
|
### 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).
|
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/InfiniTimeOrg/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.
|
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:
|
#### Fill the stack section by a known pattern:
|
||||||
|
@ -197,10 +197,10 @@ On the following dump, the maximum stack usage is 520 bytes (0xFFFF - 0xFDF8):
|
||||||
According to my experimentations, we don't use the stack that much, and 8192 bytes is probably way too big for InfiniTime!
|
According to my experimentations, we don't use the stack that much, and 8192 bytes is probably way too big for InfiniTime!
|
||||||
|
|
||||||
#### Links
|
#### Links
|
||||||
- https://github.com/JF002/InfiniTime/issues/313#issuecomment-851035070
|
- https://github.com/InfiniTimeOrg/InfiniTime/issues/313#issuecomment-851035070
|
||||||
|
|
||||||
### Heap
|
### 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`...).
|
The heap is declared in the [linker script](https://github.com/InfiniTimeOrg/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:
|
Heap monitoring is not easy, but it seems that we can use the following code to know the current usage of the heap:
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ Using this technique, I was able to trace all malloc calls at boot (boot -> digi
|
||||||
- hr task = 304
|
- hr task = 304
|
||||||
|
|
||||||
#### Links
|
#### Links
|
||||||
- https://github.com/JF002/InfiniTime/issues/313#issuecomment-851035625
|
- https://github.com/InfiniTimeOrg/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-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-2-properly-allocating-stacks/
|
||||||
- https://www.embedded.com/mastering-stack-and-heap-for-system-reliability-part-3-avoiding-heap-errors/
|
- https://www.embedded.com/mastering-stack-and-heap-for-system-reliability-part-3-avoiding-heap-errors/
|
||||||
|
@ -263,7 +263,7 @@ 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).
|
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
|
### Links
|
||||||
- https://github.com/JF002/InfiniTime/issues/313#issuecomment-850890064
|
- https://github.com/InfiniTimeOrg/InfiniTime/issues/313#issuecomment-850890064
|
||||||
|
|
||||||
|
|
||||||
## FreeRTOS heap and task stack
|
## FreeRTOS heap and task stack
|
||||||
|
|
|
@ -9,19 +9,19 @@ manDist (string) - Manouvre Distance, the distance to the upcoming change
|
||||||
progress (uint8) - Percent complete of total route, value 0-100
|
progress (uint8) - Percent complete of total route, value 0-100
|
||||||
|
|
||||||
## Service
|
## Service
|
||||||
The service UUID is c7e60001-78fc-48fe-8e23-433b3a1942d0
|
The service UUID is 00010000-78fc-48fe-8e23-433b3a1942d0
|
||||||
|
|
||||||
## Characteristics
|
## Characteristics
|
||||||
## Flags (UUID c7e60002-78fc-48fe-8e23-433b3a1942d0)
|
## Flags (UUID 00010001-78fc-48fe-8e23-433b3a1942d0)
|
||||||
All included icons are from pure-maps, which provides the actual routing from the client. The icon names ultimately come from the mapbox project "direction-icons", See https://github.com/rinigus/pure-maps/tree/master/qml/icons/navigation See the end of this document for the full lsit of supported icon names.
|
All included icons are from pure-maps, which provides the actual routing from the client. The icon names ultimately come from the mapbox project "direction-icons", See https://github.com/rinigus/pure-maps/tree/master/qml/icons/navigation See the end of this document for the full lsit of supported icon names.
|
||||||
|
|
||||||
## Narrative (UUID c7e60003-78fc-48fe-8e23-433b3a1942d0)
|
## Narrative (UUID 00010002-78fc-48fe-8e23-433b3a1942d0)
|
||||||
This is a client supplied string describing the upcoming instruction such as "At the roundabout take the first exit".
|
This is a client supplied string describing the upcoming instruction such as "At the roundabout take the first exit".
|
||||||
|
|
||||||
## Man Dist (UUID c7e60004-78fc-48fe-8e23-433b3a1942d0)
|
## Man Dist (UUID 00010003-78fc-48fe-8e23-433b3a1942d0)
|
||||||
This is a short string describing the distance to the upcoming instruction such as "50 m".
|
This is a short string describing the distance to the upcoming instruction such as "50 m".
|
||||||
|
|
||||||
## Progress (UUID c7e60001=5-78fc-48fe-8e23-433b3a1942d0)
|
## Progress (UUID 00010004-78fc-48fe-8e23-433b3a1942d0)
|
||||||
The percent complete in a uint8. The watch displays this as an overall progress in a progress bar.
|
The percent complete in a uint8. The watch displays this as an overall progress in a progress bar.
|
||||||
|
|
||||||
## Full icon list
|
## Full icon list
|
||||||
|
|
|
@ -9,7 +9,7 @@ To build this project, you'll need:
|
||||||
## Build steps
|
## Build steps
|
||||||
### Clone the repo
|
### Clone the repo
|
||||||
```
|
```
|
||||||
git clone https://github.com/JF002/InfiniTime.git
|
git clone https://github.com/InfiniTimeOrg/InfiniTime.git
|
||||||
cd InfiniTime
|
cd InfiniTime
|
||||||
git submodule update --init
|
git submodule update --init
|
||||||
mkdir build
|
mkdir build
|
||||||
|
@ -31,9 +31,9 @@ CMake configures the project according to variables you specify the command line
|
||||||
**WATCH_COLMI_P8**|Use pin configuration for Colmi P8 watch|`-DWATCH_COLMI_P8=1`
|
**WATCH_COLMI_P8**|Use pin configuration for Colmi P8 watch|`-DWATCH_COLMI_P8=1`
|
||||||
|
|
||||||
####(**) Note about **CMAKE_BUILD_TYPE**:
|
####(**) Note about **CMAKE_BUILD_TYPE**:
|
||||||
By default, this variable is set to *Release*. It compiles the code with size and speed optimizations. We use this value for all the binaries we publish when we [release](https://github.com/JF002/InfiniTime/releases) new versions of InfiniTime.
|
By default, this variable is set to *Release*. It compiles the code with size and speed optimizations. We use this value for all the binaries we publish when we [release](https://github.com/InfiniTimeOrg/InfiniTime/releases) new versions of InfiniTime.
|
||||||
|
|
||||||
The *Debug* mode disables all optimizations, which makes the code easier to debug. However, the binary size will likely be too big to fit in the internal flash memory. If you want to build and debug a *Debug* binary, you'll need to disable some parts of the code. For example, the icons for the **Navigation** app use a lot of memory space. You can comment the content of `m_iconMap` in the [Navigation](https://github.com/JF002/InfiniTime/blob/develop/src/displayapp/screens/Navigation.h#L148) application to free some memory.
|
The *Debug* mode disables all optimizations, which makes the code easier to debug. However, the binary size will likely be too big to fit in the internal flash memory. If you want to build and debug a *Debug* binary, you'll need to disable some parts of the code. For example, the icons for the **Navigation** app use a lot of memory space. You can comment the content of `m_iconMap` in the [Navigation](https://github.com/InfiniTimeOrg/InfiniTime/blob/develop/src/displayapp/screens/Navigation.h#L148) application to free some memory.
|
||||||
|
|
||||||
####(**) Note about **BUILD_DFU**:
|
####(**) Note about **BUILD_DFU**:
|
||||||
DFU files are the files you'll need to install your build of InfiniTime using OTA (over-the-air) mecanism. To generate the DFU file, the Python tool [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) is needed on your system. Check that this tool is properly installed before enabling this option.
|
DFU files are the files you'll need to install your build of InfiniTime using OTA (over-the-air) mecanism. To generate the DFU file, the Python tool [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) is needed on your system. Check that this tool is properly installed before enabling this option.
|
||||||
|
|
|
@ -36,7 +36,17 @@ Using the [Remote-Containers](https://marketplace.visualstudio.com/items?itemNam
|
||||||
|
|
||||||
More documentation is available in the [readme in .devcontainer](.devcontainer/readme.md)
|
More documentation is available in the [readme in .devcontainer](.devcontainer/readme.md)
|
||||||
|
|
||||||
|
### DevContainer on Ubuntu
|
||||||
|
To use the DevContainer configuration on Ubuntu based systems two changes need to be made:
|
||||||
|
|
||||||
|
1. Modify the file ``.devcontainer/devcontainer.json`` and add the argument ``"--net=host"`` to the ``"runArgs"`` parameter making the line look like this:
|
||||||
|
`` "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined", "--net=host"],
|
||||||
|
``
|
||||||
|
2. Modify the file ``.vscode/launch.json`` and change the argument of ``"gdbTarget"`` to ``"127.0.0.1:3333"``, making the line look like:
|
||||||
|
``"gdbTarget": "127.0.0.1:3333",``
|
||||||
|
3. To start debugging launch openocd on your host system with the appropriate configuration, for example with a stlink-v2 the command is:
|
||||||
|
``openocd -f interface/stlink.cfg -f target/nrf52.cfg``. This launches openocd with the default ports ``3333``, ``4444`` and ``6666``.
|
||||||
|
4. In VsCode go to the Debug pane on the left of the screen and select the configuration ``Debug - Openocd docker Remote`` and hit the play button on the left.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
106
doc/code/Apps.md
Normal file
106
doc/code/Apps.md
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
# Apps
|
||||||
|
This page will teach you:
|
||||||
|
- what apps in InfiniTime are
|
||||||
|
- how to implement your own app
|
||||||
|
|
||||||
|
## Theory
|
||||||
|
Apps are the things you can launch from the app selection you get by swiping up.
|
||||||
|
At the moment, settings and even the app launcher itself or the clock are implemented very similarly, this might change in the future though.
|
||||||
|
Every app in InfiniTime is it's own class.
|
||||||
|
An instance of the class is created when the app is launched and destroyed when the user exits the app.
|
||||||
|
They run inside the "displayapp" task (briefly discussed [here](./Intro.md)).
|
||||||
|
Apps are responsible for everything drawn on the screen when they are running.
|
||||||
|
By default, apps only do something (as in a function is executed) when they are created or when a touch event is detected.
|
||||||
|
|
||||||
|
## Interface
|
||||||
|
Every app class has to be inside the namespace `Pinetime::Applications::Screens` and inherit from `Screen`.
|
||||||
|
The constructor should have at least one parameter `DisplayApp* app`, which it needs for the constructor of its parent class Screen.
|
||||||
|
Other parameters should be references to controllers that the app needs.
|
||||||
|
A destructor is needed to clean up LVGL and restore any changes (for example re-enable sleeping).
|
||||||
|
App classes can override `bool OnButtonPushed()`, `bool OnTouchEvent(TouchEvents event)` and `bool OnTouchEvent(uint16_t x, uint16_t y)` to implement their own functionality for those events.
|
||||||
|
If an app only needs to display some text and do something upon a touch screen button press,
|
||||||
|
it does not need to override any of these functions, as LVGL can also handle touch events for you.
|
||||||
|
If you have any doubts, you can always look at how the other apps are doing things.
|
||||||
|
|
||||||
|
### Continuous updating
|
||||||
|
If your app needs to be updated continuously, yo can do so by overriding the `Refresh()` function in your class
|
||||||
|
and calling `lv_task_create` inside the constructor.
|
||||||
|
An example call could look like this: <br>
|
||||||
|
`taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);` <br>
|
||||||
|
With `taskRefresh` being a member variable of your class and of type `lv_task_t*`.
|
||||||
|
Remember to delete the task again using `lv_task_del`.
|
||||||
|
The function `RefreshTaskCallback` is inherited from screen and just calls your `Refresh` function.
|
||||||
|
|
||||||
|
### Apps with multiple screens
|
||||||
|
InfiniTime provides a mini-library in [displayapp/screens/ScreenList.h](/src/displayapp/screens/ScreenList.h)
|
||||||
|
which makes it relatively easy to add multiple screens to your app.
|
||||||
|
To use it, #include it in the header file of your app and add a ScreenList member to your class.
|
||||||
|
The template argument should be the number of screens you need.
|
||||||
|
You will also need to add `CreateScreen` functions that return `std::unique_ptr<Screen>`
|
||||||
|
to your class, one for every screen you have.
|
||||||
|
There are still some things left to to that I won't cover here.
|
||||||
|
To figure them out, have a look at the "apps" ApplicationList, Settings and SystemInfo.
|
||||||
|
|
||||||
|
|
||||||
|
## Creating your own app
|
||||||
|
A minimal app could look like this: <br>
|
||||||
|
MyApp.h:
|
||||||
|
```cpp
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "displayapp/screens/Screen.h"
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
|
||||||
|
namespace PineTime {
|
||||||
|
namespace Applications {
|
||||||
|
namespace Screens {
|
||||||
|
class MyApp : public Screen {
|
||||||
|
public:
|
||||||
|
MyApp(DisplayApp* app);
|
||||||
|
~MyApp() override;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
MyApp.cpp:
|
||||||
|
```cpp
|
||||||
|
#include "MyApp.h"
|
||||||
|
#include "displayapp/DisplayApp.h"
|
||||||
|
|
||||||
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
MyApp::MyApp(DisplayApp* app) : Screen(app) {
|
||||||
|
lv_obj_t* title = lv_label_create(lv_scr_act(), NULL);
|
||||||
|
lv_label_set_text_static(title, "My test application");
|
||||||
|
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(title, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
MyApp::~MyApp() {
|
||||||
|
lv_obj_clean(lv_scr_act());
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Both of these files should be in [displayapp/screens/](/src/displayapp/screens/)
|
||||||
|
or [displayapp/screens/settings/](/src/displayapp/screens/settings/) if it's a setting app.
|
||||||
|
|
||||||
|
Now we have our very own app, but InfiniTime does not know about it yet.
|
||||||
|
The first step is to include your MyApp.cpp (or any new cpp files for that matter)
|
||||||
|
in the compilation by adding it to [CMakeLists.txt](/CMakeLists.txt).
|
||||||
|
The next step to making it launchable is to give your app an id.
|
||||||
|
To do this, add an entry in the enum class `Pinetime::Applications::Apps` ([displayapp/Apps.h](/src/displayapp/Apps.h)).
|
||||||
|
Name this entry after your app. Add `#include "displayapp/screens/MyApp.h"` to the file [displayapp/DisplayApp.cpp](/src/displayapp/DisplayApp.cpp).
|
||||||
|
Now, go to the function `DisplayApp::LoadApp` and add another case to the switch statement.
|
||||||
|
The case will be the id you gave your app earlier.
|
||||||
|
If your app needs any additional arguments, this is the place to pass them.
|
||||||
|
|
||||||
|
If you want your app to be launched from the regular app launcher, go to [displayapp/screens/ApplicationList.cpp](/src/displayapp/screens/ApplicationList.cpp).
|
||||||
|
Add your app to one of the `CreateScreen` functions, or add another `CreateScreen` function if there are no empty spaces for your app. <br>
|
||||||
|
If your app is a setting, do the same procedure in [displayapp/screens/settings/Settings.cpp](/src/displayapp/screens/settings/Settings.cpp).
|
||||||
|
|
||||||
|
You should now be able to [build](../buildAndProgram.md) the firmware
|
||||||
|
and flash it to your PineTime. Yay!
|
||||||
|
|
||||||
|
Please remember to pay attention to the [UI guidelines](../ui_guidelines.md)
|
||||||
|
when designing an app that you want to include in mainstream InfiniTime.
|
42
doc/code/Intro.md
Normal file
42
doc/code/Intro.md
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
# Introduction to the code
|
||||||
|
This page is meant to guide you through the source code, so you can find the relevant files for what you're working on.
|
||||||
|
|
||||||
|
## FreeRTOS
|
||||||
|
Infinitime is based on FreeRTOS, a real-time operating system.
|
||||||
|
FreeRTOS provides several quality of life abstractions (for example easy software timers)
|
||||||
|
and most importantly supports multiple tasks.
|
||||||
|
If you want to read up on real-time operating systems, you can look [here](https://www.freertos.org/implementation/a00002.html) and [here](https://www.freertos.org/features.html).
|
||||||
|
The main "process" creates at least one task and then starts the FreeRTOS task scheduler.
|
||||||
|
This main "process" is the standard main() function inside [main.cpp](/src/main.cpp).
|
||||||
|
The task scheduler is responsible for giving every task enough cpu time.
|
||||||
|
As there is only one core on the SoC of the PineTime, real concurrency is impossible and the scheduler has to swap tasks in and out to emulate it.
|
||||||
|
|
||||||
|
### Tasks
|
||||||
|
Tasks are created by calling `xTaskCreate` and passing a function with the signature `void functionName(void*)`.
|
||||||
|
For more info on task creation see the [FreeRTOS Documentation](https://www.freertos.org/a00125.html).
|
||||||
|
In our case, main calls `systemTask.Start()`, which creates the **"MAIN" task**.
|
||||||
|
The function running inside that task is `SystemTask::Work()`.
|
||||||
|
You may also see this task being referred to as the **work task**.
|
||||||
|
Both functions are located inside [systemtask/SystemTask.cpp](/src/systemtask/SystemTask.cpp). `SystemTask::Work()` initializes all the driver and controller objects.
|
||||||
|
It also starts the **task "displayapp"**, which is responsible for launching and running apps, controlling the screen and handling touch events (or forwarding them to the active app).
|
||||||
|
You can find the "displayapp" task inside [displayapp/DisplayApp.cpp](/src/displayapp/DisplayApp.cpp).
|
||||||
|
There are also other tasks that are responsible for Bluetooth ("ll" and "ble" inside [libs/mynewt-nimble/porting/npl/freertos/src/nimble_port_freertos.c](/src/libs/mynewt-nimble/porting/npl/freertos/src/nimble_port_freertos.c))
|
||||||
|
and periodic tasks like heartrate measurements ([heartratetask/HeartRateTask.cpp](/src/heartratetask/HeartRateTask.cpp)). <br>
|
||||||
|
While it is possible for you to create your own task when you need it, it is recommended to just add functionality to `SystemTask::Work()` if possible.
|
||||||
|
If you absolutely need to create another task, try to guess how much [stack space](https://www.freertos.org/FAQMem.html#StackSize) (in words/4-byte packets)
|
||||||
|
it will need instead of just typing in a large-ish number.
|
||||||
|
You can use the define `configMINIMAL_STACK_SIZE` which is currently set to 120 words.
|
||||||
|
|
||||||
|
## Controllers
|
||||||
|
Controllers in InfiniTime are singleton objects that can provide access to certain resources to apps.
|
||||||
|
Some of them interface with drivers, others are the driver for the resource.
|
||||||
|
The resources provided don't have to be hardware-based.
|
||||||
|
They are declared in main.cpp and initialized in [systemtask/SystemTask.cpp](/src/systemtask/SystemTask.cpp).
|
||||||
|
Some controllers can be passed by reference to apps that need access to the resource (for example vibration motor).
|
||||||
|
They reside in [components/](/src/components/) inside their own subfolder.
|
||||||
|
|
||||||
|
## Apps
|
||||||
|
For more detail see the [Apps page](./Apps.md)
|
||||||
|
|
||||||
|
## Bluetooth
|
||||||
|
Header files with short documentation for the functions are inside [libs/mynewt-nimble/nimble/host/include/host/](/src/libs/mynewt-nimble/nimble/host/include/host/).
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## Report bugs
|
## Report bugs
|
||||||
|
|
||||||
Have you found a bug in the firmware? [Create an issue on Github](https://github.com/JF002/InfiniTime/issues) explaining the bug, how to reproduce it, the version of the firmware you use...
|
Have you found a bug in the firmware? [Create an issue on Github](https://github.com/InfiniTimeOrg/InfiniTime/issues) explaining the bug, how to reproduce it, the version of the firmware you use...
|
||||||
|
|
||||||
## Write and improve documentation
|
## Write and improve documentation
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# Using the releases
|
# Using the releases
|
||||||
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.
|
For each new *stable* version of IniniTime, a [release note](https://github.com/InfiniTimeOrg/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.
|
This page describes the files from the release notes and how to use them.
|
||||||
|
|
||||||
**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.
|
**NOTE :** the files included in different Releases could be different. This page describes the release notes of [version 0.7.1](https://github.com/InfiniTimeOrg/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 notes
|
## Files included in the release notes
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,15 @@ You might have already seen these words by reading the announcement, release not
|
||||||
|
|
||||||
Basically, a **firmware** is just a software running on the embedded hardware of a device, the PineTime in this case.
|
Basically, a **firmware** is just a software running on the embedded hardware of a device, the PineTime in this case.
|
||||||
**InfiniTime** is based on 3 distinct **firmwares**:
|
**InfiniTime** is based on 3 distinct **firmwares**:
|
||||||
- **[InfiniTime](https://github.com/JF002/InfiniTime)** itself, this is the *application firmware* running on the PineTime. This is the main firmware which provides most of the functionalities you'll use on a daily basis : bluetooth low-energy (BLE) connectivity, applications, watchfaces,...
|
- **[InfiniTime](https://github.com/InfiniTimeOrg/InfiniTime)** itself, this is the *application firmware* running on the PineTime. This is the main firmware which provides most of the functionalities you'll use on a daily basis : bluetooth low-energy (BLE) connectivity, applications, watchfaces,...
|
||||||
- **[The bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader)** is responsible for safely applying **updates** of the *application firmware*, reverting them in case of issues and load the recovery firmware when requested.
|
- **[The bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader)** is responsible for safely applying **updates** of the *application firmware*, reverting them in case of issues and load the recovery firmware when requested.
|
||||||
- **The recovery firmware** is a specific *application firmware* than can be loaded by the bootloader on user request. This firmware can be useful in case of serious issue, when the main application firmware cannot perform an OTA update correctly. Currently, this recovery firmware is based on [InfiniTime 0.14.1](https://github.com/JF002/InfiniTime/releases/tag/0.14.1).
|
- **The recovery firmware** is a specific *application firmware* than can be loaded by the bootloader on user request. This firmware can be useful in case of serious issue, when the main application firmware cannot perform an OTA update correctly. Currently, this recovery firmware is based on [InfiniTime 0.14.1](https://github.com/InfiniTimeOrg/InfiniTime/releases/tag/0.14.1).
|
||||||
|
|
||||||
**OTA** and **DFU** refer to the update of the firmware over BLE (**B**luetooth **L**ow **E**nergy). **OTA** means **O**ver **T**he **A**ir, this is a functionality that allows the user to update the firmware how their device using a wireless communication like BLE. When we talk about **DFU** (**D**igital **F**irmware **U**pdate), we refer to the file format and protocol used to send the update of the firmware to the watch over-the-air. InfiniTime implement the (legacy) DFU protocol from Nordic Semiconductor (NRF).
|
**OTA** and **DFU** refer to the update of the firmware over BLE (**B**luetooth **L**ow **E**nergy). **OTA** means **O**ver **T**he **A**ir, this is a functionality that allows the user to update the firmware how their device using a wireless communication like BLE. When we talk about **DFU** (**D**igital **F**irmware **U**pdate), we refer to the file format and protocol used to send the update of the firmware to the watch over-the-air. InfiniTime implement the (legacy) DFU protocol from Nordic Semiconductor (NRF).
|
||||||
|
|
||||||
## How to check the version of InfiniTime and the bootloader?
|
## How to check the version of InfiniTime and the bootloader?
|
||||||
|
|
||||||
Since September 2020, all PineTimes (devkits or sealed) are flashed using the **[first iteration of the bootloader](https://github.com/lupyuen/pinetime-rust-mynewt/releases/tag/v4.1.7)** and **[InfiniTime 0.7.1](https://github.com/JF002/InfiniTime/releases/tag/0.7.1)**. There was no recovery firmware at that time.
|
Since September 2020, all PineTimes (devkits or sealed) are flashed using the **[first iteration of the bootloader](https://github.com/lupyuen/pinetime-rust-mynewt/releases/tag/v4.1.7)** and **[InfiniTime 0.7.1](https://github.com/InfiniTimeOrg/InfiniTime/releases/tag/0.7.1)**. There was no recovery firmware at that time.
|
||||||
|
|
||||||
The bootloader only runs when the watch starts (from an empty battery, for example) or after a reset (after a successful OTA or a manual reset - long push on the button).
|
The bootloader only runs when the watch starts (from an empty battery, for example) or after a reset (after a successful OTA or a manual reset - long push on the button).
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ And for version >= 1.0 :
|
||||||
|
|
||||||
![InfiniTime 1.0 version](version-1.0.jpg)
|
![InfiniTime 1.0 version](version-1.0.jpg)
|
||||||
|
|
||||||
PineTime shipped from June 2021 (to be confirmed) will be flashed with the [new version of the bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader/releases/tag/1.0.0), the [recovery firmware](https://github.com/JF002/InfiniTime/releases/tag/0.14.1) and [InfiniTime 1.0](https://github.com/JF002/InfiniTime/releases/tag/1.0.0).
|
PineTime shipped from June 2021 (to be confirmed) will be flashed with the [new version of the bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader/releases/tag/1.0.0), the [recovery firmware](https://github.com/InfiniTimeOrg/InfiniTime/releases/tag/0.14.1) and [InfiniTime 1.0](https://github.com/InfiniTimeOrg/InfiniTime/releases/tag/1.0.0).
|
||||||
|
|
||||||
The bootloader is easily recognizable with it white pine cone that is progressively drawn in green. It also displays its own version on the bottom (1.0.0 as of now).
|
The bootloader is easily recognizable with it white pine cone that is progressively drawn in green. It also displays its own version on the bottom (1.0.0 as of now).
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@ If your PineTime is currently running InfiniTime 0.7.1 and the old bootloader, w
|
||||||
|
|
||||||
Using the companion app of your choice, you'll need to apply the OTA procedure for these 3 firmwares in this sequence (failing to follow this specific order might temporarily or permanently brick your device):
|
Using the companion app of your choice, you'll need to apply the OTA procedure for these 3 firmwares in this sequence (failing to follow this specific order might temporarily or permanently brick your device):
|
||||||
|
|
||||||
1. Flash the latest version of InfiniTime. The file to upload is named **pinetime-mcuboot-app-dfu-x.y.z.zip**. Here is the link to [InfiniTime 1.0](https://github.com/JF002/InfiniTime/releases/download/1.0.0/pinetime-mcuboot-app-dfu-1.0.0.zip).
|
1. Flash the latest version of InfiniTime. The file to upload is named **pinetime-mcuboot-app-dfu-x.y.z.zip**. Here is the link to [InfiniTime 1.0](https://github.com/InfiniTimeOrg/InfiniTime/releases/download/1.0.0/pinetime-mcuboot-app-dfu-1.0.0.zip).
|
||||||
2. Update the bootloader by applying the OTA procedure with the file named [**reloader-mcuboot.zip** from the repo of the bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader/releases/download/1.0.0/reloader-mcuboot.zip).
|
2. Update the bootloader by applying the OTA procedure with the file named [**reloader-mcuboot.zip** from the repo of the bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader/releases/download/1.0.0/reloader-mcuboot.zip).
|
||||||
3. Install the recovery firmware by applying the OTA procedure with the file named [**pinetime-mcuboot-recovery-loader-dfu-0.14.1.zip** from the version 0.14.1 of InfiniTime](https://github.com/JF002/InfiniTime/releases/download/0.14.1/pinetime-mcuboot-recovery-loader-dfu-0.14.1.zip).
|
3. Install the recovery firmware by applying the OTA procedure with the file named [**pinetime-mcuboot-recovery-loader-dfu-0.14.1.zip** from the version 0.14.1 of InfiniTime](https://github.com/InfiniTimeOrg/InfiniTime/releases/download/0.14.1/pinetime-mcuboot-recovery-loader-dfu-0.14.1.zip).
|
||||||
|
|
||||||
You'll find more info about this process in [this wiki page](https://wiki.pine64.org/wiki/Upgrade_PineTime_to_InfiniTime_1.0.0). You can also see the procedure in video [here](https://video.codingfield.com/videos/watch/831077c5-16f3-47b4-9b2b-c4bbfecc6529) and [here (from Amazfish)](https://video.codingfield.com/videos/watch/f7bffb3d-a6a1-43c4-8f01-f4aeff4adf9e)
|
You'll find more info about this process in [this wiki page](https://wiki.pine64.org/wiki/Upgrade_PineTime_to_InfiniTime_1.0.0). You can also see the procedure in video [here](https://video.codingfield.com/videos/watch/831077c5-16f3-47b4-9b2b-c4bbfecc6529) and [here (from Amazfish)](https://video.codingfield.com/videos/watch/f7bffb3d-a6a1-43c4-8f01-f4aeff4adf9e)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ If you just want to flash or upgrade InfiniTime on your PineTime, this page is f
|
||||||
- [How to flash InfiniTime using the SWD interface](#how-to-flash-infinitime-using-the-swd-interface)
|
- [How to flash InfiniTime using the SWD interface](#how-to-flash-infinitime-using-the-swd-interface)
|
||||||
|
|
||||||
## InfiniTime releases and versions
|
## InfiniTime releases and versions
|
||||||
All releases of InfiniTime are available on the [release page of the GitHub repo](https://github.com/JF002/InfiniTime/releases).
|
All releases of InfiniTime are available on the [release page of the GitHub repo](https://github.com/InfiniTimeOrg/InfiniTime/releases).
|
||||||
|
|
||||||
Versions that are tagged as **RELEASE CANDIDATE** are pre-release versions, that are available for testing before actually releasing a new stable version. If you want to help us debug the project and provide stable versions to other user, you can use them. If you want stable and tested version, you should not flash these release candidate version.
|
Versions that are tagged as **RELEASE CANDIDATE** are pre-release versions, that are available for testing before actually releasing a new stable version. If you want to help us debug the project and provide stable versions to other user, you can use them. If you want stable and tested version, you should not flash these release candidate version.
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ GetGcc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
GetMcuBoot() {
|
GetMcuBoot() {
|
||||||
git clone https://github.com/JuulLabs-OSS/mcuboot.git "$TOOLS_DIR/mcuboot"
|
git clone https://github.com/mcu-tools/mcuboot.git "$TOOLS_DIR/mcuboot"
|
||||||
pip3 install -r "$TOOLS_DIR/mcuboot/scripts/requirements.txt"
|
pip3 install -r "$TOOLS_DIR/mcuboot/scripts/requirements.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/BootErrors.h
Normal file
10
src/BootErrors.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
namespace System {
|
||||||
|
enum class BootErrors {
|
||||||
|
None,
|
||||||
|
TouchController,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -421,6 +421,7 @@ list(APPEND SOURCE_FILES
|
||||||
displayapp/screens/BatteryInfo.cpp
|
displayapp/screens/BatteryInfo.cpp
|
||||||
displayapp/screens/Steps.cpp
|
displayapp/screens/Steps.cpp
|
||||||
displayapp/screens/Timer.cpp
|
displayapp/screens/Timer.cpp
|
||||||
|
displayapp/screens/Error.cpp
|
||||||
displayapp/screens/Alarm.cpp
|
displayapp/screens/Alarm.cpp
|
||||||
displayapp/Colors.cpp
|
displayapp/Colors.cpp
|
||||||
|
|
||||||
|
@ -432,6 +433,8 @@ list(APPEND SOURCE_FILES
|
||||||
displayapp/screens/settings/SettingWakeUp.cpp
|
displayapp/screens/settings/SettingWakeUp.cpp
|
||||||
displayapp/screens/settings/SettingDisplay.cpp
|
displayapp/screens/settings/SettingDisplay.cpp
|
||||||
displayapp/screens/settings/SettingSteps.cpp
|
displayapp/screens/settings/SettingSteps.cpp
|
||||||
|
displayapp/screens/settings/SettingSetDate.cpp
|
||||||
|
displayapp/screens/settings/SettingSetTime.cpp
|
||||||
|
|
||||||
## Watch faces
|
## Watch faces
|
||||||
displayapp/icons/bg_clock.c
|
displayapp/icons/bg_clock.c
|
||||||
|
|
|
@ -13,7 +13,7 @@ Battery::Battery() {
|
||||||
nrf_gpio_cfg_input(PinMap::Charging, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Disabled);
|
nrf_gpio_cfg_input(PinMap::Charging, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battery::Update() {
|
void Battery::ReadPowerState() {
|
||||||
isCharging = !nrf_gpio_pin_read(PinMap::Charging);
|
isCharging = !nrf_gpio_pin_read(PinMap::Charging);
|
||||||
isPowerPresent = !nrf_gpio_pin_read(PinMap::PowerPresent);
|
isPowerPresent = !nrf_gpio_pin_read(PinMap::PowerPresent);
|
||||||
|
|
||||||
|
@ -22,6 +22,10 @@ void Battery::Update() {
|
||||||
} else if (!isPowerPresent) {
|
} else if (!isPowerPresent) {
|
||||||
isFull = false;
|
isFull = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Battery::MeasureVoltage() {
|
||||||
|
ReadPowerState();
|
||||||
|
|
||||||
if (isReading) {
|
if (isReading) {
|
||||||
return;
|
return;
|
||||||
|
@ -69,18 +73,23 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) {
|
||||||
// p_event->data.done.p_buffer[0] = (adc_voltage / reference_voltage) * 1024
|
// p_event->data.done.p_buffer[0] = (adc_voltage / reference_voltage) * 1024
|
||||||
voltage = p_event->data.done.p_buffer[0] * (8 * 600) / 1024;
|
voltage = p_event->data.done.p_buffer[0] * (8 * 600) / 1024;
|
||||||
|
|
||||||
|
uint8_t newPercent;
|
||||||
if (isFull) {
|
if (isFull) {
|
||||||
percentRemaining = 100;
|
newPercent = 100;
|
||||||
} else if (voltage < battery_min) {
|
} else if (voltage < battery_min) {
|
||||||
percentRemaining = 0;
|
newPercent = 0;
|
||||||
} else {
|
} else {
|
||||||
percentRemaining = std::min((voltage - battery_min) * 100 / (battery_max - battery_min), isCharging ? 99 : 100);
|
newPercent = std::min((voltage - battery_min) * 100 / (battery_max - battery_min), isCharging ? 99 : 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((isPowerPresent && newPercent > percentRemaining) || (!isPowerPresent && newPercent < percentRemaining) || firstMeasurement) {
|
||||||
|
firstMeasurement = false;
|
||||||
|
percentRemaining = newPercent;
|
||||||
|
systemTask->PushMessage(System::Messages::BatteryPercentageUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
nrfx_saadc_uninit();
|
nrfx_saadc_uninit();
|
||||||
isReading = false;
|
isReading = false;
|
||||||
|
|
||||||
systemTask->PushMessage(System::Messages::BatteryMeasurementDone);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@ namespace Pinetime {
|
||||||
public:
|
public:
|
||||||
Battery();
|
Battery();
|
||||||
|
|
||||||
void Update();
|
void ReadPowerState();
|
||||||
|
void MeasureVoltage();
|
||||||
void Register(System::SystemTask* systemTask);
|
void Register(System::SystemTask* systemTask);
|
||||||
|
|
||||||
uint8_t PercentRemaining() const {
|
uint8_t PercentRemaining() const {
|
||||||
|
@ -42,6 +43,7 @@ namespace Pinetime {
|
||||||
bool isFull = false;
|
bool isFull = false;
|
||||||
bool isCharging = false;
|
bool isCharging = false;
|
||||||
bool isPowerPresent = false;
|
bool isPowerPresent = false;
|
||||||
|
bool firstMeasurement = true;
|
||||||
|
|
||||||
void SaadcInit();
|
void SaadcInit();
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ bool AlertNotificationClient::OnDiscoveryEvent(uint16_t connectionHandle, const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (service != nullptr && ble_uuid_cmp(((ble_uuid_t*) &ansServiceUuid), &service->uuid.u) == 0) {
|
if (service != nullptr && ble_uuid_cmp(&ansServiceUuid.u, &service->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("ANS discovered : 0x%x - 0x%x", service->start_handle, service->end_handle);
|
NRF_LOG_INFO("ANS discovered : 0x%x - 0x%x", service->start_handle, service->end_handle);
|
||||||
ansStartHandle = service->start_handle;
|
ansStartHandle = service->start_handle;
|
||||||
ansEndHandle = service->end_handle;
|
ansEndHandle = service->end_handle;
|
||||||
|
@ -80,21 +80,21 @@ int AlertNotificationClient::OnCharacteristicsDiscoveryEvent(uint16_t connection
|
||||||
} else
|
} else
|
||||||
onServiceDiscovered(connectionHandle);
|
onServiceDiscovered(connectionHandle);
|
||||||
} else {
|
} else {
|
||||||
if (characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*) &supportedNewAlertCategoryUuid), &characteristic->uuid.u) == 0) {
|
if (characteristic != nullptr && ble_uuid_cmp(&supportedNewAlertCategoryUuid.u, &characteristic->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("ANS Characteristic discovered : supportedNewAlertCategoryUuid");
|
NRF_LOG_INFO("ANS Characteristic discovered : supportedNewAlertCategoryUuid");
|
||||||
supportedNewAlertCategoryHandle = characteristic->val_handle;
|
supportedNewAlertCategoryHandle = characteristic->val_handle;
|
||||||
} else if (characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*) &supportedUnreadAlertCategoryUuid), &characteristic->uuid.u) == 0) {
|
} else if (characteristic != nullptr && ble_uuid_cmp(&supportedUnreadAlertCategoryUuid.u, &characteristic->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("ANS Characteristic discovered : supportedUnreadAlertCategoryUuid");
|
NRF_LOG_INFO("ANS Characteristic discovered : supportedUnreadAlertCategoryUuid");
|
||||||
supportedUnreadAlertCategoryHandle = characteristic->val_handle;
|
supportedUnreadAlertCategoryHandle = characteristic->val_handle;
|
||||||
} else if (characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*) &newAlertUuid), &characteristic->uuid.u) == 0) {
|
} else if (characteristic != nullptr && ble_uuid_cmp(&newAlertUuid.u, &characteristic->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("ANS Characteristic discovered : newAlertUuid");
|
NRF_LOG_INFO("ANS Characteristic discovered : newAlertUuid");
|
||||||
newAlertHandle = characteristic->val_handle;
|
newAlertHandle = characteristic->val_handle;
|
||||||
newAlertDefHandle = characteristic->def_handle;
|
newAlertDefHandle = characteristic->def_handle;
|
||||||
isCharacteristicDiscovered = true;
|
isCharacteristicDiscovered = true;
|
||||||
} else if (characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*) &unreadAlertStatusUuid), &characteristic->uuid.u) == 0) {
|
} else if (characteristic != nullptr && ble_uuid_cmp(&unreadAlertStatusUuid.u, &characteristic->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("ANS Characteristic discovered : unreadAlertStatusUuid");
|
NRF_LOG_INFO("ANS Characteristic discovered : unreadAlertStatusUuid");
|
||||||
unreadAlertStatusHandle = characteristic->val_handle;
|
unreadAlertStatusHandle = characteristic->val_handle;
|
||||||
} else if (characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*) &controlPointUuid), &characteristic->uuid.u) == 0) {
|
} else if (characteristic != nullptr && ble_uuid_cmp(&controlPointUuid.u, &characteristic->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("ANS Characteristic discovered : controlPointUuid");
|
NRF_LOG_INFO("ANS Characteristic discovered : controlPointUuid");
|
||||||
controlPointHandle = characteristic->val_handle;
|
controlPointHandle = characteristic->val_handle;
|
||||||
} else
|
} else
|
||||||
|
@ -119,7 +119,7 @@ int AlertNotificationClient::OnDescriptorDiscoveryEventCallback(uint16_t connect
|
||||||
uint16_t characteristicValueHandle,
|
uint16_t characteristicValueHandle,
|
||||||
const ble_gatt_dsc* descriptor) {
|
const ble_gatt_dsc* descriptor) {
|
||||||
if (error->status == 0) {
|
if (error->status == 0) {
|
||||||
if (characteristicValueHandle == newAlertHandle && ble_uuid_cmp(((ble_uuid_t*) &newAlertUuid), &descriptor->uuid.u)) {
|
if (characteristicValueHandle == newAlertHandle && ble_uuid_cmp(&newAlertUuid.u, &descriptor->uuid.u)) {
|
||||||
if (newAlertDescriptorHandle == 0) {
|
if (newAlertDescriptorHandle == 0) {
|
||||||
NRF_LOG_INFO("ANS Descriptor discovered : %d", descriptor->handle);
|
NRF_LOG_INFO("ANS Descriptor discovered : %d", descriptor->handle);
|
||||||
newAlertDescriptorHandle = descriptor->handle;
|
newAlertDescriptorHandle = descriptor->handle;
|
||||||
|
|
|
@ -26,11 +26,8 @@ void AlertNotificationService::Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertNotificationService::AlertNotificationService(System::SystemTask& systemTask, NotificationManager& notificationManager)
|
AlertNotificationService::AlertNotificationService(System::SystemTask& systemTask, NotificationManager& notificationManager)
|
||||||
: characteristicDefinition {{.uuid = (ble_uuid_t*) &ansCharUuid,
|
: characteristicDefinition {{.uuid = &ansCharUuid.u, .access_cb = AlertNotificationCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE},
|
||||||
.access_cb = AlertNotificationCallback,
|
{.uuid = ¬ificationEventUuid.u,
|
||||||
.arg = this,
|
|
||||||
.flags = BLE_GATT_CHR_F_WRITE},
|
|
||||||
{.uuid = (ble_uuid_t*) ¬ificationEventUuid,
|
|
||||||
.access_cb = AlertNotificationCallback,
|
.access_cb = AlertNotificationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_NOTIFY,
|
.flags = BLE_GATT_CHR_F_NOTIFY,
|
||||||
|
@ -39,7 +36,7 @@ AlertNotificationService::AlertNotificationService(System::SystemTask& systemTas
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &ansUuid,
|
.uuid = &ansUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
},
|
},
|
||||||
|
@ -123,4 +120,4 @@ void AlertNotificationService::MuteIncomingCall() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ble_gattc_notify_custom(connectionHandle, eventHandle, om);
|
ble_gattc_notify_custom(connectionHandle, eventHandle, om);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ int BatteryInformationServiceCallback(uint16_t conn_handle, uint16_t attr_handle
|
||||||
|
|
||||||
BatteryInformationService::BatteryInformationService(Controllers::Battery& batteryController)
|
BatteryInformationService::BatteryInformationService(Controllers::Battery& batteryController)
|
||||||
: batteryController {batteryController},
|
: batteryController {batteryController},
|
||||||
characteristicDefinition {{.uuid = (ble_uuid_t*) &batteryLevelUuid,
|
characteristicDefinition {{.uuid = &batteryLevelUuid.u,
|
||||||
.access_cb = BatteryInformationServiceCallback,
|
.access_cb = BatteryInformationServiceCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
|
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
|
||||||
|
@ -23,7 +23,7 @@ BatteryInformationService::BatteryInformationService(Controllers::Battery& batte
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &batteryInformationServiceUuid,
|
.uuid = &batteryInformationServiceUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -47,7 +47,7 @@ bool CurrentTimeClient::OnDiscoveryEvent(uint16_t connectionHandle, const ble_ga
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (service != nullptr && ble_uuid_cmp(((ble_uuid_t*) &ctsServiceUuid), &service->uuid.u) == 0) {
|
if (service != nullptr && ble_uuid_cmp(&ctsServiceUuid.u, &service->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("CTS discovered : 0x%x - 0x%x", service->start_handle, service->end_handle);
|
NRF_LOG_INFO("CTS discovered : 0x%x - 0x%x", service->start_handle, service->end_handle);
|
||||||
isDiscovered = true;
|
isDiscovered = true;
|
||||||
ctsStartHandle = service->start_handle;
|
ctsStartHandle = service->start_handle;
|
||||||
|
@ -72,7 +72,7 @@ int CurrentTimeClient::OnCharacteristicDiscoveryEvent(uint16_t conn_handle,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*) ¤tTimeCharacteristicUuid), &characteristic->uuid.u) == 0) {
|
if (characteristic != nullptr && ble_uuid_cmp(¤tTimeCharacteristicUuid.u, &characteristic->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("CTS Characteristic discovered : 0x%x", characteristic->val_handle);
|
NRF_LOG_INFO("CTS Characteristic discovered : 0x%x", characteristic->val_handle);
|
||||||
isCharacteristicDiscovered = true;
|
isCharacteristicDiscovered = true;
|
||||||
currentTimeHandle = characteristic->val_handle;
|
currentTimeHandle = characteristic->val_handle;
|
||||||
|
|
|
@ -53,7 +53,7 @@ int CurrentTimeService::OnTimeAccessed(uint16_t conn_handle, uint16_t attr_handl
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentTimeService::CurrentTimeService(DateTime& dateTimeController)
|
CurrentTimeService::CurrentTimeService(DateTime& dateTimeController)
|
||||||
: characteristicDefinition {{.uuid = (ble_uuid_t*) &ctChrUuid,
|
: characteristicDefinition {{.uuid = &ctChrUuid.u,
|
||||||
.access_cb = CTSCallback,
|
.access_cb = CTSCallback,
|
||||||
|
|
||||||
.arg = this,
|
.arg = this,
|
||||||
|
@ -62,7 +62,7 @@ CurrentTimeService::CurrentTimeService(DateTime& dateTimeController)
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &ctsUuid,
|
.uuid = &ctsUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
},
|
},
|
||||||
|
|
|
@ -56,37 +56,37 @@ int DeviceInformationService::OnDeviceInfoRequested(uint16_t conn_handle, uint16
|
||||||
|
|
||||||
DeviceInformationService::DeviceInformationService()
|
DeviceInformationService::DeviceInformationService()
|
||||||
: characteristicDefinition {{
|
: characteristicDefinition {{
|
||||||
.uuid = (ble_uuid_t*) &manufacturerNameUuid,
|
.uuid = &manufacturerNameUuid.u,
|
||||||
.access_cb = DeviceInformationCallback,
|
.access_cb = DeviceInformationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &modelNumberUuid,
|
.uuid = &modelNumberUuid.u,
|
||||||
.access_cb = DeviceInformationCallback,
|
.access_cb = DeviceInformationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &serialNumberUuid,
|
.uuid = &serialNumberUuid.u,
|
||||||
.access_cb = DeviceInformationCallback,
|
.access_cb = DeviceInformationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &fwRevisionUuid,
|
.uuid = &fwRevisionUuid.u,
|
||||||
.access_cb = DeviceInformationCallback,
|
.access_cb = DeviceInformationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &hwRevisionUuid,
|
.uuid = &hwRevisionUuid.u,
|
||||||
.access_cb = DeviceInformationCallback,
|
.access_cb = DeviceInformationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &swRevisionUuid,
|
.uuid = &swRevisionUuid.u,
|
||||||
.access_cb = DeviceInformationCallback,
|
.access_cb = DeviceInformationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
|
@ -95,7 +95,7 @@ DeviceInformationService::DeviceInformationService()
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &deviceInfoUuid,
|
.uuid = &deviceInfoUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -33,21 +33,21 @@ DfuService::DfuService(Pinetime::System::SystemTask& systemTask,
|
||||||
bleController {bleController},
|
bleController {bleController},
|
||||||
dfuImage {spiNorFlash},
|
dfuImage {spiNorFlash},
|
||||||
characteristicDefinition {{
|
characteristicDefinition {{
|
||||||
.uuid = (ble_uuid_t*) &packetCharacteristicUuid,
|
.uuid = &packetCharacteristicUuid.u,
|
||||||
.access_cb = DfuServiceCallback,
|
.access_cb = DfuServiceCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
|
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
|
||||||
.val_handle = nullptr,
|
.val_handle = nullptr,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &controlPointCharacteristicUuid,
|
.uuid = &controlPointCharacteristicUuid.u,
|
||||||
.access_cb = DfuServiceCallback,
|
.access_cb = DfuServiceCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_NOTIFY,
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_NOTIFY,
|
||||||
.val_handle = nullptr,
|
.val_handle = nullptr,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &revisionCharacteristicUuid,
|
.uuid = &revisionCharacteristicUuid.u,
|
||||||
.access_cb = DfuServiceCallback,
|
.access_cb = DfuServiceCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
|
@ -60,7 +60,7 @@ DfuService::DfuService(Pinetime::System::SystemTask& systemTask,
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &serviceUuid,
|
.uuid = &serviceUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
} {
|
} {
|
||||||
|
@ -81,9 +81,9 @@ int DfuService::OnServiceData(uint16_t connectionHandle, uint16_t attributeHandl
|
||||||
xTimerStart(timeoutTimer, 0);
|
xTimerStart(timeoutTimer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ble_gatts_find_chr((ble_uuid_t*) &serviceUuid, (ble_uuid_t*) &packetCharacteristicUuid, nullptr, &packetCharacteristicHandle);
|
ble_gatts_find_chr(&serviceUuid.u, &packetCharacteristicUuid.u, nullptr, &packetCharacteristicHandle);
|
||||||
ble_gatts_find_chr((ble_uuid_t*) &serviceUuid, (ble_uuid_t*) &controlPointCharacteristicUuid, nullptr, &controlPointCharacteristicHandle);
|
ble_gatts_find_chr(&serviceUuid.u, &controlPointCharacteristicUuid.u, nullptr, &controlPointCharacteristicHandle);
|
||||||
ble_gatts_find_chr((ble_uuid_t*) &serviceUuid, (ble_uuid_t*) &revisionCharacteristicUuid, nullptr, &revisionCharacteristicHandle);
|
ble_gatts_find_chr(&serviceUuid.u, &revisionCharacteristicUuid.u, nullptr, &revisionCharacteristicHandle);
|
||||||
|
|
||||||
if (attributeHandle == packetCharacteristicHandle) {
|
if (attributeHandle == packetCharacteristicHandle) {
|
||||||
if (context->op == BLE_GATT_ACCESS_OP_WRITE_CHR)
|
if (context->op == BLE_GATT_ACCESS_OP_WRITE_CHR)
|
||||||
|
@ -164,10 +164,10 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) {
|
||||||
|
|
||||||
if ((nbPacketReceived % nbPacketsToNotify) == 0 && bytesReceived != applicationSize) {
|
if ((nbPacketReceived % nbPacketsToNotify) == 0 && bytesReceived != applicationSize) {
|
||||||
uint8_t data[5] {static_cast<uint8_t>(Opcodes::PacketReceiptNotification),
|
uint8_t data[5] {static_cast<uint8_t>(Opcodes::PacketReceiptNotification),
|
||||||
(uint8_t) (bytesReceived & 0x000000FFu),
|
(uint8_t)(bytesReceived & 0x000000FFu),
|
||||||
(uint8_t) (bytesReceived >> 8u),
|
(uint8_t)(bytesReceived >> 8u),
|
||||||
(uint8_t) (bytesReceived >> 16u),
|
(uint8_t)(bytesReceived >> 16u),
|
||||||
(uint8_t) (bytesReceived >> 24u)};
|
(uint8_t)(bytesReceived >> 24u)};
|
||||||
NRF_LOG_INFO("[DFU] -> Send packet notification: %d bytes received", bytesReceived);
|
NRF_LOG_INFO("[DFU] -> Send packet notification: %d bytes received", bytesReceived);
|
||||||
notificationManager.Send(connectionHandle, controlPointCharacteristicHandle, data, 5);
|
notificationManager.Send(connectionHandle, controlPointCharacteristicHandle, data, 5);
|
||||||
}
|
}
|
||||||
|
@ -422,9 +422,9 @@ uint16_t DfuService::DfuImage::ComputeCrc(uint8_t const* p_data, uint32_t size,
|
||||||
uint16_t crc = (p_crc == NULL) ? 0xFFFF : *p_crc;
|
uint16_t crc = (p_crc == NULL) ? 0xFFFF : *p_crc;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < size; i++) {
|
for (uint32_t i = 0; i < size; i++) {
|
||||||
crc = (uint8_t) (crc >> 8) | (crc << 8);
|
crc = (uint8_t)(crc >> 8) | (crc << 8);
|
||||||
crc ^= p_data[i];
|
crc ^= p_data[i];
|
||||||
crc ^= (uint8_t) (crc & 0xFF) >> 4;
|
crc ^= (uint8_t)(crc & 0xFF) >> 4;
|
||||||
crc ^= (crc << 8) << 4;
|
crc ^= (crc << 8) << 4;
|
||||||
crc ^= ((crc & 0xFF) << 4) << 1;
|
crc ^= ((crc & 0xFF) << 4) << 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace {
|
||||||
HeartRateService::HeartRateService(Pinetime::System::SystemTask& system, Controllers::HeartRateController& heartRateController)
|
HeartRateService::HeartRateService(Pinetime::System::SystemTask& system, Controllers::HeartRateController& heartRateController)
|
||||||
: system {system},
|
: system {system},
|
||||||
heartRateController {heartRateController},
|
heartRateController {heartRateController},
|
||||||
characteristicDefinition {{.uuid = (ble_uuid_t*) &heartRateMeasurementUuid,
|
characteristicDefinition {{.uuid = &heartRateMeasurementUuid.u,
|
||||||
.access_cb = HeartRateServiceServiceCallback,
|
.access_cb = HeartRateServiceServiceCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
|
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
|
||||||
|
@ -27,7 +27,7 @@ HeartRateService::HeartRateService(Pinetime::System::SystemTask& system, Control
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &heartRateServiceUuid,
|
.uuid = &heartRateServiceUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -32,7 +32,7 @@ ImmediateAlertService::ImmediateAlertService(Pinetime::System::SystemTask& syste
|
||||||
Pinetime::Controllers::NotificationManager& notificationManager)
|
Pinetime::Controllers::NotificationManager& notificationManager)
|
||||||
: systemTask {systemTask},
|
: systemTask {systemTask},
|
||||||
notificationManager {notificationManager},
|
notificationManager {notificationManager},
|
||||||
characteristicDefinition {{.uuid = (ble_uuid_t*) &alertLevelUuid,
|
characteristicDefinition {{.uuid = &alertLevelUuid.u,
|
||||||
.access_cb = AlertLevelCallback,
|
.access_cb = AlertLevelCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
|
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
|
||||||
|
@ -41,7 +41,7 @@ ImmediateAlertService::ImmediateAlertService(Pinetime::System::SystemTask& syste
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &immediateAlertServiceUuid,
|
.uuid = &immediateAlertServiceUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
} {
|
} {
|
||||||
|
@ -72,4 +72,4 @@ int ImmediateAlertService::OnAlertLevelChanged(uint16_t connectionHandle, uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,54 +20,45 @@
|
||||||
|
|
||||||
#include "systemtask/SystemTask.h"
|
#include "systemtask/SystemTask.h"
|
||||||
|
|
||||||
int NAVCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) {
|
namespace {
|
||||||
auto navService = static_cast<Pinetime::Controllers::NavigationService*>(arg);
|
// 0001yyxx-78fc-48fe-8e23-433b3a1942d0
|
||||||
return navService->OnCommand(conn_handle, attr_handle, ctxt);
|
constexpr ble_uuid128_t CharUuid(uint8_t x, uint8_t y) {
|
||||||
}
|
return ble_uuid128_t {.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = {0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, x, y, 0x01, 0x00}};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 00010000-78fc-48fe-8e23-433b3a1942d0
|
||||||
|
constexpr ble_uuid128_t BaseUuid() {
|
||||||
|
return CharUuid(0x00, 0x00);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr ble_uuid128_t navUuid {BaseUuid()};
|
||||||
|
|
||||||
|
constexpr ble_uuid128_t navFlagCharUuid {CharUuid(0x01, 0x00)};
|
||||||
|
constexpr ble_uuid128_t navNarrativeCharUuid {CharUuid(0x02, 0x00)};
|
||||||
|
constexpr ble_uuid128_t navManDistCharUuid {CharUuid(0x03, 0x00)};
|
||||||
|
constexpr ble_uuid128_t navProgressCharUuid {CharUuid(0x04, 0x00)};
|
||||||
|
|
||||||
|
int NAVCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) {
|
||||||
|
auto navService = static_cast<Pinetime::Controllers::NavigationService*>(arg);
|
||||||
|
return navService->OnCommand(conn_handle, attr_handle, ctxt);
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
Pinetime::Controllers::NavigationService::NavigationService(Pinetime::System::SystemTask& system) : m_system(system) {
|
Pinetime::Controllers::NavigationService::NavigationService(Pinetime::System::SystemTask& system) : m_system(system) {
|
||||||
navUuid.value[14] = navId[0];
|
|
||||||
navUuid.value[15] = navId[1];
|
|
||||||
|
|
||||||
navFlagCharUuid.value[12] = navFlagCharId[0];
|
|
||||||
navFlagCharUuid.value[13] = navFlagCharId[1];
|
|
||||||
navFlagCharUuid.value[14] = navId[0];
|
|
||||||
navFlagCharUuid.value[15] = navId[1];
|
|
||||||
|
|
||||||
navNarrativeCharUuid.value[12] = navNarrativeCharId[0];
|
|
||||||
navNarrativeCharUuid.value[13] = navNarrativeCharId[1];
|
|
||||||
navNarrativeCharUuid.value[14] = navId[0];
|
|
||||||
navNarrativeCharUuid.value[15] = navId[1];
|
|
||||||
|
|
||||||
navManDistCharUuid.value[12] = navManDistCharId[0];
|
|
||||||
navManDistCharUuid.value[13] = navManDistCharId[1];
|
|
||||||
navManDistCharUuid.value[14] = navId[0];
|
|
||||||
navManDistCharUuid.value[15] = navId[1];
|
|
||||||
|
|
||||||
navProgressCharUuid.value[12] = navProgressCharId[0];
|
|
||||||
navProgressCharUuid.value[13] = navProgressCharId[1];
|
|
||||||
navProgressCharUuid.value[14] = navId[0];
|
|
||||||
navProgressCharUuid.value[15] = navId[1];
|
|
||||||
|
|
||||||
characteristicDefinition[0] = {
|
characteristicDefinition[0] = {
|
||||||
.uuid = (ble_uuid_t*) (&navFlagCharUuid), .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
.uuid = &navFlagCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
||||||
|
|
||||||
characteristicDefinition[1] = {.uuid = (ble_uuid_t*) (&navNarrativeCharUuid),
|
characteristicDefinition[1] = {
|
||||||
.access_cb = NAVCallback,
|
.uuid = &navNarrativeCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
||||||
.arg = this,
|
characteristicDefinition[2] = {
|
||||||
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
.uuid = &navManDistCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
||||||
characteristicDefinition[2] = {.uuid = (ble_uuid_t*) (&navManDistCharUuid),
|
characteristicDefinition[3] = {
|
||||||
.access_cb = NAVCallback,
|
.uuid = &navProgressCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
||||||
.arg = this,
|
|
||||||
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
|
||||||
characteristicDefinition[3] = {.uuid = (ble_uuid_t*) (&navProgressCharUuid),
|
|
||||||
.access_cb = NAVCallback,
|
|
||||||
.arg = this,
|
|
||||||
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
|
||||||
|
|
||||||
characteristicDefinition[4] = {0};
|
characteristicDefinition[4] = {0};
|
||||||
|
|
||||||
serviceDefinition[0] = {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = (ble_uuid_t*) &navUuid, .characteristics = characteristicDefinition};
|
serviceDefinition[0] = {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &navUuid.u, .characteristics = characteristicDefinition};
|
||||||
serviceDefinition[1] = {0};
|
serviceDefinition[1] = {0};
|
||||||
|
|
||||||
m_progress = 0;
|
m_progress = 0;
|
||||||
|
@ -90,13 +81,13 @@ int Pinetime::Controllers::NavigationService::OnCommand(uint16_t conn_handle, ui
|
||||||
data[notifSize] = '\0';
|
data[notifSize] = '\0';
|
||||||
os_mbuf_copydata(ctxt->om, 0, notifSize, data);
|
os_mbuf_copydata(ctxt->om, 0, notifSize, data);
|
||||||
char* s = (char*) &data[0];
|
char* s = (char*) &data[0];
|
||||||
if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t*) &navFlagCharUuid) == 0) {
|
if (ble_uuid_cmp(ctxt->chr->uuid, &navFlagCharUuid.u) == 0) {
|
||||||
m_flag = s;
|
m_flag = s;
|
||||||
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t*) &navNarrativeCharUuid) == 0) {
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, &navNarrativeCharUuid.u) == 0) {
|
||||||
m_narrative = s;
|
m_narrative = s;
|
||||||
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t*) &navManDistCharUuid) == 0) {
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, &navManDistCharUuid.u) == 0) {
|
||||||
m_manDist = s;
|
m_manDist = s;
|
||||||
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t*) &navProgressCharUuid) == 0) {
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, &navProgressCharUuid.u) == 0) {
|
||||||
m_progress = data[0];
|
m_progress = data[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,6 @@
|
||||||
#undef max
|
#undef max
|
||||||
#undef min
|
#undef min
|
||||||
|
|
||||||
// c7e60000-78fc-48fe-8e23-433b3a1942d0
|
|
||||||
#define NAVIGATION_SERVICE_UUID_BASE \
|
|
||||||
{ 0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, 0x00, 0x00, 0x00, 0x00 }
|
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace System {
|
namespace System {
|
||||||
class SystemTask;
|
class SystemTask;
|
||||||
|
@ -53,19 +49,6 @@ namespace Pinetime {
|
||||||
int getProgress();
|
int getProgress();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr uint8_t navId[2] = {0x01, 0x00};
|
|
||||||
static constexpr uint8_t navFlagCharId[2] = {0x01, 0x00};
|
|
||||||
static constexpr uint8_t navNarrativeCharId[2] = {0x02, 0x00};
|
|
||||||
static constexpr uint8_t navManDistCharId[2] = {0x03, 0x00};
|
|
||||||
static constexpr uint8_t navProgressCharId[2] = {0x04, 0x00};
|
|
||||||
|
|
||||||
ble_uuid128_t navUuid {.u = {.type = BLE_UUID_TYPE_128}, .value = NAVIGATION_SERVICE_UUID_BASE};
|
|
||||||
|
|
||||||
ble_uuid128_t navFlagCharUuid {.u = {.type = BLE_UUID_TYPE_128}, .value = NAVIGATION_SERVICE_UUID_BASE};
|
|
||||||
ble_uuid128_t navNarrativeCharUuid {.u = {.type = BLE_UUID_TYPE_128}, .value = NAVIGATION_SERVICE_UUID_BASE};
|
|
||||||
ble_uuid128_t navManDistCharUuid {.u = {.type = BLE_UUID_TYPE_128}, .value = NAVIGATION_SERVICE_UUID_BASE};
|
|
||||||
ble_uuid128_t navProgressCharUuid {.u = {.type = BLE_UUID_TYPE_128}, .value = NAVIGATION_SERVICE_UUID_BASE};
|
|
||||||
|
|
||||||
struct ble_gatt_chr_def characteristicDefinition[5];
|
struct ble_gatt_chr_def characteristicDefinition[5];
|
||||||
struct ble_gatt_svc_def serviceDefinition[2];
|
struct ble_gatt_svc_def serviceDefinition[2];
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,12 @@
|
||||||
|
|
||||||
using namespace Pinetime::Controllers;
|
using namespace Pinetime::Controllers;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
char const* DaysStringShort[] = {"--", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
|
||||||
|
char const* MonthsString[] = {"--", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
|
||||||
|
char const* MonthsStringLow[] = {"--", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||||
|
}
|
||||||
|
|
||||||
void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> t) {
|
void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> t) {
|
||||||
this->currentDateTime = t;
|
this->currentDateTime = t;
|
||||||
UpdateTime(previousSystickCounter); // Update internal state without updating the time
|
UpdateTime(previousSystickCounter); // Update internal state without updating the time
|
||||||
|
@ -80,48 +86,18 @@ void DateTime::UpdateTime(uint32_t systickCounter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* DateTime::MonthShortToString() {
|
const char* DateTime::MonthShortToString() {
|
||||||
return DateTime::MonthsString[static_cast<uint8_t>(month)];
|
return MonthsString[static_cast<uint8_t>(month)];
|
||||||
}
|
|
||||||
|
|
||||||
const char* DateTime::MonthShortToStringLow() {
|
|
||||||
return DateTime::MonthsStringLow[static_cast<uint8_t>(month)];
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* DateTime::MonthsToStringLow() {
|
|
||||||
return DateTime::MonthsLow[static_cast<uint8_t>(month)];
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* DateTime::DayOfWeekToString() {
|
|
||||||
return DateTime::DaysString[static_cast<uint8_t>(dayOfWeek)];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* DateTime::DayOfWeekShortToString() {
|
const char* DateTime::DayOfWeekShortToString() {
|
||||||
return DateTime::DaysStringShort[static_cast<uint8_t>(dayOfWeek)];
|
return DaysStringShort[static_cast<uint8_t>(dayOfWeek)];
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* DateTime::DayOfWeekToStringLow() {
|
const char* DateTime::MonthShortToStringLow(Months month) {
|
||||||
return DateTime::DaysStringLow[static_cast<uint8_t>(dayOfWeek)];
|
return MonthsStringLow[static_cast<uint8_t>(month)];
|
||||||
}
|
|
||||||
|
|
||||||
const char* DateTime::DayOfWeekShortToStringLow() {
|
|
||||||
return DateTime::DaysStringShortLow[static_cast<uint8_t>(dayOfWeek)];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DateTime::Register(Pinetime::System::SystemTask* systemTask) {
|
void DateTime::Register(Pinetime::System::SystemTask* systemTask) {
|
||||||
this->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"};
|
|
||||||
|
|
||||||
char const* DateTime::DaysStringShort[] = {"--", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
|
|
||||||
|
|
||||||
char const* DateTime::DaysString[] = {"--", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"};
|
|
||||||
|
|
||||||
char const* DateTime::MonthsString[] = {"--", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
|
|
||||||
|
|
||||||
char const* DateTime::MonthsStringLow[] = {"--", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
|
||||||
|
|
||||||
char const* DateTime::MonthsLow[] = {
|
|
||||||
"--", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
|
|
|
@ -59,12 +59,8 @@ namespace Pinetime {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* MonthShortToString();
|
const char* MonthShortToString();
|
||||||
const char* MonthShortToStringLow();
|
|
||||||
const char* MonthsToStringLow();
|
|
||||||
const char* DayOfWeekToString();
|
|
||||||
const char* DayOfWeekShortToString();
|
const char* DayOfWeekShortToString();
|
||||||
const char* DayOfWeekToStringLow();
|
static const char* MonthShortToStringLow(Months month);
|
||||||
const char* DayOfWeekShortToStringLow();
|
|
||||||
|
|
||||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime() const {
|
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime() const {
|
||||||
return currentDateTime;
|
return currentDateTime;
|
||||||
|
@ -91,14 +87,6 @@ namespace Pinetime {
|
||||||
|
|
||||||
bool isMidnightAlreadyNotified = false;
|
bool isMidnightAlreadyNotified = false;
|
||||||
System::SystemTask* systemTask = nullptr;
|
System::SystemTask* systemTask = nullptr;
|
||||||
|
|
||||||
static char const* DaysString[];
|
|
||||||
static char const* DaysStringShort[];
|
|
||||||
static char const* DaysStringLow[];
|
|
||||||
static char const* DaysStringShortLow[];
|
|
||||||
static char const* MonthsString[];
|
|
||||||
static char const* MonthsStringLow[];
|
|
||||||
static char const* MonthsLow[];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,10 @@ namespace Pinetime {
|
||||||
SettingTimeFormat,
|
SettingTimeFormat,
|
||||||
SettingDisplay,
|
SettingDisplay,
|
||||||
SettingWakeUp,
|
SettingWakeUp,
|
||||||
SettingSteps
|
SettingSteps,
|
||||||
|
SettingSetDate,
|
||||||
|
SettingSetTime,
|
||||||
|
Error,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "displayapp/screens/FlashLight.h"
|
#include "displayapp/screens/FlashLight.h"
|
||||||
#include "displayapp/screens/BatteryInfo.h"
|
#include "displayapp/screens/BatteryInfo.h"
|
||||||
#include "displayapp/screens/Steps.h"
|
#include "displayapp/screens/Steps.h"
|
||||||
|
#include "displayapp/screens/Error.h"
|
||||||
|
|
||||||
#include "drivers/Cst816s.h"
|
#include "drivers/Cst816s.h"
|
||||||
#include "drivers/St7789.h"
|
#include "drivers/St7789.h"
|
||||||
|
@ -43,6 +44,8 @@
|
||||||
#include "displayapp/screens/settings/SettingWakeUp.h"
|
#include "displayapp/screens/settings/SettingWakeUp.h"
|
||||||
#include "displayapp/screens/settings/SettingDisplay.h"
|
#include "displayapp/screens/settings/SettingDisplay.h"
|
||||||
#include "displayapp/screens/settings/SettingSteps.h"
|
#include "displayapp/screens/settings/SettingSteps.h"
|
||||||
|
#include "displayapp/screens/settings/SettingSetDate.h"
|
||||||
|
#include "displayapp/screens/settings/SettingSetTime.h"
|
||||||
|
|
||||||
#include "libs/lv_conf.h"
|
#include "libs/lv_conf.h"
|
||||||
|
|
||||||
|
@ -109,11 +112,16 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||||
touchHandler {touchHandler} {
|
touchHandler {touchHandler} {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::Start() {
|
void DisplayApp::Start(System::BootErrors error) {
|
||||||
msgQueue = xQueueCreate(queueSize, itemSize);
|
msgQueue = xQueueCreate(queueSize, itemSize);
|
||||||
|
|
||||||
// Start clock when smartwatch boots
|
bootError = error;
|
||||||
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None);
|
|
||||||
|
if (error == System::BootErrors::TouchController) {
|
||||||
|
LoadApp(Apps::Error, DisplayApp::FullRefreshDirections::None);
|
||||||
|
} else {
|
||||||
|
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None);
|
||||||
|
}
|
||||||
|
|
||||||
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) {
|
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) {
|
||||||
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
||||||
|
@ -308,6 +316,11 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
motionController);
|
motionController);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Apps::Error:
|
||||||
|
currentScreen = std::make_unique<Screens::Error>(this, bootError);
|
||||||
|
ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None);
|
||||||
|
break;
|
||||||
|
|
||||||
case Apps::FirmwareValidation:
|
case Apps::FirmwareValidation:
|
||||||
currentScreen = std::make_unique<Screens::FirmwareValidation>(this, validator);
|
currentScreen = std::make_unique<Screens::FirmwareValidation>(this, validator);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
|
@ -364,13 +377,21 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
currentScreen = std::make_unique<Screens::SettingSteps>(this, settingsController);
|
currentScreen = std::make_unique<Screens::SettingSteps>(this, settingsController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
break;
|
break;
|
||||||
|
case Apps::SettingSetDate:
|
||||||
|
currentScreen = std::make_unique<Screens::SettingSetDate>(this, dateTimeController);
|
||||||
|
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
|
break;
|
||||||
|
case Apps::SettingSetTime:
|
||||||
|
currentScreen = std::make_unique<Screens::SettingSetTime>(this, dateTimeController);
|
||||||
|
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
|
break;
|
||||||
case Apps::BatteryInfo:
|
case Apps::BatteryInfo:
|
||||||
currentScreen = std::make_unique<Screens::BatteryInfo>(this, batteryController);
|
currentScreen = std::make_unique<Screens::BatteryInfo>(this, batteryController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
break;
|
break;
|
||||||
case Apps::SysInfo:
|
case Apps::SysInfo:
|
||||||
currentScreen = std::make_unique<Screens::SystemInfo>(
|
currentScreen = std::make_unique<Screens::SystemInfo>(
|
||||||
this, dateTimeController, batteryController, brightnessController, bleController, watchdog, motionController);
|
this, dateTimeController, batteryController, brightnessController, bleController, watchdog, motionController, touchPanel);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
break;
|
break;
|
||||||
case Apps::FlashLight:
|
case Apps::FlashLight:
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "touchhandler/TouchHandler.h"
|
#include "touchhandler/TouchHandler.h"
|
||||||
|
|
||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
#include "BootErrors.h"
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::TimerController& timerController,
|
Pinetime::Controllers::TimerController& timerController,
|
||||||
Pinetime::Controllers::AlarmController& alarmController,
|
Pinetime::Controllers::AlarmController& alarmController,
|
||||||
Pinetime::Controllers::TouchHandler& touchHandler);
|
Pinetime::Controllers::TouchHandler& touchHandler);
|
||||||
void Start();
|
void Start(System::BootErrors error);
|
||||||
void PushMessage(Display::Messages msg);
|
void PushMessage(Display::Messages msg);
|
||||||
|
|
||||||
void StartApp(Apps app, DisplayApp::FullRefreshDirections direction);
|
void StartApp(Apps app, DisplayApp::FullRefreshDirections direction);
|
||||||
|
@ -116,6 +117,7 @@ namespace Pinetime {
|
||||||
|
|
||||||
Apps nextApp = Apps::None;
|
Apps nextApp = Apps::None;
|
||||||
DisplayApp::FullRefreshDirections nextDirection;
|
DisplayApp::FullRefreshDirections nextDirection;
|
||||||
|
System::BootErrors bootError;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <date/date.h>
|
#include <date/date.h>
|
||||||
#include <drivers/Watchdog.h>
|
#include <drivers/Watchdog.h>
|
||||||
#include <components/motor/MotorController.h>
|
#include <components/motor/MotorController.h>
|
||||||
|
#include <BootErrors.h>
|
||||||
#include "TouchEvents.h"
|
#include "TouchEvents.h"
|
||||||
#include "Apps.h"
|
#include "Apps.h"
|
||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
@ -58,6 +59,7 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::AlarmController& alarmController,
|
Pinetime::Controllers::AlarmController& alarmController,
|
||||||
Pinetime::Controllers::TouchHandler& touchHandler);
|
Pinetime::Controllers::TouchHandler& touchHandler);
|
||||||
void Start();
|
void Start();
|
||||||
|
void Start(Pinetime::System::BootErrors){ Start(); };
|
||||||
void PushMessage(Pinetime::Applications::Display::Messages msg);
|
void PushMessage(Pinetime::Applications::Display::Messages msg);
|
||||||
void Register(Pinetime::System::SystemTask* systemTask);
|
void Register(Pinetime::System::SystemTask* systemTask);
|
||||||
|
|
||||||
|
|
|
@ -120,10 +120,7 @@ void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (obj == btnMessage) {
|
if (obj == btnMessage) {
|
||||||
lv_obj_del(txtMessage);
|
HideInfo();
|
||||||
lv_obj_del(btnMessage);
|
|
||||||
txtMessage = nullptr;
|
|
||||||
btnMessage = nullptr;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If any other button was pressed, disable the alarm
|
// If any other button was pressed, disable the alarm
|
||||||
|
@ -174,6 +171,14 @@ void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Alarm::OnButtonPushed() {
|
||||||
|
if (txtMessage != nullptr && btnMessage != nullptr) {
|
||||||
|
HideInfo();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Alarm::UpdateAlarmTime() {
|
void Alarm::UpdateAlarmTime() {
|
||||||
lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes);
|
lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes);
|
||||||
alarmController.SetAlarmTime(alarmHours, alarmMinutes);
|
alarmController.SetAlarmTime(alarmHours, alarmMinutes);
|
||||||
|
@ -224,6 +229,12 @@ void Alarm::ShowInfo() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Alarm::HideInfo() {
|
||||||
|
lv_obj_del(btnMessage);
|
||||||
|
txtMessage = nullptr;
|
||||||
|
btnMessage = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void Alarm::SetRecurButtonState() {
|
void Alarm::SetRecurButtonState() {
|
||||||
using Pinetime::Controllers::AlarmController;
|
using Pinetime::Controllers::AlarmController;
|
||||||
switch (alarmController.Recurrence()) {
|
switch (alarmController.Recurrence()) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ namespace Pinetime {
|
||||||
~Alarm() override;
|
~Alarm() override;
|
||||||
void SetAlerting();
|
void SetAlerting();
|
||||||
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
|
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
|
||||||
|
bool OnButtonPushed() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool running;
|
bool running;
|
||||||
|
@ -46,6 +47,7 @@ namespace Pinetime {
|
||||||
void SetRecurButtonState();
|
void SetRecurButtonState();
|
||||||
void SetAlarm();
|
void SetAlarm();
|
||||||
void ShowInfo();
|
void ShowInfo();
|
||||||
|
void HideInfo();
|
||||||
void ToggleRecurrence();
|
void ToggleRecurrence();
|
||||||
void UpdateAlarmTime();
|
void UpdateAlarmTime();
|
||||||
};
|
};
|
||||||
|
|
50
src/displayapp/screens/Error.cpp
Normal file
50
src/displayapp/screens/Error.cpp
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#include "Error.h"
|
||||||
|
|
||||||
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void ButtonEventCallback(lv_obj_t* obj, lv_event_t /*event*/) {
|
||||||
|
auto* errorScreen = static_cast<Error*>(obj->user_data);
|
||||||
|
errorScreen->ButtonEventHandler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Error::Error(Pinetime::Applications::DisplayApp* app, System::BootErrors error)
|
||||||
|
: Screen(app) {
|
||||||
|
|
||||||
|
lv_obj_t* warningLabel = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(warningLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
|
||||||
|
lv_label_set_text_static(warningLabel, "Warning");
|
||||||
|
lv_obj_align(warningLabel, nullptr, LV_ALIGN_IN_TOP_MID, 0, 0);
|
||||||
|
|
||||||
|
lv_obj_t* causeLabel = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_long_mode(causeLabel, LV_LABEL_LONG_BREAK);
|
||||||
|
lv_obj_set_width(causeLabel, LV_HOR_RES);
|
||||||
|
lv_obj_align(causeLabel, warningLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
|
||||||
|
|
||||||
|
if (error == System::BootErrors::TouchController) {
|
||||||
|
lv_label_set_text_static(causeLabel, "Touch controller error detected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_obj_t* tipLabel = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_long_mode(tipLabel, LV_LABEL_LONG_BREAK);
|
||||||
|
lv_obj_set_width(tipLabel, LV_HOR_RES);
|
||||||
|
lv_label_set_text_static(tipLabel, "If you encounter problems and your device is under warranty, contact the devices seller.");
|
||||||
|
lv_obj_align(tipLabel, causeLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
|
||||||
|
|
||||||
|
btnOk = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnOk->user_data = this;
|
||||||
|
lv_obj_set_event_cb(btnOk, ButtonEventCallback);
|
||||||
|
lv_obj_set_size(btnOk, LV_HOR_RES, 50);
|
||||||
|
lv_obj_align(btnOk, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||||
|
lv_obj_set_style_local_value_str(btnOk, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Proceed");
|
||||||
|
lv_obj_set_style_local_bg_color(btnOk, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Error::ButtonEventHandler() {
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Error::~Error() {
|
||||||
|
lv_obj_clean(lv_scr_act());
|
||||||
|
}
|
21
src/displayapp/screens/Error.h
Normal file
21
src/displayapp/screens/Error.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Screen.h"
|
||||||
|
#include "BootErrors.h"
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
namespace Applications {
|
||||||
|
namespace Screens {
|
||||||
|
class Error : public Screen {
|
||||||
|
public:
|
||||||
|
Error(DisplayApp* app, System::BootErrors error);
|
||||||
|
~Error() override;
|
||||||
|
|
||||||
|
void ButtonEventHandler();
|
||||||
|
private:
|
||||||
|
lv_obj_t* btnOk;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,8 +47,8 @@ void Paddle::Refresh() {
|
||||||
dy *= -1;
|
dy *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks if it has touched the side (left side)
|
// checks if it has touched the side (right side)
|
||||||
if (ballX >= LV_VER_RES - ballSize - 1) {
|
if (ballX >= LV_HOR_RES - ballSize - 1) {
|
||||||
dx *= -1;
|
dx *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Infinitime distribution (https://github.com/JF002/Infinitime).
|
* This file is part of the Infinitime distribution (https://github.com/InfiniTimeOrg/Infinitime).
|
||||||
* Copyright (c) 2021 Kieran Cawthray.
|
* Copyright (c) 2021 Kieran Cawthray.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
|
|
@ -33,7 +33,8 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
|
||||||
Pinetime::Controllers::BrightnessController& brightnessController,
|
Pinetime::Controllers::BrightnessController& brightnessController,
|
||||||
Pinetime::Controllers::Ble& bleController,
|
Pinetime::Controllers::Ble& bleController,
|
||||||
Pinetime::Drivers::WatchdogView& watchdog,
|
Pinetime::Drivers::WatchdogView& watchdog,
|
||||||
Pinetime::Controllers::MotionController& motionController)
|
Pinetime::Controllers::MotionController& motionController,
|
||||||
|
Pinetime::Drivers::Cst816S& touchPanel)
|
||||||
: Screen(app),
|
: Screen(app),
|
||||||
dateTimeController {dateTimeController},
|
dateTimeController {dateTimeController},
|
||||||
batteryController {batteryController},
|
batteryController {batteryController},
|
||||||
|
@ -41,6 +42,7 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
|
||||||
bleController {bleController},
|
bleController {bleController},
|
||||||
watchdog {watchdog},
|
watchdog {watchdog},
|
||||||
motionController{motionController},
|
motionController{motionController},
|
||||||
|
touchPanel{touchPanel},
|
||||||
screens {app,
|
screens {app,
|
||||||
0,
|
0,
|
||||||
{[this]() -> std::unique_ptr<Screen> {
|
{[this]() -> std::unique_ptr<Screen> {
|
||||||
|
@ -141,7 +143,8 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
|
||||||
"#444444 Battery# %d%%/%03imV\n"
|
"#444444 Battery# %d%%/%03imV\n"
|
||||||
"#444444 Backlight# %s\n"
|
"#444444 Backlight# %s\n"
|
||||||
"#444444 Last reset# %s\n"
|
"#444444 Last reset# %s\n"
|
||||||
"#444444 Accel.# %s\n",
|
"#444444 Accel.# %s\n"
|
||||||
|
"#444444 Touch.# %x.%x.%x\n",
|
||||||
dateTimeController.Day(),
|
dateTimeController.Day(),
|
||||||
static_cast<uint8_t>(dateTimeController.Month()),
|
static_cast<uint8_t>(dateTimeController.Month()),
|
||||||
dateTimeController.Year(),
|
dateTimeController.Year(),
|
||||||
|
@ -156,7 +159,10 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
|
||||||
batteryController.Voltage(),
|
batteryController.Voltage(),
|
||||||
brightnessController.ToString(),
|
brightnessController.ToString(),
|
||||||
resetReason,
|
resetReason,
|
||||||
ToString(motionController.DeviceType()));
|
ToString(motionController.DeviceType()),
|
||||||
|
touchPanel.GetChipId(),
|
||||||
|
touchPanel.GetVendorId(),
|
||||||
|
touchPanel.GetFwVersion());
|
||||||
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||||
return std::make_unique<Screens::Label>(1, 5, app, label);
|
return std::make_unique<Screens::Label>(1, 5, app, label);
|
||||||
}
|
}
|
||||||
|
@ -200,11 +206,14 @@ bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
|
std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
|
||||||
TaskStatus_t tasksStatus[10];
|
static constexpr uint8_t maxTaskCount = 9;
|
||||||
|
TaskStatus_t tasksStatus[maxTaskCount];
|
||||||
|
|
||||||
lv_obj_t* infoTask = lv_table_create(lv_scr_act(), NULL);
|
lv_obj_t* infoTask = lv_table_create(lv_scr_act(), NULL);
|
||||||
lv_table_set_col_cnt(infoTask, 4);
|
lv_table_set_col_cnt(infoTask, 4);
|
||||||
lv_table_set_row_cnt(infoTask, 8);
|
lv_table_set_row_cnt(infoTask, maxTaskCount + 1);
|
||||||
lv_obj_set_pos(infoTask, 0, 10);
|
lv_obj_set_style_local_pad_all(infoTask, LV_TABLE_PART_CELL1, LV_STATE_DEFAULT, 0);
|
||||||
|
lv_obj_set_style_local_border_color(infoTask, LV_TABLE_PART_CELL1, LV_STATE_DEFAULT, LV_COLOR_GRAY);
|
||||||
|
|
||||||
lv_table_set_cell_value(infoTask, 0, 0, "#");
|
lv_table_set_cell_value(infoTask, 0, 0, "#");
|
||||||
lv_table_set_col_width(infoTask, 0, 30);
|
lv_table_set_col_width(infoTask, 0, 30);
|
||||||
|
@ -215,9 +224,9 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
|
||||||
lv_table_set_cell_value(infoTask, 0, 3, "Free");
|
lv_table_set_cell_value(infoTask, 0, 3, "Free");
|
||||||
lv_table_set_col_width(infoTask, 3, 90);
|
lv_table_set_col_width(infoTask, 3, 90);
|
||||||
|
|
||||||
auto nb = uxTaskGetSystemState(tasksStatus, sizeof(tasksStatus) / sizeof(tasksStatus[0]), nullptr);
|
auto nb = uxTaskGetSystemState(tasksStatus, maxTaskCount, nullptr);
|
||||||
std::sort(tasksStatus, tasksStatus + nb, sortById);
|
std::sort(tasksStatus, tasksStatus + nb, sortById);
|
||||||
for (uint8_t i = 0; i < nb && i < 7; i++) {
|
for (uint8_t i = 0; i < nb && i < maxTaskCount; i++) {
|
||||||
|
|
||||||
lv_table_set_cell_value(infoTask, i + 1, 0, std::to_string(tasksStatus[i].xTaskNumber).c_str());
|
lv_table_set_cell_value(infoTask, i + 1, 0, std::to_string(tasksStatus[i].xTaskNumber).c_str());
|
||||||
char state[2] = {0};
|
char state[2] = {0};
|
||||||
|
@ -261,7 +270,8 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
|
||||||
"Public License v3\n"
|
"Public License v3\n"
|
||||||
"#444444 Source code#\n"
|
"#444444 Source code#\n"
|
||||||
"#FFFF00 https://github.com/#\n"
|
"#FFFF00 https://github.com/#\n"
|
||||||
"#FFFF00 JF002/InfiniTime#");
|
"#FFFF00 InfiniTimeOrg/#\n"
|
||||||
|
"#FFFF00 InfiniTime#");
|
||||||
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
|
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
|
||||||
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||||
return std::make_unique<Screens::Label>(4, 5, app, label);
|
return std::make_unique<Screens::Label>(4, 5, app, label);
|
||||||
|
|
|
@ -28,7 +28,8 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::BrightnessController& brightnessController,
|
Pinetime::Controllers::BrightnessController& brightnessController,
|
||||||
Pinetime::Controllers::Ble& bleController,
|
Pinetime::Controllers::Ble& bleController,
|
||||||
Pinetime::Drivers::WatchdogView& watchdog,
|
Pinetime::Drivers::WatchdogView& watchdog,
|
||||||
Pinetime::Controllers::MotionController& motionController);
|
Pinetime::Controllers::MotionController& motionController,
|
||||||
|
Pinetime::Drivers::Cst816S& touchPanel);
|
||||||
~SystemInfo() override;
|
~SystemInfo() override;
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::Ble& bleController;
|
Pinetime::Controllers::Ble& bleController;
|
||||||
Pinetime::Drivers::WatchdogView& watchdog;
|
Pinetime::Drivers::WatchdogView& watchdog;
|
||||||
Pinetime::Controllers::MotionController& motionController;
|
Pinetime::Controllers::MotionController& motionController;
|
||||||
|
Pinetime::Drivers::Cst816S& touchPanel;
|
||||||
|
|
||||||
ScreenList<5> screens;
|
ScreenList<5> screens;
|
||||||
|
|
||||||
|
|
198
src/displayapp/screens/settings/SettingSetDate.cpp
Normal file
198
src/displayapp/screens/settings/SettingSetDate.cpp
Normal file
|
@ -0,0 +1,198 @@
|
||||||
|
#include "SettingSetDate.h"
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
#include <hal/nrf_rtc.h>
|
||||||
|
#include <nrf_log.h>
|
||||||
|
#include "displayapp/DisplayApp.h"
|
||||||
|
#include "displayapp/screens/Symbols.h"
|
||||||
|
|
||||||
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr int16_t POS_X_DAY = -72;
|
||||||
|
constexpr int16_t POS_X_MONTH = 0;
|
||||||
|
constexpr int16_t POS_X_YEAR = 72;
|
||||||
|
constexpr int16_t POS_Y_PLUS = -50;
|
||||||
|
constexpr int16_t POS_Y_TEXT = -6;
|
||||||
|
constexpr int16_t POS_Y_MINUS = 40;
|
||||||
|
|
||||||
|
void event_handler(lv_obj_t * obj, lv_event_t event) {
|
||||||
|
auto* screen = static_cast<SettingSetDate *>(obj->user_data);
|
||||||
|
screen->HandleButtonPress(obj, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::DateTime &dateTimeController) :
|
||||||
|
Screen(app),
|
||||||
|
dateTimeController {dateTimeController} {
|
||||||
|
lv_obj_t * title = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_text_static(title, "Set current date");
|
||||||
|
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15);
|
||||||
|
|
||||||
|
lv_obj_t * icon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
|
||||||
|
|
||||||
|
lv_label_set_text_static(icon, Symbols::clock);
|
||||||
|
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
|
||||||
|
|
||||||
|
dayValue = static_cast<int>(dateTimeController.Day());
|
||||||
|
lblDay = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_text_fmt(lblDay, "%d", dayValue);
|
||||||
|
lv_label_set_align(lblDay, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(lblDay, lv_scr_act(), LV_ALIGN_CENTER, POS_X_DAY, POS_Y_TEXT);
|
||||||
|
lv_obj_set_auto_realign(lblDay, true);
|
||||||
|
|
||||||
|
monthValue = static_cast<int>(dateTimeController.Month());
|
||||||
|
lblMonth = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
UpdateMonthLabel();
|
||||||
|
lv_label_set_align(lblMonth, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(lblMonth, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MONTH, POS_Y_TEXT);
|
||||||
|
lv_obj_set_auto_realign(lblMonth, true);
|
||||||
|
|
||||||
|
yearValue = static_cast<int>(dateTimeController.Year());
|
||||||
|
if (yearValue < 2021)
|
||||||
|
yearValue = 2021;
|
||||||
|
lblYear = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_text_fmt(lblYear, "%d", yearValue);
|
||||||
|
lv_label_set_align(lblYear, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(lblYear, lv_scr_act(), LV_ALIGN_CENTER, POS_X_YEAR, POS_Y_TEXT);
|
||||||
|
lv_obj_set_auto_realign(lblYear, true);
|
||||||
|
|
||||||
|
btnDayPlus = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnDayPlus->user_data = this;
|
||||||
|
lv_obj_set_size(btnDayPlus, 50, 40);
|
||||||
|
lv_obj_align(btnDayPlus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_DAY, POS_Y_PLUS);
|
||||||
|
lv_obj_set_style_local_value_str(btnDayPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+");
|
||||||
|
lv_obj_set_event_cb(btnDayPlus, event_handler);
|
||||||
|
|
||||||
|
btnDayMinus = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnDayMinus->user_data = this;
|
||||||
|
lv_obj_set_size(btnDayMinus, 50, 40);
|
||||||
|
lv_obj_align(btnDayMinus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_DAY, POS_Y_MINUS);
|
||||||
|
lv_obj_set_style_local_value_str(btnDayMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");
|
||||||
|
lv_obj_set_event_cb(btnDayMinus, event_handler);
|
||||||
|
|
||||||
|
btnMonthPlus = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnMonthPlus->user_data = this;
|
||||||
|
lv_obj_set_size(btnMonthPlus, 50, 40);
|
||||||
|
lv_obj_align(btnMonthPlus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MONTH, POS_Y_PLUS);
|
||||||
|
lv_obj_set_style_local_value_str(btnMonthPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+");
|
||||||
|
lv_obj_set_event_cb(btnMonthPlus, event_handler);
|
||||||
|
|
||||||
|
btnMonthMinus = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnMonthMinus->user_data = this;
|
||||||
|
lv_obj_set_size(btnMonthMinus, 50, 40);
|
||||||
|
lv_obj_align(btnMonthMinus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MONTH, POS_Y_MINUS);
|
||||||
|
lv_obj_set_style_local_value_str(btnMonthMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");
|
||||||
|
lv_obj_set_event_cb(btnMonthMinus, event_handler);
|
||||||
|
|
||||||
|
btnYearPlus = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnYearPlus->user_data = this;
|
||||||
|
lv_obj_set_size(btnYearPlus, 50, 40);
|
||||||
|
lv_obj_align(btnYearPlus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_YEAR, POS_Y_PLUS);
|
||||||
|
lv_obj_set_style_local_value_str(btnYearPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+");
|
||||||
|
lv_obj_set_event_cb(btnYearPlus, event_handler);
|
||||||
|
|
||||||
|
btnYearMinus = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnYearMinus->user_data = this;
|
||||||
|
lv_obj_set_size(btnYearMinus, 50, 40);
|
||||||
|
lv_obj_align(btnYearMinus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_YEAR, POS_Y_MINUS);
|
||||||
|
lv_obj_set_style_local_value_str(btnYearMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");
|
||||||
|
lv_obj_set_event_cb(btnYearMinus, event_handler);
|
||||||
|
|
||||||
|
btnSetTime = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnSetTime->user_data = this;
|
||||||
|
lv_obj_set_size(btnSetTime, 120, 48);
|
||||||
|
lv_obj_align(btnSetTime, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||||
|
lv_obj_set_style_local_value_str(btnSetTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Set");
|
||||||
|
lv_obj_set_event_cb(btnSetTime, event_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingSetDate::~SettingSetDate() {
|
||||||
|
lv_obj_clean(lv_scr_act());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingSetDate::HandleButtonPress(lv_obj_t *object, lv_event_t event) {
|
||||||
|
if (event != LV_EVENT_CLICKED)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (object == btnDayPlus) {
|
||||||
|
dayValue++;
|
||||||
|
if (dayValue > MaximumDayOfMonth())
|
||||||
|
dayValue = 1;
|
||||||
|
lv_label_set_text_fmt(lblDay, "%d", dayValue);
|
||||||
|
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
|
||||||
|
} else if (object == btnDayMinus) {
|
||||||
|
dayValue--;
|
||||||
|
if (dayValue < 1)
|
||||||
|
dayValue = MaximumDayOfMonth();
|
||||||
|
lv_label_set_text_fmt(lblDay, "%d", dayValue);
|
||||||
|
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
|
||||||
|
} else if (object == btnMonthPlus) {
|
||||||
|
monthValue++;
|
||||||
|
if (monthValue > 12)
|
||||||
|
monthValue = 1;
|
||||||
|
UpdateMonthLabel();
|
||||||
|
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
|
||||||
|
CheckDay();
|
||||||
|
} else if (object == btnMonthMinus) {
|
||||||
|
monthValue--;
|
||||||
|
if (monthValue < 1)
|
||||||
|
monthValue = 12;
|
||||||
|
UpdateMonthLabel();
|
||||||
|
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
|
||||||
|
CheckDay();
|
||||||
|
} else if (object == btnYearPlus) {
|
||||||
|
yearValue++;
|
||||||
|
lv_label_set_text_fmt(lblYear, "%d", yearValue);
|
||||||
|
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
|
||||||
|
CheckDay();
|
||||||
|
} else if (object == btnYearMinus) {
|
||||||
|
yearValue--;
|
||||||
|
lv_label_set_text_fmt(lblYear, "%d", yearValue);
|
||||||
|
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
|
||||||
|
CheckDay();
|
||||||
|
} else if (object == btnSetTime) {
|
||||||
|
NRF_LOG_INFO("Setting date (manually) to %04d-%02d-%02d", yearValue, monthValue, dayValue);
|
||||||
|
dateTimeController.SetTime(static_cast<uint16_t>(yearValue),
|
||||||
|
static_cast<uint8_t>(monthValue),
|
||||||
|
static_cast<uint8_t>(dayValue),
|
||||||
|
0,
|
||||||
|
dateTimeController.Hours(),
|
||||||
|
dateTimeController.Minutes(),
|
||||||
|
dateTimeController.Seconds(),
|
||||||
|
nrf_rtc_counter_get(portNRF_RTC_REG));
|
||||||
|
lv_btn_set_state(btnSetTime, LV_BTN_STATE_DISABLED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int SettingSetDate::MaximumDayOfMonth() const {
|
||||||
|
switch (monthValue) {
|
||||||
|
case 2:
|
||||||
|
if ((((yearValue % 4) == 0) && ((yearValue % 100) != 0)) || ((yearValue % 400) == 0))
|
||||||
|
return 29;
|
||||||
|
return 28;
|
||||||
|
case 4:
|
||||||
|
case 6:
|
||||||
|
case 9:
|
||||||
|
case 11:
|
||||||
|
return 30;
|
||||||
|
default:
|
||||||
|
return 31;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingSetDate::CheckDay() {
|
||||||
|
int maxDay = MaximumDayOfMonth();
|
||||||
|
if (dayValue > maxDay) {
|
||||||
|
dayValue = maxDay;
|
||||||
|
lv_label_set_text_fmt(lblDay, "%d", dayValue);
|
||||||
|
lv_obj_align(lblDay, lv_scr_act(), LV_ALIGN_CENTER, POS_X_DAY, POS_Y_TEXT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingSetDate::UpdateMonthLabel() {
|
||||||
|
lv_label_set_text_static(
|
||||||
|
lblMonth, Pinetime::Controllers::DateTime::MonthShortToStringLow(static_cast<Pinetime::Controllers::DateTime::Months>(monthValue)));
|
||||||
|
}
|
41
src/displayapp/screens/settings/SettingSetDate.h
Normal file
41
src/displayapp/screens/settings/SettingSetDate.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
#include "components/datetime/DateTimeController.h"
|
||||||
|
#include "displayapp/screens/Screen.h"
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
namespace Applications {
|
||||||
|
namespace Screens {
|
||||||
|
class SettingSetDate : public Screen{
|
||||||
|
public:
|
||||||
|
SettingSetDate(DisplayApp* app, Pinetime::Controllers::DateTime &dateTimeController);
|
||||||
|
~SettingSetDate() override;
|
||||||
|
|
||||||
|
void HandleButtonPress(lv_obj_t *object, lv_event_t event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Controllers::DateTime& dateTimeController;
|
||||||
|
|
||||||
|
int dayValue;
|
||||||
|
int monthValue;
|
||||||
|
int yearValue;
|
||||||
|
lv_obj_t * lblDay;
|
||||||
|
lv_obj_t * lblMonth;
|
||||||
|
lv_obj_t * lblYear;
|
||||||
|
lv_obj_t * btnDayPlus;
|
||||||
|
lv_obj_t * btnDayMinus;
|
||||||
|
lv_obj_t * btnMonthPlus;
|
||||||
|
lv_obj_t * btnMonthMinus;
|
||||||
|
lv_obj_t * btnYearPlus;
|
||||||
|
lv_obj_t * btnYearMinus;
|
||||||
|
lv_obj_t * btnSetTime;
|
||||||
|
|
||||||
|
int MaximumDayOfMonth() const;
|
||||||
|
void CheckDay();
|
||||||
|
void UpdateMonthLabel();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
154
src/displayapp/screens/settings/SettingSetTime.cpp
Normal file
154
src/displayapp/screens/settings/SettingSetTime.cpp
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
#include "SettingSetTime.h"
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
#include <hal/nrf_rtc.h>
|
||||||
|
#include <nrf_log.h>
|
||||||
|
#include "displayapp/DisplayApp.h"
|
||||||
|
#include "displayapp/screens/Symbols.h"
|
||||||
|
|
||||||
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr int16_t POS_X_HOURS = -72;
|
||||||
|
constexpr int16_t POS_X_MINUTES = 0;
|
||||||
|
constexpr int16_t POS_X_SECONDS = 72;
|
||||||
|
constexpr int16_t POS_Y_PLUS = -50;
|
||||||
|
constexpr int16_t POS_Y_TEXT = -6;
|
||||||
|
constexpr int16_t POS_Y_MINUS = 40;
|
||||||
|
constexpr int16_t OFS_Y_COLON = -2;
|
||||||
|
|
||||||
|
void event_handler(lv_obj_t * obj, lv_event_t event) {
|
||||||
|
auto* screen = static_cast<SettingSetTime *>(obj->user_data);
|
||||||
|
screen->HandleButtonPress(obj, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::DateTime &dateTimeController) :
|
||||||
|
Screen(app),
|
||||||
|
dateTimeController {dateTimeController} {
|
||||||
|
lv_obj_t * title = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_text_static(title, "Set current time");
|
||||||
|
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15);
|
||||||
|
|
||||||
|
lv_obj_t * icon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
|
||||||
|
|
||||||
|
lv_label_set_text_static(icon, Symbols::clock);
|
||||||
|
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
|
||||||
|
|
||||||
|
hoursValue = static_cast<int>(dateTimeController.Hours());
|
||||||
|
lblHours = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_font(lblHours, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
|
||||||
|
lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
|
||||||
|
lv_label_set_align(lblHours, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(lblHours, lv_scr_act(), LV_ALIGN_CENTER, POS_X_HOURS, POS_Y_TEXT);
|
||||||
|
lv_obj_set_auto_realign(lblHours, true);
|
||||||
|
|
||||||
|
lv_obj_t * lblColon1 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_font(lblColon1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
|
||||||
|
lv_label_set_text_static(lblColon1, ":");
|
||||||
|
lv_label_set_align(lblColon1, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(lblColon1, lv_scr_act(), LV_ALIGN_CENTER, (POS_X_HOURS + POS_X_MINUTES) / 2, POS_Y_TEXT + OFS_Y_COLON);
|
||||||
|
|
||||||
|
minutesValue = static_cast<int>(dateTimeController.Minutes());
|
||||||
|
lblMinutes = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_font(lblMinutes, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
|
||||||
|
lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue);
|
||||||
|
lv_label_set_align(lblMinutes, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(lblMinutes, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MINUTES, POS_Y_TEXT);
|
||||||
|
lv_obj_set_auto_realign(lblMinutes, true);
|
||||||
|
|
||||||
|
lv_obj_t * lblColon2 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_font(lblColon2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
|
||||||
|
lv_label_set_text_static(lblColon2, ":");
|
||||||
|
lv_label_set_align(lblColon2, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(lblColon2, lv_scr_act(), LV_ALIGN_CENTER, (POS_X_MINUTES + POS_X_SECONDS) / 2, POS_Y_TEXT + OFS_Y_COLON);
|
||||||
|
|
||||||
|
lv_obj_t * lblSeconds = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_font(lblSeconds, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
|
||||||
|
lv_label_set_text_static(lblSeconds, "00");
|
||||||
|
lv_label_set_align(lblSeconds, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(lblSeconds, lv_scr_act(), LV_ALIGN_CENTER, POS_X_SECONDS, POS_Y_TEXT);
|
||||||
|
|
||||||
|
btnHoursPlus = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnHoursPlus->user_data = this;
|
||||||
|
lv_obj_set_size(btnHoursPlus, 50, 40);
|
||||||
|
lv_obj_align(btnHoursPlus, lv_scr_act(), LV_ALIGN_CENTER, -72, -50);
|
||||||
|
lv_obj_set_style_local_value_str(btnHoursPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+");
|
||||||
|
lv_obj_set_event_cb(btnHoursPlus, event_handler);
|
||||||
|
|
||||||
|
btnHoursMinus = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnHoursMinus->user_data = this;
|
||||||
|
lv_obj_set_size(btnHoursMinus, 50, 40);
|
||||||
|
lv_obj_align(btnHoursMinus, lv_scr_act(), LV_ALIGN_CENTER, -72, 40);
|
||||||
|
lv_obj_set_style_local_value_str(btnHoursMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");
|
||||||
|
lv_obj_set_event_cb(btnHoursMinus, event_handler);
|
||||||
|
|
||||||
|
btnMinutesPlus = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnMinutesPlus->user_data = this;
|
||||||
|
lv_obj_set_size(btnMinutesPlus, 50, 40);
|
||||||
|
lv_obj_align(btnMinutesPlus, lv_scr_act(), LV_ALIGN_CENTER, 0, -50);
|
||||||
|
lv_obj_set_style_local_value_str(btnMinutesPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+");
|
||||||
|
lv_obj_set_event_cb(btnMinutesPlus, event_handler);
|
||||||
|
|
||||||
|
btnMinutesMinus = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnMinutesMinus->user_data = this;
|
||||||
|
lv_obj_set_size(btnMinutesMinus, 50, 40);
|
||||||
|
lv_obj_align(btnMinutesMinus, lv_scr_act(), LV_ALIGN_CENTER, 0, 40);
|
||||||
|
lv_obj_set_style_local_value_str(btnMinutesMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");
|
||||||
|
lv_obj_set_event_cb(btnMinutesMinus, event_handler);
|
||||||
|
|
||||||
|
btnSetTime = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnSetTime->user_data = this;
|
||||||
|
lv_obj_set_size(btnSetTime, 120, 48);
|
||||||
|
lv_obj_align(btnSetTime, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||||
|
lv_obj_set_style_local_value_str(btnSetTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Set");
|
||||||
|
lv_obj_set_event_cb(btnSetTime, event_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingSetTime::~SettingSetTime() {
|
||||||
|
lv_obj_clean(lv_scr_act());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingSetTime::HandleButtonPress(lv_obj_t *object, lv_event_t event) {
|
||||||
|
if (event != LV_EVENT_CLICKED)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (object == btnHoursPlus) {
|
||||||
|
hoursValue++;
|
||||||
|
if (hoursValue > 23)
|
||||||
|
hoursValue = 0;
|
||||||
|
lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
|
||||||
|
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
|
||||||
|
} else if (object == btnHoursMinus) {
|
||||||
|
hoursValue--;
|
||||||
|
if (hoursValue < 0)
|
||||||
|
hoursValue = 23;
|
||||||
|
lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
|
||||||
|
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
|
||||||
|
} else if (object == btnMinutesPlus) {
|
||||||
|
minutesValue++;
|
||||||
|
if (minutesValue > 59)
|
||||||
|
minutesValue = 0;
|
||||||
|
lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue);
|
||||||
|
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
|
||||||
|
} else if (object == btnMinutesMinus) {
|
||||||
|
minutesValue--;
|
||||||
|
if (minutesValue < 0)
|
||||||
|
minutesValue = 59;
|
||||||
|
lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue);
|
||||||
|
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
|
||||||
|
} else if (object == btnSetTime) {
|
||||||
|
NRF_LOG_INFO("Setting time (manually) to %02d:%02d:00", hoursValue, minutesValue);
|
||||||
|
dateTimeController.SetTime(dateTimeController.Year(),
|
||||||
|
static_cast<uint8_t>(dateTimeController.Month()),
|
||||||
|
dateTimeController.Day(),
|
||||||
|
static_cast<uint8_t>(dateTimeController.DayOfWeek()),
|
||||||
|
static_cast<uint8_t>(hoursValue),
|
||||||
|
static_cast<uint8_t>(minutesValue),
|
||||||
|
0,
|
||||||
|
nrf_rtc_counter_get(portNRF_RTC_REG));
|
||||||
|
lv_btn_set_state(btnSetTime, LV_BTN_STATE_DISABLED);
|
||||||
|
}
|
||||||
|
}
|
33
src/displayapp/screens/settings/SettingSetTime.h
Normal file
33
src/displayapp/screens/settings/SettingSetTime.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
#include "components/datetime/DateTimeController.h"
|
||||||
|
#include "displayapp/screens/Screen.h"
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
namespace Applications {
|
||||||
|
namespace Screens {
|
||||||
|
class SettingSetTime : public Screen{
|
||||||
|
public:
|
||||||
|
SettingSetTime(DisplayApp* app, Pinetime::Controllers::DateTime &dateTimeController);
|
||||||
|
~SettingSetTime() override;
|
||||||
|
|
||||||
|
void HandleButtonPress(lv_obj_t *object, lv_event_t event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Controllers::DateTime& dateTimeController;
|
||||||
|
|
||||||
|
int hoursValue;
|
||||||
|
int minutesValue;
|
||||||
|
lv_obj_t * lblHours;
|
||||||
|
lv_obj_t * lblMinutes;
|
||||||
|
lv_obj_t * btnHoursPlus;
|
||||||
|
lv_obj_t * btnHoursMinus;
|
||||||
|
lv_obj_t * btnMinutesPlus;
|
||||||
|
lv_obj_t * btnMinutesMinus;
|
||||||
|
lv_obj_t * btnSetTime;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,8 +47,20 @@ std::unique_ptr<Screen> Settings::CreateScreen2() {
|
||||||
std::array<Screens::List::Applications, 4> applications {{
|
std::array<Screens::List::Applications, 4> applications {{
|
||||||
{Symbols::shoe, "Steps", Apps::SettingSteps},
|
{Symbols::shoe, "Steps", Apps::SettingSteps},
|
||||||
{Symbols::batteryHalf, "Battery", Apps::BatteryInfo},
|
{Symbols::batteryHalf, "Battery", Apps::BatteryInfo},
|
||||||
|
{Symbols::clock, "Set date", Apps::SettingSetDate},
|
||||||
|
{Symbols::clock, "Set time", Apps::SettingSetTime}
|
||||||
|
}};
|
||||||
|
|
||||||
|
return std::make_unique<Screens::List>(1, 3, app, settingsController, applications);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Screen> Settings::CreateScreen3() {
|
||||||
|
|
||||||
|
std::array<Screens::List::Applications, 4> applications {{
|
||||||
{Symbols::check, "Firmware", Apps::FirmwareValidation},
|
{Symbols::check, "Firmware", Apps::FirmwareValidation},
|
||||||
{Symbols::list, "About", Apps::SysInfo},
|
{Symbols::list, "About", Apps::SysInfo},
|
||||||
|
{Symbols::none, "None", Apps::None},
|
||||||
|
{Symbols::none, "None", Apps::None}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
return std::make_unique<Screens::List>(1, 2, app, settingsController, applications);
|
return std::make_unique<Screens::List>(1, 2, app, settingsController, applications);
|
||||||
|
|
|
@ -18,7 +18,7 @@ using namespace Pinetime::Drivers;
|
||||||
Cst816S::Cst816S(TwiMaster& twiMaster, uint8_t twiAddress) : twiMaster {twiMaster}, twiAddress {twiAddress} {
|
Cst816S::Cst816S(TwiMaster& twiMaster, uint8_t twiAddress) : twiMaster {twiMaster}, twiAddress {twiAddress} {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cst816S::Init() {
|
bool Cst816S::Init() {
|
||||||
nrf_gpio_cfg_output(PinMap::Cst816sReset);
|
nrf_gpio_cfg_output(PinMap::Cst816sReset);
|
||||||
nrf_gpio_pin_set(PinMap::Cst816sReset);
|
nrf_gpio_pin_set(PinMap::Cst816sReset);
|
||||||
vTaskDelay(50);
|
vTaskDelay(50);
|
||||||
|
@ -51,10 +51,27 @@ void Cst816S::Init() {
|
||||||
*/
|
*/
|
||||||
static constexpr uint8_t irqCtl = 0b01110000;
|
static constexpr uint8_t irqCtl = 0b01110000;
|
||||||
twiMaster.Write(twiAddress, 0xFA, &irqCtl, 1);
|
twiMaster.Write(twiAddress, 0xFA, &irqCtl, 1);
|
||||||
|
|
||||||
|
// There's mixed information about which register contains which information
|
||||||
|
if (twiMaster.Read(twiAddress, 0xA7, &chipId, 1) == TwiMaster::ErrorCodes::TransactionFailed) {
|
||||||
|
chipId = 0xFF;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (twiMaster.Read(twiAddress, 0xA8, &vendorId, 1) == TwiMaster::ErrorCodes::TransactionFailed) {
|
||||||
|
vendorId = 0xFF;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (twiMaster.Read(twiAddress, 0xA9, &fwVersion, 1) == TwiMaster::ErrorCodes::TransactionFailed) {
|
||||||
|
fwVersion = 0xFF;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return chipId == 0xb4 && vendorId == 0 && fwVersion == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cst816S::TouchInfos Cst816S::GetTouchInfo() {
|
Cst816S::TouchInfos Cst816S::GetTouchInfo() {
|
||||||
Cst816S::TouchInfos info;
|
Cst816S::TouchInfos info;
|
||||||
|
uint8_t touchData[7];
|
||||||
|
|
||||||
auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData));
|
auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData));
|
||||||
if (ret != TwiMaster::ErrorCodes::NoError) {
|
if (ret != TwiMaster::ErrorCodes::NoError) {
|
||||||
|
@ -62,18 +79,17 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto nbTouchPoints = touchData[2] & 0x0f;
|
// This can only be 0 or 1
|
||||||
|
uint8_t nbTouchPoints = touchData[touchPointNumIndex] & 0x0f;
|
||||||
|
|
||||||
auto xHigh = touchData[touchXHighIndex] & 0x0f;
|
uint8_t xHigh = touchData[touchXHighIndex] & 0x0f;
|
||||||
auto xLow = touchData[touchXLowIndex];
|
uint8_t xLow = touchData[touchXLowIndex];
|
||||||
uint16_t x = (xHigh << 8) | xLow;
|
info.x = (xHigh << 8) | xLow;
|
||||||
|
|
||||||
auto yHigh = touchData[touchYHighIndex] & 0x0f;
|
uint8_t yHigh = touchData[touchYHighIndex] & 0x0f;
|
||||||
auto yLow = touchData[touchYLowIndex];
|
uint8_t yLow = touchData[touchYLowIndex];
|
||||||
uint16_t y = (yHigh << 8) | yLow;
|
info.y = (yHigh << 8) | yLow;
|
||||||
|
|
||||||
info.x = x;
|
|
||||||
info.y = y;
|
|
||||||
info.touching = (nbTouchPoints > 0);
|
info.touching = (nbTouchPoints > 0);
|
||||||
info.gesture = static_cast<Gestures>(touchData[gestureIndex]);
|
info.gesture = static_cast<Gestures>(touchData[gestureIndex]);
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,20 @@ namespace Pinetime {
|
||||||
Cst816S(Cst816S&&) = delete;
|
Cst816S(Cst816S&&) = delete;
|
||||||
Cst816S& operator=(Cst816S&&) = delete;
|
Cst816S& operator=(Cst816S&&) = delete;
|
||||||
|
|
||||||
void Init();
|
bool Init();
|
||||||
TouchInfos GetTouchInfo();
|
TouchInfos GetTouchInfo();
|
||||||
void Sleep();
|
void Sleep();
|
||||||
void Wakeup();
|
void Wakeup();
|
||||||
|
|
||||||
|
uint8_t GetChipId() const {
|
||||||
|
return chipId;
|
||||||
|
}
|
||||||
|
uint8_t GetVendorId() const {
|
||||||
|
return vendorId;
|
||||||
|
}
|
||||||
|
uint8_t GetFwVersion() const {
|
||||||
|
return fwVersion;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
// Unused/Unavailable commented out
|
// Unused/Unavailable commented out
|
||||||
static constexpr uint8_t gestureIndex = 1;
|
static constexpr uint8_t gestureIndex = 1;
|
||||||
|
@ -49,9 +58,12 @@ namespace Pinetime {
|
||||||
//static constexpr uint8_t touchXYIndex = 7;
|
//static constexpr uint8_t touchXYIndex = 7;
|
||||||
//static constexpr uint8_t touchMiscIndex = 8;
|
//static constexpr uint8_t touchMiscIndex = 8;
|
||||||
|
|
||||||
uint8_t touchData[7];
|
|
||||||
TwiMaster& twiMaster;
|
TwiMaster& twiMaster;
|
||||||
uint8_t twiAddress;
|
uint8_t twiAddress;
|
||||||
|
|
||||||
|
uint8_t chipId;
|
||||||
|
uint8_t vendorId;
|
||||||
|
uint8_t fwVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Pinetime {
|
||||||
SetOffAlarm,
|
SetOffAlarm,
|
||||||
StopRinging,
|
StopRinging,
|
||||||
MeasureBatteryTimerExpired,
|
MeasureBatteryTimerExpired,
|
||||||
BatteryMeasurementDone,
|
BatteryPercentageUpdated,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "drivers/Hrs3300.h"
|
#include "drivers/Hrs3300.h"
|
||||||
#include "drivers/PinMap.h"
|
#include "drivers/PinMap.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "BootErrors.h"
|
||||||
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -116,6 +117,8 @@ void SystemTask::Process(void* instance) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTask::Work() {
|
void SystemTask::Work() {
|
||||||
|
BootErrors bootError = BootErrors::None;
|
||||||
|
|
||||||
watchdog.Setup(7);
|
watchdog.Setup(7);
|
||||||
watchdog.Start();
|
watchdog.Start();
|
||||||
NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::Watchdog::ResetReasonToString(watchdog.ResetReason()));
|
NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::Watchdog::ResetReasonToString(watchdog.ResetReason()));
|
||||||
|
@ -133,10 +136,11 @@ void SystemTask::Work() {
|
||||||
lcd.Init();
|
lcd.Init();
|
||||||
|
|
||||||
twiMaster.Init();
|
twiMaster.Init();
|
||||||
touchPanel.Init();
|
if (!touchPanel.Init()) {
|
||||||
|
bootError = BootErrors::TouchController;
|
||||||
|
}
|
||||||
dateTimeController.Register(this);
|
dateTimeController.Register(this);
|
||||||
batteryController.Register(this);
|
batteryController.Register(this);
|
||||||
batteryController.Update();
|
|
||||||
motorController.Init();
|
motorController.Init();
|
||||||
motionSensor.SoftReset();
|
motionSensor.SoftReset();
|
||||||
timerController.Register(this);
|
timerController.Register(this);
|
||||||
|
@ -152,25 +156,27 @@ void SystemTask::Work() {
|
||||||
settingsController.Init();
|
settingsController.Init();
|
||||||
|
|
||||||
displayApp.Register(this);
|
displayApp.Register(this);
|
||||||
displayApp.Start();
|
displayApp.Start(bootError);
|
||||||
|
|
||||||
heartRateSensor.Init();
|
heartRateSensor.Init();
|
||||||
heartRateSensor.Disable();
|
heartRateSensor.Disable();
|
||||||
heartRateApp.Start();
|
heartRateApp.Start();
|
||||||
|
|
||||||
nrf_gpio_cfg_sense_input(PinMap::Button, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_High);
|
// Button
|
||||||
nrf_gpio_cfg_output(15);
|
nrf_gpio_cfg_output(15);
|
||||||
nrf_gpio_pin_set(15);
|
nrf_gpio_pin_set(15);
|
||||||
|
|
||||||
nrfx_gpiote_in_config_t pinConfig;
|
nrfx_gpiote_in_config_t pinConfig;
|
||||||
pinConfig.skip_gpio_setup = true;
|
pinConfig.skip_gpio_setup = false;
|
||||||
pinConfig.hi_accuracy = false;
|
pinConfig.hi_accuracy = false;
|
||||||
pinConfig.is_watcher = false;
|
pinConfig.is_watcher = false;
|
||||||
pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_HITOLO;
|
pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_TOGGLE;
|
||||||
pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown;
|
pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown;
|
||||||
|
|
||||||
nrfx_gpiote_in_init(PinMap::Button, &pinConfig, nrfx_gpiote_evt_handler);
|
nrfx_gpiote_in_init(PinMap::Button, &pinConfig, nrfx_gpiote_evt_handler);
|
||||||
|
nrfx_gpiote_in_event_enable(PinMap::Button, true);
|
||||||
|
|
||||||
|
// Touchscreen
|
||||||
nrf_gpio_cfg_sense_input(PinMap::Cst816sIrq, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_Low);
|
nrf_gpio_cfg_sense_input(PinMap::Cst816sIrq, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_Low);
|
||||||
|
|
||||||
pinConfig.skip_gpio_setup = true;
|
pinConfig.skip_gpio_setup = true;
|
||||||
|
@ -181,18 +187,16 @@ void SystemTask::Work() {
|
||||||
|
|
||||||
nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler);
|
nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler);
|
||||||
|
|
||||||
|
// Power present
|
||||||
pinConfig.sense = NRF_GPIOTE_POLARITY_TOGGLE;
|
pinConfig.sense = NRF_GPIOTE_POLARITY_TOGGLE;
|
||||||
pinConfig.pull = NRF_GPIO_PIN_NOPULL;
|
pinConfig.pull = NRF_GPIO_PIN_NOPULL;
|
||||||
pinConfig.is_watcher = false;
|
pinConfig.is_watcher = false;
|
||||||
pinConfig.hi_accuracy = false;
|
pinConfig.hi_accuracy = false;
|
||||||
pinConfig.skip_gpio_setup = true;
|
pinConfig.skip_gpio_setup = false;
|
||||||
nrfx_gpiote_in_init(PinMap::PowerPresent, &pinConfig, nrfx_gpiote_evt_handler);
|
nrfx_gpiote_in_init(PinMap::PowerPresent, &pinConfig, nrfx_gpiote_evt_handler);
|
||||||
|
nrfx_gpiote_in_event_enable(PinMap::PowerPresent, true);
|
||||||
|
|
||||||
if (nrf_gpio_pin_read(PinMap::PowerPresent)) {
|
batteryController.MeasureVoltage();
|
||||||
nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
|
|
||||||
} else {
|
|
||||||
nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
|
|
||||||
}
|
|
||||||
|
|
||||||
idleTimer = xTimerCreate("idleTimer", pdMS_TO_TICKS(2000), pdFALSE, this, IdleTimerCallback);
|
idleTimer = xTimerCreate("idleTimer", pdMS_TO_TICKS(2000), pdFALSE, this, IdleTimerCallback);
|
||||||
dimTimer = xTimerCreate("dimTimer", pdMS_TO_TICKS(settingsController.GetScreenTimeOut() - 2000), pdFALSE, this, DimTimerCallback);
|
dimTimer = xTimerCreate("dimTimer", pdMS_TO_TICKS(settingsController.GetScreenTimeOut() - 2000), pdFALSE, this, DimTimerCallback);
|
||||||
|
@ -246,12 +250,13 @@ void SystemTask::Work() {
|
||||||
isDimmed = false;
|
isDimmed = false;
|
||||||
break;
|
break;
|
||||||
case Messages::TouchWakeUp: {
|
case Messages::TouchWakeUp: {
|
||||||
if(touchHandler.GetNewTouchInfo()) {
|
if (touchHandler.GetNewTouchInfo()) {
|
||||||
auto gesture = touchHandler.GestureGet();
|
auto gesture = touchHandler.GestureGet();
|
||||||
if (gesture != Pinetime::Drivers::Cst816S::Gestures::None and ((gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap and
|
if (gesture != Pinetime::Drivers::Cst816S::Gestures::None and
|
||||||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) or
|
((gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap and
|
||||||
(gesture == Pinetime::Drivers::Cst816S::Gestures::SingleTap and
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) or
|
||||||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
|
(gesture == Pinetime::Drivers::Cst816S::Gestures::SingleTap and
|
||||||
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,6 +277,8 @@ void SystemTask::Work() {
|
||||||
if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::ON) {
|
if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::ON) {
|
||||||
if (isSleeping && !isWakingUp) {
|
if (isSleeping && !isWakingUp) {
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
|
} else {
|
||||||
|
ReloadIdleTimer();
|
||||||
}
|
}
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
|
||||||
}
|
}
|
||||||
|
@ -345,18 +352,18 @@ void SystemTask::Work() {
|
||||||
stepCounterMustBeReset = true;
|
stepCounterMustBeReset = true;
|
||||||
break;
|
break;
|
||||||
case Messages::OnChargingEvent:
|
case Messages::OnChargingEvent:
|
||||||
batteryController.Update();
|
batteryController.ReadPowerState();
|
||||||
motorController.RunForDuration(15);
|
motorController.RunForDuration(15);
|
||||||
|
ReloadIdleTimer();
|
||||||
|
if (isSleeping && !isWakingUp) {
|
||||||
|
GoToRunning();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Messages::MeasureBatteryTimerExpired:
|
case Messages::MeasureBatteryTimerExpired:
|
||||||
sendBatteryNotification = true;
|
batteryController.MeasureVoltage();
|
||||||
batteryController.Update();
|
|
||||||
break;
|
break;
|
||||||
case Messages::BatteryMeasurementDone:
|
case Messages::BatteryPercentageUpdated:
|
||||||
if (sendBatteryNotification) {
|
nimbleController.NotifyBatteryLevel(batteryController.PercentRemaining());
|
||||||
sendBatteryNotification = false;
|
|
||||||
nimbleController.NotifyBatteryLevel(batteryController.PercentRemaining());
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -133,14 +133,12 @@ namespace Pinetime {
|
||||||
TimerHandle_t dimTimer;
|
TimerHandle_t dimTimer;
|
||||||
TimerHandle_t idleTimer;
|
TimerHandle_t idleTimer;
|
||||||
TimerHandle_t measureBatteryTimer;
|
TimerHandle_t measureBatteryTimer;
|
||||||
bool sendBatteryNotification = false;
|
|
||||||
bool doNotGoToSleep = false;
|
bool doNotGoToSleep = false;
|
||||||
|
|
||||||
void GoToRunning();
|
void GoToRunning();
|
||||||
void UpdateMotion();
|
void UpdateMotion();
|
||||||
bool stepCounterMustBeReset = false;
|
bool stepCounterMustBeReset = false;
|
||||||
static constexpr TickType_t batteryMeasurementPeriod = pdMS_TO_TICKS(10 * 60 * 1000);
|
static constexpr TickType_t batteryMeasurementPeriod = pdMS_TO_TICKS(10 * 60 * 1000);
|
||||||
TickType_t lastBatteryNotificationTime = 0;
|
|
||||||
|
|
||||||
#if configUSE_TRACE_FACILITY == 1
|
#if configUSE_TRACE_FACILITY == 1
|
||||||
SystemMonitor<FreeRtosMonitor> monitor;
|
SystemMonitor<FreeRtosMonitor> monitor;
|
||||||
|
|
Loading…
Reference in a new issue