Skip to content

Commit 27366bd

Browse files
committed
Merge branch 'develop' into wake-time
2 parents db50131 + 3eb7377 commit 27366bd

File tree

113 files changed

+1270
-779
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1270
-779
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ name: Build PineTime Firmware
99
# When to run this Workflow...
1010
on:
1111

12-
# Run this Workflow when files are updated (Pushed) in the "master" Branch
12+
# Run this Workflow when files are updated (Pushed) in the "master" and "develop" Branch
1313
push:
14-
branches: [ master ]
14+
branches: [ master, develop ]
1515

16-
# Also run this Workflow when a Pull Request is created or updated in the "master" Branch
16+
# Also run this Workflow when a Pull Request is created or updated in the "master" and "develop" Branch
1717
pull_request:
18-
branches: [ master ]
18+
branches: [ master, develop ]
1919

2020
# Steps to run for the Workflow
2121
jobs:
@@ -44,7 +44,7 @@ jobs:
4444

4545
- name: Install Embedded Arm Toolchain arm-none-eabi-gcc
4646
if: steps.cache-toolchain.outputs.cache-hit != 'true' # Install toolchain if not found in cache
47-
uses: fiam/[email protected].2
47+
uses: fiam/[email protected].4
4848
with:
4949
# GNU Embedded Toolchain for Arm release name, in the V-YYYY-qZ format (e.g. "9-2019-q4")
5050
release: 9-2020-q2
@@ -83,10 +83,11 @@ jobs:
8383
if: steps.cache-mcuboot.outputs.cache-hit != 'true' # Install MCUBoot if not found in cache
8484
run: |
8585
cd ${{ runner.temp }}
86-
git clone --branch v1.5.0 https://github.com/JuulLabs-OSS/mcuboot
86+
git clone --branch v1.7.2 https://github.com/mcu-tools/mcuboot
8787
8888
- name: Install imgtool dependencies
89-
run: pip3 install --user -r ${{ runner.temp }}/mcuboot/scripts/requirements.txt
89+
run: |
90+
pip3 install --user -r ${{ runner.temp }}/mcuboot/scripts/requirements.txt
9091
9192
- name: Install adafruit-nrfutil
9293
run: |
@@ -99,6 +100,8 @@ jobs:
99100

100101
- name: Checkout source files
101102
uses: actions/checkout@v2
103+
with:
104+
submodules: recursive
102105

103106
- name: Show files
104107
run: set ; pwd ; ls -l
@@ -110,7 +113,7 @@ jobs:
110113
run: |
111114
mkdir -p build
112115
cd build
113-
cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=${{ runner.temp }}/arm-none-eabi -DNRF5_SDK_PATH=${{ runner.temp }}/nrf5_sdk -DUSE_OPENOCD=1 ../
116+
cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=${{ runner.temp }}/arm-none-eabi -DNRF5_SDK_PATH=${{ runner.temp }}/nrf5_sdk -DUSE_OPENOCD=1 -DBUILD_DFU=1 ../
114117
115118
#########################################################################################
116119
# Make and Upload DFU Package
@@ -125,19 +128,10 @@ jobs:
125128
cd build
126129
make pinetime-mcuboot-app
127130
128-
- name: Create firmware image
129-
run: |
130-
# The generated firmware binary looks like "pinetime-mcuboot-app-0.8.2.bin"
131-
ls -l build/src/pinetime-mcuboot-app*.bin
132-
${{ runner.temp }}/mcuboot/scripts/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header build/src/pinetime-mcuboot-app*.bin build/src/pinetime-mcuboot-app-img.bin
133-
${{ runner.temp }}/mcuboot/scripts/imgtool.py verify build/src/pinetime-mcuboot-app-img.bin
134-
135-
- name: Create DFU package
131+
- name: Unzip DFU package
136132
run: |
137-
~/.local/bin/adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application build/src/pinetime-mcuboot-app-img.bin build/src/pinetime-mcuboot-app-dfu.zip
138-
unzip -v build/src/pinetime-mcuboot-app-dfu.zip
139133
# Unzip the package because Upload Artifact will zip up the files
140-
unzip build/src/pinetime-mcuboot-app-dfu.zip -d build/src/pinetime-mcuboot-app-dfu
134+
unzip build/src/pinetime-mcuboot-app-dfu*.zip -d build/src/pinetime-mcuboot-app-dfu
141135
142136
- name: Upload DFU package
143137
uses: actions/upload-artifact@v2

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.10)
2-
project(pinetime VERSION 1.3.0 LANGUAGES C CXX ASM)
2+
project(pinetime VERSION 1.4.0 LANGUAGES C CXX ASM)
33

