Skip to content

Commit 1986a5d

Browse files
committed
Merge branch 'battery_app_redesign_fixup' of github.com:tituscmd/InfiniTime into battery_app_redesign_fixup
2 parents d270ceb + e722d40 commit 1986a5d

10 files changed

Lines changed: 47 additions & 27 deletions

File tree

.github/workflows/main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ jobs:
3939
apt-get -y install --no-install-recommends python3-pil
4040
- name: Build
4141
shell: bash
42-
run: /opt/build.sh all
42+
run: |
43+
git config --global --add safe.directory /__w/InfiniTime/InfiniTime
44+
/opt/build.sh all
4345
- name: Output build size
4446
id: output-sizes
47+
shell: bash
4548
run: |
4649
. /opt/build.sh
4750
.github/workflows/getSize.sh "$BUILD_DIR"/src/pinetime-app-*.out >> $GITHUB_OUTPUT
@@ -159,6 +162,7 @@ jobs:
159162

160163
- name: Output build size
161164
id: output-sizes
165+
shell: bash
162166
run: |
163167
. /opt/build.sh
164168
.github/workflows/getSize.sh "$BUILD_DIR"/src/pinetime-app-*.out >> $GITHUB_OUTPUT

doc/buildAndProgram.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
To build this project, you'll need:
66

