Skip to content

Commit 30b32e4

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into pinetimestyle-colorpicker
2 parents 9851ed3 + ee44b6f commit 30b32e4

24 files changed

Lines changed: 358 additions & 335 deletions

.vscode/launch.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,25 @@
4040
"break main",
4141
"continue"
4242
]
43+
},
44+
{
45+
"cwd": "${workspaceRoot}",
46+
// TODO: find better way to get latest build filename
47+
"executable": "./build/src/pinetime-app-1.3.0.out",
48+
"name": "Debug OpenOCD ST-LINK pinetime-app-1.3.0.out",
49+
"request": "launch",
50+
"type": "cortex-debug",
51+
"showDevDebugOutput": false,
52+
"servertype": "openocd",
53+
"runToMain": true,
54+
// Only use armToolchainPath if your arm-none-eabi-gdb is not in your path (some GCC packages does not contain arm-none-eabi-gdb)
55+
"armToolchainPath": "${workspaceRoot}/../gcc-arm-none-eabi-9-2020-q2-update/bin",
56+
"svdFile": "${workspaceRoot}/nrf52.svd",
57+
"configFiles": [
58+
"interface/stlink.cfg",
59+
"target/nrf52.cfg"
60+
],
4361
}
4462

4563
]
46-
}
64+
}

CONTRIBUTING.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
doc/contribute.md

doc/contribute.md

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,89 @@
11
# How to contribute?
2+
23
## Report bugs
3-
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...
4+
5+
Have you found a bug in the firmware? [Create an issue on Github](https://github.com/JF002/InfiniTime/issues) explaining the bug, how to reproduce it, the version of the firmware you use...
6+
47
## Write and improve documentation
8+
59
Documentation might be incomplete, or not clear enough, and it is always possible to improve it with better wording, pictures, photo, video,...
610

711
As the documentation is part of the source code, you can submit your improvements to the documentation by submitting a pull request (see below).
12+
813
## Fix bugs, add functionalities and improve the code
14+
915
You want to fix a bug, add a cool new functionality or improve the code? See *How to submit a pull request below*.
16+
1017
## Spread the word
11-
The Pinetime is a cool open source project that deserves to be known. Talk about it around you, on social networks, on your blog,... and let people know that we are working on an open-source firmware for a smartwatch!
18+
19+
The Pinetime is a cool open source project that deserves to be known. Talk about it around you, on social networks, on your blog,... and let people know that we are working on an open source firmware for a smartwatch!
1220

1321
# How to submit a pull request ?
1422

1523
## TL;DR
24+
1625
- Create a branch from develop;
1726
- Work on a single subject in this branch. Create multiple branches/pulls-requests if you want to work on multiple subjects (bugs, features,...);
1827
- Test your modifications on the actual hardware;
1928
- Check the code formatting against our coding conventions and [clang-format](../.clang-format) and [clang-tidy](../.clang-tidy);
2029
- Clean your code and remove files that are not needed;
21-
- Write documentation related to your new feature is applicable;
22-
- Create the pull-request and write a great description about it : what does your PR do, why, how,... Add pictures and video if possible;
30+
- Write documentation related to your new feature if applicable;
31+
- Create a pull request and write a great description about it : what does your PR do, why, how,... Add pictures and video if possible;
2332
- Wait for someone to review your PR and take part in the review process;
2433
- Your PR will eventually be merged :)
2534

26-
Your contribution is more than welcome!
35+
Your contributions are more than welcome!
2736

28-
If you want to fix a bug, add a functionality or improve the code, you'll first need to create a branch from the **develop** branch (see [this page about the branching model](./branches.md)). This branch is called a feature branch, and you should choose a name that explains what you are working on (ex: "add-doc-about-contributions"). In this branch, **focus on only one topic, bug or feature**. For example, if you created this branch to work on the UI of a specific application, do not commit modifications about the SPI driver. If you want to work on multiple topics, create one branch per topic.
37+
If you want to fix a bug, add functionality or improve the code, you'll first need to create a branch from the **develop** branch (see [this page about the branching model](./branches.md)). This branch is called a feature branch, and you should choose a name that explains what you are working on (ex: "add-doc-about-contributions"). In this branch, **focus on only one topic, bug or feature**. For example, if you created this branch to work on the UI of a specific application, do not commit modifications about the SPI driver. If you want to work on multiple topics, create one branch for each topic.
2938

