Skip to content

Commit c07fbf6

Browse files
committed
Merge branch 'develop' into button-unlock
2 parents 9412ccc + e823c8e commit c07fbf6

23 files changed

+223
-121
lines changed

.github/workflows/format.yml

+36-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ jobs:
1717
with:
1818
fetch-depth: 1000
1919

20-
- name: Configure git
21-
run: |
22-
git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF" --depth=1000
20+
- name: Fetch base branch
21+
run: git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF"
2322

2423
- name: Install clang-format
2524
run: |
@@ -35,3 +34,37 @@ jobs:
3534
with:
3635
name: Patches
3736
path: ./*.patch
37+
test-clang-tidy:
38+
runs-on: ubuntu-latest
39+
container:
40+
image: infinitime/infinitime-build
41+
steps:
42+
# This workaround fixes the error "unsafe repository (REPO is owned by someone else)".
43+
# See https://github.com/actions/checkout/issues/760 and https://github.com/actions/checkout/issues/766
44+
# The fix in "actions/checkout@v2" was not sufficient as the build process also uses git (to get the current
45+
# commit hash, for example).
46+
- name: Workaround permission issues
47+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
48+
- name: Checkout source files
49+
uses: actions/checkout@v3
50+
with:
51+
submodules: recursive
52+
fetch-depth: 1000
53+
- name: Fetch base branch
54+
run: git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF"
55+
- name: Install clang-tidy
56+
run: |
57+
apt-get update
58+
apt-get -y install clang-tidy-12
59+
- name: Prepare environment
60+
shell: bash
61+
env:
62+
SOURCES_DIR: .
63+
run: |
64+
. docker/build.sh
65+
GetGcc
66+
# I guess these already exist inside the docker?
67+
#GetNrfSdk
68+
#GetMcuBoot
69+
CmakeGenerate
70+
- run: tests/test-tidy.sh

.github/workflows/main.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ jobs:
4848
with:
4949
name: InfiniTime MCUBoot image ${{ github.head_ref }}
5050
path: ./build/output/pinetime-mcuboot-app-image-*.bin
51+
- name: Upload resources artifacts
52+
uses: actions/upload-artifact@v3
53+
with:
54+
name: InfiniTime resources ${{ github.head_ref }}
55+
path: ./build/output/infinitime-resources-*.zip
5156

5257
build-simulator:
5358
runs-on: ubuntu-latest
@@ -75,8 +80,9 @@ jobs:
7580
git -C InfiniSim submodule update --init lv_drivers libpng
7681
7782
- name: CMake
83+
# disable BUILD_RESOURCES as this is already done when building the firmware
7884
run: |
79-
cmake -G Ninja -S InfiniSim -B build_lv_sim -DInfiniTime_DIR="${PWD}"
85+
cmake -G Ninja -S InfiniSim -B build_lv_sim -DInfiniTime_DIR="${PWD}" -DBUILD_RESOURCES=OFF
8086
8187
- name: Build simulator executable
8288
run: |

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10)
22

33
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose Debug or Release")
44

5-
project(pinetime VERSION 1.10.0 LANGUAGES C CXX ASM)
5+
project(pinetime VERSION 1.11.0 LANGUAGES C CXX ASM)
66

77
set(CMAKE_C_STANDARD 99)
88
set(CMAKE_CXX_STANDARD 14)

doc/InfiniTimeVision.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ InfiniTime is not to be used for medical or other health tracking purposes.
1717
- Easy and simple navigation
1818
- Behaviour should be predictable and easy to understand
1919
- Prefer solid default experience over customization
20-
- Personalization is achieved through custom watchfaces.
20+
- Personalization is achieved through custom watch faces.
2121
More options may be available through a companion app.
2222
- Use standard protocols and methods
2323

2424
## Long term vision
2525

2626
The perfect version of InfiniTime would include:
2727

28-
- Capability to sideload apps and watchfaces
28+
- Capability to sideload apps and watch faces
2929
- Only a minimal feature set in the flashed firmware.
3030
Users would add the features they want.
3131
- Ports to other devices

doc/MemoryAnalysis.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ void* __wrap_malloc(size_t size) {
245245

246246
Now, your function `__wrap_malloc()` will be called instead of `malloc()`. You can call the actual malloc from the stdlib by calling `__real_malloc()`.
247247

248-
Using this technique, I was able to trace all malloc calls at boot (boot -> digital watchface):
248+
Using this technique, I was able to trace all malloc calls at boot (boot -> digital watch face):
249249

250250
- system task = 3464 bytes (SystemTask could potentially be declared as a global variable to avoid heap allocation here)
251251
- string music = 31 (maybe we should not use std::string when not needed, as it does heap allocation)
Loading
Loading

doc/gettingStarted/gettingStarted-1.0.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ It is highly recommended to update the firmware to the latest version when you r
88

99
### Setting the time
1010

11-
By default, InfiniTime starts on the digital watchface. It'll probably display the epoch time (1 Jan 1970, 00:00).
11+
By default, InfiniTime starts on the digital watch face. It'll probably display the epoch time (1 Jan 1970, 00:00).
1212

1313
You can sync the time using companion apps.
1414

doc/gettingStarted/updating-software.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ If you just want to flash or upgrade InfiniTime on your PineTime, this page is f
44

55
## Checking the version of InfiniTime
66

7-
You can check the InfiniTime version by first swiping right on the watchface to open quick settings, tapping the cogwheel to open settings, swipe up until you find an entry named "About" and tap on it.
7+
You can check the InfiniTime version by first swiping right on the watch face to open quick settings, tapping the cogwheel to open settings, swipe up until you find an entry named "About" and tap on it.
88

99
![InfiniTime 1.0 version](version-1.0.jpg)
1010

@@ -35,7 +35,7 @@ Firmware updates must be manually validated. If the firmware isn't validated and
3535

3636
You can validate your updated firmware on InfiniTime >= 1.0 by following this simple procedure:
3737

38-
- From the watchface, swipe **right** to display the *quick settings menu*
38+
- From the watch face, swipe **right** to display the *quick settings menu*
3939
- Open settings by tapping the cogwheel on the bottom right
4040
- Swipe up until you find an entry named **Firmware** and tap on it
4141
- If the firmware is not validated yet, you can either validate the running firmware, or reset and revert to the previous firmware version

src/components/ble/weather/WeatherData.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ namespace Pinetime {
239239
* In order to represent bursts of wind instead of constant wind,
240240
* you have minimum and maximum speeds.
241241
*
242-
* As direction can fluctuate wildly and some watchfaces might wish to display it nicely,
242+
* As direction can fluctuate wildly and some watch faces might wish to display it nicely,
243243
* we're following the aerospace industry weather report option of specifying a range.
244244
*/
245245
class Wind : public TimelineHeader {
@@ -283,7 +283,7 @@ namespace Pinetime {
283283
* as it usually is, but it could change during a trip for ex.
284284
* so we allow changing it dynamically.
285285
*
286-
* Location info can be for some kind of map watchface
286+
* Location info can be for some kind of map watch face
287287
* or daylight calculations, should those be required.
288288
*
289289
*/
@@ -331,7 +331,7 @@ namespace Pinetime {
331331
*
332332
* These events are a bit more complex because the topic is not simple,
333333
* the intention is to heavy-lift the annoying preprocessing from the watch
334-
* this allows watchface or watchapp makers to generate accurate alerts and graphics
334+
* this allows watch face or watchapp makers to generate accurate alerts and graphics
335335
*
336336
* If this needs further enforced standardization, pull requests are welcome
337337
*/

src/components/settings/Settings.h

+5-8
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ namespace Pinetime {
5353

5454
Settings(Pinetime::Controllers::FS& fs);
5555

56+
Settings(const Settings&) = delete;
57+
Settings& operator=(const Settings&) = delete;
58+
Settings(Settings&&) = delete;
59+
Settings& operator=(Settings&&) = delete;
60+
5661
void Init();
5762
void SaveSettings();
5863

@@ -136,14 +141,6 @@ namespace Pinetime {
136141
appMenu = menu;
137142
};
138143

139-
void SetWatchfacesMenu(uint8_t menu) {
140-
watchFacesMenu = menu;
141-
};
142-
143-
uint8_t GetWatchfacesMenu() const {
144-
return watchFacesMenu;
145-
};
146-
147144
uint8_t GetAppMenu() const {
148145
return appMenu;
149146
};

src/displayapp/DisplayApp.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ using namespace Pinetime::Applications;
5555
using namespace Pinetime::Applications::Display;
5656

5757
namespace {
58-
static inline bool in_isr(void) {
58+
inline bool in_isr() {
5959
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
6060
}
6161
}
@@ -391,7 +391,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
391391
ReturnApp(Apps::QuickSettings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
392392
break;
393393
case Apps::SettingWatchFace:
394-
currentScreen = std::make_unique<Screens::SettingWatchFace>(this, settingsController);
394+
currentScreen = std::make_unique<Screens::SettingWatchFace>(this, settingsController, filesystem);
395395
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
396396
break;
397397
case Apps::SettingTimeFormat:

src/displayapp/screens/CheckboxList.cpp

+21-42
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include "displayapp/screens/CheckboxList.h"
21
#include "displayapp/DisplayApp.h"
2+
#include "displayapp/screens/CheckboxList.h"
33
#include "displayapp/screens/Styles.h"
44

55
using namespace Pinetime::Applications::Screens;
@@ -9,54 +9,26 @@ namespace {
99
CheckboxList* screen = static_cast<CheckboxList*>(obj->user_data);
1010
screen->UpdateSelected(obj, event);
1111
}
12-
1312
}
1413

1514
CheckboxList::CheckboxList(const uint8_t screenID,
1615
const uint8_t numScreens,
1716
DisplayApp* app,
18-
Controllers::Settings& settingsController,
1917
const char* optionsTitle,
2018
const char* optionsSymbol,
21-
void (Controllers::Settings::*SetOptionIndex)(uint8_t),
22-
uint8_t (Controllers::Settings::*GetOptionIndex)() const,
23-
std::array<const char*, MaxItems> options)
19+
uint32_t originalValue,
20+
std::function<void(uint32_t)> OnValueChanged,
21+
std::array<Item, MaxItems> options)
2422
: Screen(app),
2523
screenID {screenID},
26-
settingsController {settingsController},
27-
SetOptionIndex {SetOptionIndex},
28-
GetOptionIndex {GetOptionIndex},
29-
options {options} {
30-
31-
settingsController.SetWatchfacesMenu(screenID);
32-
24+
OnValueChanged {std::move(OnValueChanged)},
25+
options {options},
26+
value {originalValue},
27+
pageIndicator(screenID, numScreens) {
3328
// Set the background to Black
3429
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
3530

36-
if (numScreens > 1) {
37-
pageIndicatorBasePoints[0].x = LV_HOR_RES - 1;
38-
pageIndicatorBasePoints[0].y = 0;
39-
pageIndicatorBasePoints[1].x = LV_HOR_RES - 1;
40-
pageIndicatorBasePoints[1].y = LV_VER_RES;
41-
42-
pageIndicatorBase = lv_line_create(lv_scr_act(), NULL);
43-
lv_obj_set_style_local_line_width(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
44-
lv_obj_set_style_local_line_color(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111));
45-
lv_line_set_points(pageIndicatorBase, pageIndicatorBasePoints.data(), 2);
46-
47-
const uint16_t indicatorSize = LV_VER_RES / numScreens;
48-
const uint16_t indicatorPos = indicatorSize * screenID;
49-
50-
pageIndicatorPoints[0].x = LV_HOR_RES - 1;
51-
pageIndicatorPoints[0].y = indicatorPos;
52-
pageIndicatorPoints[1].x = LV_HOR_RES - 1;
53-
pageIndicatorPoints[1].y = indicatorPos + indicatorSize;
54-
55-
pageIndicator = lv_line_create(lv_scr_act(), NULL);
56-
lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
57-
lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
58-
lv_line_set_points(pageIndicator, pageIndicatorPoints.data(), 2);
59-
}
31+
pageIndicator.Create();
6032

6133
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
6234

@@ -82,14 +54,17 @@ CheckboxList::CheckboxList(const uint8_t screenID,
8254
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
8355

8456
for (unsigned int i = 0; i < options.size(); i++) {
85-
if (strcmp(options[i], "")) {
57+
if (strcmp(options[i].name, "")) {
8658
cbOption[i] = lv_checkbox_create(container1, nullptr);
87-
lv_checkbox_set_text(cbOption[i], options[i]);
59+
lv_checkbox_set_text(cbOption[i], options[i].name);
60+
if (!options[i].enabled) {
61+
lv_checkbox_set_disabled(cbOption[i]);
62+
}
8863
cbOption[i]->user_data = this;
8964
lv_obj_set_event_cb(cbOption[i], event_handler);
9065
SetRadioButtonStyle(cbOption[i]);
9166

92-
if (static_cast<unsigned int>((settingsController.*GetOptionIndex)() - MaxItems * screenID) == i) {
67+
if (static_cast<unsigned int>(originalValue - MaxItems * screenID) == i) {
9368
lv_checkbox_set_checked(cbOption[i], true);
9469
}
9570
}
@@ -98,18 +73,22 @@ CheckboxList::CheckboxList(const uint8_t screenID,
9873

9974
CheckboxList::~CheckboxList() {
10075
lv_obj_clean(lv_scr_act());
76+
OnValueChanged(value);
10177
}
10278

10379
void CheckboxList::UpdateSelected(lv_obj_t* object, lv_event_t event) {
10480
if (event == LV_EVENT_VALUE_CHANGED) {
10581
for (unsigned int i = 0; i < options.size(); i++) {
106-
if (strcmp(options[i], "")) {
82+
if (strcmp(options[i].name, "")) {
10783
if (object == cbOption[i]) {
10884
lv_checkbox_set_checked(cbOption[i], true);
109-
(settingsController.*SetOptionIndex)(MaxItems * screenID + i);
85+
value = MaxItems * screenID + i;
11086
} else {
11187
lv_checkbox_set_checked(cbOption[i], false);
11288
}
89+
if (!options[i].enabled) {
90+
lv_checkbox_set_disabled(cbOption[i]);
91+
}
11392
}
11493
}
11594
}

src/displayapp/screens/CheckboxList.h

+18-21
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,44 @@
11
#pragma once
22

3-
#include <lvgl/lvgl.h>
3+
#include "displayapp/Apps.h"
4+
#include "displayapp/screens/Screen.h"
5+
#include <array>
46
#include <cstdint>
7+
#include <functional>
8+
#include <lvgl/lvgl.h>
59
#include <memory>
6-
#include <array>
7-
#include "displayapp/screens/Screen.h"
8-
#include "displayapp/Apps.h"
9-
#include "components/settings/Settings.h"
10+
#include "displayapp/widgets/PageIndicator.h"
1011

1112
namespace Pinetime {
1213
namespace Applications {
1314
namespace Screens {
1415
class CheckboxList : public Screen {
1516
public:
1617
static constexpr size_t MaxItems = 4;
18+
struct Item {
19+
const char* name;
20+
bool enabled;
21+
};
1722

1823
CheckboxList(const uint8_t screenID,
1924
const uint8_t numScreens,
2025
DisplayApp* app,
21-
Controllers::Settings& settingsController,
2226
const char* optionsTitle,
2327
const char* optionsSymbol,
24-
void (Controllers::Settings::*SetOptionIndex)(uint8_t),
25-
uint8_t (Controllers::Settings::*GetOptionIndex)() const,
26-
std::array<const char*, MaxItems> options);
27-
28+
uint32_t originalValue,
29+
std::function<void(uint32_t)> OnValueChanged,
30+
std::array<Item, MaxItems> options);
2831
~CheckboxList() override;
29-
3032
void UpdateSelected(lv_obj_t* object, lv_event_t event);
3133

3234
private:
3335
const uint8_t screenID;
34-
Controllers::Settings& settingsController;
35-
const char* optionsTitle;
36-
const char* optionsSymbol;
37-
void (Controllers::Settings::*SetOptionIndex)(uint8_t);
38-
uint8_t (Controllers::Settings::*GetOptionIndex)() const;
39-
std::array<const char*, MaxItems> options;
36+
std::function<void(uint32_t)> OnValueChanged;
37+
std::array<Item, MaxItems> options;
4038
std::array<lv_obj_t*, MaxItems> cbOption;
41-
std::array<lv_point_t, 2> pageIndicatorBasePoints;
42-
std::array<lv_point_t, 2> pageIndicatorPoints;
43-
lv_obj_t* pageIndicatorBase;
44-
lv_obj_t* pageIndicator;
39+
uint32_t value;
40+
41+
Widgets::PageIndicator pageIndicator;
4542
};
4643
}
4744
}

0 commit comments

Comments
 (0)