Skip to content

Commit 85415e7

Browse files
authored
Merge branch 'main' into disable_tracking_while_charging
2 parents 71ee078 + 7128fc0 commit 85415e7

File tree

4 files changed

+54
-16
lines changed

4 files changed

+54
-16
lines changed

src/components/timer/Timer.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,33 @@ Timer::Timer(void* const timerData, TimerCallbackFunction_t timerCallbackFunctio
99
void Timer::StartTimer(std::chrono::milliseconds duration) {
1010
xTimerChangePeriod(timer, pdMS_TO_TICKS(duration.count()), 0);
1111
xTimerStart(timer, 0);
12+
expiry = xTimerGetExpiryTime(timer);
13+
triggered = true;
1214
}
1315

14-
std::chrono::milliseconds Timer::GetTimeRemaining() {
16+
// nullopt if timer stopped (StopTimer called / StartTimer not yet called)
17+
// otherwise TimerStatus with the ticks until/since expiry (depending on state of expired flag)
18+
std::optional<Timer::TimerStatus> Timer::GetTimerState() {
1519
if (IsRunning()) {
16-
TickType_t remainingTime = xTimerGetExpiryTime(timer) - xTaskGetTickCount();
17-
return std::chrono::milliseconds(remainingTime * 1000 / configTICK_RATE_HZ);
20+
TickType_t remainingTime = expiry - xTaskGetTickCount();
21+
return std::make_optional<Timer::TimerStatus>(
22+
{.distanceToExpiry = std::chrono::seconds(remainingTime / configTICK_RATE_HZ) +
23+
std::chrono::milliseconds((remainingTime % configTICK_RATE_HZ) * 1000 / configTICK_RATE_HZ),
24+
.expired = false});
1825
}
19-
return std::chrono::milliseconds(0);
26+
if (triggered) {
27+
TickType_t timeSinceExpiry = xTaskGetTickCount() - expiry;
28+
return std::make_optional<Timer::TimerStatus>(
29+
{.distanceToExpiry = std::chrono::seconds(timeSinceExpiry / configTICK_RATE_HZ) +
30+
std::chrono::milliseconds((timeSinceExpiry % configTICK_RATE_HZ) * 1000 / configTICK_RATE_HZ),
31+
.expired = true});
32+
}
33+
return std::nullopt;
2034
}
2135

2236
void Timer::StopTimer() {
2337
xTimerStop(timer, 0);
38+
triggered = false;
2439
}
2540

2641
bool Timer::IsRunning() {

src/components/timer/Timer.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,31 @@
44
#include <timers.h>
55

66
#include <chrono>
7+
#include <optional>
78

89
namespace Pinetime {
910
namespace Controllers {
1011
class Timer {
1112
public:
13+
struct TimerStatus {
14+
std::chrono::milliseconds distanceToExpiry;
15+
bool expired;
16+
};
17+
1218
Timer(void* timerData, TimerCallbackFunction_t timerCallbackFunction);
1319

1420
void StartTimer(std::chrono::milliseconds duration);
1521

1622
void StopTimer();
1723

18-
std::chrono::milliseconds GetTimeRemaining();
24+
std::optional<TimerStatus> GetTimerState();
1925

2026
bool IsRunning();
2127

2228
private:
2329
TimerHandle_t timer;
30+
TickType_t expiry;
31+
bool triggered = false;
2432
};
2533
}
2634
}

src/displayapp/screens/FirmwareValidation.cpp

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "components/firmwarevalidator/FirmwareValidator.h"
55
#include "displayapp/DisplayApp.h"
66
#include "displayapp/InfiniTimeTheme.h"
7+
#include "displayapp/screens/Symbols.h"
78

89
using namespace Pinetime::Applications::Screens;
910

@@ -15,27 +16,40 @@ namespace {
1516
}
1617

1718
FirmwareValidation::FirmwareValidation(Pinetime::Controllers::FirmwareValidator& validator) : validator {validator} {
19+
lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
20+
lv_label_set_text_static(title, "Firmware");
21+
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
22+
lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 10, 15);
23+
24+
lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
25+
lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
26+
lv_label_set_text_static(icon, Symbols::check);
27+
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
28+
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
29+
1830
labelVersion = lv_label_create(lv_scr_act(), nullptr);
31+
lv_label_set_recolor(labelVersion, true);
1932
lv_label_set_text_fmt(labelVersion,
20-
"Version: %lu.%lu.%lu\n"
21-
"ShortRef: %s",
33+
"#808080 Version# %lu.%lu.%lu\n"
34+
"#808080 Short Ref# %s\n",
2235
Version::Major(),
2336
Version::Minor(),
2437
Version::Patch(),
2538
Version::GitCommitHash());
26-
lv_obj_align(labelVersion, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
39+
lv_obj_align(labelVersion, nullptr, LV_ALIGN_CENTER, 0, -40);
40+
lv_label_set_align(labelVersion, LV_LABEL_ALIGN_CENTER);
2741

2842
labelIsValidated = lv_label_create(lv_scr_act(), nullptr);
29-
lv_obj_align(labelIsValidated, labelVersion, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
43+
lv_obj_align(labelIsValidated, nullptr, LV_ALIGN_CENTER, 0, 10);
44+
lv_label_set_align(labelIsValidated, LV_LABEL_ALIGN_CENTER);
45+
lv_obj_set_auto_realign(labelIsValidated, true);
3046
lv_label_set_recolor(labelIsValidated, true);
31-
lv_label_set_long_mode(labelIsValidated, LV_LABEL_LONG_BREAK);
32-
lv_obj_set_width(labelIsValidated, 240);
3347

3448
if (validator.IsValidated()) {
35-
lv_label_set_text_static(labelIsValidated, "You have already\n#00ff00 validated# this firmware#");
49+
lv_label_set_text_static(labelIsValidated, "This firmware has\nbeen #00ff00 validated#");
50+
lv_obj_align(labelIsValidated, nullptr, LV_ALIGN_CENTER, 0, 10);
3651
} else {
37-
lv_label_set_text_static(labelIsValidated,
38-
"Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version.");
52+
lv_label_set_text_static(labelIsValidated, "Any reboot will\nrollback to last\nvalidated firmware");
3953

4054
buttonValidate = lv_btn_create(lv_scr_act(), nullptr);
4155
buttonValidate->user_data = this;
@@ -55,7 +69,7 @@ FirmwareValidation::FirmwareValidation(Pinetime::Controllers::FirmwareValidator&
5569
lv_obj_set_event_cb(buttonReset, ButtonEventHandler);
5670

5771
labelButtonReset = lv_label_create(buttonReset, nullptr);
58-
lv_label_set_text_static(labelButtonReset, "Reset");
72+
lv_label_set_text_static(labelButtonReset, "Rollback");
5973
}
6074
}
6175

src/displayapp/screens/Timer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ void Timer::Refresh() {
118118
}
119119

120120
void Timer::DisplayTime() {
121-
displaySeconds = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
121+
displaySeconds =
122+
std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimerState().value_or(Controllers::Timer::TimerStatus {}).distanceToExpiry);
122123
if (displaySeconds.IsUpdated()) {
123124
minuteCounter.SetValue(displaySeconds.Get().count() / 60);
124125
secondCounter.SetValue(displaySeconds.Get().count() % 60);

0 commit comments

Comments
 (0)