3039
When your feature branch is ready, **make sure it actually works** and **do not forget to write documentation** about it if it's relevant.
3140

32-
I **strongly discourage to create a PR containing modifications that haven't been tested**. If, for any reason, you cannot test your modifications but want to publish them anyway, **please mention it in the description**. This way, other contributors might be willing to test it and provide feedback about your code.
41+
**Creating a pull request containing modifications that haven't been tested is strongly discouraged.** If, for any reason, you cannot test your modifications but want to publish them anyway, **please mention it in the description**. This way, other contributors might be willing to test it and provide feedback about your code.
3342

3443
Also, before submitting your PR, check the coding style of your code against the **coding conventions** detailed below. This project also provides [clang-format](../.clang-format) and [clang-tidy](../.clang-tidy) configuration files. You can use them to ensure correct formatting of your code.
3544

36-
Do not forget to check the files you are going to commit and remove those who are not necessary (config files from your IDE, for example). Remove old comments, commented code,...
45+
Don't forget to check the files you are going to commit and remove those which aren't necessary (config files from your IDE, for example). Remove old comments, commented code,...
3746

38-
Then, you can submit a pull-request for review. Try to **describe your pull request as much as possible**: what did you do in this branch, how does it work, how is it designed, are there any limitations,... This will help the contributors to understand and review your code easily. You can add pictures and video to the description so that contributors will have a quick overview of your work.
47+
Then, you can submit a pull request for review. Try to **describe your pull request as much as possible**: what did you do in this branch, how does it work, how it is designed, are there any limitations,... This will help the contributors to understand and review your code easily. You can add pictures and video to the description so that contributors will have a quick overview of your work.
3948

4049
Other contributors can post comments about the pull request, maybe ask for more info or adjustments in the code.
4150

42-
Once the pull request is reviewed and accepted, it'll be merge in **develop** and will be released in the next release version of the firmware.
51+
Once the pull request is reviewed and accepted, it'll be merged into **develop** and will be released in the next version of the firmware.
4352

