Merge remote-tracking branch 'upstream/develop' into pts-settings
This commit is contained in:
commit
da97a94a0f
1
.github/ISSUE_TEMPLATE/bug-report.yaml
vendored
1
.github/ISSUE_TEMPLATE/bug-report.yaml
vendored
|
@ -1,6 +1,5 @@
|
||||||
name: Bug Report
|
name: Bug Report
|
||||||
description: File a bug report
|
description: File a bug report
|
||||||
title: "[Bug]: "
|
|
||||||
labels: ["bug"]
|
labels: ["bug"]
|
||||||
body:
|
body:
|
||||||
- type: markdown
|
- type: markdown
|
||||||
|
|
1
.github/ISSUE_TEMPLATE/feature-request.yaml
vendored
1
.github/ISSUE_TEMPLATE/feature-request.yaml
vendored
|
@ -1,6 +1,5 @@
|
||||||
name: Feature Request
|
name: Feature Request
|
||||||
description: File a feature request
|
description: File a feature request
|
||||||
title: ""
|
|
||||||
labels: ["feature request"]
|
labels: ["feature request"]
|
||||||
body:
|
body:
|
||||||
- type: markdown
|
- type: markdown
|
||||||
|
|
8
.github/workflows/main.yml
vendored
8
.github/workflows/main.yml
vendored
|
@ -153,6 +153,14 @@ jobs:
|
||||||
name: pinetime-app.out
|
name: pinetime-app.out
|
||||||
path: build/src/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: |
|
||||||
|
cd build
|
||||||
|
make pinetime-recovery
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# Finish
|
# Finish
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ As of now, here is the list of achievements of this project:
|
||||||
* [Amazfish](https://openrepos.net/content/piggz/amazfish) (on SailfishOS and Linux)
|
* [Amazfish](https://openrepos.net/content/piggz/amazfish) (on SailfishOS and Linux)
|
||||||
* [Siglo](https://github.com/alexr4535/siglo) (on Linux)
|
* [Siglo](https://github.com/alexr4535/siglo) (on Linux)
|
||||||
* **[Experimental]** [WebBLEWatch](https://hubmartin.github.io/WebBLEWatch/) Synchronize time directly from your web browser. [video](https://youtu.be/IakiuhVDdrY)
|
* **[Experimental]** [WebBLEWatch](https://hubmartin.github.io/WebBLEWatch/) Synchronize time directly from your web browser. [video](https://youtu.be/IakiuhVDdrY)
|
||||||
* **[Experimental]** [Infini-iOS](https://github.com/xan-m/Infini-iOS) (on iOS)
|
* **[Experimental]** [InfiniLink](https://github.com/xan-m/InfiniLink) (on iOS)
|
||||||
- OTA (Over-the-air) update via BLE
|
- OTA (Over-the-air) update via BLE
|
||||||
- [Bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader) based on [MCUBoot](https://www.mcuboot.com)
|
- [Bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader) based on [MCUBoot](https://www.mcuboot.com)
|
||||||
|
|
||||||
|
|
242
doc/ble.md
242
doc/ble.md
|
@ -2,23 +2,59 @@
|
||||||
## Introduction
|
## Introduction
|
||||||
This page describes the BLE implementation and API built in this firmware.
|
This page describes the BLE implementation and API built in this firmware.
|
||||||
|
|
||||||
**Note** : I'm a beginner in BLE related technologies and the information of this document reflect my current knowledge and understanding of the BLE stack. These informations might be erroneous or incomplete. Feel free to submit a PR if you think you can improve these.
|
**Note** : I'm a beginner in BLE related technologies and the information in this document reflects my current knowledge and understanding of the BLE stack. This information might be erroneous or incomplete. Feel free to submit a PR if you think you can improve it.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Table of Contents
|
||||||
|
|
||||||
|
- [BLE Connection](#ble-connection)
|
||||||
|
- [BLE UUIDs](#ble-uuids)
|
||||||
|
- [BLE Services](#ble-services)
|
||||||
|
- [CTS](#cts)
|
||||||
|
- [ANS](#ans)
|
||||||
|
- [Getting Information](#getting-information)
|
||||||
|
- [Firmware Version](#firmware-version)
|
||||||
|
- [Battery Level](#battery-level)
|
||||||
|
- [Heart Rate](#heart-rate)
|
||||||
|
- [Notifications](#notifications)
|
||||||
|
- [New Alert](#new-alert)
|
||||||
|
- [Notification Event](#notification-event)
|
||||||
|
- [Firmware Upgrades](#firmware-upgrades)
|
||||||
|
- [Step one](#step-one)
|
||||||
|
- [Step two](#step-two)
|
||||||
|
- [Step three](#step-three)
|
||||||
|
- [Step four](#step-four)
|
||||||
|
- [Step five](#step-five)
|
||||||
|
- [Step six](#step-six)
|
||||||
|
- [Step seven](#step-seven)
|
||||||
|
- [Step eight](#step-eight)
|
||||||
|
- [Step nine](#step-nine)
|
||||||
|
- [Music Control](#music-control)
|
||||||
|
- [Events](#events)
|
||||||
|
- [Status](#status)
|
||||||
|
- [Artist, Track, and Album](#artist-track-and-album)
|
||||||
|
- [Time](#time)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## BLE Connection
|
## BLE Connection
|
||||||
When starting the firmware start a BLE advertising : it sends small messages that can be received by any *central* device in range. This allows the device to announce its presence to other devices.
|
When starting, the firmware starts BLE advertising. It sends small messages that can be received by any *central* device in range. This allows the device to announce its presence to other devices.
|
||||||
|
|
||||||
A companion application (running on a PC, RaspberryPi, smartphone) which received this avertising packet can request a connection to the device. This connection procedure allows the 2 devices to negotiate communication parameters, security keys,...
|
A companion application (running on a PC, Raspberry Pi, smartphone, etc.) which receives this advertising packet can request a connection to the device. This connection procedure allows the 2 devices to negotiate communication parameters, security keys, etc.
|
||||||
|
|
||||||
When the connection is established, the pinetime will try to discover services running on the companion application. For now **CTS** (**C**urrent **T**ime **S**ervice) and **ANS** (**A**lert **N**otification **S**ervice) are supported.
|
When the connection is established, the PineTime will try to discover services running on the companion application. For now **CTS** (**C**urrent **T**ime **S**ervice) and **ANS** (**A**lert **N**otification **S**ervice) are supported.
|
||||||
|
|
||||||
If **CTS** is detected, it'll request the current time to the companion application. If **ANS** is detected, it will listen to new notifications coming from the companion application.
|
If **CTS** is detected, it'll request the current time to the companion application. If **ANS** is detected, it will listen to new notifications coming from the companion application.
|
||||||
|
|
||||||
![BLE connection sequence diagram](ble/connection_sequence.png "BLE connection sequence diagram")
|
![BLE connection sequence diagram](ble/connection_sequence.png "BLE connection sequence diagram")
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## BLE UUIDs
|
## BLE UUIDs
|
||||||
When possible, InfiniTime tries to implement BLE services defined by the BLE specification.
|
When possible, InfiniTime tries to implement BLE services defined by the BLE specification.
|
||||||
|
|
||||||
When the service does not exist in the BLE specification, InfiniTime implement custom services. As all BLE services, custom services are identified by a UUID. Here is how to define the UUID of custom services in InfiniTime:
|
When the service does not exist in the BLE specification, InfiniTime implements custom services. Custom services are identified by a UUID, as are all BLE services. Here is how to define the UUID of custom services in InfiniTime:
|
||||||
|
|
||||||
```
|
```
|
||||||
- Base UUID : xxxxxxxx-78fc-48fe-8e23-433b3a1942d0
|
- Base UUID : xxxxxxxx-78fc-48fe-8e23-433b3a1942d0
|
||||||
|
@ -38,6 +74,8 @@ The following custom services are implemented in InfiniTime:
|
||||||
* Navigation Service : 00010000-78fc-48fe-8e23-433b3a1942d0
|
* Navigation Service : 00010000-78fc-48fe-8e23-433b3a1942d0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## BLE services
|
## BLE services
|
||||||
[List of standard BLE services](https://www.bluetooth.com/specifications/gatt/services/)
|
[List of standard BLE services](https://www.bluetooth.com/specifications/gatt/services/)
|
||||||
|
|
||||||
|
@ -49,3 +87,197 @@ The following custom services are implemented in InfiniTime:
|
||||||
|
|
||||||
![ANS sequence diagram](./ble/ans_sequence.png "ANS sequence diagram")
|
![ANS sequence diagram](./ble/ans_sequence.png "ANS sequence diagram")
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Getting Information
|
||||||
|
|
||||||
|
The InfiniTime firmware exposes some information about itself through BLE. The BLE characteristic UUIDs for this information are as follows:
|
||||||
|
|
||||||
|
- Firmware Version: `00002a26-0000-1000-8000-00805f9b34fb`
|
||||||
|
- Battery Level: `00002a19-0000-1000-8000-00805f9b34fb`
|
||||||
|
- Heart Rate: `00002a37-0000-1000-8000-00805f9b34fb`
|
||||||
|
|
||||||
|
#### Firmware Version
|
||||||
|
|
||||||
|
Reading a value from the firmware version characteristic will yield a UTF-8 encoded string containing the version of InfiniTime being run on the device. Example: `1.6.0`.
|
||||||
|
|
||||||
|
#### Battery Level
|
||||||
|
|
||||||
|
Reading from the battery level characteristic yields a single byte of data. This byte can be converted to an unsigned 8-bit integer which will be the battery percentage. This characteristic allows notify for updates as the value changes.
|
||||||
|
|
||||||
|
#### Heart Rate
|
||||||
|
|
||||||
|
Reading from the heart rate characteristic yields two bytes of data. I am not sure of the function of the first byte. It appears to always be zero. The second byte can be converted to an unsigned 8-bit integer which is the current heart rate. This characteristic also allows notify for updates as the value changes.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Notifications
|
||||||
|
|
||||||
|
InfiniTime uses the Alert Notification Service (ANS) for notifications. The relevant UUIDs are as follows:
|
||||||
|
|
||||||
|
- New Alert: `00002a46-0000-1000-8000-00805f9b34fb`
|
||||||
|
- Notification Event: `00020001-78fc-48fe-8e23-433b3a1942d0`
|
||||||
|
|
||||||
|
#### New Alert
|
||||||
|
|
||||||
|
The new alert characteristic allows sending new notifications to InfiniTime. It requires the following format:
|
||||||
|
|
||||||
|
```
|
||||||
|
<category><amount>\x00<\x00-separated data>
|
||||||
|
```
|
||||||
|
|
||||||
|
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\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\x01\x00Mary"
|
||||||
|
```
|
||||||
|
|
||||||
|
The `\x00` stands for hexadecimal `00` which means null.
|
||||||
|
|
||||||
|
Here is the list of categories and commands:
|
||||||
|
|
||||||
|
- Simple Alert: `0`
|
||||||
|
- Email: `1`
|
||||||
|
- News: `2`
|
||||||
|
- Call Notification: `3`
|
||||||
|
- Missed Call: `4`
|
||||||
|
- SMS/MMS: `5`
|
||||||
|
- Voicemail: `6`
|
||||||
|
- Schedule: `7`
|
||||||
|
- High Prioritized Alert: `8`
|
||||||
|
- Instant Message: `9`
|
||||||
|
- All Alerts: `0xFF`
|
||||||
|
|
||||||
|
These lists and information were retrieved from the following pages in the Nordic docs:
|
||||||
|
|
||||||
|
- [Alert Notification Service Client](https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v12.2.0%2Fgroup__ble__ans__c.html)
|
||||||
|
- [Alert Notification Application](https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v13.0.0%2Fble_sdk_app_alert_notification.html)
|
||||||
|
|
||||||
|
#### Notification Event
|
||||||
|
|
||||||
|
A call notification in InfiniTime contains three buttons. Decline, Accept, and Mute. The notification event characteristic contains the button tapped by the user on a call notification. This characteristic only allows notify, **not** read.
|
||||||
|
|
||||||
|
Enabling notifications from this characteristic, you get a single byte whenever the user taps a button on the call notification. This byte is an unsigned 8-bit integer that signifies one of the buttons. The numbers are as follows:
|
||||||
|
|
||||||
|
- 0: Declined
|
||||||
|
- 1: Accepted
|
||||||
|
- 2: Muted
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Firmware Upgrades
|
||||||
|
|
||||||
|
Firmware upgrades in InfiniTime are probably the most complex of the BLE operations. It is a nine step process requiring multiple commands be sent to multiple characteristics. The relevant UUIDs are as follows:
|
||||||
|
|
||||||
|
- Control Point: `00001531-1212-efde-1523-785feabcd123`
|
||||||
|
- Packet: `00001532-1212-efde-1523-785feabcd123`
|
||||||
|
|
||||||
|
A DFU upgrade archive for InfiniTime consists of multiple files. The most important being the .bin and .dat files. The first is the actual firmware, while the second is a packet that initializes DFU. Both are needed for a DFU upgrade.
|
||||||
|
|
||||||
|
The first thing to do is to enable notifications on the control point characteristic. This will be needed for verifying that the proper responses are being sent back from InfiniTime.
|
||||||
|
|
||||||
|
#### Step one
|
||||||
|
|
||||||
|
For the first step, write `0x01`, `0x04` to the control point characteristic. This will signal InfiniTime that a DFU upgrade is to be started.
|
||||||
|
|
||||||
|
#### Step two
|
||||||
|
|
||||||
|
In step two, send the total size in bytes of the firmware file to the packet characteristic. This value should be an unsigned 32-bit integer encoded as little-endian. In front of this integer should be 8 null bytes. This is because there are three items that can be updated and each 4 bytes is for one of those. The last four are for the InfiniTime application, so those are the ones that need to be set.
|
||||||
|
|
||||||
|
#### Step three
|
||||||
|
|
||||||
|
Before running step three, wait for a response from the control point. This response should be `0x10`, `0x01`, `0x01` which indicates a successful DFU start. In step three, send `0x02`, `0x00` to the control point. This will signal InfiniTime to expect the init packet on the packet characteristic.
|
||||||
|
|
||||||
|
#### Step four
|
||||||
|
|
||||||
|
The previous step prepared InfiniTime for this one. In this step, send the contents of the .dat init packet file to the packet characteristic. After this, send `0x02`, `0x01` indicating that the packet has been sent.
|
||||||
|
|
||||||
|
#### Step five
|
||||||
|
|
||||||
|
Before running this step, wait to receive `0x10`, `0x02`, `0x01` which indicates that the packet has been received. During this step, send the packet receipt interval to the control point. The firmware file will be sent in segments of 20 bytes each. The packet receipt interval indicates how many segments should be received before sending a receipt containing the amount of bytes received so that it can be confirmed to be the same as the amount sent. This is very useful for detecting packet loss. `itd` uses `0x08`, `0x0A` which indicates 10 segments.
|
||||||
|
|
||||||
|
#### Step six
|
||||||
|
|
||||||
|
In step six, write `0x03` to the control point, indicating that the firmware will be sent next on the packet characteristic.
|
||||||
|
|
||||||
|
#### Step seven
|
||||||
|
|
||||||
|
This step is the most difficult. Here, the actual firmware is sent to InfiniTime.
|
||||||
|
|
||||||
|
As mentioned before, the firmware file must be split up into segments of 20 bytes each and sent to the packet characteristic one by one. Every 10 segments (or whatever you have set the interval to), check for a response starting with `0x11`. The rest of the response will be the amount of bytes received encoded as a little-endian unsigned 32-bit integer. Confirm that this matches the amount of bytes sent, and then continue sending more segments.
|
||||||
|
|
||||||
|
#### Step eight
|
||||||
|
|
||||||
|
Before running this step, wait to receive `0x10`, `0x03`, `0x01` which indicates a successful receipt of the firmware image. In this step, write `0x04` to the control point to signal InfiniTime to validate the image it has received.
|
||||||
|
|
||||||
|
#### Step nine
|
||||||
|
|
||||||
|
Before running this step, wait to receive `0x10`, `0x04`, `0x01` which indicates that the image has been validated. In this step, send `0x05` to the control point as a command with no response. This signals InfiniTime to activate the new firmware and reboot.
|
||||||
|
|
||||||
|
Once all of these steps are complete, the DFU is complete. Don't forget to validate the firmware in the settings.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Music Control
|
||||||
|
|
||||||
|
InfiniTime contains a music controller app which is meant to control the music playback and volume through the companion.
|
||||||
|
|
||||||
|
The following UUIDs are relevant to this:
|
||||||
|
|
||||||
|
- Events: `00000001-78fc-48fe-8e23-433b3a1942d0`
|
||||||
|
- Status: `00000002-78fc-48fe-8e23-433b3a1942d0`
|
||||||
|
- Artist: `00000003-78fc-48fe-8e23-433b3a1942d0`
|
||||||
|
- Track: `00000004-78fc-48fe-8e23-433b3a1942d0`
|
||||||
|
- Album: `00000005-78fc-48fe-8e23-433b3a1942d0`
|
||||||
|
|
||||||
|
#### Events
|
||||||
|
|
||||||
|
The events characteristic is meant to respond to user input in the music controller app.
|
||||||
|
|
||||||
|
Enabling notifications on this characteristic gives you a single byte upon any event. This byte can be converted to an unsigned 8-bit integer which corresponds to each possible event. Here are the events:
|
||||||
|
|
||||||
|
- App Opened: `0xe0`
|
||||||
|
- Play: `0x00`
|
||||||
|
- Pause: `0x01`
|
||||||
|
- Next: `0x03`
|
||||||
|
- Previous: `0x04`
|
||||||
|
- Volume up: `0x05`
|
||||||
|
- Volume down: `0x06`
|
||||||
|
|
||||||
|
#### Status
|
||||||
|
|
||||||
|
The status characteristic allows setting the playing status of music. Send `0x01` to the status characteristic for playing, and `0x00` for paused.
|
||||||
|
|
||||||
|
#### Artist, Track, and Album
|
||||||
|
|
||||||
|
These characteristics all work the same way. Simply send a UTF-8 encoded string to the relevant characteristic in order to set the value in the app.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Time
|
||||||
|
|
||||||
|
InfiniTime allows setting its time via the Current Time Service (CTS)
|
||||||
|
|
||||||
|
The UUID for the current time characteristic is: `00002a2b-0000-1000-8000-00805f9b34fb`
|
||||||
|
|
||||||
|
This characteristic expects a particular format:
|
||||||
|
|
||||||
|
- Year (`uint16`)
|
||||||
|
- Month (`uint8`)
|
||||||
|
- Day (`uint8`)
|
||||||
|
- Hour (`uint8`)
|
||||||
|
- Minute (`uint8`)
|
||||||
|
- Second (`uint8`)
|
||||||
|
- Weekday (`uint8`)
|
||||||
|
- Microsecond divided by `1e6*256` (`uint8`)
|
||||||
|
- Binary 0001 (`uint8`)
|
||||||
|
|
||||||
|
Write all of these together, encoded as little-endian, to the current time characteristic.
|
|
@ -3,7 +3,14 @@
|
||||||
To build this project, you'll need:
|
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 (9-2020-q2-update)](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads/9-2020-q2-update)
|
||||||
- The NRF52 SDK 15.3.0 : [nRF-SDK v15.3.0](https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip)
|
- The NRF52 SDK 15.3.0 : [nRF-SDK v15.3.0](https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip)
|
||||||
- The `cbor` and `intelhex` modules for Python 3
|
- The Python 3 modules `cbor`, `intelhex`, `click` and `cryptography` modules for the `mcuboot` tool (see [requirements.txt](../tools/mcuboot/requirements.txt))
|
||||||
|
- To to keep the system clean a python virtual environment (`venv`) can be used to install the python modules into
|
||||||
|
```sh
|
||||||
|
python -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
python -m pip install wheel
|
||||||
|
python -m pip install -r tools/mcuboot/requirements.txt
|
||||||
|
```
|
||||||
- A reasonably recent version of CMake (I use 3.16.5)
|
- A reasonably recent version of CMake (I use 3.16.5)
|
||||||
|
|
||||||
## Build steps
|
## Build steps
|
||||||
|
|
|
@ -13,6 +13,8 @@ Based on Ubuntu 18.04 with the following build dependencies:
|
||||||
|
|
||||||
The `infinitime-build` image contains all the dependencies you need. The default `CMD` will compile sources found in `/sources`, so you need only mount your code.
|
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
|
```bash
|
||||||
|
@ -28,10 +30,10 @@ docker run --rm -it -v $(pwd):/sources infinitime-build /opt/build.sh pinetime-a
|
||||||
|
|
||||||
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).
|
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`
|
Running with this image is the same as above, you just specify the ids to `docker run`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run --rm -it -v $(pwd):/sources --user $(id -u):$(id -g) pfeerick/infinitime-build
|
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:
|
Or you can specify your user id and group id (by number, not by name) directly:
|
||||||
|
@ -42,7 +44,7 @@ docker run --rm -it -v $(pwd):/sources --user 1234:1234 infinitime-build
|
||||||
|
|
||||||
## Using the image from Docker Hub
|
## Using the image from Docker Hub
|
||||||
|
|
||||||
The image is avaiable via Docker Hub for both the amd64 and arm64v8 architectures at [pfeerick/infinitime-build](https://hub.docker.com/repository/docker/pfeerick/infinitime-build).
|
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).
|
||||||
|
|
||||||
It can be pulled (downloaded) using the following command:
|
It can be pulled (downloaded) using the following command:
|
||||||
|
|
||||||
|
|
|
@ -51,14 +51,14 @@ MyApp.h:
|
||||||
#include "displayapp/screens/Screen.h"
|
#include "displayapp/screens/Screen.h"
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
|
|
||||||
namespace PineTime {
|
namespace Pinetime {
|
||||||
namespace Applications {
|
namespace Applications {
|
||||||
namespace Screens {
|
namespace Screens {
|
||||||
class MyApp : public Screen {
|
class MyApp : public Screen {
|
||||||
public:
|
public:
|
||||||
MyApp(DisplayApp* app);
|
MyApp(DisplayApp* app);
|
||||||
~MyApp() override;
|
~MyApp() override;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,3 +94,10 @@ If there are no preconfigured rules for your IDE, you can use one of the existin
|
||||||
- **Includes** :
|
- **Includes** :
|
||||||
- files from the project : `#include "relative/path/to/the/file.h"`
|
- files from the project : `#include "relative/path/to/the/file.h"`
|
||||||
- external files and std : `#include <file.h>`
|
- external files and std : `#include <file.h>`
|
||||||
|
- Only use [primary spellings for operators and tokens](https://en.cppreference.com/w/cpp/language/operator_alternative)
|
||||||
|
- Use auto sparingly. Don't use auto for [fundamental/built-in types](https://en.cppreference.com/w/cpp/language/types) and [fixed width integer types](https://en.cppreference.com/w/cpp/types/integer), except when initializing with a cast to avoid duplicating the type name.
|
||||||
|
- Examples:
|
||||||
|
- `auto* app = static_cast<DisplayApp*>(instance);`
|
||||||
|
- `auto number = static_cast<uint8_t>(variable);`
|
||||||
|
- `uint8_t returnValue = MyFunction();`
|
||||||
|
- Use nullptr instead of NULL
|
||||||
|
|
|
@ -396,7 +396,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
break;
|
break;
|
||||||
case Apps::FlashLight:
|
case Apps::FlashLight:
|
||||||
currentScreen = std::make_unique<Screens::FlashLight>(this, *systemTask, brightnessController);
|
currentScreen = std::make_unique<Screens::FlashLight>(this, *systemTask, brightnessController);
|
||||||
ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None);
|
ReturnApp(Apps::QuickSettings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
break;
|
break;
|
||||||
case Apps::StopWatch:
|
case Apps::StopWatch:
|
||||||
currentScreen = std::make_unique<Screens::StopWatch>(this, *systemTask);
|
currentScreen = std::make_unique<Screens::StopWatch>(this, *systemTask);
|
||||||
|
|
|
@ -5,30 +5,41 @@
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
static void event_handler(lv_obj_t* obj, lv_event_t event) {
|
void event_handler(lv_obj_t* obj, lv_event_t event) {
|
||||||
FlashLight* screen = static_cast<FlashLight*>(obj->user_data);
|
auto* screen = static_cast<FlashLight*>(obj->user_data);
|
||||||
screen->OnClickEvent(obj, event);
|
screen->OnClickEvent(obj, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
|
FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
|
||||||
System::SystemTask& systemTask,
|
System::SystemTask& systemTask,
|
||||||
Controllers::BrightnessController& brightness)
|
Controllers::BrightnessController& brightnessController)
|
||||||
: Screen(app),
|
: Screen(app),
|
||||||
systemTask {systemTask},
|
systemTask {systemTask},
|
||||||
brightness {brightness}
|
brightnessController {brightnessController}
|
||||||
|
|
||||||
{
|
{
|
||||||
brightness.Backup();
|
brightnessController.Backup();
|
||||||
brightness.Set(Controllers::BrightnessController::Levels::High);
|
|
||||||
// Set the background
|
|
||||||
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF));
|
|
||||||
|
|
||||||
flashLight = lv_label_create(lv_scr_act(), NULL);
|
brightnessLevel = brightnessController.Level();
|
||||||
lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
|
||||||
|
flashLight = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_font(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
|
lv_obj_set_style_local_text_font(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
|
||||||
lv_label_set_text_static(flashLight, Symbols::highlight);
|
lv_label_set_text_static(flashLight, Symbols::highlight);
|
||||||
lv_obj_align(flashLight, NULL, LV_ALIGN_CENTER, 0, 0);
|
lv_obj_align(flashLight, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_obj_align(indicators[1], flashLight, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
|
||||||
|
lv_obj_align(indicators[0], indicators[1], LV_ALIGN_OUT_LEFT_MID, -8, 0);
|
||||||
|
lv_obj_align(indicators[2], indicators[1], LV_ALIGN_OUT_RIGHT_MID, 8, 0);
|
||||||
|
|
||||||
|
SetIndicators();
|
||||||
|
SetColors();
|
||||||
|
|
||||||
backgroundAction = lv_label_create(lv_scr_act(), nullptr);
|
backgroundAction = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_label_set_long_mode(backgroundAction, LV_LABEL_LONG_CROP);
|
lv_label_set_long_mode(backgroundAction, LV_LABEL_LONG_CROP);
|
||||||
|
@ -44,27 +55,80 @@ FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
|
||||||
|
|
||||||
FlashLight::~FlashLight() {
|
FlashLight::~FlashLight() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
brightness.Restore();
|
brightnessController.Restore();
|
||||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) {
|
void FlashLight::SetColors() {
|
||||||
if (obj == backgroundAction) {
|
|
||||||
if (event == LV_EVENT_CLICKED) {
|
|
||||||
isOn = !isOn;
|
|
||||||
|
|
||||||
if (isOn) {
|
if (isOn) {
|
||||||
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF));
|
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_hex(0x000000));
|
lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
|
||||||
|
for (auto & i : indicators) {
|
||||||
|
lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
|
||||||
|
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_GRAY);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
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_hex(0xFFFFFF));
|
lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlashLight::SetIndicators() {
|
||||||
|
using namespace Pinetime::Controllers;
|
||||||
|
|
||||||
|
if (brightnessLevel == BrightnessController::Levels::High) {
|
||||||
|
lv_obj_set_state(indicators[1], LV_STATE_DEFAULT);
|
||||||
|
lv_obj_set_state(indicators[2], LV_STATE_DEFAULT);
|
||||||
|
} else if (brightnessLevel == BrightnessController::Levels::Medium) {
|
||||||
|
lv_obj_set_state(indicators[1], LV_STATE_DEFAULT);
|
||||||
|
lv_obj_set_state(indicators[2], LV_STATE_DISABLED);
|
||||||
|
} else {
|
||||||
|
lv_obj_set_state(indicators[1], LV_STATE_DISABLED);
|
||||||
|
lv_obj_set_state(indicators[2], LV_STATE_DISABLED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
|
if (obj == backgroundAction && event == LV_EVENT_CLICKED) {
|
||||||
|
isOn = !isOn;
|
||||||
|
SetColors();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FlashLight::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
bool FlashLight::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
|
using namespace Pinetime::Controllers;
|
||||||
|
|
||||||
|
if (event == TouchEvents::SwipeLeft) {
|
||||||
|
if (brightnessLevel == BrightnessController::Levels::High) {
|
||||||
|
brightnessLevel = BrightnessController::Levels::Medium;
|
||||||
|
brightnessController.Set(brightnessLevel);
|
||||||
|
SetIndicators();
|
||||||
|
} else if (brightnessLevel == BrightnessController::Levels::Medium) {
|
||||||
|
brightnessLevel = BrightnessController::Levels::Low;
|
||||||
|
brightnessController.Set(brightnessLevel);
|
||||||
|
SetIndicators();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (event == TouchEvents::SwipeRight) {
|
||||||
|
if (brightnessLevel == BrightnessController::Levels::Low) {
|
||||||
|
brightnessLevel = BrightnessController::Levels::Medium;
|
||||||
|
brightnessController.Set(brightnessLevel);
|
||||||
|
SetIndicators();
|
||||||
|
} else if (brightnessLevel == BrightnessController::Levels::Medium) {
|
||||||
|
brightnessLevel = BrightnessController::Levels::High;
|
||||||
|
brightnessController.Set(brightnessLevel);
|
||||||
|
SetIndicators();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
#include <lvgl/lvgl.h>
|
|
||||||
#include "systemtask/SystemTask.h"
|
|
||||||
#include "components/brightness/BrightnessController.h"
|
#include "components/brightness/BrightnessController.h"
|
||||||
|
#include "systemtask/SystemTask.h"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
|
|
||||||
|
@ -20,12 +20,18 @@ namespace Pinetime {
|
||||||
void OnClickEvent(lv_obj_t* obj, lv_event_t event);
|
void OnClickEvent(lv_obj_t* obj, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void SetIndicators();
|
||||||
|
void SetColors();
|
||||||
|
|
||||||
Pinetime::System::SystemTask& systemTask;
|
Pinetime::System::SystemTask& systemTask;
|
||||||
Controllers::BrightnessController& brightness;
|
Controllers::BrightnessController& brightnessController;
|
||||||
|
|
||||||
|
Controllers::BrightnessController::Levels brightnessLevel;
|
||||||
|
|
||||||
lv_obj_t* flashLight;
|
lv_obj_t* flashLight;
|
||||||
lv_obj_t* backgroundAction;
|
lv_obj_t* backgroundAction;
|
||||||
bool isOn = true;
|
lv_obj_t* indicators[3];
|
||||||
|
bool isOn = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
||||||
if (object == btn2 && event == LV_EVENT_CLICKED) {
|
if (object == btn2 && event == LV_EVENT_CLICKED) {
|
||||||
|
|
||||||
running = false;
|
running = false;
|
||||||
app->StartApp(Apps::FlashLight, DisplayApp::FullRefreshDirections::None);
|
app->StartApp(Apps::FlashLight, DisplayApp::FullRefreshDirections::Up);
|
||||||
|
|
||||||
} else if (object == btn1 && event == LV_EVENT_CLICKED) {
|
} else if (object == btn1 && event == LV_EVENT_CLICKED) {
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@ Cst816S::Cst816S(TwiMaster& twiMaster, uint8_t twiAddress) : twiMaster {twiMaste
|
||||||
|
|
||||||
bool Cst816S::Init() {
|
bool Cst816S::Init() {
|
||||||
nrf_gpio_cfg_output(PinMap::Cst816sReset);
|
nrf_gpio_cfg_output(PinMap::Cst816sReset);
|
||||||
nrf_gpio_pin_set(PinMap::Cst816sReset);
|
|
||||||
vTaskDelay(50);
|
|
||||||
nrf_gpio_pin_clear(PinMap::Cst816sReset);
|
nrf_gpio_pin_clear(PinMap::Cst816sReset);
|
||||||
vTaskDelay(5);
|
vTaskDelay(5);
|
||||||
nrf_gpio_pin_set(PinMap::Cst816sReset);
|
nrf_gpio_pin_set(PinMap::Cst816sReset);
|
||||||
|
|
|
@ -170,16 +170,7 @@ void St7789::Sleep() {
|
||||||
|
|
||||||
void St7789::Wakeup() {
|
void St7789::Wakeup() {
|
||||||
nrf_gpio_cfg_output(pinDataCommand);
|
nrf_gpio_cfg_output(pinDataCommand);
|
||||||
// TODO why do we need to reset the controller?
|
|
||||||
HardwareReset();
|
|
||||||
SoftwareReset();
|
|
||||||
SleepOut();
|
SleepOut();
|
||||||
ColMod();
|
|
||||||
MemoryDataAccessControl();
|
|
||||||
ColumnAddressSet();
|
|
||||||
RowAddressSet();
|
|
||||||
DisplayInversionOn();
|
|
||||||
NormalModeOn();
|
|
||||||
VerticalScrollStartAddress(verticalScrollingStartAddress);
|
VerticalScrollStartAddress(verticalScrollingStartAddress);
|
||||||
DisplayOn();
|
DisplayOn();
|
||||||
NRF_LOG_INFO("[LCD] Wakeup")
|
NRF_LOG_INFO("[LCD] Wakeup")
|
||||||
|
|
Loading…
Reference in a new issue