44
set(CMAKE_C_STANDARD 99)
55
set(CMAKE_CXX_STANDARD 14)
@@ -51,6 +51,14 @@ if(BUILD_DFU)
5151
set(BUILD_DFU true)
5252
endif()
5353

54+
option(WATCH_COLMI_P8 "Build for the Colmi P8" OFF)
55+
set(TARGET_DEVICE "PineTime")
56+
57+
if(WATCH_COLMI_P8)
58+
set(TARGET_DEVICE "Colmi P8")
59+
add_definitions(-DWATCH_P8)
60+
endif()
61+
5462
set(PROJECT_GIT_COMMIT_HASH "")
5563

5664
execute_process(COMMAND git rev-parse --short HEAD
@@ -68,6 +76,7 @@ message(" * Version : " ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${P
6876
message(" * Toolchain : " ${ARM_NONE_EABI_TOOLCHAIN_PATH})
6977
message(" * GitRef(S) : " ${PROJECT_GIT_COMMIT_HASH})
7078
message(" * NRF52 SDK : " ${NRF5_SDK_PATH})
79+
message(" * Target device : " ${TARGET_DEVICE})
7180
set(PROGRAMMER "???")
7281
if(USE_JLINK)
7382
message(" * Programmer/debugger : JLINK")

README.md

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
1-
# PineTime
1+
# InfiniTime
22

33
[![Build PineTime Firmware](https://github.com/JF002/InfiniTime/workflows/Build%20PineTime%20Firmware/badge.svg?branch=master)](https://github.com/JF002/InfiniTime/actions)
44

5-
> The PineTime is a free and open source smartwatch capable of running custom-built open operating systems. Some of the notable features include a heart rate monitor, a week-long battery as well as a capacitive touch IPS display that is legible in direct sunlight. It is a fully community driven side-project, which means that it will ultimately be up to the developers and end-users to determine when they deem the PineTime ready to ship.
6-
7-
> We envision the PineTime as a companion for not only your PinePhone but also for your favorite devices — any phone, tablet, or even PC.
8-
9-
*https://www.pine64.org/pinetime/*
10-
11-
The **Pinetime** smartwatch is built around the NRF52832 MCU (512KB Flash, 64KB RAM), a 240*240 LCD display driven by the ST7789 controller, an accelerometer, a heart rate sensor, and a vibration motor.
12-
13-
# InfiniTime
14-
155
![InfiniTime logo](images/infinitime-logo.jpg "InfiniTime Logo")
166

17-
The goal of this project is to design an open-source firmware for the Pinetime smartwatch :
7+
The goal of this project is to design an open-source firmware for the [Pinetime smartwatch](https://www.pine64.org/pinetime/) :
188

199
- Code written in **modern C++**;
2010
- Build system based on **CMake**;
2111
- Based on **[FreeRTOS 10.0.0](https://freertos.org)** real-time OS.
2212
- Using **[LittleVGL/LVGL 7](https://lvgl.io/)** as UI library...
2313
- ... and **[NimBLE 1.3.0](https://github.com/apache/mynewt-nimble)** as BLE stack.
2414

15+
## New to InfiniTime?
16+
17+
- [Getting started with InfiniTime 1.0 (quick user guide, update bootloader and InfiniTime,...)](doc/gettingStarted/gettingStarted-1.0.md)
18+
- [Flash, upgrade (OTA), time synchronization,...](doc/gettingStarted/ota-gadgetbridge-nrfconnect.md)
19+
2520
## Overview
2621

2722
![Pinetime screens](images/1.0.0/collage.png "PinetimeScreens")
@@ -70,16 +65,12 @@ As of now, here is the list of achievements of this project:
7065
* [Amazfish](https://openrepos.net/content/piggz/amazfish) (on SailfishOS and Linux)
7166
* [Siglo](https://github.com/alexr4535/siglo) (on Linux)
7267
* **[Experimental]** [WebBLEWatch](https://hubmartin.github.io/WebBLEWatch/) Synchronize time directly from your web browser. [video](https://youtu.be/IakiuhVDdrY)
68+
* **[Experimental]** [Infini-iOS](https://github.com/xan-m/Infini-iOS) (on iOS)
7369
- OTA (Over-the-air) update via BLE
7470
- [Bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader) based on [MCUBoot](https://juullabs-oss.github.io/mcuboot/)
7571

7672
## Documentation
7773

78-
### Getting started
79-
80-
- [Getting started with InfiniTime 1.0 (quick user guide, update bootloader and InfiniTime,...)](doc/gettingStarted/gettingStarted-1.0.md)
81-
- [Flash, upgrade (OTA), time synchronization,...](doc/gettingStarted/ota-gadgetbridge-nrfconnect.md)
82-
8374
### Develop
8475

8576
- [Generate the fonts and symbols](src/displayapp/fonts/README.md)

cmake-nRF5x/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ The script makes use of the following tools:
9898

9999
After setup you can use cmake as usual:
100100

101-
1. Generate the actual build files (out-of-source builds are strongly recomended):
101+
1. Generate the actual build files (out-of-source builds are strongly recommended):
102102

103103
```commandline
104104
cmake -H. -B"cmake-build" -G "Unix Makefiles"

doc/buildAndProgram.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ CMake configures the project according to variables you specify the command line
2828
**GDB_CLIENT_BIN_PATH**|Path to arm-none-eabi-gdb executable. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_BIN_PATH=/home/jf/nrf52/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gdb`
2929
**GDB_CLIENT_TARGET_REMOTE**|Target remote connection string. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_TARGET_REMOTE=/dev/ttyACM0`
3030
**BUILD_DFU (\*\*)**|Build DFU files while building (needs [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-DBUILD_DFU=1`
31+
**WATCH_COLMI_P8**|Use pin configuration for Colmi P8 watch|`-DWATCH_COLMI_P8=1`
3132

3233
####(**) Note about **CMAKE_BUILD_TYPE**:
3334
By default, this variable is set to *Release*. It compiles the code with size and speed optimizations. We use this value for all the binaries we publish when we [release](https://github.com/JF002/InfiniTime/releases) new versions of InfiniTime.

doc/gettingStarted/ota-gadgetbridge-nrfconnect.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Read carefully the warning and tap **Install**:
4747

4848
Wait for the transfer to finish. Your PineTime should reset and reboot with the new version of InfiniTime!
4949

50+
Don't forget to **validate** your firmware. In the InfiniTime go to the settings (swipe right, select gear icon) and Firmware option and click **validate**. Otherwise after reboot the previous firmware will be used.
51+
5052
![Gadgetbridge 5](gadgetbridge5.jpg)
5153

5254
### Using NRFConnect
@@ -64,6 +66,8 @@ Select **Distribution packet (ZIP)**:
6466

6567
Browse to the DFU file you downloaded previously, the DFU transfer will start automatically. When the transfer is finished, your PineTime will reset and restart on the new version of InfiniTime!
6668

69+
Don't forget to **validate** your firmware. In the InfiniTime go to the settings (swipe right, select gear icon) and Firmware option and click **validate**. Otherwise after reboot the previous firmware will be used.
70+
6771
![NRFConnect 3](nrfconnect3.jpg)
6872

6973
## How to flash InfiniTime using the SWD interface
@@ -88,6 +92,10 @@ If you are using OpenOCD with a STLinkV2, you can find more info [on this page](
8892
### Using Gadgetbridge
8993
Good news! Gadgetbridge **automatically** synchronizes the time when connecting to your PineTime!
9094

95+
### Using any Chromium-based web browser
96+
You can use it from your PC, Mac, Android. Browsers now have BLE support.
97+
https://hubmartin.github.io/WebBLEWatch/
98+
9199
### Using NRFConnect
92100
You must enable the **CTS** *GATT server* into NRFConnect so that InfiniTime can synchronize the time with your smartphone.
93101

doc/versioning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ The versioning of this project is based on [Semantic versionning](https://semver
33

44
- The **patch** is incremented when we fix a bug on a **released** version (most of the time using a **hotfix** branch).
55
- The **minor** is incremented when we release a new version with new features. It corresponds to a merge of **develop** into **master**.
6-
- The **major** should be incremented when a breaking change is made to the application. We still have to define what is a breaking change in the context of this project. For now, I suggest that it stays **0** until we have a fully functionning firmware suited for the final user.
6+
- The **major** should be incremented when a breaking change is made to the application. We still have to define what is a breaking change in the context of this project. For now, I suggest that it stays **0** until we have a fully functioning firmware suited for the final user.

src/CMakeLists.txt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ set(SDK_SOURCE_FILES
9292
set(TINYCRYPT_SRC
9393
libs/mynewt-nimble/ext/tinycrypt/src/aes_encrypt.c
9494
libs/mynewt-nimble/ext/tinycrypt/src/utils.c
95+
libs/mynewt-nimble/ext/tinycrypt/src/cmac_mode.c
96+
libs/mynewt-nimble/ext/tinycrypt/src/ecc.c
97+
libs/mynewt-nimble/ext/tinycrypt/src/ecc_dh.c
9598
)
9699

97100
set(NIMBLE_SRC
@@ -104,6 +107,10 @@ set(NIMBLE_SRC
104107
libs/mynewt-nimble/nimble/host/src/ble_l2cap.c
105108
libs/mynewt-nimble/nimble/host/src/ble_hs_mbuf.c
106109
libs/mynewt-nimble/nimble/host/src/ble_sm.c
110+
libs/mynewt-nimble/nimble/host/src/ble_sm_cmd.c
111+
libs/mynewt-nimble/nimble/host/src/ble_sm_lgcy.c
112+
libs/mynewt-nimble/nimble/host/src/ble_sm_alg.c
113+
libs/mynewt-nimble/nimble/host/src/ble_sm_sc.c
107114
libs/mynewt-nimble/nimble/host/src/ble_gap.c
108115
libs/mynewt-nimble/nimble/host/src/ble_gatts.c
109116
libs/mynewt-nimble/nimble/host/src/ble_gattc.c
@@ -127,10 +134,6 @@ set(NIMBLE_SRC
127134
libs/mynewt-nimble/nimble/host/src/ble_hs_atomic.c
128135
libs/mynewt-nimble/nimble/host/src/ble_hs_adv.c
129136
libs/mynewt-nimble/nimble/host/src/ble_hs_flow.c
130-
libs/mynewt-nimble/nimble/host/src/ble_sm.c
131-
libs/mynewt-nimble/nimble/host/src/ble_sm_cmd.c
132-
libs/mynewt-nimble/nimble/host/src/ble_sm_lgcy.c
133-
libs/mynewt-nimble/nimble/host/src/ble_sm_alg.c
134137
libs/mynewt-nimble/nimble/host/src/ble_hs_mqueue.c
135138
libs/mynewt-nimble/nimble/host/src/ble_hs_stop.c
136139
libs/mynewt-nimble/nimble/host/src/ble_hs_startup.c
@@ -418,6 +421,7 @@ list(APPEND SOURCE_FILES
418421
displayapp/screens/BatteryInfo.cpp
419422
displayapp/screens/Steps.cpp
420423
displayapp/screens/Timer.cpp
424+
displayapp/Colors.cpp
421425

422426
## Settings
423427
displayapp/screens/settings/QuickSettings.cpp
@@ -427,6 +431,7 @@ list(APPEND SOURCE_FILES
427431
displayapp/screens/settings/SettingWakeUp.cpp
428432
displayapp/screens/settings/SettingDisplay.cpp
429433
displayapp/screens/settings/SettingSteps.cpp
434+
displayapp/screens/settings/SettingPineTimeStyle.cpp
430435

431436
## Watch faces
432437
displayapp/icons/bg_clock.c
@@ -495,6 +500,8 @@ list(APPEND SOURCE_FILES
495500
components/heartrate/Biquad.cpp
496501
components/heartrate/Ptagc.cpp
497502
components/heartrate/HeartRateController.cpp
503+
504+
touchhandler/TouchHandler.cpp
498505
)
499506

500507
list(APPEND RECOVERY_SOURCE_FILES
@@ -552,6 +559,7 @@ list(APPEND RECOVERY_SOURCE_FILES
552559
components/heartrate/Ptagc.cpp
553560
components/motor/MotorController.cpp
554561
components/fs/FS.cpp
562+
touchhandler/TouchHandler.cpp
555563
)
556564

557565
list(APPEND RECOVERYLOADER_SOURCE_FILES
@@ -607,6 +615,7 @@ set(INCLUDE_FILES
607615
displayapp/screens/Metronome.h
608616
displayapp/screens/Motion.h
609617
displayapp/screens/Timer.h
618+
displayapp/Colors.h
610619
drivers/St7789.h
611620
drivers/SpiNorFlash.h
612621
drivers/SpiMaster.h
@@ -615,6 +624,7 @@ set(INCLUDE_FILES
615624
drivers/DebugPins.h
616625
drivers/InternalFlash.h
617626
drivers/Hrs3300.h
627+
drivers/PinMap.h
618628
drivers/Bma421.h
619629
drivers/Bma421_C/bma4.c
620630
drivers/Bma421_C/bma423.c
@@ -660,6 +670,7 @@ set(INCLUDE_FILES
660670
components/heartrate/Ptagc.h
661671
components/heartrate/HeartRateController.h
662672
components/motor/MotorController.h
673+
touchhandler/TouchHandler.h
663674
)
664675

665676
include_directories(

src/components/battery/BatteryController.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "BatteryController.h"
2+
#include "drivers/PinMap.h"
23
#include <hal/nrf_gpio.h>
34
#include <nrfx_saadc.h>
45
#include <algorithm>
@@ -9,15 +10,12 @@ Battery* Battery::instance = nullptr;
910

1011
Battery::Battery() {
1112
instance = this;
12-
}
13-
14-
void Battery::Init() {
15-
nrf_gpio_cfg_input(chargingPin, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Pullup);
13+
nrf_gpio_cfg_input(PinMap::Charging, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Disabled);
1614
}
1715

1816
void Battery::Update() {
19-
isCharging = !nrf_gpio_pin_read(chargingPin);
20-
isPowerPresent = !nrf_gpio_pin_read(powerPresentPin);
17+
isCharging = !nrf_gpio_pin_read(PinMap::Charging);
18+
isPowerPresent = !nrf_gpio_pin_read(PinMap::PowerPresent);
2119

2220
if (isReading) {
2321
return;
@@ -75,5 +73,11 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) {
7573

7674
nrfx_saadc_uninit();
7775
isReading = false;
76+
77+
systemTask->PushMessage(System::Messages::BatteryMeasurementDone);
7878
}
7979
}
80+
81+
void Battery::Register(Pinetime::System::SystemTask* systemTask) {
82+
this->systemTask = systemTask;
83+
}

src/components/battery/BatteryController.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#pragma once
22
#include <cstdint>
33
#include <drivers/include/nrfx_saadc.h>
4-
#include <array>
5-
#include <numeric>
4+
#include <systemtask/SystemTask.h>
65

76
namespace Pinetime {
87
namespace Controllers {
@@ -11,8 +10,8 @@ namespace Pinetime {
1110
public:
1211
Battery();
1312

14-
void Init();
1513
void Update();
14+
void Register(System::SystemTask* systemTask);
1615

1716
uint8_t PercentRemaining() const {
1817
return percentRemaining;
@@ -34,8 +33,6 @@ namespace Pinetime {
3433
static Battery* instance;
3534
nrf_saadc_value_t saadc_value;
3635

37-
static constexpr uint32_t chargingPin = 12;
38-
static constexpr uint32_t powerPresentPin = 19;
3936
static constexpr nrf_saadc_input_t batteryVoltageAdcInput = NRF_SAADC_INPUT_AIN7;
4037
uint16_t voltage = 0;
4138
uint8_t percentRemaining = 0;
@@ -49,6 +46,8 @@ namespace Pinetime {
4946
static void AdcCallbackStatic(nrfx_saadc_evt_t const* event);
5047

5148
bool isReading = false;
49+
50+
Pinetime::System::SystemTask* systemTask = nullptr;
5251
};
5352
}
5453
}

0 commit comments

Comments
 (0)