4453
## Why all these rules?
45-
Reviewing pull-requests is a **very time consuming task** for the creator of this project ([JF002](https://github.com/JF002)) and for other contributors who take the time to review them. Every little thing you do to make their lives easier will **increase the chances your PR will be merge quickly**.
4654

47-
When reviewing PR, the author and contributors will first look at the **description**. If it's easy to understand what the PR does, why the modification is needed or interesting and how it's done, a good part of the work is already done : we understand the PR and its context.
55+
Reviewing pull requests is a **very time consuming task** for the creator of this project ([JF002](https://github.com/JF002)) and for other contributors who take the time to review them. Everything you do to make reviewing easier will **get your PR merged faster**.
4856

49-
Then, reviewing **a few files that were modified for a single purpose** is a lot more easier than to review 30 files modified for many reasons (bug fix, UI improvements, typos in doc,...), even if all these changes make sense. Also, it's possible that we agree on some modification but not on some other, and we won't be able to merge the PR because of the changes that are not accepted.
57+
When reviewing PRs, the author and contributors will first look at the **description**. If it's easy to understand what the PR does, why the modification is needed or interesting and how it's done, a good part of the work is already done : we understand the PR and its context.
5058

51-
We do our best to keep the code as consistent as possible, and that means we pay attention to the **formatting** of the code. If the code formatting is not consistent with our code base, we'll ask you to review it, which will take more time.
59+
Then, reviewing **a few files that were modified for a single purpose** is a lot more easier than to review 30 files modified for many reasons (bug fix, UI improvements, typos in doc,...), even if all these changes make sense. Also, it's possible that we agree on some modification but not on some other, so we won't be able to merge the PR because of the changes that are not accepted.
5260

53-
The last step of the review consists in **testing** the modification. If it doesn't work out of the box, we'll ask your to review your code and to ensure that it works as expected.
61+
We do our best to keep the code as consistent as possible. If the formatting of the code in your PR is not consistent with our code base, we'll ask you to review it, which will take more time.
5462

55-
It's totally normal for a PR to need some more work even after it was created, that's why we review them. But every round trip takes time, and it's good practice to try to reduce them as much as possible by following those simple rules.
63+
The last step of the review consists of **testing** the modification. If it doesn't work out of the box, we'll ask your to review your code and to ensure that it works as expected.
64+
65+
It's totally normal for a PR to need some more work even after it was created, that's why we review them. But every round trip takes time, so it's good practice to try to reduce them as much as possible by following those simple rules.
5666

5767
# Coding convention
68+
5869
## Language
59-
The language of this project is **C++**, and all new code must be written in C++. (Modern) C++ provides a lot of useful tools and functionalities that are beneficial for embedded software development like `constexpr`, `template` and anything that provides zero-cost abstraction.
6070

61-
It's OK to include C code if this code comes from another library like FreeRTOS, NimBLE, LVGL or the NRF-SDK.
71+
The language of this project is **C++**, and all new code must be written in C++. (Modern) C++ provides a lot of useful tools and functionalities that are beneficial for embedded software development like `constexpr`, `template` and anything that provides zero-cost abstraction.
72+
73+
C code is accepted if it comes from another library like FreeRTOS, NimBLE, LVGL or the NRF-SDK.
6274

6375
## Coding style
76+
6477
The most important rule to follow is to try to keep the code as easy to read and maintain as possible.
6578

79+
Using an autoformatter is highly recommended, but make sure it's configured properly.
80+
81+
There are preconfigured autoformatter rules for:
82+
83+
* CLion (IntelliJ) in .idea/codeStyles/Project.xml
84+
85+
If there are no preconfigured rules for your IDE, you can use one of the existing ones to configure your IDE.
86+
6687
- **Indentation** : 2 spaces, no tabulation
6788
- **Opening brace** at the end of the line
6889
- **Naming** : Choose self-describing variable name

doc/ui/example.png

10.4 KB
Loading

doc/ui_guidelines.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# UI design guidelines
2+
3+
- Align objects all the way to the edge or corner
4+
- Buttons should generally be at least 50px high
5+
- Buttons should generally be on the bottom edge
6+
- Make interactable objects **big**
7+
- Recommendations for inner padding, aka distance between buttons:
8+
- When aligning 4 objects: 4px, e.g. Settings
9+
- When aligning 3 objects: 6px, e.g. App list
10+
- When aligning 2 objects: 10px, e.g. Quick settings
11+
- When using a page indicator, leave 8px for it on the right side
12+
- It is acceptable to leave 8px on the left side as well to center the content
13+
- Top bar takes at least 20px + padding
14+
- Top bar right icons move 8px to the left when using a page indicator
15+
16+
![example layouts](./ui/example.png)

src/components/motor/MotorController.cpp

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#include "systemtask/SystemTask.h"
44
#include "app_timer.h"
55

6-
APP_TIMER_DEF(vibTimer);
6+
APP_TIMER_DEF(shortVibTimer);
7+
APP_TIMER_DEF(longVibTimer);
78

89
using namespace Pinetime::Controllers;
910

@@ -13,19 +14,39 @@ MotorController::MotorController(Controllers::Settings& settingsController) : se
1314
void MotorController::Init() {
1415
nrf_gpio_cfg_output(pinMotor);
1516
nrf_gpio_pin_set(pinMotor);
16-
app_timer_create(&vibTimer, APP_TIMER_MODE_SINGLE_SHOT, vibrate);
17+
app_timer_init();
18+
19+
app_timer_create(&shortVibTimer, APP_TIMER_MODE_SINGLE_SHOT, StopMotor);
20+
app_timer_create(&longVibTimer, APP_TIMER_MODE_REPEATED, Ring);
1721
}
1822

19-
void MotorController::SetDuration(uint8_t motorDuration) {
23+
void MotorController::Ring(void* p_context) {
24+
auto* motorController = static_cast<MotorController*>(p_context);
25+
motorController->RunForDuration(50);
26+
}
2027

21-
if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF)
28+
void MotorController::RunForDuration(uint8_t motorDuration) {
29+
if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) {
2230
return;
31+
}
2332

2433
nrf_gpio_pin_clear(pinMotor);
25-
/* Start timer for motorDuration miliseconds and timer triggers vibrate() when it finishes*/
26-
app_timer_start(vibTimer, APP_TIMER_TICKS(motorDuration), NULL);
34+
app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr);
35+
}
36+
37+
void MotorController::StartRinging() {
38+
if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) {
39+
return;
40+
}
41+
Ring(this);
42+
app_timer_start(longVibTimer, APP_TIMER_TICKS(1000), this);
2743
}
2844

29-
void MotorController::vibrate(void* p_context) {
45+
void MotorController::StopRinging() {
46+
app_timer_stop(longVibTimer);
3047
nrf_gpio_pin_set(pinMotor);
31-
}
48+
}
49+
50+
void MotorController::StopMotor(void* p_context) {
51+
nrf_gpio_pin_set(pinMotor);
52+
}

src/components/motor/MotorController.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ namespace Pinetime {
1212
public:
1313
MotorController(Controllers::Settings& settingsController);
1414
void Init();
15-
void SetDuration(uint8_t motorDuration);
15+
void RunForDuration(uint8_t motorDuration);
16+
void StartRinging();
17+
static void StopRinging();
1618

1719
private:
20+
static void Ring(void* p_context);
1821
Controllers::Settings& settingsController;
19-
static void vibrate(void* p_context);
22+
static void StopMotor(void* p_context);
2023
};
2124
}
2225
}