77
- A cross-compiler : [ARM-GCC (10.3-2021.10)](https://developer.arm.com/downloads/-/gnu-rm)
8-
- 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)
8+
- The NRF52 SDK 15.3.0 : [nRF-SDK v15.3.0](https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/sdks/nrf5/binaries/nrf5sdk153059ac345.zip)
99
- The Python 3 modules `cbor`, `intelhex`, `click` and `cryptography` modules for the `mcuboot` tool (see [requirements.txt](../tools/mcuboot/requirements.txt))
1010
- To keep the system clean, you can install python modules into a python virtual environment (`venv`)
1111
```sh

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ RUN apt-get update -qq \
3333
libpixman-1-dev \
3434
libcairo2-dev \
3535
libpango-1.0-0 \
36-
ibpango1.0-dev \
36+
libpango1.0-dev \
3737
libpangocairo-1.0-0 \
3838
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/*;
3939

docker/build.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export npm_config_cache="${NPM_DIR}"
1818
export BUILD_TYPE=${BUILD_TYPE:=Release}
1919
export GCC_ARM_VER=${GCC_ARM_VER:="10.3-2021.10"}
2020
export NRF_SDK_VER=${NRF_SDK_VER:="nRF5_SDK_15.3.0_59ac345"}
21+
# convert to lower case and remove _ and . character
22+
# the download URL uses the SLUG, but the extracted folder is named like the original value
23+
NRF_SDK_VER_SLUG=${NRF_SDK_VER,,}
24+
export NRF_SDK_VER_SLUG=${NRF_SDK_VER_SLUG//[_.]/}
2125

2226
MACHINE="$(uname -m)"
2327
[ "$MACHINE" = "arm64" ] && MACHINE="aarch64"
@@ -47,17 +51,29 @@ main() {
4751

4852
GetGcc() {
4953
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/$GCC_ARM_VER/$GCC_ARM_PATH-$MACHINE-linux.tar.bz2 -O - | tar -xj -C $TOOLS_DIR/
54+
if [ ! -d "$TOOLS_DIR/$GCC_ARM_PATH" ]; then
55+
echo "missing GCC path: $TOOLS_DIR/$GCC_ARM_PATH"
56+
return 1
57+
fi
5058
}
5159

5260
GetMcuBoot() {
5361
git clone https://github.com/mcu-tools/mcuboot.git "$TOOLS_DIR/mcuboot"
5462
pip3 install -r "$TOOLS_DIR/mcuboot/scripts/requirements.txt"
63+
if [ ! -d "$TOOLS_DIR/mcuboot" ]; then
64+
echo "missing mcuboot path: $TOOLS_DIR/mcuboot"
65+
return 1
66+
fi
5567
}
5668

5769
GetNrfSdk() {
58-
wget -q "https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/$NRF_SDK_VER.zip" -O /tmp/$NRF_SDK_VER
70+
wget -q "https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/sdks/nrf5/binaries/$NRF_SDK_VER_SLUG.zip" -O /tmp/$NRF_SDK_VER
5971
unzip -q /tmp/$NRF_SDK_VER -d "$TOOLS_DIR/"
6072
rm /tmp/$NRF_SDK_VER
73+
if [ ! -d "$TOOLS_DIR/$NRF_SDK_VER" ]; then
74+
echo "missing NRF_SDK path: $TOOLS_DIR/$NRF_SDK_VER"
75+
return 1
76+
fi
6177
}
6278

6379
CmakeGenerate() {

src/components/ble/NotificationManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace Pinetime {
2828
using Id = uint8_t;
2929
using Idx = uint8_t;
3030

31-
std::array<char, MessageSize + 1> message;
31+
std::array<char, MessageSize + 1> message{};
3232
uint8_t size;
3333
Categories category = Categories::Unknown;
3434
Id id = 0;

src/displayapp/DisplayApp.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
#include "libs/lv_conf.h"
5555
#include "UserApps.h"
5656

57+
#include <algorithm>
58+
5759
using namespace Pinetime::Applications;
5860
using namespace Pinetime::Applications::Display;
5961

@@ -516,10 +518,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
516518
switch (app) {
517519
case Apps::Launcher: {
518520
std::array<Screens::Tile::Applications, UserAppTypes::Count> apps;
519-
int i = 0;
520-
for (const auto& userApp : userApps) {
521-
apps[i++] = Screens::Tile::Applications {userApp.icon, userApp.app, true};
522-
}
521+
std::ranges::transform(userApps, apps.begin(), [](const auto& userApp) {
522+
return Screens::Tile::Applications {userApp.icon, userApp.app, true};
523+
});
523524
currentScreen = std::make_unique<Screens::ApplicationList>(this,
524525
settingsController,
525526
batteryController,
@@ -530,13 +531,12 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
530531
std::move(apps));
531532
} break;
532533
case Apps::Clock: {
533-
const auto* watchFace =
534-
std::find_if(userWatchFaces.begin(), userWatchFaces.end(), [this](const WatchFaceDescription& watchfaceDescription) {
535-
return watchfaceDescription.watchFace == settingsController.GetWatchFace();
536-
});
537-
if (watchFace != userWatchFaces.end())
534+
const auto* watchFace = std::ranges::find_if(userWatchFaces, [this](const WatchFaceDescription& watchfaceDescription) {
535+
return watchfaceDescription.watchFace == settingsController.GetWatchFace();
536+
});
537+
if (watchFace != userWatchFaces.end()) {
538538
currentScreen.reset(watchFace->create(controllers));
539-
else {
539+
} else {
540540
currentScreen.reset(userWatchFaces[0].create(controllers));
541541
}
542542
settingsController.SetAppMenu(0);
@@ -587,11 +587,11 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
587587
break;
588588
case Apps::SettingWatchFace: {
589589
std::array<Screens::SettingWatchFace::Item, UserWatchFaceTypes::Count> items;
590-
int i = 0;
591-
for (const auto& userWatchFace : userWatchFaces) {
592-
items[i++] =
593-
Screens::SettingWatchFace::Item {userWatchFace.name, userWatchFace.watchFace, userWatchFace.isAvailable(controllers.filesystem)};
594-
}
590+
std::ranges::transform(userWatchFaces, items.begin(), [this](const WatchFaceDescription& userWatchFace) {
591+
return Screens::SettingWatchFace::Item {userWatchFace.name,
592+
userWatchFace.watchFace,
593+
userWatchFace.isAvailable(controllers.filesystem)};
594+
});
595595
currentScreen = std::make_unique<Screens::SettingWatchFace>(this, std::move(items), settingsController, filesystem);
596596
} break;
597597
case Apps::SettingTimeFormat:
@@ -639,7 +639,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
639639
currentScreen = std::make_unique<Screens::FlashLight>(*systemTask, brightnessController);
640640
break;
641641
default: {
642-
const auto* d = std::find_if(userApps.begin(), userApps.end(), [app](const AppDescription& appDescription) {
642+
const auto* d = std::ranges::find_if(userApps, [app](const AppDescription& appDescription) {
643643
return appDescription.app == app;
644644
});
645645
if (d != userApps.end()) {

src/displayapp/screens/WatchFaceInfineat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ WatchFaceInfineat::~WatchFaceInfineat() {
316316
bool WatchFaceInfineat::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
317317
if ((event == Pinetime::Applications::TouchEvents::LongTap) && lv_obj_get_hidden(btnSettings)) {
318318
lv_obj_set_hidden(btnSettings, false);
319-
savedTick = lv_tick_get();
319+
savedTick = xTaskGetTickCount();
320320
return true;
321321
}
322322
// Prevent screen from sleeping when double tapping with settings on
@@ -463,7 +463,7 @@ void WatchFaceInfineat::Refresh() {
463463
}
464464

465465
if (!lv_obj_get_hidden(btnSettings)) {
466-
if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) {
466+
if ((savedTick > 0) && (xTaskGetTickCount() - savedTick > pdMS_TO_TICKS(3000))) {
467467
lv_obj_set_hidden(btnSettings, true);
468468
savedTick = 0;
469469
}

src/displayapp/screens/WatchFaceInfineat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ namespace Pinetime {
4545
static bool IsAvailable(Pinetime::Controllers::FS& filesystem);
4646

4747
private:
48-
uint32_t savedTick = 0;
4948
uint8_t chargingBatteryPercent = 101; // not a mistake ;)
49+
TickType_t savedTick = 0;
5050
TickType_t chargingAnimationTick = 0;
5151

5252
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};

src/displayapp/screens/WatchFacePineTimeStyle.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ bool WatchFacePineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents ev
407407
if ((event == Pinetime::Applications::TouchEvents::LongTap) && lv_obj_get_hidden(btnClose)) {
408408
lv_obj_set_hidden(btnSetColor, false);
409409
lv_obj_set_hidden(btnSetOpts, false);
410-
savedTick = lv_tick_get();
410+
savedTick = xTaskGetTickCount();
411411
return true;
412412
}
413413
if ((event == Pinetime::Applications::TouchEvents::DoubleTap) && (lv_obj_get_hidden(btnClose) == false)) {
@@ -558,7 +558,7 @@ void WatchFacePineTimeStyle::Refresh() {
558558
}
559559

560560
if (!lv_obj_get_hidden(btnSetColor)) {
561-
if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) {
561+
if ((savedTick > 0) && (xTaskGetTickCount() - savedTick > pdMS_TO_TICKS(3000))) {
562562
lv_obj_set_hidden(btnSetColor, true);
563563
lv_obj_set_hidden(btnSetOpts, true);
564564
savedTick = 0;

src/displayapp/screens/WatchFacePineTimeStyle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace Pinetime {
5252
Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
5353
Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
5454
uint8_t currentDay = 0;
55-
uint32_t savedTick = 0;
55+
TickType_t savedTick = 0;
5656

5757
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
5858
Utility::DirtyValue<bool> isCharging {};

0 commit comments

Comments
 (0)