Compare commits

...

60 Commits

Author SHA1 Message Date
e54d78a04b WORKING 35 entries. Will use on trip 2022-06-17 22:13:09 +01:00
8f32478141 WORKING on real PineTime 2022-06-17 19:05:16 +01:00
b002fddc29 Try to fix and add logging for date handling 2022-06-17 17:47:34 +01:00
ea62510eb6 Fix BLE service not being registered 2022-06-17 17:47:24 +01:00
a4598ed63e FIRST FLASHED VERSION 2022-06-16 22:09:54 +01:00
72a020127f Add base scaffolding for new Agenda application 2022-06-15 21:22:04 +01:00
Finlay Davidson
373289c072 Be more specific about the compiler version 2022-06-11 22:59:38 +03:00
Finlay Davidson
350bca3965 Replace more instances of old gcc ver 2022-06-11 22:59:38 +03:00
Finlay Davidson
94cd2ba563 Update arm gcc toolchain to 11.2-2022.02
Updates the buildAndProgram doc and the docker
image, which means GitHub Actions will also use
the new toolchain.
2022-06-11 22:59:38 +03:00
Reinhold Gschweicher
ecb3cd3e31 SettingChimes: private Option struct, use std::array for cbOption 2022-06-11 22:46:38 +03:00
Riku Isokoski
d55ec42b17 Simplify SettingChimes code 2022-06-11 22:46:38 +03:00
FintasticMan
a1385cb481
Minor changes to clang-format workflow (#1177) 2022-06-11 22:45:11 +03:00
Diego Miguel Lozano
de62620de1
Remove duplicated value in fonts.json (#1179) 2022-06-11 17:00:26 +03:00
kieranc
7e169ee4aa
Fix typo in gettingStarted guide (#1178) 2022-06-07 21:44:40 +03:00
Riku Isokoski
955dda60c5 Use lambda to reduce code duplication 2022-06-06 21:28:03 +02:00
Riku Isokoski
6cfb45e280 Move event handlers to unnamed namespace 2022-06-06 21:28:03 +02:00
Riku Isokoski
c6026aa617 Use static constexpr to force compile time initialization 2022-06-06 21:28:03 +02:00
Riku Isokoski
254c85246e Timer: Replace time label with Counter control hiding functionality 2022-06-06 21:28:03 +02:00
Riku Isokoski
4a40d29279 Counter: add show and hide controls functions 2022-06-06 21:28:03 +02:00
Riku Isokoski
41c461d1f6 Move linePoints to a member variable 2022-06-06 21:28:03 +02:00
Riku Isokoski
17cedd6629 Move bg color to a constexpr variable 2022-06-06 21:28:03 +02:00
Riku Isokoski
1d34e83c97 Use Counter widget in Timer 2022-06-06 21:28:03 +02:00
Riku Isokoski
9e18c23aac Lighten the large font for a more balanced look
Add Jetbrains Mono Light font
2022-06-06 21:28:03 +02:00
Riku Isokoski
12d4bc4139 Add initial counter widget 2022-06-06 21:28:03 +02:00
Seth Itow
17079fb114 doc: Fix imageFile.png path in SWD.md 2022-06-06 21:20:13 +02:00
Riku Isokoski
c2b15b1446 Move basic apps to the top of the app list 2022-06-06 20:47:34 +02:00
Ildar Mulyukov
7bc692eea4 src/CMakeLists.txt: use iHEX format for mcuboot image creation
for better control of addresses used by img/fw
+ fix typo (RECOVERYY)
2022-06-06 19:41:57 +02:00
Ildar Mulyukov
36740498db CMakeLists.txt: add double quotes in STRIP command
fixes cases when git is missing in the build system
2022-06-06 19:41:57 +02:00
Ildar Mulyukov
5f28f89df2 fix wrong linker script
introduced in 58a2d000c4
2022-06-06 19:41:57 +02:00
Michele Bini
35dcf8c860
Switch to freertos timers (#1095)
* Use FreeRTOS timer for AlarmController
* Use FreeRTOS timer for MotorController
* Remove app_timer component from compilation as we now solely use
  FreeROTS timer
* Simplify variable and text names for AlarmController and MotorController timers
* Call ScheduleAlarm directly from StopAlerting, for recurring timers

Co-authored-by: Riku Isokoski <riksu9000@gmail.com>
Co-authored-by: NeroBurner <pyro4hell@gmail.com>
2022-06-06 17:47:43 +02:00
mabuch
f95147cf0e
remove unused symbols, free a little bit of space (#1167) 2022-06-05 19:43:49 +02:00
mabuch
91a3e98276
remove unused Meter.cpp and Meter.h (#1171) 2022-06-05 19:35:33 +02:00
mabuch
8a71f2b9e0
remove unused Brightness App (#1170) 2022-06-05 19:34:37 +02:00
mabuch
8999158528
remove old unused bluetooth icons (#1172) 2022-06-05 18:50:36 +02:00
Christoph Honal
977936e8e2 System: Refactor pin and interrupt setup
This should ensure better readability of the pin setup procedure,
as well as allow the configuration of the hardware button enable pin
and the accelerometer interrupt pin via the pin mapping header.
2022-06-05 09:53:22 +03:00
Christoph Honal
03a2059e87 SystemTask: Use "&&" instead of "and" for operators
As per the coding style, only primary spelling should be used for operators.
2022-06-05 09:53:22 +03:00
Christoph Honal
702f65d3ee Bootloader: Ignore __pycache__ in Git 2022-06-05 09:53:22 +03:00
luz paz
20ac1cd374 revert portion of previous commit 2022-06-05 09:31:23 +03:00
luz paz
03a510bd18 Fix various typos
Found via `codespell -q 3 -S ./src/libs -L ans,doubleclick,trough`
2022-06-05 09:31:23 +03:00
Finlay Davidson
7f45538eb5 Apply clang-format to all C++ files 2022-06-05 09:15:46 +03:00
Finlay Davidson
718fbdab98 Replace C-style casts with static_cast 2022-06-05 09:15:46 +03:00
Finlay Davidson
0ce4183640 Rename lvgl image files to .c 2022-06-05 09:15:46 +03:00
Ludovic J
87a69fe52d Fix assertion failure in TimerController
0 is not valid for xTimerPeriodInTicks, changing it to 1 to pass the assertion
2022-05-27 22:14:28 +03:00
Riku Isokoski
0fabba1c9a Remove extra linebreaks 2022-05-27 17:52:26 +02:00
Riku Isokoski
a2218dd4ad Unzip DFU, so the artifact doesn't need to be unzipped by the user. 2022-05-27 17:52:26 +02:00
Riku Isokoski
619477cbd1 Rename uploaded files with source branch in workflows 2022-05-27 17:52:26 +02:00
Riku Isokoski
cc2d5c39ce Cleanup workflows 2022-05-27 17:52:26 +02:00
Jean-François Milants
dd313eb419 Docker container documentation : Fix typos, 1 line per sentence, remove obsolete paragraph, remove redundant 'image' parameter in the command to build the docker image, use ${PWD} instead of $(pwd). 2022-05-26 11:35:25 +02:00
Jean-François Milants
9b216bb16f Docker container documentation : Adapt the --user documentation according to the new behavior. 2022-05-26 11:35:25 +02:00
Jean-François Milants
1ffca52715 Edit workflow to use the new docker image : infinitime/infinitime-build. 2022-05-26 11:35:25 +02:00
Jean-François Milants
c77f923a33 Update links to the docker image with the new account : infinitime/infinitime-build. 2022-05-26 11:35:25 +02:00
Jean-François Milants
83b3a2a469 Small modernization with --platform parameter in docker readme 2022-05-26 11:35:25 +02:00
Jean-François Milants
123c801f17 Add comment about the workaround that was needed in the github workflow. 2022-05-26 11:35:25 +02:00
Jean-François Milants
831f93cd92 The main build workflow for GitHub Actions now uses the infinitime-build docker image to build the firmware. This allows to avoid the duplication of the build logic in Docker and Github workflow format.
The Dockerfile has been slightly adapted (remove the USER instructions). Docker images are now published in DockerHub (jf002/infinitime-build).
2022-05-26 11:35:25 +02:00
Yehoshua Pesach Wallach
34506be06e
comment about common error "glyphs.map" in old nodejs (#1142) 2022-05-18 16:14:58 +02:00
Riku Isokoski
6171c9d45d Only test format when it is wanted 2022-05-16 23:25:47 +02:00
Riku Isokoski
a6fcdec0f8 Don't allow test-format.sh to be run locally 2022-05-16 23:25:47 +02:00
Reinhold Gschweicher
443408312a fonts: gen.py: clearify missing exe message 2022-05-16 11:59:44 +03:00
Reinhold Gschweicher
324927f2b7 update build stop, lv_font_conv not required globally installed 2022-05-16 11:59:44 +03:00
Reinhold Gschweicher
db0f909b46 generalize lv-font creation
In https://github.com/InfiniTimeOrg/InfiniTime/pull/1097 new font
generation capabilites were added. Generalize the font creation to
make it possible to reuse the `displayapp/fonts/CMakeLists.txt` file
for `InfiniSim` and just add the new cmake file to the project and
link against the new `infinitime_fonts` target.

In the following a list of changes.

Allow non-global installed `lv_font_conv` executable installed with

```sh
npm install lv_font_conv@1.5.2
```

In CMake we search for `lv_font_conv` executable. Add the found
executable to the python script `generate.py`, to remove the need for
`lv_font_conv` to be in the path.

Search for `python3` executable, if CMake version 3.12 is available.
Otherwise use `python` as hard coded executable.

Instead of adding the generated fonts to `SOURCE_FILES` variable, create
a static library `infinitime_fonts`. Link this library to the
executables instead.

Use `add_custom_target()` together with `add_custom_command()` to
generate the font.c files once (like the original PR does).
2022-05-16 11:59:44 +03:00
144 changed files with 1529 additions and 1318 deletions

View File

@ -8,9 +8,9 @@ AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
@ -83,6 +83,8 @@ IndentGotoLabels: true
IndentPPDirectives: BeforeHash
IndentWidth: 2
IndentWrappedFunctionNames: false
# Requires Clang >= 15, could also cause incorrect code formatting:
# InsertBraces: true
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true

View File

@ -3,6 +3,11 @@ name: Code formatting
on:
pull_request:
branches: [ master, develop ]
paths:
- '**.cpp'
- '**.h'
- '!src/libs/**'
- '!src/FreeRTOS/**'
jobs:
test-format:
@ -14,8 +19,6 @@ jobs:
- name: Configure git
run: |
git config --global user.email "-"
git config --global user.name "Autoformatter"
git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF" --depth=1000
- name: Install clang-format
@ -24,7 +27,7 @@ jobs:
sudo apt-get -y install clang-format-12
- name: Check formatting
run: tests/test-format.sh "$GITHUB_BASE_REF"
run: tests/test-format.sh
- name: Upload patches
uses: actions/upload-artifact@v3

View File

@ -1,24 +1,15 @@
# GitHub Actions Workflow to build Simulator for PineTime Smart Watch LVGL Interface
# Name of this Workflow
name: Build PineTime LVGL Simulator
# When to run this Workflow...
on:
# Run this Workflow when files are updated (Pushed) in the "master" and "develop" Branch
push:
branches: [ master, develop ]
# Also run this Workflow when a Pull Request is created or updated in the "master" and "develop" Branch
pull_request:
branches: [ master, develop ]
# Steps to run for the Workflow
jobs:
build:
# Run these steps on Ubuntu
runs-on: ubuntu-latest
steps:
@ -64,15 +55,12 @@ jobs:
#########################################################################################
# Build and Upload simulator
# For Debugging Builds: Remove "make" option "-j" for clearer output. Add "--trace" to see details.
# For Faster Builds: Add "make" option "-j"
- name: Build simulator executable
run: |
cmake --build build_lv_sim
- name: Upload simulator executable
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: infinisim
name: infinisim-${{ github.head_ref }}
path: build_lv_sim/infinisim

View File

@ -3,172 +3,45 @@
# Based on https://github.com/JF002/InfiniTime/blob/master/doc/buildAndProgram.md
# and https://github.com/JF002/InfiniTime/blob/master/bootloader/README.md
# Name of this Workflow
name: Build PineTime Firmware
# When to run this Workflow...
on:
# Run this Workflow when files are updated (Pushed) in the "master" and "develop" Branch
push:
branches: [ master, develop ]
# Also run this Workflow when a Pull Request is created or updated in the "master" and "develop" Branch
pull_request:
branches: [ master, develop ]
# Steps to run for the Workflow
jobs:
build:
# Run these steps on Ubuntu
runs-on: ubuntu-latest
container:
image: infinitime/infinitime-build
steps:
#########################################################################################
# Download and Cache Dependencies
- name: Install cmake
uses: lukka/get-cmake@v3.18.3
- name: Check cache for Embedded Arm Toolchain arm-none-eabi-gcc
id: cache-toolchain
uses: actions/cache@v2
env:
cache-name: cache-toolchain-9-2020-q2
with:
path: ${{ runner.temp }}/arm-none-eabi
key: ${{ runner.os }}-build-${{ env.cache-name }}
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}
- name: Install Embedded Arm Toolchain arm-none-eabi-gcc
if: steps.cache-toolchain.outputs.cache-hit != 'true' # Install toolchain if not found in cache
uses: fiam/arm-none-eabi-gcc@v1.0.4
with:
# GNU Embedded Toolchain for Arm release name, in the V-YYYY-qZ format (e.g. "9-2019-q4")
release: 9-2020-q2
# Directory to unpack GCC to. Defaults to a temporary directory.
directory: ${{ runner.temp }}/arm-none-eabi
- name: Check cache for nRF5 SDK
id: cache-nrf5sdk
uses: actions/cache@v2
env:
cache-name: cache-nrf5sdk
with:
path: ${{ runner.temp }}/nrf5_sdk
key: ${{ runner.os }}-build-${{ env.cache-name }}
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}
- name: Install nRF5 SDK
if: steps.cache-nrf5sdk.outputs.cache-hit != 'true' # Install SDK if not found in cache
run: |
cd ${{ runner.temp }}
curl https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip -o nrf5_sdk.zip
unzip nrf5_sdk.zip
mv nRF5_SDK_15.3.0_59ac345 nrf5_sdk
- name: Check cache for MCUBoot
id: cache-mcuboot
uses: actions/cache@v2
env:
cache-name: cache-mcuboot
with:
path: ${{ runner.temp }}/mcuboot
key: ${{ runner.os }}-build-${{ env.cache-name }}
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}
- name: Install MCUBoot
if: steps.cache-mcuboot.outputs.cache-hit != 'true' # Install MCUBoot if not found in cache
run: |
cd ${{ runner.temp }}
git clone --branch v1.7.2 https://github.com/mcu-tools/mcuboot
- name: Install imgtool dependencies
run: |
pip3 install --user -r ${{ runner.temp }}/mcuboot/scripts/requirements.txt
- name: Install adafruit-nrfutil
run: |
pip3 install --user wheel
pip3 install --user setuptools
pip3 install --user adafruit-nrfutil
- name: Install lv_font_conv
run:
npm i -g lv_font_conv@1.5.2
#########################################################################################
# Checkout
# This workaround fixes the error "unsafe repository (REPO is owned by someone else)".
# See https://github.com/actions/checkout/issues/760 and https://github.com/actions/checkout/issues/766
# The fix in "actions/checkout@v2" was not sufficient as the build process also uses git (to get the current
# commit hash, for example).
- name: Workaround permission issues
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Checkout source files
uses: actions/checkout@v2
with:
submodules: recursive
- name: Show files
run: set ; pwd ; ls -l
#########################################################################################
# CMake
- name: CMake
run: |
mkdir -p build
cd build
cmake -G Ninja -DARM_NONE_EABI_TOOLCHAIN_PATH=${{ runner.temp }}/arm-none-eabi -DNRF5_SDK_PATH=${{ runner.temp }}/nrf5_sdk -DUSE_OPENOCD=1 -DBUILD_DFU=1 ../
#########################################################################################
# Make and Upload DFU Package
# pinetime-mcuboot-app.img must be flashed at address 0x8000 in the internal flash memory with OpenOCD:
# program image.bin 0x8000
# For Debugging Builds: Remove "make" option "-j" for clearer output. Add "--trace" to see details.
# For Faster Builds: Add "make" option "-j"
- name: Make pinetime-mcuboot-app
run: |
cmake --build build --target pinetime-mcuboot-app
- name: Build
shell: bash
env:
SOURCES_DIR: .
run: /opt/build.sh all
# Unzip the package because Upload Artifact will zip up the files
- name: Unzip DFU package
run: |
# Unzip the package because Upload Artifact will zip up the files
unzip build/src/pinetime-mcuboot-app-dfu*.zip -d build/src/pinetime-mcuboot-app-dfu
- name: Upload DFU package
uses: actions/upload-artifact@v2
run: unzip ./build/output/pinetime-mcuboot-app-dfu-*.zip -d ./build/output/pinetime-mcuboot-app-dfu
- name: Upload DFU artifacts
uses: actions/upload-artifact@v3
with:
name: pinetime-mcuboot-app-dfu
path: build/src/pinetime-mcuboot-app-dfu/*
#########################################################################################
# Make and Upload Standalone Firmware
- name: Make pinetime-app
run: |
cmake --build build --target pinetime-app
- name: Upload standalone firmware
uses: actions/upload-artifact@v2
name: InfiniTime DFU ${{ github.head_ref }}
path: ./build/output/pinetime-mcuboot-app-dfu/*
- name: Upload MCUBoot image artifacts
uses: actions/upload-artifact@v3
with:
name: pinetime-app.out
path: build/src/pinetime-app*.out
#########################################################################################
# Make but don't Upload the Recovery Firmware to be sure it builds correctly
- name: Make pinetime-recovery
run: |
cmake --build build --target pinetime-recovery
#########################################################################################
# Finish
- name: Find output
run: |
find . -name "pinetime-app.*" -ls
find . -name "pinetime-mcuboot-app.*" -ls
# Embedded Arm Toolchain and nRF5 SDK will only be cached if the build succeeds.
# So make sure that the first build always succeeds, e.g. comment out the "Make" step.
name: InfiniTime MCUBoot image ${{ github.head_ref }}
path: ./build/output/pinetime-mcuboot-app-image-*.bin

2
.vscode/launch.json vendored
View File

@ -52,7 +52,7 @@
"servertype": "openocd",
"runToMain": true,
// Only use armToolchainPath if your arm-none-eabi-gdb is not in your path (some GCC packages does not contain arm-none-eabi-gdb)
"armToolchainPath": "${workspaceRoot}/../gcc-arm-none-eabi-9-2020-q2-update/bin",
"armToolchainPath": "${workspaceRoot}/../gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin",
"svdFile": "${workspaceRoot}/nrf52.svd",
"configFiles": [
"interface/stlink.cfg",

View File

@ -66,7 +66,7 @@ execute_process(COMMAND git rev-parse --short HEAD
OUTPUT_VARIABLE PROJECT_GIT_COMMIT_HASH
RESULT_VARIABLE PROJECT_GIT_COMMIT_HASH_SUCCESS)
string(STRIP ${PROJECT_GIT_COMMIT_HASH} PROJECT_GIT_COMMIT_HASH)
string(STRIP "${PROJECT_GIT_COMMIT_HASH}" PROJECT_GIT_COMMIT_HASH)
message("PROJECT_GIT_COMMIT_HASH_SUCCESS? " ${PROJECT_GIT_COMMIT_HASH_SUCCESS})

View File

@ -9,14 +9,14 @@ Integrating a BLE stack for the OTA functionality would have used to much memory
When it is run, this bootloader looks in the SPI flash memory if a new firmware is available. It there is one, it *swaps* the current firmware with the new one (the new one is copied in the main flash memory, and the current one is copied in the SPI flash memory) and run the new one. If the new one fails to run properly, the bootloader is able to revert to the old one and mark the new one as not working.
As this bootloader does not provide any OTA capability, it is not able to actually download a new version of the application. Providing OTA functionality is thus the responsability of the application firmware.
As this bootloader does not provide any OTA capability, it is not able to actually download a new version of the application. Providing OTA functionality is thus the responsibility of the application firmware.
# About MCUBoot
MCUBoot is run at boot time. In normal operation, it just jumps to the reset handler of the application firmware to run it. Once the application firmware is running, MCUBoot does not run at all.
![MCUBoot boot sequence diagram](../doc/bootloader/boot.png "MCUBoot boot sequence diagram")
But MCUBoot does much more than that : it can upgrade the firmware that is currently running by a new one, and it is also able to revert to the previous version of the firmware in case the new one does not run propertly.
But MCUBoot does much more than that : it can upgrade the firmware that is currently running by a new one, and it is also able to revert to the previous version of the firmware in case the new one does not run properly.
To do this, it uses 2 memory 'slots' :
- **The primary slot** : it contains the current firmware, the one that will be executed by MCUBoot
@ -40,7 +40,7 @@ This chapter describes degraded cases that are handled by our bootloader and tho
Case | Current bootloader | Solution
-----|--------------------|----------------------------------------------
Data got corrupted during file transfer | [OK] Application firmware does a CRC check before applying the update, and does not proceed if it fails. | N/A
New firmware does not run at all (bad file) (1) | [NOK] MCU executes unknown instructions and will most likely end up in an infinite loop or freeze in an error handler. The bootloader does not run, it can do nothing, the MCU is stucked until next reset | [OK] The bootloader starts the watchdog just before running the new firmware. This way, the watchdog will reset the MCU after ~7s because the firmware does not refresh it. Bootloader reverts to the previous version of the firmware during the reset.
New firmware does not run at all (bad file) (1) | [NOK] MCU executes unknown instructions and will most likely end up in an infinite loop or freeze in an error handler. The bootloader does not run, it can do nothing, the MCU is stuck until next reset | [OK] The bootloader starts the watchdog just before running the new firmware. This way, the watchdog will reset the MCU after ~7s because the firmware does not refresh it. Bootloader reverts to the previous version of the firmware during the reset.
New firmware runs, does not set the valid bit and does not refresh the watchdog | [NOK] The new firmware runs until the next reset. The bootloader will be able to revert to the previous firmware only during the next reset. If the new firmware does not run properly and does not reset, the bootloader can do nothing until the next reset | [OK] The bootloader starts the watchdog just before running the new firmware. This way, the watchdog will reset the MCU after ~7s because the firmware does not refresh it. Bootloader reverts to the previous version of the firmware during the reset.
New firmware does not run properly, does not set the valid bit but refreshes the watchdog | [NOK] The bootloader will be able to revert to the previous firmware only during the next reset. If the new firmware does not run properly and does not reset, the bootloader can do nothing until the next reset | [~] Wait for the battery to drain. The CPU will reset the next time the device is charged and will be able to rollback to the previous version.
New firmware does not run properly but sets the valid bit and refreshes the watchdog | [NOK] The bootloader won't revert to the previous version because the valid flag is set | [~] Wait for the battery to drain. The CPU will reset the next time the device is charged. Then, the bootloader must provide a way for the user to force the rollback to the previous version

1
bootloader/ota-dfu-python/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__

View File

@ -236,7 +236,7 @@ class BleDfuControllerSecure(NrfBleDfuController):
self._dfu_send_command(Procedures.EXECUTE)
self._wait_and_parse_notify()
print("Init packet successfully transfered")
print("Init packet successfully transferred")
# --------------------------------------------------------------------------
# Send the Firmware image to peripheral device.
@ -319,5 +319,5 @@ class BleDfuControllerSecure(NrfBleDfuController):
self._dfu_send_command(Procedures.EXECUTE)
self._wait_and_parse_notify()
# If everything executed correctly, return amount of bytes transfered
# If everything executed correctly, return amount of bytes transferred
return obj_max_size

View File

@ -106,7 +106,6 @@ macro(nRF5x_setup)
${NRF5_SDK_PATH}/external/freertos/source/stream_buffer.c
${NRF5_SDK_PATH}/external/freertos/source/tasks.c
${NRF5_SDK_PATH}/external/freertos/source/timers.c
${NRF5_SDK_PATH}/components/libraries/timer/app_timer_freertos.c
)
# freertos include
@ -335,7 +334,6 @@ endmacro(nRF5x_addAppFIFO)
# adds app-level Timer libraries
macro(nRF5x_addAppTimer)
list(APPEND SDK_SOURCE_FILES
"${NRF5_SDK_PATH}/components/libraries/timer/app_timer.c"
)
endmacro(nRF5x_addAppTimer)

View File

@ -7,7 +7,7 @@ Cmake script for projects targeting Nordic Semiconductor nRF5x series devices us
The script makes use of the following tools:
- nRF5x SDK by Nordic Semiconductor - SoC specific drivers and libraries (also includes a lot of examples)
- JLink by Segger - interface software for the JLink familiy of programmers
- JLink by Segger - interface software for the JLink family of programmers
- nrfjprog by Nordic Semiconductor - Wrapper utility around JLink
- arm-non-eabi-gcc by ARM and the GCC Team - compiler toolchain for embedded (= bare metal) ARM chips
@ -15,11 +15,11 @@ The script makes use of the following tools:
1. Download this repo (or add as submodule) to the directory `cmake-nRF5x` in your project
1. Search the SDK `example` directory for a `sdk_config.h`, `main.c` and a linker script (normally named `<project_name>_gcc_<chip familly>.ld`) that fits your chip and project needs.
1. Search the SDK `example` directory for a `sdk_config.h`, `main.c` and a linker script (normally named `<project_name>_gcc_<chip family>.ld`) that fits your chip and project needs.
1. Copy the `sdk_config.h` and the project `main.c` into a new directory `src`. Modify them as required for your project.
1. Copy the linker script into the root of your project. Rename it to just `gcc_<chip familly>.ld` For example:
1. Copy the linker script into the root of your project. Rename it to just `gcc_<chip family>.ld` For example:
```
gcc_nrf51.ld

View File

@ -51,16 +51,16 @@ Puncover is really easy to install:
- `python -m virtualenv venv`
- `source venv/bin/activate`
- Install : `pip install .`
- Run : `puncover --gcc_tools_base=/path/to/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi- --elf_file /path/to/build/directory/src/pinetime-app-1.1.0.out --src_root /path/to/sources --build_dir /path/to/build/directory`
- Run : `puncover --gcc_tools_base=/path/to/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi- --elf_file /path/to/build/directory/src/pinetime-app-1.1.0.out --src_root /path/to/sources --build_dir /path/to/build/directory`
- Replace
* `/path/to/gcc-arm-none-eabi-9-2020-q2-update/bin` with the path to your gcc-arm-none-eabi toolchain
* `/path/to/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin` with the path to your gcc-arm-none-eabi toolchain
* `/path/to/build/directory/src/pinetime-app-1.1.0.out` with the path to the binary generated by GCC (.out file)
* `/path/to/sources` with the path to the root folder of the sources (checkout directory)
* `/path/to/build/directory` with the path to the build directory
- Launch a browser at http://localhost:5000/
### Analysis
Using the MAP file and tools, we can easily see what symbols are using most of the flash memory. In this case, unsuprisingly, fonts and graphics are the largest use of flash memory.
Using the MAP file and tools, we can easily see what symbols are using most of the flash memory. In this case, unsurprisingly, fonts and graphics are the largest use of flash memory.
![Puncover](./memoryAnalysis/puncover-all-symbols.png)
@ -150,7 +150,7 @@ You can then display the file using objdump:
hexdump ram.bin -v | less
```
The stack is positionned at the end of the RAM -> 0xFFFF. Its size is 8192 bytes, so the end of the stack is at 0xE000.
The stack is positioned at the end of the RAM -> 0xFFFF. Its size is 8192 bytes, so the end of the stack is at 0xE000.
On the following dump, the maximum stack usage is 520 bytes (0xFFFF - 0xFDF8):
```

View File

@ -13,7 +13,7 @@ The service UUID is 00010000-78fc-48fe-8e23-433b3a1942d0
## Characteristics
## 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 list of supported icon names.
## 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".

View File

@ -1,5 +1,5 @@
# Build a stub for PineTime using NRF52-DK
[NRF52-DK](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52-DK) is the official developpment kit for the NRF52832 SoC from Nordic Semiconductor used in the PineTime.
[NRF52-DK](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52-DK) is the official development kit for the NRF52832 SoC from Nordic Semiconductor used in the PineTime.
This development kit can be very useful for PineTime development:
* You can use its embedded JLink SWD programmer/debugger to program and debug your code on the PineTime

View File

@ -1,7 +1,7 @@
# How to flash InfiniTime using the SWD interface
Download the files **bootloader.bin**, **image-x.y.z.bin** and **pinetime-graphics-x.y.z.bin** from the release page:
![Image file](imageFile.png)
![Image file](gettingStarted/imageFile.png)
The bootloader reads a boot logo from the external SPI flash memory. The first step consists of flashing a tool in the MCU that will flash the boot logo into this SPI flash memory. This first step is optional but recommended (the bootloader will display garbage on screen for a few second if you don't do it).
Using your SWD tool, flash **pinetime-graphics-x.y.z.bin** at offset **0x0000**. Reset the MCU and wait for a few seconds until the logo is completely drawn on the display.

View File

@ -146,14 +146,14 @@ The new alert characteristic allows sending new notifications to InfiniTime. It
For example, here is what a normal notification looks like in Golang (language of `itd`):
```go
// \x00 is the category for simple alert, and there is one new notifcation, hence \x01.
// \x00 is the category for simple alert, and there is one new notification, hence \x01.
"\x00\x01\x00Test Title\x00Test Body"
```
A call notification looks like so:
```go
// \x03 is the category for calls, and there is one new call notifcation, hence \x01.
// \x03 is the category for calls, and there is one new call notification, hence \x01.
"\x03\x01\x00Mary"
```

View File

@ -3,7 +3,7 @@ Pinetime --> CompanionApp: Start advertising
group BLE Connection
CompanionApp -> Pinetime: Connection request
CompanionApp <-> Pinetime: Connection parameters negociation, security procedure,...
CompanionApp <-> Pinetime: Connection parameters negotiation, security procedure,...
end
group Service Discovery

View File

@ -5,7 +5,7 @@ The project is based on 2 main branches:
- **master** : this branch is always ready to be deployed. It means that at any time, we should be able to build the branch and release a new version of the application.
- **develop** : this branch contains the latest development that will be integrated in the next release once it's considered as stable.
New features should be implemented in **feature branches** created from **develop**. When the feature is ready, a pull-request is created and it'll be merge into **develop** when it is succesfully reviewed and accepted.
New features should be implemented in **feature branches** created from **develop**. When the feature is ready, a pull-request is created and it'll be merge into **develop** when it is successfully reviewed and accepted.
To release a new version of the application, when develop is considered stable, a **release** branch is created from **develop**. This can be considered as a *release candidate* branch. When everything is OK, this release branch is merged into **master** and the release is generated (a tag is applied to git, the release note is finalized, binaries are built,...) from **master**.

View File

@ -1,7 +1,7 @@
# Build
## Dependencies
To build this project, you'll need:
- A cross-compiler : [ARM-GCC (9-2020-q2-update)](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads/9-2020-q2-update)
- A cross-compiler : [ARM-GCC (arm-none-eabi 11.2-2022.02)](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/downloads)
- The NRF52 SDK 15.3.0 : [nRF-SDK v15.3.0](https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip)
- The Python 3 modules `cbor`, `intelhex`, `click` and `cryptography` modules for the `mcuboot` tool (see [requirements.txt](../tools/mcuboot/requirements.txt))
- To keep the system clean, you can install python modules into a python virtual environment (`venv`)
@ -14,9 +14,8 @@ To build this project, you'll need:
- A reasonably recent version of CMake (I use 3.16.5)
- lv_font_conv, to generate the font .c files
- see [lv_font_conv](https://github.com/lvgl/lv_font_conv#install-the-script)
- install npm (commonly done via the package manager)
- install lv_font_conv: `npm i lv_font_conv -g`
- if installed non-globally, make sure `lv_font_conv` is in the PATH
- install npm (commonly done via the package manager, ensure node's version is at least 12)
- install lv_font_conv: `npm install lv_font_conv`
## Build steps
### Clone the repo
@ -32,7 +31,7 @@ CMake configures the project according to variables you specify the command line
Variable | Description | Example|
----------|-------------|--------|
**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`-DARM_NONE_EABI_TOOLCHAIN_PATH=/home/jf/nrf52/gcc-arm-none-eabi-9-2020-q2-update/`|
**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`-DARM_NONE_EABI_TOOLCHAIN_PATH=/home/jf/nrf52/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/`|
**NRF5_SDK_PATH**|path to the NRF52 SDK|`-DNRF5_SDK_PATH=/home/jf/nrf52/Pinetime/sdk`|
**USE_JLINK, USE_GDB_CLIENT and USE_OPENOCD**|Enable *JLink* mode, *GDB Client* (Black Magic Probe) mode or *OpenOCD* mode (set the one you want to use to `1`)|`-DUSE_JLINK=1`
**CMAKE_BUILD_TYPE (\*)**| Build type (Release or Debug). Release is applied by default if this variable is not specified.|`-DCMAKE_BUILD_TYPE=Debug`
@ -48,7 +47,7 @@ By default, this variable is set to *Release*. It compiles the code with size an
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**:
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) mechanism. 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.
#### CMake command line for JLink
```

View File

@ -1,62 +1,58 @@
# Build the project using Docker
A [Docker image (Dockerfile)](../docker) containing all the build environment is available for X86_64 and AMD64 architectures. These images make the build of the firmware and the generation of the DFU file for OTA quite easy, as well as preventing clashes with any other toolchains or development environments you may have installed.
A [Docker image (Dockerfile)](../docker) containing all the build environment is available for X86_64 and AMD64 architectures.
These images make the build of the firmware and the generation of the DFU file for OTA quite easy, as well as preventing clashes with any other toolchains or development environments you may have installed.
Based on Ubuntu 18.04 with the following build dependencies:
Based on Ubuntu 22.04 with the following build dependencies:
* ARM GCC Toolchain
* nRF SDK
* MCUBoot
* adafruit-nrfutil
* lv_font_conv
## Run a container to build the project
The `infinitime-build` image contains all the dependencies you need. The default `CMD` will compile sources found in `/sources`, so you need only mount your code.
The `infinitime-build` image contains all the dependencies you need.
The default `CMD` will compile sources found in `/sources`, so you need only mount your code.
Before continuing, make sure you first build the image as indicated in the [Build the image](#build-the-image) section, or check the [Using the image from Docker Hub](#using-the-image-from-docker-hub) section if you prefer to use a pre-made image.
This example will build the firmware, generate the MCUBoot image and generate the DFU file. For cloning the repo, see [these instructions](../doc/buildAndProgram.md#clone-the-repo). Outputs will be written to **<project_root>/build/output**:
This example will build the firmware, generate the MCUBoot image and generate the DFU file.
For cloning the repo, see [these instructions](../doc/buildAndProgram.md#clone-the-repo). Outputs will be written to **<project_root>/build/output**:
```bash
cd <project_root> # e.g. cd ./work/Pinetime
docker run --rm -it -v $(pwd):/sources infinitime-build
docker run --rm -it -v ${PWD}:/sources --user $(id -u):$(id -g) infinitime-build
```
If you only want to build a single CMake target, you can pass it in as the first parameter to the build script. This means calling the script explicitly as it will override the `CMD`. Here's an example For `pinetime-app`:
By default, the container runs as `root`, which is not convenient as all the files generated by the build will also belong to `root`.
The parameter `--user` overrides that default behavior.
The command above will run as your current user.
If you only want to build a single CMake target, you can pass it in as the first parameter to the build script.
This means calling the script explicitly as it will override the `CMD`.
Here's an example for `pinetime-app`:
```bash
docker run --rm -it -v $(pwd):/sources infinitime-build /opt/build.sh pinetime-app
```
The image is built using 1000:1000 for the user id and group id. If this is different to your user or group ids (run `id -u` and `id -g` to find out what your id values are if you are unsure), you will need to override them via the `--user` parameter in order to prevent permission errors with the output files (and the cmake build cache).
Running with this image is the same as above, you just specify the ids to `docker run`:
```bash
docker run --rm -it -v $(pwd):/sources --user $(id -u):$(id -g) infinitime-build
```
Or you can specify your user id and group id (by number, not by name) directly:
```bash
docker run --rm -it -v $(pwd):/sources --user 1234:1234 infinitime-build
docker run --rm -it -v ${PWD}:/sources --user $(id -u):$(id -g) infinitime-build /opt/build.sh pinetime-app
```
## Using the image from Docker Hub
The image is available via Docker Hub for both the amd64 and arm64v8 architectures at [pfeerick/infinitime-build](https://hub.docker.com/r/pfeerick/infinitime-build).
The image is available via Docker Hub for both the amd64 and arm64v8 architectures at [infinitime/infinitime-build](https://hub.docker.com/repository/docker/infinitime/infinitime-build).
It can be pulled (downloaded) using the following command:
You can run it using the following command:
```bash
docker pull pfeerick/infinitime-build
docker run --rm -it -v ${PWD}:/sources --user $(id -u):$(id -g) infinitime/infinitime-build
```
The default `latest` tag *should* automatically identify the correct image architecture, but if for some reason Docker does not, you can specify it manually:
* For AMD64 (x86_64) systems: `docker pull pfeerick/infinitime-build:amd64`
* For AMD64 (x86_64) systems: `docker pull --platform linux/amd64 infinitime/infinitime-build`
* For ARM64v8 (ARM64/aarch64) systems: `docker pull pfeerick/infinitime-build:arm64v8`
* For ARM64v8 (ARM64/aarch64) systems: `docker pull --platform linux/arm64 infinitime/infinitime-build`
## Build the image
@ -65,11 +61,5 @@ You can build the image yourself if you like!
The following commands must be run from the root of the project. This operation will take some time but, when done, a new image named *infinitime-build* is available.
```bash
docker image build -t infinitime-build ./docker
```
The `PUID` and `PGID` build arguments are used to set the user and group ids used in the container, meaning you will not need to specify it later unless they change for some reason. Specifying them is not mandatory, as this can be over-ridden at build time via the `--user` flag, but doing so will make the command you need to run later a bit shorter. In the below examples, they are set to your current user id and group id automatically. You can specify them manually, but they must be specified by number, not by name.
```bash
docker image build -t infinitime-build --build-arg PUID=$(id -u) --build-arg PGID=$(id -g) ./docker
```
docker build -t infinitime-build ./docker
```

View File

@ -8,7 +8,7 @@ To support as many setups as possible the VS Code configuration files expect the
Variable | Description | Example
----------|-------------|--------
**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`export ARM_NONE_EABI_TOOLCHAIN_PATH=/opt/gcc-arm-none-eabi-9-2020-q2-update`
**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`export ARM_NONE_EABI_TOOLCHAIN_PATH=/opt/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi`
**NRF5_SDK_PATH**|path to the NRF52 SDK|`export NRF5_SDK_PATH=/opt/nRF5_SDK_15.3.0_59ac345`
## VS Code Extensions

View File

@ -18,7 +18,7 @@ You can sync the time using companion apps.
You can also set the time in the settings without a companion app. (version >1.7.0)
InfiniTime doesn't handle daylight savings automatically, so make sure to set the correct the time or sync it with a companion app.
InfiniTime doesn't handle daylight savings automatically, so make sure to set the correct time or sync it with a companion app.
### Digital watch face

View File

@ -44,10 +44,5 @@ RUN bash -c "source /opt/build.sh; GetNrfSdk;"
# McuBoot
RUN bash -c "source /opt/build.sh; GetMcuBoot;"
ARG PUID=1000
ARG PGID=1000
RUN groupadd --system --gid $PGID infinitime && useradd --system --uid $PUID --gid $PGID infinitime
USER infinitime:infinitime
ENV SOURCES_DIR /sources
CMD ["/opt/build.sh"]

View File

@ -9,21 +9,23 @@ set -e
export TOOLS_DIR="${TOOLS_DIR:=/opt}"
export SOURCES_DIR="${SOURCES_DIR:=/sources}"
export BUILD_DIR="${BUILD_DIR:=$SOURCES_DIR/build}"
export OUTPUT_DIR="${OUTPUT_DIR:=$BUILD_DIR/output}"
export OUTPUT_DIR="${OUTPUT_DIR:=$SOURCES_DIR/build/output}"
export BUILD_TYPE=${BUILD_TYPE:=Release}
export GCC_ARM_VER=${GCC_ARM_VER:="gcc-arm-none-eabi-9-2020-q2-update"}
export GCC_ARM_VER=${GCC_ARM_VER:="11.2-2022.02"}
export NRF_SDK_VER=${NRF_SDK_VER:="nRF5_SDK_15.3.0_59ac345"}
MACHINE="$(uname -m)"
[[ "$MACHINE" == "arm64" ]] && MACHINE="aarch64"
export GCC_ARM_PATH="gcc-arm-$GCC_ARM_VER-$MACHINE-arm-none-eabi"
main() {
local target="$1"
mkdir -p "$TOOLS_DIR"
[[ ! -d "$TOOLS_DIR/$GCC_ARM_VER" ]] && GetGcc
[[ ! -d "$TOOLS_DIR/$GCC_ARM_PATH" ]] && GetGcc
[[ ! -d "$TOOLS_DIR/$NRF_SDK_VER" ]] && GetNrfSdk
[[ ! -d "$TOOLS_DIR/mcuboot" ]] && GetMcuBoot
@ -31,15 +33,14 @@ main() {
CmakeGenerate
CmakeBuild $target
BUILD_RESULT=$?
BUILD_RESULT=$?
if [ "$DISABLE_POSTBUILD" != "true" -a "$BUILD_RESULT" == 0 ]; then
source "$BUILD_DIR/post_build.sh"
fi
}
GetGcc() {
GCC_SRC="$GCC_ARM_VER-$MACHINE-linux.tar.bz"
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/$GCC_SRC -O - | tar -xj -C $TOOLS_DIR/
wget -q https://developer.arm.com/-/media/Files/downloads/gnu/$GCC_ARM_VER/binrel/$GCC_ARM_PATH.tar.xz -O - | tar -xJ -C $TOOLS_DIR/
}
GetMcuBoot() {
@ -54,18 +55,14 @@ GetNrfSdk() {
}
CmakeGenerate() {
# We can swap the CD and trailing SOURCES_DIR for -B and -S respectively
# once we go to newer CMake (Ubuntu 18.10 gives us CMake 3.10)
cd "$BUILD_DIR"
cmake -G "Unix Makefiles" \
-S "$SOURCES_DIR" \
-B "$BUILD_DIR" \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DUSE_OPENOCD=1 \
-DARM_NONE_EABI_TOOLCHAIN_PATH="$TOOLS_DIR/$GCC_ARM_VER" \
-DARM_NONE_EABI_TOOLCHAIN_PATH="$TOOLS_DIR/$GCC_ARM_PATH" \
-DNRF5_SDK_PATH="$TOOLS_DIR/$NRF_SDK_VER" \
-DBUILD_DFU=1 \
"$SOURCES_DIR"
cmake -L -N .
-DBUILD_DFU=1
}
CmakeBuild() {
@ -76,4 +73,4 @@ CmakeBuild() {
fi
}
[[ $SOURCED == "false" ]] && main "$@" || echo "Sourced!"
[[ $SOURCED == "false" ]] && main "$@" || echo "Sourced!"

View File

@ -15,12 +15,10 @@ cp "$BUILD_DIR/src/pinetime-mcuboot-app-dfu-$PROJECT_VERSION.zip" "$OUTPUT_DIR/p
cp "$BUILD_DIR/src/pinetime-mcuboot-recovery-loader-image-$PROJECT_VERSION.bin" "$OUTPUT_DIR/pinetime-mcuboot-recovery-loader-image-$PROJECT_VERSION.bin"
cp "$BUILD_DIR/src/pinetime-mcuboot-recovery-loader-dfu-$PROJECT_VERSION.zip" "$OUTPUT_DIR/pinetime-mcuboot-recovery-loader-dfu-$PROJECT_VERSION.zip"
mkdir -p "$OUTPUT_DIR/src"
cd "$BUILD_DIR"
cp src/*.bin "$OUTPUT_DIR/src"
cp src/*.hex "$OUTPUT_DIR/src"
cp src/*.out "$OUTPUT_DIR/src"
cp src/*.map "$OUTPUT_DIR/src"
cp $BUILD_DIR/src/*.bin "$OUTPUT_DIR/src/"
cp $BUILD_DIR/src/*.hex "$OUTPUT_DIR/src/"
cp $BUILD_DIR/src/*.out "$OUTPUT_DIR/src/"
cp $BUILD_DIR/src/*.map "$OUTPUT_DIR/src/"
ls -RUv1 "$OUTPUT_DIR" | sed 's;^\([^/]\); \1;g'

View File

@ -13659,12 +13659,12 @@ POSSIBILITY OF SUCH DAMAGE.\n
<usage>read</usage>
<enumeratedValue>
<name>NotPresent</name>
<description>Read: no overrun occured</description>
<description>Read: no overrun occurred</description>
<value>0</value>
</enumeratedValue>
<enumeratedValue>
<name>Present</name>
<description>Read: overrun occured</description>
<description>Read: overrun occurred</description>
<value>1</value>
</enumeratedValue>
</enumeratedValues>

View File

@ -31,6 +31,10 @@ const bool BootloaderVersion::IsValid() {
void BootloaderVersion::SetVersion(uint32_t v) {
BootloaderVersion::version = v;
snprintf(BootloaderVersion::versionString, BootloaderVersion::VERSION_STR_LEN, "%ld.%ld.%ld",
BootloaderVersion::Major(), BootloaderVersion::Minor(), BootloaderVersion::Patch());
snprintf(BootloaderVersion::versionString,
BootloaderVersion::VERSION_STR_LEN,
"%ld.%ld.%ld",
BootloaderVersion::Major(),
BootloaderVersion::Minor(),
BootloaderVersion::Patch());
}

View File

@ -12,6 +12,7 @@ namespace Pinetime {
static const char* VersionString();
static const bool IsValid();
static void SetVersion(uint32_t v);
private:
static uint32_t version;
static constexpr size_t VERSION_STR_LEN = 12;

View File

@ -42,7 +42,6 @@ set(SDK_SOURCE_FILES
"${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_gpiote.c"
"${NRF5_SDK_PATH}/modules/nrfx/soc/nrfx_atomic.c"
"${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_saadc.c"
"${NRF5_SDK_PATH}/components/libraries/timer/app_timer.h"
# FreeRTOS
${NRF5_SDK_PATH}/external/freertos/source/croutine.c
@ -53,7 +52,6 @@ set(SDK_SOURCE_FILES
${NRF5_SDK_PATH}/external/freertos/source/stream_buffer.c
${NRF5_SDK_PATH}/external/freertos/source/tasks.c
${NRF5_SDK_PATH}/external/freertos/source/timers.c
${NRF5_SDK_PATH}/components/libraries/timer/app_timer_freertos.c
# Libs
"${NRF5_SDK_PATH}/components/libraries/atomic/nrf_atomic.c"
@ -368,12 +366,7 @@ set(QCBOR_SRC
list(APPEND IMAGE_FILES
displayapp/icons/battery/batteryicon.c
displayapp/icons/bluetooth/os_bt_connected.c
displayapp/icons/bluetooth/os_bt_disconnected.c
)
include(displayapp/fonts/CMakeLists.txt)
list(APPEND SOURCE_FILES
BootloaderVersion.cpp
logging/NrfLogger.cpp
@ -381,14 +374,12 @@ list(APPEND SOURCE_FILES
displayapp/screens/Screen.cpp
displayapp/screens/Clock.cpp
displayapp/screens/Tile.cpp
displayapp/screens/Meter.cpp
displayapp/screens/InfiniPaint.cpp
displayapp/screens/Paddle.cpp
displayapp/screens/StopWatch.cpp
displayapp/screens/BatteryIcon.cpp
displayapp/screens/BleIcon.cpp
displayapp/screens/NotificationIcon.cpp
displayapp/screens/Brightness.cpp
displayapp/screens/SystemInfo.cpp
displayapp/screens/Label.cpp
displayapp/screens/FirmwareUpdate.cpp
@ -412,7 +403,9 @@ list(APPEND SOURCE_FILES
displayapp/screens/Error.cpp
displayapp/screens/Alarm.cpp
displayapp/screens/Styles.cpp
displayapp/screens/Agenda.cpp
displayapp/Colors.cpp
displayapp/widgets/Counter.cpp
## Settings
displayapp/screens/settings/QuickSettings.cpp
@ -465,7 +458,7 @@ list(APPEND SOURCE_FILES
components/ble/MusicService.cpp
components/ble/weather/WeatherService.cpp
components/ble/NavigationService.cpp
displayapp/fonts/lv_font_navi_80.c
components/ble/AgendaService.cpp
components/ble/BatteryInformationService.cpp
components/ble/FSService.cpp
components/ble/ImmediateAlertService.cpp
@ -484,12 +477,6 @@ list(APPEND SOURCE_FILES
FreeRTOS/port_cmsis.c
displayapp/LittleVgl.cpp
displayapp/fonts/jetbrains_mono_extrabold_compressed.c
displayapp/fonts/jetbrains_mono_bold_20.c
displayapp/fonts/jetbrains_mono_76.c
displayapp/fonts/jetbrains_mono_42.c
displayapp/fonts/lv_font_sys_48.c
displayapp/fonts/open_sans_light.c
displayapp/lv_pinetime_theme.c
systemtask/SystemTask.cpp
@ -543,6 +530,7 @@ list(APPEND RECOVERY_SOURCE_FILES
components/ble/ImmediateAlertService.cpp
components/ble/ServiceDiscovery.cpp
components/ble/NavigationService.cpp
components/ble/AgendaService.cpp
components/ble/HeartRateService.cpp
components/ble/MotionService.cpp
components/firmwarevalidator/FirmwareValidator.cpp
@ -603,14 +591,12 @@ set(INCLUDE_FILES
displayapp/screens/Screen.h
displayapp/screens/Clock.h
displayapp/screens/Tile.h
displayapp/screens/Meter.h
displayapp/screens/InfiniPaint.h
displayapp/screens/StopWatch.h
displayapp/screens/Paddle.h
displayapp/screens/BatteryIcon.h
displayapp/screens/BleIcon.h
displayapp/screens/NotificationIcon.h
displayapp/screens/Brightness.h
displayapp/screens/SystemInfo.h
displayapp/screens/ScreenList.h
displayapp/screens/Label.h
@ -625,6 +611,7 @@ set(INCLUDE_FILES
displayapp/screens/Timer.h
displayapp/screens/Alarm.h
displayapp/Colors.h
displayapp/widgets/Counter.h
drivers/St7789.h
drivers/SpiNorFlash.h
drivers/SpiMaster.h
@ -803,6 +790,15 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif ()
add_subdirectory(displayapp/fonts)
target_compile_options(infinitime_fonts PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3 -fno-rtti>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Os -fno-rtti>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -x assembler-with-cpp>
)
# NRF SDK
add_library(nrf-sdk STATIC ${SDK_SOURCE_FILES})
target_include_directories(nrf-sdk SYSTEM PUBLIC . ../)
@ -876,7 +872,7 @@ set(EXECUTABLE_FILE_NAME ${EXECUTABLE_NAME}-${pinetime_VERSION_MAJOR}.${pinetime
set(NRF5_LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/gcc_nrf52.ld")
add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES})
set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FILE_NAME})
target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl littlefs QCBOR)
target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl littlefs QCBOR infinitime_fonts)
target_compile_options(${EXECUTABLE_NAME} PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Wextra -Wformat -Wno-missing-field-initializers -Wno-unused-parameter -Og -g3>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -Wextra -Wformat -Wno-missing-field-initializers -Wno-unused-parameter -Os>
@ -900,11 +896,11 @@ add_custom_command(TARGET ${EXECUTABLE_NAME}
# Build binary intended to be used by bootloader
set(EXECUTABLE_MCUBOOT_NAME "pinetime-mcuboot-app")
set(EXECUTABLE_MCUBOOT_FILE_NAME ${EXECUTABLE_MCUBOOT_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH})
set(IMAGE_MCUBOOT_FILE_NAME ${EXECUTABLE_MCUBOOT_NAME}-image-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.bin)
set(IMAGE_MCUBOOT_FILE_NAME ${EXECUTABLE_MCUBOOT_NAME}-image-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.hex)
set(DFU_MCUBOOT_FILE_NAME ${EXECUTABLE_MCUBOOT_NAME}-dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip)
set(NRF5_LINKER_SCRIPT_MCUBOOT "${CMAKE_SOURCE_DIR}/gcc_nrf52-mcuboot.ld")
add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES})
target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl littlefs QCBOR)
target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl littlefs QCBOR infinitime_fonts)
set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_FILE_NAME})
target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3>
@ -924,7 +920,7 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME}
COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_MCUBOOT_FILE_NAME}.out
COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_FILE_NAME}.bin"
COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_FILE_NAME}.hex"
COMMAND ${CMAKE_SOURCE_DIR}/tools/mcuboot/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header ${EXECUTABLE_MCUBOOT_FILE_NAME}.bin ${IMAGE_MCUBOOT_FILE_NAME}
COMMAND ${CMAKE_SOURCE_DIR}/tools/mcuboot/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header ${EXECUTABLE_MCUBOOT_FILE_NAME}.hex ${IMAGE_MCUBOOT_FILE_NAME}
COMMENT "post build steps for ${EXECUTABLE_MCUBOOT_FILE_NAME}"
)
@ -940,7 +936,7 @@ endif()
set(EXECUTABLE_RECOVERY_NAME "pinetime-recovery")
set(EXECUTABLE_RECOVERY_FILE_NAME ${EXECUTABLE_RECOVERY_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH})
add_executable(${EXECUTABLE_RECOVERY_NAME} ${RECOVERY_SOURCE_FILES})
target_link_libraries(${EXECUTABLE_RECOVERY_NAME} nimble nrf-sdk littlefs QCBOR)
target_link_libraries(${EXECUTABLE_RECOVERY_NAME} nimble nrf-sdk littlefs QCBOR infinitime_fonts)
set_target_properties(${EXECUTABLE_RECOVERY_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_FILE_NAME})
target_compile_definitions(${EXECUTABLE_RECOVERY_NAME} PUBLIC "PINETIME_IS_RECOVERY")
target_compile_options(${EXECUTABLE_RECOVERY_NAME} PUBLIC
@ -967,10 +963,10 @@ add_custom_command(TARGET ${EXECUTABLE_RECOVERY_NAME}
# InfiniTime recovery firmware (mcuboot)
set(EXECUTABLE_RECOVERY_MCUBOOT_NAME "pinetime-mcuboot-recovery")
set(EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH})
set(IMAGE_RECOVERY_MCUBOOT_FILE_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}-image-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.bin)
set(IMAGE_RECOVERY_MCUBOOT_FILE_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}-image-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.hex)
set(DFU_RECOVERY_MCUBOOT_FILE_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}-dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip)
add_executable(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} ${RECOVERY_SOURCE_FILES})
target_link_libraries(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} nimble nrf-sdk littlefs QCBOR)
target_link_libraries(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} nimble nrf-sdk littlefs QCBOR infinitime_fonts)
set_target_properties(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME})
target_compile_definitions(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC "PINETIME_IS_RECOVERY")
target_compile_options(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC
@ -983,16 +979,17 @@ target_compile_options(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC
set_target_properties(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PROPERTIES
SUFFIX ".out"
LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_GRAPHICS_FILE_NAME}.map"
LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_GRAPHICS_FILE_NAME}.map"
)
add_custom_command(TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}
POST_BUILD
COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.out
COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.bin"
COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_RECOVERYY_MCUBOOT_FILE_NAME}.hex"
COMMAND ${CMAKE_SOURCE_DIR}/tools/mcuboot/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.bin ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME}
COMMAND python3 ${CMAKE_SOURCE_DIR}/tools/bin2c.py ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} recoveryImage > recoveryImage.h
COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.hex"
COMMAND ${CMAKE_SOURCE_DIR}/tools/mcuboot/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}.hex ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME}
COMMAND ${CMAKE_OBJCOPY} -I ihex -O binary ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} "${IMAGE_RECOVERY_MCUBOOT_FILE_NAME}.bin"
COMMAND python3 ${CMAKE_SOURCE_DIR}/tools/bin2c.py ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME}.bin recoveryImage > recoveryImage.h
COMMENT "post build steps for ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}"
)
@ -1008,7 +1005,7 @@ endif()
set(EXECUTABLE_RECOVERYLOADER_NAME "pinetime-recovery-loader")
set(EXECUTABLE_RECOVERYLOADER_FILE_NAME ${EXECUTABLE_RECOVERYLOADER_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH})
add_executable(${EXECUTABLE_RECOVERYLOADER_NAME} ${RECOVERYLOADER_SOURCE_FILES})
target_link_libraries(${EXECUTABLE_RECOVERYLOADER_NAME} nrf-sdk QCBOR)
target_link_libraries(${EXECUTABLE_RECOVERYLOADER_NAME} nrf-sdk QCBOR infinitime_fonts)
set_target_properties(${EXECUTABLE_RECOVERYLOADER_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERYLOADER_FILE_NAME})
target_compile_options(${EXECUTABLE_RECOVERYLOADER_NAME} PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3>
@ -1038,10 +1035,10 @@ add_custom_command(TARGET ${EXECUTABLE_RECOVERYLOADER_NAME}
# Build binary that writes the recovery image (MCUBoot version)
set(EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME "pinetime-mcuboot-recovery-loader")
set(EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH})
set(IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}-image-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.bin)
set(IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}-image-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.hex)
set(DFU_MCUBOOT_RECOVERYLOADER_FILE_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}-dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip)
add_executable(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} ${RECOVERYLOADER_SOURCE_FILES})
target_link_libraries(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} nrf-sdk QCBOR)
target_link_libraries(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} nrf-sdk QCBOR infinitime_fonts)
set_target_properties(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME})
target_compile_options(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -Og -g3>
@ -1065,8 +1062,9 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}
COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.out
COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.bin"
COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.hex"
COMMAND ${CMAKE_SOURCE_DIR}/tools/mcuboot/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.bin ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME}
COMMAND python3 ${CMAKE_SOURCE_DIR}/tools/bin2c.py ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} recoveryLoaderImage > recoveryLoaderImage.h
COMMAND ${CMAKE_SOURCE_DIR}/tools/mcuboot/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.hex ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME}
COMMAND ${CMAKE_OBJCOPY} -I ihex -O binary ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} "${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.bin"
COMMAND python3 ${CMAKE_SOURCE_DIR}/tools/bin2c.py ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.bin recoveryLoaderImage > recoveryLoaderImage.h
COMMENT "post build steps for ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}"
)

View File

@ -17,7 +17,6 @@
*/
#include "components/alarm/AlarmController.h"
#include "systemtask/SystemTask.h"
#include "app_timer.h"
#include "task.h"
#include <chrono>
@ -27,20 +26,16 @@ using namespace std::chrono_literals;
AlarmController::AlarmController(Controllers::DateTime& dateTimeController) : dateTimeController {dateTimeController} {
}
APP_TIMER_DEF(alarmAppTimer);
namespace {
void SetOffAlarm(void* p_context) {
auto* controller = static_cast<Pinetime::Controllers::AlarmController*>(p_context);
if (controller != nullptr) {
controller->SetOffAlarmNow();
}
void SetOffAlarm(TimerHandle_t xTimer) {
auto controller = static_cast<Pinetime::Controllers::AlarmController*>(pvTimerGetTimerID(xTimer));
controller->SetOffAlarmNow();
}
}
void AlarmController::Init(System::SystemTask* systemTask) {
app_timer_create(&alarmAppTimer, APP_TIMER_MODE_SINGLE_SHOT, SetOffAlarm);
this->systemTask = systemTask;
alarmTimer = xTimerCreate("Alarm", 1, pdFALSE, this, SetOffAlarm);
}
void AlarmController::SetAlarmTime(uint8_t alarmHr, uint8_t alarmMin) {
@ -49,13 +44,12 @@ void AlarmController::SetAlarmTime(uint8_t alarmHr, uint8_t alarmMin) {
}
void AlarmController::ScheduleAlarm() {
// Determine the next time the alarm needs to go off and set the app_timer
app_timer_stop(alarmAppTimer);
// Determine the next time the alarm needs to go off and set the timer
xTimerStop(alarmTimer, 0);
auto now = dateTimeController.CurrentDateTime();
alarmTime = now;
time_t ttAlarmTime = std::chrono::system_clock::to_time_t(
std::chrono::time_point_cast<std::chrono::system_clock::duration>(alarmTime));
time_t ttAlarmTime = std::chrono::system_clock::to_time_t(std::chrono::time_point_cast<std::chrono::system_clock::duration>(alarmTime));
tm* tmAlarmTime = std::localtime(&ttAlarmTime);
// If the time being set has already passed today,the alarm should be set for tomorrow
@ -81,8 +75,9 @@ void AlarmController::ScheduleAlarm() {
// now can convert back to a time_point
alarmTime = std::chrono::system_clock::from_time_t(std::mktime(tmAlarmTime));
auto mSecToAlarm = std::chrono::duration_cast<std::chrono::milliseconds>(alarmTime - now).count();
app_timer_start(alarmAppTimer, APP_TIMER_TICKS(mSecToAlarm), this);
auto secondsToAlarm = std::chrono::duration_cast<std::chrono::seconds>(alarmTime - now).count();
xTimerChangePeriod(alarmTimer, secondsToAlarm * configTICK_RATE_HZ, 0);
xTimerStart(alarmTimer, 0);
state = AlarmState::Set;
}
@ -92,7 +87,7 @@ uint32_t AlarmController::SecondsToAlarm() {
}
void AlarmController::DisableAlarm() {
app_timer_stop(alarmAppTimer);
xTimerStop(alarmTimer, 0);
state = AlarmState::Not_Set;
}
@ -102,14 +97,12 @@ void AlarmController::SetOffAlarmNow() {
}
void AlarmController::StopAlerting() {
systemTask->PushMessage(System::Messages::StopRinging);
// Alarm state is off unless this is a recurring alarm
if (recurrence == RecurType::None) {
state = AlarmState::Not_Set;
} else {
state = AlarmState::Set;
// set next instance
ScheduleAlarm();
}
systemTask->PushMessage(System::Messages::StopRinging);
}

View File

@ -17,6 +17,8 @@
*/
#pragma once
#include <FreeRTOS.h>
#include <timers.h>
#include <cstdint>
#include "components/datetime/DateTimeController.h"
@ -57,6 +59,7 @@ namespace Pinetime {
private:
Controllers::DateTime& dateTimeController;
System::SystemTask* systemTask = nullptr;
TimerHandle_t alarmTimer;
uint8_t hours = 7;
uint8_t minutes = 0;
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> alarmTime;

View File

@ -0,0 +1,109 @@
/* Copyright (C) 2021 Adam Pigg
This file is part of InfiniTime.
InfiniTime is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
InfiniTime is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "components/ble/AgendaService.h"
#include "systemtask/SystemTask.h"
namespace {
// 3fdaYYXX-e246-472e-b7e0-d2b0f3d9c17a
constexpr ble_uuid128_t CharUuid(uint8_t x, uint8_t y) {
return ble_uuid128_t {.u = {.type = BLE_UUID_TYPE_128},
.value = {0x7a, 0xc1, 0xd9, 0xf3, 0xb0, 0xd2, 0xe0, 0xb7, 0x2e, 0x47, 0x46, 0xe2, x, y, 0xda, 0x3f}};
}
// 00010000-78fc-48fe-8e23-433b3a1942d0
constexpr ble_uuid128_t BaseUuid() {
return CharUuid(0x00, 0x00);
}
constexpr ble_uuid128_t agendaUuid {BaseUuid()};
constexpr ble_uuid128_t agendaItemCharUuid {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 AgendaCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) {
auto agendaService = static_cast<Pinetime::Controllers::AgendaService*>(arg);
return agendaService->OnCommand(conn_handle, attr_handle, ctxt);
}
} // namespace
Pinetime::Controllers::AgendaService::AgendaService(Pinetime::System::SystemTask& system) : m_system(system) {
characteristicDefinition[0] = {.uuid = &agendaItemCharUuid.u,
.access_cb = AgendaCallback,
.arg = this,
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
characteristicDefinition[1] = {0};
serviceDefinition[0] = {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &agendaUuid.u, .characteristics = characteristicDefinition};
serviceDefinition[1] = {0};
}
void Pinetime::Controllers::AgendaService::Init() {
int res = 0;
res = ble_gatts_count_cfg(serviceDefinition);
ASSERT(res == 0);
res = ble_gatts_add_svcs(serviceDefinition);
ASSERT(res == 0);
m_agenda_times[0] = 1655327841;
m_agenda_pieces[0] = "C++ Fumbling";
}
int Pinetime::Controllers::AgendaService::OnCommand(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt) {
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
size_t notifSize = OS_MBUF_PKTLEN(ctxt->om);
uint8_t data[notifSize + 1];
data[notifSize] = '\0';
os_mbuf_copydata(ctxt->om, 0, notifSize, data);
if (ble_uuid_cmp(ctxt->chr->uuid, &agendaItemCharUuid.u) == 0) {
if (notifSize >= 5) {
uint8_t itemIndex = (uint8_t) data[0];
uint32_t itemTime = ((uint32_t) data[1]) << 24 | ((uint32_t) data[2]) << 16 | ((uint32_t) data[3]) << 8 | ((uint32_t) data[4]);
char* sAgendaItem = (char*) &data[5];
if (itemIndex < AGENDA_CAPACITY) { // don't allow a buffer overflow
m_agenda_times[itemIndex] = itemTime;
// implicit std::string copy/conversion here:
m_agenda_pieces[itemIndex] = sAgendaItem;
}
}
}
}
return 0;
}
uint32_t Pinetime::Controllers::AgendaService::getAgendaTime(uint8_t index) {
if (index < AGENDA_CAPACITY) {
return m_agenda_times[index];
} else {
return 0;
}
}
std::string Pinetime::Controllers::AgendaService::getAgendaPiece(uint8_t index) {
if (index < AGENDA_CAPACITY) {
return m_agenda_pieces[index];
} else {
return 0;
}
}

View File

@ -0,0 +1,59 @@
/* Copyright (C) 2021 Adam Pigg
This file is part of InfiniTime.
InfiniTime is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
InfiniTime is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <cstdint>
#include <string>
#define min // workaround: nimble's min/max macros conflict with libstdc++
#define max
#include <host/ble_gap.h>
#include <host/ble_uuid.h>
#undef max
#undef min
namespace Pinetime {
namespace System {
class SystemTask;
}
namespace Controllers {
class AgendaService {
public:
static const uint8_t AGENDA_CAPACITY = 35;
explicit AgendaService(Pinetime::System::SystemTask& system);
void Init();
int OnCommand(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt);
uint32_t getAgendaTime(uint8_t index);
std::string getAgendaPiece(uint8_t index);
private:
struct ble_gatt_chr_def characteristicDefinition[2];
struct ble_gatt_svc_def serviceDefinition[2];
uint32_t m_agenda_times[AGENDA_CAPACITY];
std::string m_agenda_pieces[AGENDA_CAPACITY];
Pinetime::System::SystemTask& m_system;
};
}
}

View File

@ -26,8 +26,11 @@ namespace {
return client->OnCharacteristicsDiscoveryEvent(conn_handle, error, chr);
}
int OnAlertNotificationDescriptorDiscoveryEventCallback(
uint16_t conn_handle, const struct ble_gatt_error* error, uint16_t chr_val_handle, const struct ble_gatt_dsc* dsc, void* arg) {
int OnAlertNotificationDescriptorDiscoveryEventCallback(uint16_t conn_handle,
const struct ble_gatt_error* error,
uint16_t chr_val_handle,
const struct ble_gatt_dsc* dsc,
void* arg) {
auto client = static_cast<AlertNotificationClient*>(arg);
return client->OnDescriptorDiscoveryEventCallback(conn_handle, error, chr_val_handle, dsc);
}

View File

@ -18,6 +18,7 @@ namespace Pinetime {
int OnBatteryServiceRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context);
void NotifyBatteryLevel(uint16_t connectionHandle, uint8_t level);
private:
Controllers::Battery& batteryController;
static constexpr uint16_t batteryInformationServiceId {0x180F};

View File

@ -85,10 +85,21 @@ int CurrentTimeClient::OnCurrentTimeReadResult(uint16_t conn_handle, const ble_g
// TODO check that attribute->handle equals the handle discovered in OnCharacteristicDiscoveryEvent
CtsData result;
os_mbuf_copydata(attribute->om, 0, sizeof(CtsData), &result);
NRF_LOG_INFO(
"Received data: %d-%d-%d %d:%d:%d", result.year, result.month, result.dayofmonth, result.hour, result.minute, result.second);
dateTimeController.SetTime(
result.year, result.month, result.dayofmonth, 0, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG));
NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d",
result.year,
result.month,
result.dayofmonth,
result.hour,
result.minute,
result.second);
dateTimeController.SetTime(result.year,
result.month,
result.dayofmonth,
0,
result.hour,
result.minute,
result.second,
nrf_rtc_counter_get(portNRF_RTC_REG));
} else {
NRF_LOG_INFO("Error retrieving current time: %d", error->status);
}

View File

@ -29,11 +29,22 @@ int CurrentTimeService::OnTimeAccessed(uint16_t conn_handle, uint16_t attr_handl
CtsData result;
os_mbuf_copydata(ctxt->om, 0, sizeof(CtsData), &result);
NRF_LOG_INFO(
"Received data: %d-%d-%d %d:%d:%d", result.year, result.month, result.dayofmonth, result.hour, result.minute, result.second);
NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d",
result.year,
result.month,
result.dayofmonth,
result.hour,
result.minute,
result.second);
m_dateTimeController.SetTime(
result.year, result.month, result.dayofmonth, 0, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG));
m_dateTimeController.SetTime(result.year,
result.month,
result.dayofmonth,
0,
result.hour,
result.minute,
result.second,
nrf_rtc_counter_get(portNRF_RTC_REG));
} else if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR) {
CtsData currentDateTime;

View File

@ -119,8 +119,10 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) {
bootloaderSize = om->om_data[4] + (om->om_data[5] << 8) + (om->om_data[6] << 16) + (om->om_data[7] << 24);
applicationSize = om->om_data[8] + (om->om_data[9] << 8) + (om->om_data[10] << 16) + (om->om_data[11] << 24);
bleController.FirmwareUpdateTotalBytes(applicationSize);
NRF_LOG_INFO(
"[DFU] -> Start data received : SD size : %d, BT size : %d, app size : %d", softdeviceSize, bootloaderSize, applicationSize);
NRF_LOG_INFO("[DFU] -> Start data received : SD size : %d, BT size : %d, app size : %d",
softdeviceSize,
bootloaderSize,
applicationSize);
// wait until SystemTask has finished waking up all devices
while (systemTask.IsSleeping()) {
@ -165,10 +167,10 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) {
if ((nbPacketReceived % nbPacketsToNotify) == 0 && bytesReceived != applicationSize) {
uint8_t data[5] {static_cast<uint8_t>(Opcodes::PacketReceiptNotification),
(uint8_t)(bytesReceived & 0x000000FFu),
(uint8_t)(bytesReceived >> 8u),
(uint8_t)(bytesReceived >> 16u),
(uint8_t)(bytesReceived >> 24u)};
static_cast<uint8_t>(bytesReceived & 0x000000FFu),
static_cast<uint8_t>(bytesReceived >> 8u),
static_cast<uint8_t>(bytesReceived >> 16u),
static_cast<uint8_t>(bytesReceived >> 24u)};
NRF_LOG_INFO("[DFU] -> Send packet notification: %d bytes received", bytesReceived);
notificationManager.Send(connectionHandle, controlPointCharacteristicHandle, data, 5);
}
@ -244,7 +246,7 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) {
NRF_LOG_INFO("[DFU] -> Receive firmware image requested, but we are not in Start Init");
return 0;
}
// TODO the chunk size is dependant of the implementation of the host application...
// TODO the chunk size is dependent of the implementation of the host application...
dfuImage.Init(20, applicationSize, expectedCrc);
NRF_LOG_INFO("[DFU] -> Starting receive firmware");
state = States::Data;
@ -423,9 +425,9 @@ uint16_t DfuService::DfuImage::ComputeCrc(uint8_t const* p_data, uint32_t size,
uint16_t crc = (p_crc == NULL) ? 0xFFFF : *p_crc;
for (uint32_t i = 0; i < size; i++) {
crc = (uint8_t)(crc >> 8) | (crc << 8);
crc = static_cast<uint8_t>(crc >> 8) | (crc << 8);
crc ^= p_data[i];
crc ^= (uint8_t)(crc & 0xFF) >> 4;
crc ^= static_cast<uint8_t>(crc & 0xFF) >> 4;
crc ^= (crc << 8) << 4;
crc ^= ((crc & 0xFF) << 4) << 1;
}

View File

@ -81,7 +81,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
return -1;
}
memcpy(filepath, header->pathstr, plen);
filepath[plen] = 0; // Copy and null teminate string
filepath[plen] = 0; // Copy and null terminate string
ReadResponse resp;
os_mbuf* om;
resp.command = commands::READ_DATA;
@ -148,7 +148,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
return -1; // TODO make this actually return a BLE notif
}
memcpy(filepath, header->pathstr, plen);
filepath[plen] = 0; // Copy and null teminate string
filepath[plen] = 0; // Copy and null terminate string
fileSize = header->totalSize;
WriteResponse resp;
resp.command = commands::WRITE_PACING;
@ -193,7 +193,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
uint16_t plen = header->pathlen;
char path[plen + 1] = {0};
memcpy(path, header->pathstr, plen);
path[plen] = 0; // Copy and null teminate string
path[plen] = 0; // Copy and null terminate string
DelResponse resp {};
resp.command = commands::DELETE_STATUS;
int res = fs.FileDelete(path);
@ -208,7 +208,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
uint16_t plen = header->pathlen;
char path[plen + 1] = {0};
memcpy(path, header->pathstr, plen);
path[plen] = 0; // Copy and null teminate string
path[plen] = 0; // Copy and null terminate string
MKDirResponse resp {};
resp.command = commands::MKDIR_STATUS;
resp.modification_time = 0;
@ -223,7 +223,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
ListDirHeader* header = (ListDirHeader*) om->om_data;
uint16_t plen = header->pathlen;
char path[plen + 1] = {0};
path[plen] = 0; // Copy and null teminate string
path[plen] = 0; // Copy and null terminate string
memcpy(path, header->pathstr, plen);
ListDirResponse resp {};
@ -290,7 +290,7 @@ int FSService::FSCommandHandler(uint16_t connectionHandle, os_mbuf* om) {
header->pathstr[plen] = 0;
char path[header->NewPathLength + 1] = {0};
memcpy(path, &header->pathstr[plen + 1], header->NewPathLength);
path[header->NewPathLength] = 0; // Copy and null teminate string
path[header->NewPathLength] = 0; // Copy and null terminate string
MoveResponse resp {};
resp.command = commands::MOVE_STATUS;
int8_t res = (int8_t) fs.Rename(header->pathstr, path);

View File

@ -57,7 +57,8 @@ int HeartRateService::OnHeartRateRequested(uint16_t connectionHandle, uint16_t a
}
void HeartRateService::OnNewHeartRateValue(uint8_t heartRateValue) {
if(!heartRateMeasurementNotificationEnable) return;
if (!heartRateMeasurementNotificationEnable)
return;
uint8_t buffer[2] = {0, heartRateController.HeartRate()}; // [0] = flags, [1] = hr value
auto* om = ble_hs_mbuf_from_flat(buffer, 2);
@ -72,11 +73,11 @@ void HeartRateService::OnNewHeartRateValue(uint8_t heartRateValue) {
}
void HeartRateService::SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) {
if(attributeHandle == heartRateMeasurementHandle)
if (attributeHandle == heartRateMeasurementHandle)
heartRateMeasurementNotificationEnable = true;
}
void HeartRateService::UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) {
if(attributeHandle == heartRateMeasurementHandle)
if (attributeHandle == heartRateMeasurementHandle)
heartRateMeasurementNotificationEnable = false;
}

View File

@ -8,10 +8,8 @@ using namespace Pinetime::Controllers;
namespace {
// 0003yyxx-78fc-48fe-8e23-433b3a1942d0
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, 0x03, 0x00 }
};
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, 0x03, 0x00}};
}
// 00030000-78fc-48fe-8e23-433b3a1942d0
@ -45,11 +43,7 @@ MotionService::MotionService(Pinetime::System::SystemTask& system, Controllers::
.val_handle = &motionValuesHandle},
{0}},
serviceDefinition {
{
.type = BLE_GATT_SVC_TYPE_PRIMARY,
.uuid = &motionServiceUuid.u,
.characteristics = characteristicDefinition
},
{.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &motionServiceUuid.u, .characteristics = characteristicDefinition},
{0},
} {
// TODO refactor to prevent this loop dependency (service depends on controller and controller depends on service)
@ -72,8 +66,8 @@ int MotionService::OnStepCountRequested(uint16_t connectionHandle, uint16_t attr
int res = os_mbuf_append(context->om, &buffer, 4);
return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
} else if(attributeHandle == motionValuesHandle) {
int16_t buffer[3] = { motionController.X(), motionController.Y(), motionController.Z() };
} else if (attributeHandle == motionValuesHandle) {
int16_t buffer[3] = {motionController.X(), motionController.Y(), motionController.Z()};
int res = os_mbuf_append(context->om, buffer, 3 * sizeof(int16_t));
return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
@ -82,7 +76,8 @@ int MotionService::OnStepCountRequested(uint16_t connectionHandle, uint16_t attr
}
void MotionService::OnNewStepCountValue(uint32_t stepCount) {
if(!stepCountNoficationEnabled) return;
if (!stepCountNoficationEnabled)
return;
uint32_t buffer = stepCount;
auto* om = ble_hs_mbuf_from_flat(&buffer, 4);
@ -96,9 +91,10 @@ void MotionService::OnNewStepCountValue(uint32_t stepCount) {
ble_gattc_notify_custom(connectionHandle, stepCountHandle, om);
}
void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) {
if(!motionValuesNoficationEnabled) return;
if (!motionValuesNoficationEnabled)
return;
int16_t buffer[3] = { motionController.X(), motionController.Y(), motionController.Z() };
int16_t buffer[3] = {motionController.X(), motionController.Y(), motionController.Z()};
auto* om = ble_hs_mbuf_from_flat(buffer, 3 * sizeof(int16_t));
uint16_t connectionHandle = system.nimble().connHandle();
@ -111,15 +107,15 @@ void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) {
}
void MotionService::SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) {
if(attributeHandle == stepCountHandle)
if (attributeHandle == stepCountHandle)
stepCountNoficationEnabled = true;
else if(attributeHandle == motionValuesHandle)
else if (attributeHandle == motionValuesHandle)
motionValuesNoficationEnabled = true;
}
void MotionService::UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) {
if(attributeHandle == stepCountHandle)
if (attributeHandle == stepCountHandle)
stepCountNoficationEnabled = false;
else if(attributeHandle == motionValuesHandle)
else if (attributeHandle == motionValuesHandle)
motionValuesNoficationEnabled = false;
}

View File

@ -22,10 +22,8 @@
namespace {
// 0000yyxx-78fc-48fe-8e23-433b3a1942d0
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, 0x00, 0x00 }
};
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, 0x00, 0x00}};
}
// 00000000-78fc-48fe-8e23-433b3a1942d0
@ -111,8 +109,7 @@ Pinetime::Controllers::MusicService::MusicService(Pinetime::System::SystemTask&
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
characteristicDefinition[13] = {0};
serviceDefinition[0] = {
.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &msUuid.u, .characteristics = characteristicDefinition};
serviceDefinition[0] = {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &msUuid.u, .characteristics = characteristicDefinition};
serviceDefinition[1] = {0};
}
@ -137,9 +134,9 @@ int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_
os_mbuf_copydata(ctxt->om, 0, bufferSize, data);
if (notifSize > bufferSize) {
data[bufferSize-1] = '.';
data[bufferSize-2] = '.';
data[bufferSize-3] = '.';
data[bufferSize - 1] = '.';
data[bufferSize - 2] = '.';
data[bufferSize - 3] = '.';
}
data[bufferSize] = '\0';
@ -157,7 +154,8 @@ int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_
if (playing) {
trackProgressUpdateTime = xTaskGetTickCount();
} else {
trackProgress += static_cast<int>((static_cast<float>(xTaskGetTickCount() - trackProgressUpdateTime) / 1024.0f) * getPlaybackSpeed());
trackProgress +=
static_cast<int>((static_cast<float>(xTaskGetTickCount() - trackProgressUpdateTime) / 1024.0f) * getPlaybackSpeed());
}
} else if (ble_uuid_cmp(ctxt->chr->uuid, &msRepeatCharUuid.u) == 0) {
repeat = s[0];
@ -201,7 +199,8 @@ float Pinetime::Controllers::MusicService::getPlaybackSpeed() const {
int Pinetime::Controllers::MusicService::getProgress() const {
if (isPlaying()) {
return trackProgress + static_cast<int>((static_cast<float>(xTaskGetTickCount() - trackProgressUpdateTime) / 1024.0f) * getPlaybackSpeed());
return trackProgress +
static_cast<int>((static_cast<float>(xTaskGetTickCount() - trackProgressUpdateTime) / 1024.0f) * getPlaybackSpeed());
}
return trackProgress;
}

View File

@ -46,15 +46,23 @@ namespace {
} // namespace
Pinetime::Controllers::NavigationService::NavigationService(Pinetime::System::SystemTask& system) : m_system(system) {
characteristicDefinition[0] = {
.uuid = &navFlagCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
characteristicDefinition[0] = {.uuid = &navFlagCharUuid.u,
.access_cb = NAVCallback,
.arg = this,
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
characteristicDefinition[1] = {
.uuid = &navNarrativeCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
characteristicDefinition[2] = {
.uuid = &navManDistCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
characteristicDefinition[3] = {
.uuid = &navProgressCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
characteristicDefinition[1] = {.uuid = &navNarrativeCharUuid.u,
.access_cb = NAVCallback,
.arg = this,
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
characteristicDefinition[2] = {.uuid = &navManDistCharUuid.u,
.access_cb = NAVCallback,
.arg = this,
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
characteristicDefinition[3] = {.uuid = &navProgressCharUuid.u,
.access_cb = NAVCallback,
.arg = this,
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
characteristicDefinition[4] = {0};

View File

@ -51,6 +51,7 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask,
heartRateService {systemTask, heartRateController},
motionService {systemTask, motionController},
fsService {systemTask, fs},
agendaService {systemTask},
serviceDiscovery({&currentTimeClient, &alertNotificationClient}) {
}
@ -93,6 +94,7 @@ void NimbleController::Init() {
musicService.Init();
weatherService.Init();
navService.Init();
agendaService.Init();
anService.Init();
dfuService.Init();
batteryInformationService.Init();
@ -223,7 +225,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
currentTimeClient.Reset();
alertNotificationClient.Reset();
connectionHandle = BLE_HS_CONN_HANDLE_NONE;
if(bleController.IsConnected()) {
if (bleController.IsConnected()) {
bleController.Disconnect();
fastAdvCount = 0;
StartAdvertising();

View File

@ -21,6 +21,7 @@
#include "components/ble/NavigationService.h"
#include "components/ble/ServiceDiscovery.h"
#include "components/ble/MotionService.h"
#include "components/ble/AgendaService.h"
#include "components/ble/weather/WeatherService.h"
#include "components/fs/FS.h"
@ -61,6 +62,9 @@ namespace Pinetime {
Pinetime::Controllers::NavigationService& navigation() {
return navService;
};
Pinetime::Controllers::AgendaService& agenda() {
return agendaService;
};
Pinetime::Controllers::AlertNotificationService& alertService() {
return anService;
};
@ -103,6 +107,7 @@ namespace Pinetime {
HeartRateService heartRateService;
MotionService motionService;
FSService fsService;
AgendaService agendaService;
ServiceDiscovery serviceDiscovery;
uint8_t addrType;

View File

@ -127,7 +127,8 @@ namespace Pinetime {
{.uuid = &weatherControlCharUuid.u, .access_cb = WeatherCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ},
{nullptr}};
const struct ble_gatt_svc_def serviceDefinition[2] = {
{.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &weatherUuid.u, .characteristics = characteristicDefinition}, {0}};
{.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &weatherUuid.u, .characteristics = characteristicDefinition},
{0}};
uint16_t eventHandle {};

View File

@ -19,8 +19,14 @@ void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock,
UpdateTime(previousSystickCounter); // Update internal state without updating the time
}
void DateTime::SetTime(
uint16_t year, uint8_t month, uint8_t day, uint8_t dayOfWeek, uint8_t hour, uint8_t minute, uint8_t second, uint32_t systickCounter) {
void DateTime::SetTime(uint16_t year,
uint8_t month,
uint8_t day,
uint8_t dayOfWeek,
uint8_t hour,
uint8_t minute,
uint8_t second,
uint32_t systickCounter) {
std::tm tm = {
/* .tm_sec = */ second,
/* .tm_min = */ minute,
@ -129,16 +135,16 @@ std::string DateTime::FormattedTime() {
// Return time as a string in 12- or 24-hour format
char buff[9];
if (settingsController.GetClockType() == ClockType::H12) {
uint8_t hour12;
const char* amPmStr;
if (hour < 12) {
hour12 = (hour == 0) ? 12 : hour;
amPmStr = "AM";
} else {
hour12 = (hour == 12) ? 12 : hour - 12;
amPmStr = "PM";
}
sprintf(buff, "%i:%02i %s", hour12, minute, amPmStr);
uint8_t hour12;
const char* amPmStr;
if (hour < 12) {
hour12 = (hour == 0) ? 12 : hour;
amPmStr = "AM";
} else {
hour12 = (hour == 12) ? 12 : hour - 12;
amPmStr = "PM";
}
sprintf(buff, "%i:%02i %s", hour12, minute, amPmStr);
} else {
sprintf(buff, "%02i:%02i", hour, minute);
}

View File

@ -95,8 +95,8 @@ int FS::DirRewind(lfs_dir_t* dir) {
int FS::DirCreate(const char* path) {
return lfs_mkdir(&lfs, path);
}
int FS::Rename(const char* oldPath, const char* newPath){
return lfs_rename(&lfs,oldPath,newPath);
int FS::Rename(const char* oldPath, const char* newPath) {
return lfs_rename(&lfs, oldPath, newPath);
}
int FS::Stat(const char* path, lfs_info* info) {
return lfs_stat(&lfs, path, info);

View File

@ -26,7 +26,7 @@ namespace Pinetime {
int DirRead(lfs_dir_t* dir, lfs_info* info);
int DirRewind(lfs_dir_t* dir);
int DirCreate(const char* path);
lfs_ssize_t GetFSSize();
int Rename(const char* oldPath, const char* newPath);
int Stat(const char* path, lfs_info* info);

View File

@ -1,43 +1,39 @@
#include "components/motor/MotorController.h"
#include <hal/nrf_gpio.h>
#include "systemtask/SystemTask.h"
#include "app_timer.h"
#include "drivers/PinMap.h"
APP_TIMER_DEF(shortVibTimer);
APP_TIMER_DEF(longVibTimer);
using namespace Pinetime::Controllers;
void MotorController::Init() {
nrf_gpio_cfg_output(PinMap::Motor);
nrf_gpio_pin_set(PinMap::Motor);
app_timer_init();
app_timer_create(&shortVibTimer, APP_TIMER_MODE_SINGLE_SHOT, StopMotor);
app_timer_create(&longVibTimer, APP_TIMER_MODE_REPEATED, Ring);
shortVib = xTimerCreate("shortVib", 1, pdFALSE, nullptr, StopMotor);
longVib = xTimerCreate("longVib", pdMS_TO_TICKS(1000), pdTRUE, this, Ring);
}
void MotorController::Ring(void* p_context) {
auto* motorController = static_cast<MotorController*>(p_context);
void MotorController::Ring(TimerHandle_t xTimer) {
auto* motorController = static_cast<MotorController*>(pvTimerGetTimerID(xTimer));
motorController->RunForDuration(50);
}
void MotorController::RunForDuration(uint8_t motorDuration) {
nrf_gpio_pin_clear(PinMap::Motor);
app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr);
if (xTimerChangePeriod(shortVib, pdMS_TO_TICKS(motorDuration), 0) == pdPASS && xTimerStart(shortVib, 0) == pdPASS) {
nrf_gpio_pin_clear(PinMap::Motor);
}
}
void MotorController::StartRinging() {
Ring(this);
app_timer_start(longVibTimer, APP_TIMER_TICKS(1000), this);
RunForDuration(50);
xTimerStart(longVib, 0);
}
void MotorController::StopRinging() {
app_timer_stop(longVibTimer);
xTimerStop(longVib, 0);
nrf_gpio_pin_set(PinMap::Motor);
}
void MotorController::StopMotor(void* p_context) {
void MotorController::StopMotor(TimerHandle_t xTimer) {
nrf_gpio_pin_set(PinMap::Motor);
}

View File

@ -1,5 +1,7 @@
#pragma once
#include <FreeRTOS.h>
#include <timers.h>
#include <cstdint>
namespace Pinetime {
@ -15,8 +17,10 @@ namespace Pinetime {
void StopRinging();
private:
static void Ring(void* p_context);
static void StopMotor(void* p_context);
static void Ring(TimerHandle_t xTimer);
static void StopMotor(TimerHandle_t xTimer);
TimerHandle_t shortVib;
TimerHandle_t longVib;
};
}
}

View File

@ -26,12 +26,12 @@ void Settings::LoadSettingsFromFile() {
SettingsData bufferSettings;
lfs_file_t settingsFile;
if ( fs.FileOpen(&settingsFile, "/settings.dat", LFS_O_RDONLY) != LFS_ERR_OK) {
if (fs.FileOpen(&settingsFile, "/settings.dat", LFS_O_RDONLY) != LFS_ERR_OK) {
return;
}
fs.FileRead(&settingsFile, reinterpret_cast<uint8_t*>(&bufferSettings), sizeof(settings));
fs.FileClose(&settingsFile);
if ( bufferSettings.version == settingsVersion ) {
if (bufferSettings.version == settingsVersion) {
settings = bufferSettings;
}
}
@ -39,7 +39,7 @@ void Settings::LoadSettingsFromFile() {
void Settings::SaveSettingsToFile() {
lfs_file_t settingsFile;
if ( fs.FileOpen(&settingsFile, "/settings.dat", LFS_O_WRONLY | LFS_O_CREAT) != LFS_ERR_OK) {
if (fs.FileOpen(&settingsFile, "/settings.dat", LFS_O_WRONLY | LFS_O_CREAT) != LFS_ERR_OK) {
return;
}
fs.FileWrite(&settingsFile, reinterpret_cast<uint8_t*>(&settings), sizeof(settings));

View File

@ -140,15 +140,14 @@ namespace Pinetime {
return settings.screenTimeOut;
};
void SetShakeThreshold(uint16_t thresh){
if(settings.shakeWakeThreshold != thresh){
settings.shakeWakeThreshold = thresh;
settingsChanged = true;
void SetShakeThreshold(uint16_t thresh) {
if (settings.shakeWakeThreshold != thresh) {
settings.shakeWakeThreshold = thresh;
settingsChanged = true;
}
}
int16_t GetShakeThreshold() const{
int16_t GetShakeThreshold() const {
return settings.shakeWakeThreshold;
}
@ -195,20 +194,20 @@ namespace Pinetime {
if (goal != settings.stepsGoal) {
settingsChanged = true;
}
settings.stepsGoal = goal;
settings.stepsGoal = goal;
};
uint32_t GetStepsGoal() const {
return settings.stepsGoal;
};
void SetBleRadioEnabled(bool enabled) {
bleRadioEnabled = enabled;
};
void SetBleRadioEnabled(bool enabled) {
bleRadioEnabled = enabled;
};
bool GetBleRadioEnabled() const {
return bleRadioEnabled;
};
bool GetBleRadioEnabled() const {
return bleRadioEnabled;
};
private:
Pinetime::Controllers::FS& fs;

View File

@ -10,7 +10,7 @@ void TimerCallback(TimerHandle_t xTimer) {
void TimerController::Init(Pinetime::System::SystemTask* systemTask) {
this->systemTask = systemTask;
timer = xTimerCreate("Timer", 0, pdFALSE, this, TimerCallback);
timer = xTimerCreate("Timer", 1, pdFALSE, this, TimerCallback);
}
void TimerController::StartTimer(uint32_t duration) {

View File

@ -39,7 +39,9 @@ namespace Pinetime {
SettingChimes,
SettingShakeThreshold,
SettingBluetooth,
Error
Error,
// oli: custom
Agenda
};
}
}

View File

@ -5,23 +5,41 @@ using namespace Pinetime::Controllers;
lv_color_t Pinetime::Applications::Convert(Pinetime::Controllers::Settings::Colors color) {
switch (color) {
case Pinetime::Controllers::Settings::Colors::White: return LV_COLOR_WHITE;
case Pinetime::Controllers::Settings::Colors::Silver: return LV_COLOR_SILVER;
case Pinetime::Controllers::Settings::Colors::Gray: return LV_COLOR_GRAY;
case Pinetime::Controllers::Settings::Colors::Black: return LV_COLOR_BLACK;
case Pinetime::Controllers::Settings::Colors::Red: return LV_COLOR_RED;
case Pinetime::Controllers::Settings::Colors::Maroon: return LV_COLOR_MAKE(0xb0, 0x0, 0x0);
case Pinetime::Controllers::Settings::Colors::Yellow: return LV_COLOR_YELLOW;
case Pinetime::Controllers::Settings::Colors::Olive: return LV_COLOR_MAKE(0xb0, 0xb0, 0x0);
case Pinetime::Controllers::Settings::Colors::Lime: return LV_COLOR_LIME;
case Pinetime::Controllers::Settings::Colors::Green: return LV_COLOR_MAKE(0x0, 0xb0, 0x0);
case Pinetime::Controllers::Settings::Colors::Cyan: return LV_COLOR_CYAN;
case Pinetime::Controllers::Settings::Colors::Teal: return LV_COLOR_MAKE(0x0, 0xb0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Blue: return LV_COLOR_BLUE;
case Pinetime::Controllers::Settings::Colors::Navy: return LV_COLOR_MAKE(0x0, 0x0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Magenta: return LV_COLOR_MAGENTA;
case Pinetime::Controllers::Settings::Colors::Purple: return LV_COLOR_MAKE(0xb0, 0x0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Orange: return LV_COLOR_ORANGE;
default: return LV_COLOR_WHITE;
case Pinetime::Controllers::Settings::Colors::White:
return LV_COLOR_WHITE;
case Pinetime::Controllers::Settings::Colors::Silver:
return LV_COLOR_SILVER;
case Pinetime::Controllers::Settings::Colors::Gray:
return LV_COLOR_GRAY;
case Pinetime::Controllers::Settings::Colors::Black:
return LV_COLOR_BLACK;
case Pinetime::Controllers::Settings::Colors::Red:
return LV_COLOR_RED;
case Pinetime::Controllers::Settings::Colors::Maroon:
return LV_COLOR_MAKE(0xb0, 0x0, 0x0);
case Pinetime::Controllers::Settings::Colors::Yellow:
return LV_COLOR_YELLOW;
case Pinetime::Controllers::Settings::Colors::Olive:
return LV_COLOR_MAKE(0xb0, 0xb0, 0x0);
case Pinetime::Controllers::Settings::Colors::Lime:
return LV_COLOR_LIME;
case Pinetime::Controllers::Settings::Colors::Green:
return LV_COLOR_MAKE(0x0, 0xb0, 0x0);
case Pinetime::Controllers::Settings::Colors::Cyan:
return LV_COLOR_CYAN;
case Pinetime::Controllers::Settings::Colors::Teal:
return LV_COLOR_MAKE(0x0, 0xb0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Blue:
return LV_COLOR_BLUE;
case Pinetime::Controllers::Settings::Colors::Navy:
return LV_COLOR_MAKE(0x0, 0x0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Magenta:
return LV_COLOR_MAGENTA;
case Pinetime::Controllers::Settings::Colors::Purple:
return LV_COLOR_MAKE(0xb0, 0x0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Orange:
return LV_COLOR_ORANGE;
default:
return LV_COLOR_WHITE;
}
}

View File

@ -11,14 +11,12 @@
#include "components/motion/MotionController.h"
#include "components/motor/MotorController.h"
#include "displayapp/screens/ApplicationList.h"
#include "displayapp/screens/Brightness.h"
#include "displayapp/screens/Clock.h"
#include "displayapp/screens/FirmwareUpdate.h"
#include "displayapp/screens/FirmwareValidation.h"
#include "displayapp/screens/InfiniPaint.h"
#include "displayapp/screens/Paddle.h"
#include "displayapp/screens/StopWatch.h"
#include "displayapp/screens/Meter.h"
#include "displayapp/screens/Metronome.h"
#include "displayapp/screens/Music.h"
#include "displayapp/screens/Navigation.h"
@ -32,6 +30,8 @@
#include "displayapp/screens/PassKey.h"
#include "displayapp/screens/Error.h"
#include "displayapp/screens/Agenda.h"
#include "drivers/Cst816s.h"
#include "drivers/St7789.h"
#include "drivers/Watchdog.h"
@ -325,7 +325,8 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
notificationManager,
settingsController,
heartRateController,
motionController);
motionController,
systemTask->nimble().agenda());
break;
case Apps::Error:
@ -348,13 +349,21 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
break;
case Apps::Notifications:
currentScreen = std::make_unique<Screens::Notifications>(
this, notificationManager, systemTask->nimble().alertService(), motorController, *systemTask, Screens::Notifications::Modes::Normal);
currentScreen = std::make_unique<Screens::Notifications>(this,
notificationManager,
systemTask->nimble().alertService(),
motorController,
*systemTask,
Screens::Notifications::Modes::Normal);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break;
case Apps::NotificationsPreview:
currentScreen = std::make_unique<Screens::Notifications>(
this, notificationManager, systemTask->nimble().alertService(), motorController, *systemTask, Screens::Notifications::Modes::Preview);
currentScreen = std::make_unique<Screens::Notifications>(this,
notificationManager,
systemTask->nimble().alertService(),
motorController,
*systemTask,
Screens::Notifications::Modes::Preview);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break;
case Apps::Timer:
@ -366,8 +375,12 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
// Settings
case Apps::QuickSettings:
currentScreen = std::make_unique<Screens::QuickSettings>(
this, batteryController, dateTimeController, brightnessController, motorController, settingsController);
currentScreen = std::make_unique<Screens::QuickSettings>(this,
batteryController,
dateTimeController,
brightnessController,
motorController,
settingsController);
ReturnApp(Apps::Clock, FullRefreshDirections::LeftAnim, TouchEvents::SwipeLeft);
break;
case Apps::Settings:
@ -419,8 +432,14 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
case Apps::SysInfo:
currentScreen = std::make_unique<Screens::SystemInfo>(
this, dateTimeController, batteryController, brightnessController, bleController, watchdog, motionController, touchPanel);
currentScreen = std::make_unique<Screens::SystemInfo>(this,
dateTimeController,
batteryController,
brightnessController,
bleController,
watchdog,
motionController,
touchPanel);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
case Apps::FlashLight:
@ -458,6 +477,10 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
case Apps::Steps:
currentScreen = std::make_unique<Screens::Steps>(this, motionController, settingsController);
break;
case Apps::Agenda:
currentScreen = std::make_unique<Screens::Agenda>(this, systemTask->nimble().agenda(), dateTimeController);
break;
}
currentApp = app;
}
@ -495,6 +518,9 @@ void DisplayApp::SetFullRefresh(DisplayApp::FullRefreshDirections direction) {
case DisplayApp::FullRefreshDirections::RightAnim:
lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::RightAnim);
break;
// case DisplayApp::FullRefreshDirections::None:
// lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::None);
// break;
default:
break;
}

View File

@ -88,7 +88,7 @@ namespace Pinetime {
Pinetime::Controllers::MotionController& motionController;
Pinetime::Controllers::TimerController& timerController;
Pinetime::Controllers::AlarmController& alarmController;
Pinetime::Controllers::BrightnessController &brightnessController;
Pinetime::Controllers::BrightnessController& brightnessController;
Pinetime::Controllers::TouchHandler& touchHandler;
Pinetime::Controllers::FirmwareValidator validator;

View File

@ -26,7 +26,6 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::TouchHandler& touchHandler)
: lcd {lcd}, bleController {bleController} {
}
void DisplayApp::Start() {
@ -121,5 +120,4 @@ void DisplayApp::PushMessage(Display::Messages msg) {
}
void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) {
}

View File

@ -61,7 +61,9 @@ namespace Pinetime {
Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::TouchHandler& touchHandler);
void Start();
void Start(Pinetime::System::BootErrors){ Start(); };
void Start(Pinetime::System::BootErrors) {
Start();
};
void PushMessage(Pinetime::Applications::Display::Messages msg);
void Register(Pinetime::System::SystemTask* systemTask);

View File

@ -20,7 +20,6 @@ namespace Pinetime {
LittleVgl& operator=(LittleVgl&&) = delete;
void Init() {
}
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p) {
@ -33,7 +32,6 @@ namespace Pinetime {
void SetNewTapEvent(uint16_t x, uint16_t y) {
}
void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) {
}
};
}

View File

@ -94,8 +94,8 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) {
uint16_t y1, y2, width, height = 0;
ulTaskNotifyTake(pdTRUE, 200);
// NOtification is still needed (even if there is a mutex on SPI) because of the DataCommand pin
// which cannot be set/clear during a transfert.
// Notification is still needed (even if there is a mutex on SPI) because of the DataCommand pin
// which cannot be set/clear during a transfer.
if ((scrollDirection == LittleVgl::FullRefreshDirections::Down) && (area->y2 == visibleNbLines - 1)) {
writeOffset = ((writeOffset + totalNbLines) - visibleNbLines) % totalNbLines;
@ -195,8 +195,13 @@ bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
void LittleVgl::InitTheme() {
lv_theme_t* th = lv_pinetime_theme_init(
LV_COLOR_WHITE, LV_COLOR_SILVER, 0, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20);
lv_theme_t* th = lv_pinetime_theme_init(LV_COLOR_WHITE,
LV_COLOR_SILVER,
0,
&jetbrains_mono_bold_20,
&jetbrains_mono_bold_20,
&jetbrains_mono_bold_20,
&jetbrains_mono_bold_20);
lv_theme_set_act(th);
}

View File

@ -1,19 +1,35 @@
cmake_minimum_required(VERSION 3.10)
set(FONTS jetbrains_mono_42 jetbrains_mono_76 jetbrains_mono_bold_20
jetbrains_mono_extrabold_compressed lv_font_navi_80 lv_font_sys_48
open_sans_light)
find_program(LV_FONT_CONV "lv_font_conv" NO_CACHE REQUIRED)
find_program(LV_FONT_CONV "lv_font_conv" NO_CACHE REQUIRED
HINTS "${CMAKE_SOURCE_DIR}/node_modules/.bin")
message(STATUS "Using ${LV_FONT_CONV} to generate font files")
configure_file(${CMAKE_CURRENT_LIST_DIR}/jetbrains_mono_bold_20.c_zero.patch
displayapp/fonts/jetbrains_mono_bold_20.c_zero.patch COPYONLY)
foreach(FONT ${FONTS})
set_source_files_properties(displayapp/fonts/${FONT}.c
PROPERTIES GENERATED TRUE)
${CMAKE_CURRENT_BINARY_DIR}/jetbrains_mono_bold_20.c_zero.patch COPYONLY)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
# FindPython3 module introduces with CMake 3.12
# https://cmake.org/cmake/help/latest/module/FindPython3.html
find_package(Python3 REQUIRED)
else()
set(Python3_EXECUTABLE "python")
endif()
add_custom_command(OUTPUT displayapp/fonts/${FONT}.c
COMMAND python ${CMAKE_CURRENT_LIST_DIR}/generate.py
-f ${FONT} ${CMAKE_CURRENT_LIST_DIR}/fonts.json
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/fonts.json
WORKING_DIRECTORY displayapp/fonts
)
# create static library building fonts
add_library(infinitime_fonts STATIC)
# add include directory to lvgl headers needed to compile the font files on its own
target_include_directories(infinitime_fonts PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../libs")
foreach(FONT ${FONTS})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${FONT}.c
COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/generate.py
--lv-font-conv "${LV_FONT_CONV}"
--font ${FONT} ${CMAKE_CURRENT_SOURCE_DIR}/fonts.json
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/fonts.json
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(infinitime_fonts_${FONT}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${FONT}.c
)
target_sources(infinitime_fonts PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${FONT}.c")
add_dependencies(infinitime_fonts infinitime_fonts_${FONT})
endforeach()

Binary file not shown.

View File

@ -7,7 +7,7 @@
},
{
"file": "FontAwesome5-Solid+Brands+Regular.woff",
"range": "0xf293, 0xf294, 0xf244, 0xf240, 0xf242, 0xf243, 0xf241, 0xf54b, 0xf21e, 0xf1e6, 0xf54b, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf069, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf029, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf201, 0xf06e, 0xf015"
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf201, 0xf06e, 0xf015"
}
],
"bpp": 1,
@ -18,7 +18,7 @@
"sources": [
{
"file": "JetBrainsMono-Regular.ttf",
"range": "0x25, 0x30-0x3a"
"range": "0x25, 0x2b, 0x2d, 0x30-0x3a"
}
],
"bpp": 1,
@ -27,7 +27,7 @@
"jetbrains_mono_76": {
"sources": [
{
"file": "JetBrainsMono-Regular.ttf",
"file": "JetBrainsMono-Light.ttf",
"range": "0x25, 0x2D, 0x2F, 0x30-0x3a"
}
],

View File

@ -18,8 +18,8 @@ class Source(object):
self.symbols = d.get('symbols')
def gen_lvconv_line(dest: str, size: int, bpp: int, sources: typing.List[Source], compress:bool=False):
args = ['lv_font_conv', '--size', str(size), '--output', dest, '--bpp', str(bpp), '--format', 'lvgl']
def gen_lvconv_line(lv_font_conv: str, dest: str, size: int, bpp: int, sources: typing.List[Source], compress:bool=False):
args = [lv_font_conv, '--size', str(size), '--output', dest, '--bpp', str(bpp), '--format', 'lvgl']
if not compress:
args.append('--no-compress')
for source in sources:
@ -35,14 +35,15 @@ def main():
ap = argparse.ArgumentParser(description='auto generate LVGL font files from fonts')
ap.add_argument('config', type=str, help='config file to use')
ap.add_argument('-f', '--font', type=str, action='append', help='Choose specific fonts to generate (default: all)', default=[])
ap.add_argument('--lv-font-conv', type=str, help='Path to "lv_font_conf" executable', default="lv_font_conv")
args = ap.parse_args()
if not shutil.which('lv_font_conv'):
sys.exit(f'Missing lv_font_conv. (make sure it is installed and in PATH)')
if not shutil.which(args.lv_font_conv):
sys.exit(f"Missing lv_font_conv. Make sure it's findable (in PATH) or specify it manually")
if not os.path.exists(args.config):
sys.exit(f'Error: the config file {args.config} does not exist.')
if not os.access(args.config, os.R_OK):
sys.exit(f'Error: the config file {args.config} is not accessable (permissions?).')
sys.exit(f'Error: the config file {args.config} is not accessible (permissions?).')
with open(args.config, 'r') as fd:
data = json.load(fd)
@ -62,7 +63,7 @@ def main():
sources = font.pop('sources')
patches = font.pop('patches') if 'patches' in font else []
font['sources'] = [Source(thing) for thing in sources]
line = gen_lvconv_line(f'{name}.c', **font)
line = gen_lvconv_line(args.lv_font_conv, f'{name}.c', **font)
subprocess.check_call(line)
if patches:
for patch in patches:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -1,56 +0,0 @@
#include "lvgl/lvgl.h"
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif
#ifndef LV_ATTRIBUTE_IMG_CK_OS_BT_CONNECTED
#define LV_ATTRIBUTE_IMG_CK_OS_BT_CONNECTED
#endif
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_IMG_CK_OS_BT_CONNECTED uint8_t ck_os_bt_connected_map[] = {
0x6c, 0xfe, 0x6c, 0xff, /*Color of index 0*/
0xe4, 0xe6, 0xe4, 0xff, /*Color of index 1*/
0x00, 0x0e, 0x00, 0x00,
0x00, 0x0f, 0x00, 0x00,
0x00, 0x0f, 0x80, 0x00,
0x00, 0x0f, 0xc0, 0x00,
0x00, 0x0f, 0xe0, 0x00,
0x00, 0x0f, 0xf0, 0x00,
0x03, 0x8f, 0xf8, 0x00,
0x03, 0xcf, 0x7c, 0x00,
0x03, 0xef, 0x3e, 0x00,
0x01, 0xff, 0x1f, 0x00,
0x00, 0xff, 0x1f, 0x00,
0x00, 0x7f, 0x3e, 0x00,
0x00, 0x3f, 0x7c, 0x00,
0x00, 0x1f, 0xf8, 0x00,
0x00, 0x0f, 0xf0, 0x00,
0x00, 0x0f, 0xe0, 0x00,
0x00, 0x0f, 0xe0, 0x00,
0x00, 0x0f, 0xf0, 0x00,
0x00, 0x1f, 0xf8, 0x00,
0x00, 0x3f, 0x7c, 0x00,
0x00, 0x7f, 0x3e, 0x00,
0x00, 0xff, 0x1f, 0x00,
0x01, 0xff, 0x1f, 0x00,
0x03, 0xef, 0x3e, 0x00,
0x03, 0xcf, 0x7c, 0x00,
0x03, 0x8f, 0xf8, 0x00,
0x00, 0x0f, 0xf0, 0x00,
0x00, 0x0f, 0xe0, 0x00,
0x00, 0x0f, 0xc0, 0x00,
0x00, 0x0f, 0x80, 0x00,
0x00, 0x0f, 0x00, 0x00,
0x00, 0x0e, 0x00, 0x00,
};
const lv_img_dsc_t ck_os_bt_connected = {
.header.always_zero = 0,
.header.w = 32,
.header.h = 32,
.data_size = 136,
.header.cf = LV_IMG_CF_INDEXED_1BIT,
.data = ck_os_bt_connected_map,
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -1,58 +0,0 @@
#include "lvgl/lvgl.h"
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif
#ifndef LV_ATTRIBUTE_IMG_CK_OS_BT_DISCONNECTED
#define LV_ATTRIBUTE_IMG_CK_OS_BT_DISCONNECTED
#endif
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_IMG_CK_OS_BT_DISCONNECTED uint8_t ck_os_bt_disconnected_map[] = {
0x6c, 0xfe, 0x6c, 0xff, /*Color of index 0*/
0xc4, 0xc2, 0xc4, 0xff, /*Color of index 1*/
0xe4, 0xe6, 0xe4, 0xff, /*Color of index 2*/
0xff, 0xff, 0xff, 0xff, /*Color of index 3*/
0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00,
0x0a, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x00,
0x2a, 0x80, 0x00, 0x55, 0x40, 0x00, 0x00, 0x00,
0x2a, 0xa0, 0x00, 0x55, 0x50, 0x00, 0x00, 0x00,
0x0a, 0xa8, 0x00, 0x55, 0x54, 0x00, 0x00, 0x00,
0x02, 0xaa, 0x00, 0x55, 0x55, 0x00, 0x00, 0x00,
0x00, 0xaa, 0x80, 0x55, 0x55, 0x40, 0x00, 0x00,
0x00, 0x2a, 0xa0, 0x55, 0x15, 0x50, 0x00, 0x00,
0x00, 0x0a, 0xa8, 0x15, 0x05, 0x54, 0x00, 0x00,
0x00, 0x02, 0xaa, 0x05, 0x01, 0x55, 0x00, 0x00,
0x00, 0x00, 0xaa, 0x81, 0x01, 0x55, 0x00, 0x00,
0x00, 0x00, 0x2a, 0xa0, 0x05, 0x54, 0x00, 0x00,
0x00, 0x00, 0x0a, 0xa8, 0x15, 0x50, 0x00, 0x00,
0x00, 0x00, 0x02, 0xaa, 0x05, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0xaa, 0x81, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x2a, 0xa0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0a, 0xa8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x42, 0xaa, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x50, 0xaa, 0x80, 0x00, 0x00,
0x00, 0x00, 0x05, 0x54, 0x2a, 0xa0, 0x00, 0x00,
0x00, 0x00, 0x15, 0x55, 0x0a, 0xa8, 0x00, 0x00,
0x00, 0x00, 0x55, 0x55, 0x02, 0xaa, 0x00, 0x00,
0x00, 0x01, 0x55, 0x55, 0x00, 0xaa, 0x80, 0x00,
0x00, 0x05, 0x54, 0x55, 0x04, 0x2a, 0xa0, 0x00,
0x00, 0x05, 0x50, 0x55, 0x15, 0x0a, 0xa8, 0x00,
0x00, 0x05, 0x40, 0x55, 0x55, 0x42, 0xaa, 0x00,
0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0xaa, 0x80,
0x00, 0x00, 0x00, 0x55, 0x54, 0x00, 0x2a, 0xa0,
0x00, 0x00, 0x00, 0x55, 0x50, 0x00, 0x0a, 0xa8,
0x00, 0x00, 0x00, 0x55, 0x40, 0x00, 0x02, 0xa8,
0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0xa0,
0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00,
};
const lv_img_dsc_t ck_os_bt_disconnected = {
.header.always_zero = 0,
.header.w = 32,
.header.h = 32,
.data_size = 272,
.header.cf = LV_IMG_CF_INDEXED_2BIT,
.data = ck_os_bt_disconnected_map,
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,147 @@
#include "displayapp/screens/Agenda.h"
#include <date/date.h>
#include <nrf_log.h>
using Pinetime::Applications::TouchEvents;
using namespace Pinetime::Applications::Screens;
using namespace Pinetime::Controllers;
Agenda::Agenda(DisplayApp* app, AgendaService& agenda, Controllers::DateTime& dateTimeController) : Screen(app), agendaSvc(agenda), dateTimeController(dateTimeController) {
lv_obj_t* alignNextTo = lv_scr_act();
for (uint8_t i = 0; i < AGENDA_ONSCREEN; ++i) {
lv_obj_t* agendaItem = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(agendaItem, ".\n.");
//lv_label_set_align(agendaItem, LV_LABEL_ALIGN_CENTER);
if (i != 0) {
lv_obj_align(agendaItem, alignNextTo, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
}
agendaItems[i] = agendaItem;
alignNextTo = agendaItem;
}
pagingOffset = 0;
using namespace date;
using namespace std::chrono;
std::chrono::system_clock::time_point nowTp = dateTimeController.CurrentDateTime();
//sys_seconds now = nowTp;
// Find first entry that is just after the current time (- 5 min)!
for (uint8_t i = 0; i < AgendaService::AGENDA_CAPACITY; ++i) {
uint32_t time = agendaSvc.getAgendaTime(i);
sys_seconds timestamp = sys_days{1970_y/1/1} + seconds{time};
if (timestamp > nowTp - minutes{5}) {
uint8_t positionInPage = i % AGENDA_ONSCREEN;
pagingOffset = i - positionInPage;
break;
}
}
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
Relabel();
//Refresh();
}
bool Agenda::OnTouchEvent(TouchEvents event) {
// NRF_LOG_INFO("touch");
switch (event) {
case TouchEvents::SwipeDown:
if (pagingOffset >= AGENDA_ONSCREEN) {
// NRF_LOG_INFO("swdn");
pagingOffset -= AGENDA_ONSCREEN;
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down);
Relabel();
}
break;
case TouchEvents::SwipeUp:
if (pagingOffset + 2*AGENDA_ONSCREEN <= AgendaService::AGENDA_CAPACITY) {
// NRF_LOG_INFO("swup");
pagingOffset += AGENDA_ONSCREEN;
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up);
Relabel();
}
break;
default:
break;
}
return true;
}
Agenda::~Agenda() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
void Agenda::Relabel() {
using namespace date;
using namespace std::chrono;
std::chrono::system_clock::time_point now = dateTimeController.CurrentDateTime();
auto todayDate = floor<date::days>(now);
//auto nowTimePart = make_time(now - todayDate);
//auto todayYmd = year_month_day(todayDate);
// NRF_LOG_INFO("date CURRENT %d-%u-%u %ldh%ldh%ld", (int) todayYmd.year(), (unsigned) todayYmd.month(), (unsigned) todayYmd.day(), nowTimePart.hours().count(), nowTimePart.minutes().count(), nowTimePart.seconds().count());
//std::cout << todayDate << ' ' << nowTimePart << '\n';
for (uint8_t i = 0; i < AGENDA_ONSCREEN; ++i) {
uint8_t itemIdx = i + pagingOffset;
uint32_t time = agendaSvc.getAgendaTime(itemIdx);
lv_obj_t* agendaItem = agendaItems[i];
if (time == 0) {
lv_label_set_text_static(agendaItem, "--h--\n .....");
lv_obj_set_style_local_text_color(agendaItem, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x332222));
} else {
sys_seconds timestamp = sys_days{1970_y/1/1} + seconds{time};
//auto timestamp = std::chrono::system_clock::time_point{time * 1s};
sys_days agendaDate = floor<days>(timestamp);
time_of_day<seconds> agendaTimePart = make_time(timestamp - agendaDate);
year_month_day ymd = year_month_day(agendaDate);
//std::cout << agendaDate << ' ' << agendaTimePart << '\n';
/*std::time_t result = std::time(nullptr);
std::time_t result = std::time(nullptr);
std::chrono::time_point = */;
// NRF_LOG_INFO("IDX %u", itemIdx);
// NRF_LOG_INFO("unix %u", time);
// NRF_LOG_INFO("date %d-%u-%u ", (int) ymd.year(), (unsigned) ymd.month(), (unsigned) ymd.day());
// NRF_LOG_INFO("time %ldh%ldm%ld", agendaTimePart.hours().count(), agendaTimePart.minutes().count(), agendaTimePart.seconds().count());
// NRF_LOG_INFO("item %s", agendaSvc.getAgendaPiece(itemIdx).data());
if (agendaDate == todayDate) {
lv_label_set_text_fmt(agendaItem, "%02lldh%02lld\n %s", agendaTimePart.hours().count(), agendaTimePart.minutes().count(), agendaSvc.getAgendaPiece(itemIdx).data());
} else {
lv_label_set_text_fmt(agendaItem, "%04d-%02u-%02u %02lldh%02lld\n %s", (int) ymd.year(), (unsigned) ymd.month(), (unsigned) ymd.day(), agendaTimePart.hours().count(), agendaTimePart.minutes().count(), agendaSvc.getAgendaPiece(itemIdx).data());
}
if (timestamp + 30min < now) {
lv_obj_set_style_local_text_color(agendaItem, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x334433));
} else if (timestamp + 5min < now) {
lv_obj_set_style_local_text_color(agendaItem, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
} else if (timestamp - 5min < now && now < timestamp + 5min) {
lv_obj_set_style_local_text_color(agendaItem, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFA500));
} else if (now + 5min < timestamp) {
lv_obj_set_style_local_text_color(agendaItem, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFF00));
} else if (now + 30min < timestamp) {
lv_obj_set_style_local_text_color(agendaItem, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF));
}
}
}
}
/* Refresh seems to refer to re-render, but changing any LVGL widgets triggers a refresh again! */
void Agenda::Refresh() {
//NRF_LOG_INFO("refr");
}

View File

@ -0,0 +1,40 @@
#pragma once
#include "displayapp/screens/Screen.h"
#include "components/ble/AgendaService.h"
#include "displayapp/DisplayApp.h"
#include "components/datetime/DateTimeController.h"
#include <lvgl/lvgl.h>
namespace Pinetime {
namespace Controllers {
class DateTime;
}
namespace Applications {
namespace Screens {
class Agenda : public Screen {
public:
static const uint8_t AGENDA_ONSCREEN = 5;
Agenda(DisplayApp* app, Pinetime::Controllers::AgendaService& agendaSvc, Pinetime::Controllers::DateTime &dateTimeController);
~Agenda() override;
bool OnTouchEvent(TouchEvents event) override;
void Refresh() override;
void Relabel();
private:
Pinetime::Controllers::AgendaService& agendaSvc;
Controllers::DateTime& dateTimeController;
lv_obj_t* agendaItems[AGENDA_ONSCREEN];
uint8_t pagingOffset;
lv_task_t* taskRefresh;
};
}
}
}

View File

@ -300,8 +300,12 @@ void Alarm::ShowInfo() {
auto minToAlarm = (timeToAlarm % 3600) / 60;
auto secToAlarm = timeToAlarm % 60;
lv_label_set_text_fmt(
txtMessage, "Time to\nalarm:\n%2lu Days\n%2lu Hours\n%2lu Minutes\n%2lu Seconds", daysToAlarm, hrsToAlarm, minToAlarm, secToAlarm);
lv_label_set_text_fmt(txtMessage,
"Time to\nalarm:\n%2lu Days\n%2lu Hours\n%2lu Minutes\n%2lu Seconds",
daysToAlarm,
hrsToAlarm,
minToAlarm,
secToAlarm);
} else {
lv_label_set_text_static(txtMessage, "Alarm\nis not\nset.");
}

View File

@ -45,8 +45,8 @@ namespace Pinetime {
Controllers::Settings& settingsController;
System::SystemTask& systemTask;
lv_obj_t *time, *lblampm, *btnStop, *txtStop, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp,
*txtMinDown, *txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo, *enableSwitch;
lv_obj_t *time, *lblampm, *btnStop, *txtStop, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp, *txtMinDown,
*txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo, *enableSwitch;
lv_obj_t* txtMessage = nullptr;
lv_obj_t* btnMessage = nullptr;
lv_task_t* taskStopAlarm = nullptr;

View File

@ -25,6 +25,9 @@ ApplicationList::ApplicationList(Pinetime::Applications::DisplayApp* app,
[this]() -> std::unique_ptr<Screen> {
return CreateScreen2();
},
[this]() -> std::unique_ptr<Screen> {
return CreateScreen3();
},
//[this]() -> std::unique_ptr<Screen> { return CreateScreen3(); }
},
Screens::ScreenListModes::UpDown} {
@ -41,14 +44,14 @@ bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
std::unique_ptr<Screen> ApplicationList::CreateScreen1() {
std::array<Screens::Tile::Applications, 6> applications {{
{Symbols::stopWatch, Apps::StopWatch},
{Symbols::music, Apps::Music},
{Symbols::map, Apps::Navigation},
{Symbols::clock, Apps::Alarm},
{Symbols::hourGlass, Apps::Timer},
{Symbols::shoe, Apps::Steps},
{Symbols::heartBeat, Apps::HeartRate},
{Symbols::hourGlass, Apps::Timer},
{Symbols::music, Apps::Music},
}};
return std::make_unique<Screens::Tile>(0, 2, app, settingsController, batteryController, dateTimeController, applications);
return std::make_unique<Screens::Tile>(0, 3, app, settingsController, batteryController, dateTimeController, applications);
}
std::unique_ptr<Screen> ApplicationList::CreateScreen2() {
@ -58,10 +61,23 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen2() {
{"2", Apps::Twos},
{Symbols::chartLine, Apps::Motion},
{Symbols::drum, Apps::Metronome},
{Symbols::clock, Apps::Alarm},
{Symbols::map, Apps::Navigation},
}};
return std::make_unique<Screens::Tile>(1, 2, app, settingsController, batteryController, dateTimeController, applications);
return std::make_unique<Screens::Tile>(1, 3, app, settingsController, batteryController, dateTimeController, applications);
}
std::unique_ptr<Screen> ApplicationList::CreateScreen3() {
std::array<Screens::Tile::Applications, 6> applications {{
{"A", Apps::Agenda},
{".", Apps::Paddle},
{".", Apps::Twos},
{".", Apps::Motion},
{".", Apps::Metronome},
{".", Apps::Navigation},
}};
return std::make_unique<Screens::Tile>(2, 3, app, settingsController, batteryController, dateTimeController, applications);
}
/*std::unique_ptr<Screen> ApplicationList::CreateScreen3() {

View File

@ -25,10 +25,10 @@ namespace Pinetime {
Pinetime::Controllers::Battery& batteryController;
Controllers::DateTime& dateTimeController;
ScreenList<2> screens;
ScreenList<3> screens;
std::unique_ptr<Screen> CreateScreen1();
std::unique_ptr<Screen> CreateScreen2();
// std::unique_ptr<Screen> CreateScreen3();
std::unique_ptr<Screen> CreateScreen3();
};
}
}

View File

@ -15,6 +15,7 @@ namespace Pinetime {
static const char* GetUnknownIcon();
static const char* GetPlugIcon(bool isCharging);
private:
lv_obj_t* batteryImg;
lv_obj_t* batteryJuice;

View File

@ -1,103 +0,0 @@
#include "displayapp/screens/Brightness.h"
#include <lvgl/lvgl.h>
using namespace Pinetime::Applications::Screens;
void slider_event_cb(lv_obj_t* slider, lv_event_t event) {
if (event == LV_EVENT_VALUE_CHANGED) {
auto* brightnessSlider = static_cast<Brightness*>(slider->user_data);
brightnessSlider->OnValueChanged();
}
}
Brightness::Brightness(Pinetime::Applications::DisplayApp* app, Controllers::BrightnessController& brightness)
: Screen(app), brightness {brightness} {
slider = lv_slider_create(lv_scr_act(), nullptr);
lv_obj_set_user_data(slider, this);
lv_obj_set_width(slider, LV_DPI * 2);
lv_obj_align(slider, nullptr, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_event_cb(slider, slider_event_cb);
lv_slider_set_range(slider, 0, 2);
lv_slider_set_value(slider, LevelToInt(brightness.Level()), LV_ANIM_OFF);
slider_label = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(slider_label, LevelToString(brightness.Level()));
lv_obj_set_auto_realign(slider_label, true);
lv_obj_align(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 30);
}
Brightness::~Brightness() {
lv_obj_clean(lv_scr_act());
}
const char* Brightness::LevelToString(Pinetime::Controllers::BrightnessController::Levels level) {
switch (level) {
case Pinetime::Controllers::BrightnessController::Levels::Off:
return "Off";
case Pinetime::Controllers::BrightnessController::Levels::Low:
return "Low";
case Pinetime::Controllers::BrightnessController::Levels::Medium:
return "Medium";
case Pinetime::Controllers::BrightnessController::Levels::High:
return "High";
default:
return "???";
}
}
void Brightness::OnValueChanged() {
SetValue(lv_slider_get_value(slider));
}
void Brightness::SetValue(uint8_t value) {
switch (value) {
case 0:
brightness.Set(Controllers::BrightnessController::Levels::Low);
break;
case 1:
brightness.Set(Controllers::BrightnessController::Levels::Medium);
break;
case 2:
brightness.Set(Controllers::BrightnessController::Levels::High);
break;
}
lv_label_set_text(slider_label, LevelToString(brightness.Level()));
}
uint8_t Brightness::LevelToInt(Pinetime::Controllers::BrightnessController::Levels level) {
switch (level) {
case Pinetime::Controllers::BrightnessController::Levels::Off:
return 0;
case Pinetime::Controllers::BrightnessController::Levels::Low:
return 0;
case Pinetime::Controllers::BrightnessController::Levels::Medium:
return 1;
case Pinetime::Controllers::BrightnessController::Levels::High:
return 2;
default:
return 0;
}
}
bool Brightness::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch (event) {
case TouchEvents::SwipeLeft:
brightness.Lower();
if (brightness.Level() == Pinetime::Controllers::BrightnessController::Levels::Off) {
brightness.Set(Controllers::BrightnessController::Levels::Low);
}
SetValue();
return true;
case TouchEvents::SwipeRight:
brightness.Higher();
SetValue();
return true;
default:
return false;
}
}
void Brightness::SetValue() {
lv_slider_set_value(slider, LevelToInt(brightness.Level()), LV_ANIM_OFF);
lv_label_set_text(slider_label, LevelToString(brightness.Level()));
}

View File

@ -1,33 +0,0 @@
#pragma once
#include <lvgl/src/lv_core/lv_obj.h>
#include <cstdint>
#include "displayapp/screens/Screen.h"
#include "components/brightness/BrightnessController.h"
namespace Pinetime {
namespace Applications {
namespace Screens {
class Brightness : public Screen {
public:
Brightness(DisplayApp* app, Controllers::BrightnessController& brightness);
~Brightness() override;
bool OnTouchEvent(TouchEvents event) override;
void OnValueChanged();
private:
Controllers::BrightnessController& brightness;
lv_obj_t* slider_label;
lv_obj_t* slider;
const char* LevelToString(Controllers::BrightnessController::Levels level);
uint8_t LevelToInt(Controllers::BrightnessController::Levels level);
void SetValue(uint8_t value);
void SetValue();
};
}
}
}

View File

@ -22,7 +22,8 @@ Clock::Clock(DisplayApp* app,
Controllers::NotificationManager& notificatioManager,
Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController)
Controllers::MotionController& motionController,
Controllers::AgendaService& agendaService)
: Screen(app),
dateTimeController {dateTimeController},
batteryController {batteryController},
@ -31,6 +32,7 @@ Clock::Clock(DisplayApp* app,
settingsController {settingsController},
heartRateController {heartRateController},
motionController {motionController},
agendaService {agendaService},
screen {[this, &settingsController]() {
switch (settingsController.GetClockFace()) {
case 0:
@ -71,17 +73,27 @@ std::unique_ptr<Screen> Clock::WatchFaceDigitalScreen() {
notificatioManager,
settingsController,
heartRateController,
motionController);
motionController,
agendaService);
}
std::unique_ptr<Screen> Clock::WatchFaceAnalogScreen() {
return std::make_unique<Screens::WatchFaceAnalog>(
app, dateTimeController, batteryController, bleController, notificatioManager, settingsController);
return std::make_unique<Screens::WatchFaceAnalog>(app,
dateTimeController,
batteryController,
bleController,
notificatioManager,
settingsController);
}
std::unique_ptr<Screen> Clock::WatchFacePineTimeStyleScreen() {
return std::make_unique<Screens::WatchFacePineTimeStyle>(
app, dateTimeController, batteryController, bleController, notificatioManager, settingsController, motionController);
return std::make_unique<Screens::WatchFacePineTimeStyle>(app,
dateTimeController,
batteryController,
bleController,
notificatioManager,
settingsController,
motionController);
}
std::unique_ptr<Screen> Clock::WatchFaceTerminalScreen() {

View File

@ -15,6 +15,7 @@ namespace Pinetime {
class Ble;
class NotificationManager;
class MotionController;
class AgendaService;
}
namespace Applications {
@ -28,7 +29,8 @@ namespace Pinetime {
Controllers::NotificationManager& notificatioManager,
Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController);
Controllers::MotionController& motionController,
Controllers::AgendaService& agendaService);
~Clock() override;
bool OnTouchEvent(TouchEvents event) override;
@ -42,6 +44,7 @@ namespace Pinetime {
Controllers::Settings& settingsController;
Controllers::HeartRateController& heartRateController;
Controllers::MotionController& motionController;
Controllers::AgendaService& agendaService;
std::unique_ptr<Screen> screen;
std::unique_ptr<Screen> WatchFaceDigitalScreen();

View File

@ -9,8 +9,7 @@ namespace {
}
}
Error::Error(Pinetime::Applications::DisplayApp* app, System::BootErrors error)
: Screen(app) {
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);

View File

@ -13,6 +13,7 @@ namespace Pinetime {
~Error() override;
void ButtonEventHandler();
private:
lv_obj_t* btnOk;
};

View File

@ -34,7 +34,8 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app,
if (validator.IsValidated())
lv_label_set_text_static(labelIsValidated, "You have already\n#00ff00 validated# this firmware#");
else {
lv_label_set_text_static(labelIsValidated, "Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version.");
lv_label_set_text_static(labelIsValidated,
"Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version.");
buttonValidate = lv_btn_create(lv_scr_act(), nullptr);
buttonValidate->user_data = this;

View File

@ -28,7 +28,7 @@ FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
lv_label_set_text_static(flashLight, Symbols::highlight);
lv_obj_align(flashLight, nullptr, LV_ALIGN_CENTER, 0, 0);
for (auto & i : indicators) {
for (auto& i : indicators) {
i = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_size(i, 15, 10);
lv_obj_set_style_local_border_width(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 2);
@ -64,7 +64,7 @@ void FlashLight::SetColors() {
if (isOn) {
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
for (auto & i : indicators) {
for (auto& i : indicators) {
lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DISABLED, LV_COLOR_WHITE);
lv_obj_set_style_local_border_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
@ -72,7 +72,7 @@ void FlashLight::SetColors() {
} else {
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
for (auto & i : indicators) {
for (auto& i : indicators) {
lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DISABLED, LV_COLOR_BLACK);
lv_obj_set_style_local_border_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);

View File

@ -1,36 +0,0 @@
#include "displayapp/screens/Meter.h"
#include <lvgl/lvgl.h>
#include "displayapp/DisplayApp.h"
using namespace Pinetime::Applications::Screens;
Meter::Meter(Pinetime::Applications::DisplayApp* app) : Screen(app) {
/*Create a line meter */
lmeter = lv_linemeter_create(lv_scr_act(), nullptr);
lv_linemeter_set_range(lmeter, 0, 60); /*Set the range*/
lv_linemeter_set_value(lmeter, value); /*Set the current value*/
lv_linemeter_set_angle_offset(lmeter, 180);
lv_linemeter_set_scale(lmeter, 360, 60); /*Set the angle and number of lines*/
lv_obj_set_style_local_scale_end_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(255, 0, 0));
lv_obj_set_style_local_scale_grad_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(160, 0, 0));
lv_obj_set_style_local_line_width(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 2);
lv_obj_set_style_local_line_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_obj_set_size(lmeter, 200, 200);
lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Meter::~Meter() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
void Meter::Refresh() {
lv_linemeter_set_value(lmeter, value++); /*Set the current value*/
if (value >= 60)
value = 0;
}

View File

@ -1,29 +0,0 @@
#pragma once
#include <cstdint>
#include "displayapp/screens/Screen.h"
#include <lvgl/src/lv_core/lv_style.h>
#include <lvgl/src/lv_core/lv_obj.h>
namespace Pinetime {
namespace Applications {
namespace Screens {
class Meter : public Screen {
public:
Meter(DisplayApp* app);
~Meter() override;
void Refresh() override;
private:
lv_style_t style_lmeter;
lv_obj_t* lmeter;
uint32_t value = 0;
lv_task_t* taskRefresh;
};
}
}
}

View File

@ -30,7 +30,7 @@ namespace Pinetime {
lv_obj_t *bpmArc, *bpmTap, *bpmValue;
lv_obj_t *bpbDropdown, *currentBpbText;
lv_obj_t *playPause;
lv_obj_t* playPause;
lv_task_t* taskRefresh;
};

View File

@ -20,9 +20,9 @@
#include <cstdint>
#include "displayapp/DisplayApp.h"
#include "components/ble/MusicService.h"
#include "displayapp/icons/music/disc.cpp"
#include "displayapp/icons/music/disc_f_1.cpp"
#include "displayapp/icons/music/disc_f_2.cpp"
#include "displayapp/icons/music/disc.c"
#include "displayapp/icons/music/disc_f_1.c"
#include "displayapp/icons/music/disc_f_2.c"
using namespace Pinetime::Applications::Screens;

View File

@ -198,12 +198,12 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_t* alert_type = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
if(title == nullptr) {
if (title == nullptr) {
lv_label_set_text_static(alert_type, "Notification");
} else {
// copy title to label and replace newlines with spaces
lv_label_set_text(alert_type, title);
char *pchar = strchr(lv_label_get_text(alert_type), '\n');
char* pchar = strchr(lv_label_get_text(alert_type), '\n');
while (pchar != nullptr) {
*pchar = ' ';
pchar = strchr(pchar + 1, '\n');

View File

@ -53,7 +53,7 @@ void Paddle::Refresh() {
if (ballX >= LV_HOR_RES - ballSize - 1) {
dx *= -1;
dy += rand() % 3 - 1; // add a little randomization in wall bounce direction, one of [-1, 0, 1]
if (dy > 5) { // limit dy to be in range [-5 to 5]
if (dy > 5) { // limit dy to be in range [-5 to 5]
dy = 5;
}
if (dy < -5) {

View File

@ -14,4 +14,3 @@ PassKey::PassKey(Pinetime::Applications::DisplayApp* app, uint32_t key) : Screen
PassKey::~PassKey() {
lv_obj_clean(lv_scr_act());
}

View File

@ -35,7 +35,7 @@ namespace Pinetime {
private:
T value {}; // NSDMI - default initialise type
bool isUpdated {true}; // NSDMI - use brace initilisation
bool isUpdated {true}; // NSDMI - use brace initialisation
};
class Screen {

View File

@ -17,8 +17,12 @@ namespace Pinetime {
uint8_t initScreen,
const std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens,
ScreenListModes mode)
: Screen(app), initScreen {initScreen}, screens {std::move(screens)}, mode {mode}, screenIndex{initScreen}, current {this->screens[initScreen]()} {
: Screen(app),
initScreen {initScreen},
screens {std::move(screens)},
mode {mode},
screenIndex {initScreen},
current {this->screens[initScreen]()} {
}
ScreenList(const ScreenList&) = delete;

View File

@ -166,8 +166,12 @@ void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
lapBuffer.addLaps(currentTimeSeparated);
lapNr++;
if (lapBuffer[1]) {
lv_label_set_text_fmt(
lapOneText, "#%2d %2d:%02d.%02d", (lapNr - 1), lapBuffer[1]->mins, lapBuffer[1]->secs, lapBuffer[1]->hundredths);
lv_label_set_text_fmt(lapOneText,
"#%2d %2d:%02d.%02d",
(lapNr - 1),
lapBuffer[1]->mins,
lapBuffer[1]->secs,
lapBuffer[1]->hundredths);
}
if (lapBuffer[0]) {
lv_label_set_text_fmt(lapTwoText, "#%2d %2d:%02d.%02d", lapNr, lapBuffer[0]->mins, lapBuffer[0]->secs, lapBuffer[0]->hundredths);

Some files were not shown because too many files have changed in this diff Show More