src/displayapp/DisplayApp.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,12 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
337337

338338
case Apps::Notifications:
339339
currentScreen = std::make_unique<Screens::Notifications>(
340-
this, notificationManager, systemTask->nimble().alertService(), Screens::Notifications::Modes::Normal);
340+
this, notificationManager, systemTask->nimble().alertService(), motorController, Screens::Notifications::Modes::Normal);
341341
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
342342
break;
343343
case Apps::NotificationsPreview:
344344
currentScreen = std::make_unique<Screens::Notifications>(
345-
this, notificationManager, systemTask->nimble().alertService(), Screens::Notifications::Modes::Preview);
345+
this, notificationManager, systemTask->nimble().alertService(), motorController, Screens::Notifications::Modes::Preview);
346346
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
347347
break;
348348
case Apps::Timer:
@@ -419,6 +419,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
419419
break;
420420
case Apps::Metronome:
421421
currentScreen = std::make_unique<Screens::Metronome>(this, motorController, *systemTask);
422+
ReturnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::None);
422423
break;
423424
case Apps::Motion:
424425
currentScreen = std::make_unique<Screens::Motion>(this, motionController);

src/displayapp/screens/FirmwareValidation.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app,
3838
lv_label_set_text(labelIsValidated, "Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version.");
3939

4040
buttonValidate = lv_btn_create(lv_scr_act(), nullptr);
41-
lv_obj_align(buttonValidate, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
4241
buttonValidate->user_data = this;
42+
lv_obj_set_size(buttonValidate, 115, 50);
43+
lv_obj_align(buttonValidate, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
4344
lv_obj_set_event_cb(buttonValidate, ButtonEventHandler);
4445
lv_obj_set_style_local_bg_color(buttonValidate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x009900));
4546

@@ -48,6 +49,7 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app,
4849

4950
buttonReset = lv_btn_create(lv_scr_act(), nullptr);
5051
buttonReset->user_data = this;
52+
lv_obj_set_size(buttonReset, 115, 50);
5153
lv_obj_align(buttonReset, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
5254
lv_obj_set_style_local_bg_color(buttonReset, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x990000));
5355
lv_obj_set_event_cb(buttonReset, ButtonEventHandler);

0 commit comments

Comments
 (0)