Skip to content

Commit

Permalink
Merge branch 'develop' of JF/PineTime into master
Browse files Browse the repository at this point in the history
  • Loading branch information
JF002 authored and Gitea committed Mar 21, 2021
2 parents 5cd4b36 + 9f9d0eb commit 24d3eea
Show file tree
Hide file tree
Showing 46 changed files with 1,769 additions and 469 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GitHub Actions Workflow to build FreeRTOS Firmware for PineTime Smart Watch
# See https://lupyuen.github.io/pinetime-rust-mynewt/articles/cloud
# Based on /~https://github.com/JF002/Pinetime/blob/master/doc/buildAndProgram.md
# and /~https://github.com/JF002/Pinetime/blob/master/bootloader/README.md
# 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
Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"chrono": "cpp"
}
}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
project(pinetime VERSION 0.14.1 LANGUAGES C CXX ASM)
project(pinetime VERSION 0.15.0 LANGUAGES C CXX ASM)

set(NRF_TARGET "nrf52")

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# PineTime

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

> 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.
Expand Down Expand Up @@ -44,6 +44,7 @@ As of now, here is the list of achievements of this project:
* Notification (displays the last notification received)
* Paddle (single player pong-like game)
* Two (2048 clone game)
* Stopwatch (with all the necessary functions such as play, pause, lap, stop)
- Supported by 2 companion apps (development is in progress):
* [Gadgetbridge](https://codeberg.org/Freeyourgadget/Gadgetbridge/) (on Android)
* [Amazfish](https://openrepos.net/content/piggz/amazfish) (on SailfishOS and Linux)
Expand Down
19 changes: 12 additions & 7 deletions doc/buildAndProgram.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ To build this project, you'll need:
## Build steps
### Clone the repo
```
git clone /~https://github.com/JF002/Pinetime.git
cd Pinetime
git clone /~https://github.com/JF002/InfiniTime.git
cd InfiniTime
git submodule update --init
mkdir build
cd build
Expand All @@ -22,18 +22,23 @@ CMake configures the project according to variables you specify the command line
**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/`|
**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`
**CMAKE_BUILD_TYPE (\*)**| Build type (Release or Debug). Release is applied by default if this variable is not specified.|`-DCMAKE_BUILD_TYPE=Debug`
**NRFJPROG**|Path to the NRFJProg executable. Used only if `USE_JLINK` is 1.|`-DNRFJPROG=/opt/nrfjprog/nrfjprog`
**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`
**GDB_CLIENT_TARGET_REMOTE**|Target remote connection string. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_TARGET_REMOTE=/dev/ttyACM0`
**BUILD_DFU (\*)**|Build DFU files while building (needs [adafruit-nrfutil](/~https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-BUILD_DFU=1`
**BUILD_DFU (\*\*)**|Build DFU files while building (needs [adafruit-nrfutil](/~https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-BUILD_DFU=1`

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

The *Debug* mode disables all optimizations, which makes the code easier to debug. However, the binary size will likely be too big to fit in the internal flash memory. If you want to build and debug a *Debug* binary, you'll need to disable some parts of the code. For example, the icons for the **Navigation** app use a lot of memory space. You can comment the content of `m_iconMap` in the [Navigation](/~https://github.com/JF002/InfiniTime/blob/develop/src/displayapp/screens/Navigation.h#L148) application to free some memory.

####(**) 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.

#### CMake command line for JLink
```
cmake -DCMAKE_BUILD_TYPE=Debug -DARM_NONE_EABI_TOOLCHAIN_PATH=... -DNRF5_SDK_PATH=... -DUSE_JLINK=1 -DNRFJPROG=... ../
cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=... -DNRF5_SDK_PATH=... -DUSE_JLINK=1 -DNRFJPROG=... ../
```

#### CMake command line for GDB Client (Black Magic Probe)
Expand All @@ -57,7 +62,7 @@ During the project generation, CMake created the following targets:
- **pinetime-mcuboot-recovery** : build pinetime-recovery with bootloader support
- **pinetime-mcuboot-recovery-loader** : build pinetime-recovery-loader with bootloader support

If you just want to build the project and run it on the Pinetime, using *pinetime-app* is recommanded. See [this page](../bootloader/README.md) for more info about bootloader support.
If you just want to build the project and run it on the Pinetime, using *pinetime-app* is recommended. See [this page](../bootloader/README.md) for more info about bootloader support.

Build:
```
Expand Down
4 changes: 2 additions & 2 deletions doc/contribute.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# How to contribute?
## Report bugs
You use your Pinetime and find a bug in the firmware? [Create an issue on Github](/~https://github.com/JF002/Pinetime/issues) explaining the bug, how to reproduce it, the version of the firmware you use...
You use your Pinetime and find a bug in the firmware? [Create an issue on Github](/~https://github.com/JF002/InfiniTime/issues) explaining the bug, how to reproduce it, the version of the firmware you use...
## Write and improve documentation
Documentation might be incomplete, or not clear enough, and it is always possible to improve it with better wording, pictures, photo, video,...

Expand Down Expand Up @@ -41,4 +41,4 @@ The most important rule to follow is to try to keep the code as easy to read and
- **Include guard** : `#pragma once` (no `#ifdef __MODULE__ / #define __MODULE__ / #endif`)
- **Includes** :
- 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>`
4 changes: 2 additions & 2 deletions doc/filesInReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Using the releases
For each new *stable* version of Pinetime, a [release note](/~https://github.com/JF002/Pinetime/releases) is created. It contains a description of the main changes in the release and some files you can use to flash the firmware in your Pinetime.
For each new *stable* version of Pinetime, a [release note](/~https://github.com/JF002/InfiniTime/releases) is created. It contains a description of the main changes in the release and some files you can use to flash the firmware in your Pinetime.

This page describes the files from the release notes and how to use them.

**NOTE :** the files included in different could be different. This page describes the release note of [version 0.7.1](/~https://github.com/JF002/Pinetime/releases/tag/0.7.1), which is the version that'll probably be pre-programmed at the factory for the next batch of Pinetime devkits.
**NOTE :** the files included in different could be different. This page describes the release note of [version 0.7.1](/~https://github.com/JF002/InfiniTime/releases/tag/0.7.1), which is the version that'll probably be pre-programmed at the factory for the next batch of Pinetime devkits.

## Files included in the release note

Expand Down
4 changes: 2 additions & 2 deletions doc/gettingStarted/gettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ If you just want to flash or upgrade InfiniTime on your PineTime, this page is f
- [How to flash InfiniTime using the SWD interface](#how-to-flash-infinitime-using-the-swd-interface)

## InfiniTime releases and versions
All releases of InfiniTime are available on the [release page of the GitHub repo](/~https://github.com/JF002/Pinetime/releases).
All releases of InfiniTime are available on the [release page of the GitHub repo](/~https://github.com/JF002/InfiniTime/releases).

Versions that are tagged as **RELEASE CANDIDATE** are pre-release versions, that are available for testing before actually releasing a new stable version. If you want to help us debug the project and provide stable versions to other user, you can use them. If you want stable and tested version, you should not flash these release candidate version.

Expand Down Expand Up @@ -98,4 +98,4 @@ Launch NRFConnect, tap the sandwish button on the top left and select *Configure

Tap *Add service* and select the server configuration *Current Time service*. Tap OK and connect to your PineTime, it should automcatically sync the time once the connection is established!

![NRFConnect CTS 1](nrfconnectcts1.jpg)
![NRFConnect CTS 1](nrfconnectcts1.jpg)
16 changes: 15 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ list(APPEND SOURCE_FILES
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
Expand All @@ -499,6 +500,15 @@ list(APPEND SOURCE_FILES
displayapp/screens/Notifications.cpp
displayapp/screens/Twos.cpp
displayapp/screens/HeartRate.cpp

## Watch faces
displayapp/icons/bg_clock.c
displayapp/screens/WatchFaceAnalog.cpp

displayapp/screens/WatchFaceDigital.cpp

##

main.cpp
drivers/St7789.cpp
drivers/SpiNorFlash.cpp
Expand Down Expand Up @@ -528,6 +538,7 @@ list(APPEND SOURCE_FILES
components/ble/HeartRateService.cpp
components/firmwarevalidator/FirmwareValidator.cpp
components/motor/MotorController.cpp
components/settings/Settings.cpp
drivers/Cst816s.cpp
FreeRTOS/port.c
FreeRTOS/port_cmsis_systick.c
Expand Down Expand Up @@ -581,6 +592,7 @@ list(APPEND RECOVERY_SOURCE_FILES
components/ble/NavigationService.cpp
components/ble/HeartRateService.cpp
components/firmwarevalidator/FirmwareValidator.cpp
components/settings/Settings.cpp
drivers/Cst816s.cpp
FreeRTOS/port.c
FreeRTOS/port_cmsis_systick.c
Expand Down Expand Up @@ -633,6 +645,7 @@ set(INCLUDE_FILES
displayapp/screens/Tile.h
displayapp/screens/Meter.h
displayapp/screens/InfiniPaint.h
displayapp/screens/StopWatch.h
displayapp/screens/Paddle.h
displayapp/screens/DropDownDemo.h
displayapp/screens/BatteryIcon.h
Expand Down Expand Up @@ -671,7 +684,8 @@ set(INCLUDE_FILES
components/ble/ImmediateAlertService.h
components/ble/ServiceDiscovery.h
components/ble/BleClient.h
components/ble/HeartRateService.h.h
components/ble/HeartRateService.h
components/settings/Settings.h
drivers/Cst816s.h
FreeRTOS/portmacro.h
FreeRTOS/portmacro_cmsis.h
Expand Down
120 changes: 120 additions & 0 deletions src/components/datetime/DateTimeController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,123 @@ void DateTime::UpdateTime(uint32_t systickCounter) {
second = time.seconds().count();
}

const char *DateTime::MonthShortToString() {
return DateTime::MonthsString[(uint8_t)month];
}

const char *DateTime::MonthShortToStringLow() {
return DateTime::MonthsStringLow[(uint8_t)month];
}

const char *DateTime::MonthsToStringLow() {
return DateTime::MonthsLow[(uint8_t)month];
}

const char *DateTime::DayOfWeekToString() {
return DateTime::DaysString[(uint8_t)dayOfWeek];
}

const char *DateTime::DayOfWeekShortToString() {
return DateTime::DaysStringShort[(uint8_t)dayOfWeek];
}

const char *DateTime::DayOfWeekToStringLow() {
return DateTime::DaysStringLow[(uint8_t)dayOfWeek];
}

const char *DateTime::DayOfWeekShortToStringLow() {
return DateTime::DaysStringShortLow[(uint8_t)dayOfWeek];
}


char const *DateTime::DaysStringLow[] = {
"--",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
};

char const *DateTime::DaysStringShortLow[] = {
"--",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun"
};

char const *DateTime::DaysStringShort[] = {
"--",
"MON",
"TUE",
"WED",
"THU",
"FRI",
"SAT",
"SUN"
};

char const *DateTime::DaysString[] = {
"--",
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY",
"SUNDAY"
};

char const *DateTime::MonthsString[] = {
"--",
"JAN",
"FEB",
"MAR",
"APR",
"MAY",
"JUN",
"JUL",
"AUG",
"SEP",
"OCT",
"NOV",
"DEC"
};

char const *DateTime::MonthsStringLow[] = {
"--",
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
};

char const *DateTime::MonthsLow[] = {
"--",
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};
17 changes: 17 additions & 0 deletions src/components/datetime/DateTimeController.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ namespace Pinetime {
uint8_t Minutes() const { return minute; }
uint8_t Seconds() const { return second; }

const char *MonthShortToString();
const char *MonthShortToStringLow();
const char *MonthsToStringLow();
const char *DayOfWeekToString();
const char *DayOfWeekShortToString();
const char *DayOfWeekToStringLow();
const char *DayOfWeekShortToStringLow();

std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime() const { return currentDateTime; }
std::chrono::seconds Uptime() const { return uptime; }
private:
Expand All @@ -34,6 +42,15 @@ namespace Pinetime {
uint32_t previousSystickCounter = 0;
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> currentDateTime;
std::chrono::seconds uptime {0};

static char const *DaysString[];
static char const *DaysStringShort[];
static char const *DaysStringLow[];
static char const *DaysStringShortLow[];
static char const *MonthsString[];
static char const *MonthsStringLow[];
static char const *MonthsLow[];

};
}
}
14 changes: 5 additions & 9 deletions src/components/gfx/Gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ void Gfx::ClearScreen() {
state.busy = true;
state.action = Action::FillRectangle;
state.taskToNotify = xTaskGetCurrentTaskHandle();

lcd.BeginDrawBuffer(0, 0, width, height);
lcd.NextDrawBuffer(reinterpret_cast<const uint8_t *>(buffer), width * 2);

lcd.DrawBuffer(0, 0, width, height, reinterpret_cast<const uint8_t *>(buffer), width * 2);
WaitTransferFinished();

}
Expand All @@ -34,8 +33,7 @@ void Gfx::FillRectangle(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint16_t col
state.color = color;
state.taskToNotify = xTaskGetCurrentTaskHandle();

lcd.BeginDrawBuffer(x, y, w, h);
lcd.NextDrawBuffer(reinterpret_cast<const uint8_t *>(buffer), width * 2);
lcd.DrawBuffer(x, y, w, h, reinterpret_cast<const uint8_t *>(buffer), width * 2);

WaitTransferFinished();
}
Expand All @@ -48,8 +46,7 @@ void Gfx::FillRectangle(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t* b)
state.color = 0x00;
state.taskToNotify = xTaskGetCurrentTaskHandle();

lcd.BeginDrawBuffer(x, y, w, h);
lcd.NextDrawBuffer(reinterpret_cast<const uint8_t *>(b), width * 2);
lcd.DrawBuffer(x, y, w, h, reinterpret_cast<const uint8_t *>(b), width * 2);

WaitTransferFinished();
}
Expand Down Expand Up @@ -120,8 +117,7 @@ void Gfx::DrawChar(const FONT_INFO *font, uint8_t c, uint8_t *x, uint8_t y, uint
state.color = color;
state.taskToNotify = xTaskGetCurrentTaskHandle();

lcd.BeginDrawBuffer(*x, y, bytes_in_line*8, font->height);
lcd.NextDrawBuffer(reinterpret_cast<const uint8_t *>(&buffer), bytes_in_line*8*2);
lcd.DrawBuffer(*x, y, bytes_in_line*8, font->height, reinterpret_cast<const uint8_t *>(&buffer), bytes_in_line*8*2);
WaitTransferFinished();

*x += font->charInfo[char_idx].widthBits + font->spacePixels;
Expand Down
Loading

0 comments on commit 24d3eea

Please sign in to comment.