Skip to content

Commit 21d37d1

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into timer_battery_reading
2 parents 085c9ab + 6c02378 commit 21d37d1

80 files changed

Lines changed: 686 additions & 313 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ list(APPEND SOURCE_FILES
418418
displayapp/screens/BatteryInfo.cpp
419419
displayapp/screens/Steps.cpp
420420
displayapp/screens/Timer.cpp
421+
displayapp/Colors.cpp
421422

422423
## Settings
423424
displayapp/screens/settings/QuickSettings.cpp
@@ -427,6 +428,7 @@ list(APPEND SOURCE_FILES
427428
displayapp/screens/settings/SettingWakeUp.cpp
428429
displayapp/screens/settings/SettingDisplay.cpp
429430
displayapp/screens/settings/SettingSteps.cpp
431+
displayapp/screens/settings/SettingPineTimeStyle.cpp
430432

431433
## Watch faces
432434
displayapp/icons/bg_clock.c
@@ -610,6 +612,7 @@ set(INCLUDE_FILES
610612
displayapp/screens/Metronome.h
611613
displayapp/screens/Motion.h
612614
displayapp/screens/Timer.h
615+
displayapp/Colors.h
613616
drivers/St7789.h
614617
drivers/SpiNorFlash.h
615618
drivers/SpiMaster.h

src/components/settings/Settings.h

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ namespace Pinetime {
1717
DoubleTap = 1,
1818
RaiseWrist = 2,
1919
};
20+
enum class Colors : uint8_t {
21+
White, Silver, Gray, Black, Red, Maroon, Yellow, Olive, Lime, Green, Cyan, Teal, Blue, Navy, Magenta, Purple, Orange
22+
};
23+
struct PineTimeStyle {
24+
Colors ColorTime = Colors::Teal;
25+
Colors ColorBar = Colors::Teal;
26+
Colors ColorBG = Colors::Black;
27+
};
2028

2129
Settings(Pinetime::Controllers::FS& fs);
2230

@@ -33,10 +41,38 @@ namespace Pinetime {
3341
return settings.clockFace;
3442
};
3543

44+
void SetPTSColorTime(Colors colorTime) {
45+
if (colorTime != settings.PTS.ColorTime)
46+
settingsChanged = true;
47+
settings.PTS.ColorTime = colorTime;
48+
};
49+
Colors GetPTSColorTime() const {
50+
return settings.PTS.ColorTime;
51+
};
52+
53+
void SetPTSColorBar(Colors colorBar) {
54+
if (colorBar != settings.PTS.ColorBar)
55+
settingsChanged = true;
56+
settings.PTS.ColorBar = colorBar;
57+
};
58+
Colors GetPTSColorBar() const {
59+
return settings.PTS.ColorBar;
60+
};
61+
62+
void SetPTSColorBG(Colors colorBG) {
63+
if (colorBG != settings.PTS.ColorBG)
64+
settingsChanged = true;
65+
settings.PTS.ColorBG = colorBG;
66+
};
67+
Colors GetPTSColorBG() const {
68+
return settings.PTS.ColorBG;
69+
};
70+
3671
void SetAppMenu(uint8_t menu) {
3772
appMenu = menu;
3873
};
39-
uint8_t GetAppMenu() {
74+
75+
uint8_t GetAppMenu() const {
4076
return appMenu;
4177
};
4278

@@ -127,9 +163,8 @@ namespace Pinetime {
127163
private:
128164
Pinetime::Controllers::FS& fs;
129165

130-
static constexpr uint32_t settingsVersion = 0x0001;
166+
static constexpr uint32_t settingsVersion = 0x0002;
131167
struct SettingsData {
132-
133168
uint32_t version = settingsVersion;
134169
uint32_t stepsGoal = 10000;
135170
uint32_t screenTimeOut = 15000;
@@ -139,6 +174,8 @@ namespace Pinetime {
139174

140175
uint8_t clockFace = 0;
141176

177+
PineTimeStyle PTS;
178+
142179
std::bitset<3> wakeUpMode {0};
143180

144181
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;

src/displayapp/Apps.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ namespace Pinetime {
3030
SettingTimeFormat,
3131
SettingDisplay,
3232
SettingWakeUp,
33-
SettingSteps
33+
SettingSteps,
34+
SettingPineTimeStyle
3435
};
3536
}
3637
}

src/displayapp/Colors.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include "Colors.h"
2+
3+
using namespace Pinetime::Applications;
4+
using namespace Pinetime::Controllers;
5+
6+
lv_color_t Pinetime::Applications::Convert(Pinetime::Controllers::Settings::Colors color) {
7+
switch (color) {
8+
case Pinetime::Controllers::Settings::Colors::White: return LV_COLOR_WHITE;
9+
case Pinetime::Controllers::Settings::Colors::Silver: return LV_COLOR_SILVER;
10+
case Pinetime::Controllers::Settings::Colors::Gray: return LV_COLOR_GRAY;
11+
case Pinetime::Controllers::Settings::Colors::Black: return LV_COLOR_BLACK;
12+
case Pinetime::Controllers::Settings::Colors::Red: return LV_COLOR_RED;
13+
case Pinetime::Controllers::Settings::Colors::Maroon: return LV_COLOR_MAROON;
14+
case Pinetime::Controllers::Settings::Colors::Yellow: return LV_COLOR_YELLOW;
15+
case Pinetime::Controllers::Settings::Colors::Olive: return LV_COLOR_OLIVE;
16+
case Pinetime::Controllers::Settings::Colors::Lime: return LV_COLOR_LIME;
17+
case Pinetime::Controllers::Settings::Colors::Green: return LV_COLOR_GREEN;
18+
case Pinetime::Controllers::Settings::Colors::Cyan: return LV_COLOR_CYAN;
19+
case Pinetime::Controllers::Settings::Colors::Teal: return LV_COLOR_TEAL;
20+
case Pinetime::Controllers::Settings::Colors::Blue: return LV_COLOR_BLUE;
21+
case Pinetime::Controllers::Settings::Colors::Navy: return LV_COLOR_NAVY;
22+
case Pinetime::Controllers::Settings::Colors::Magenta: return LV_COLOR_MAGENTA;
23+
case Pinetime::Controllers::Settings::Colors::Purple: return LV_COLOR_PURPLE;
24+
case Pinetime::Controllers::Settings::Colors::Orange: return LV_COLOR_ORANGE;
25+
default: return LV_COLOR_WHITE;
26+
}
27+
}

src/displayapp/Colors.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
3+
#include <lvgl/src/lv_misc/lv_color.h>
4+
#include <components/settings/Settings.h>
5+
6+
namespace Pinetime {
7+
namespace Applications {
8+
lv_color_t Convert(Controllers::Settings::Colors color);
9+
}
10+
}

src/displayapp/DisplayApp.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "displayapp/screens/settings/SettingWakeUp.h"
4343
#include "displayapp/screens/settings/SettingDisplay.h"
4444
#include "displayapp/screens/settings/SettingSteps.h"
45+
#include "displayapp/screens/settings/SettingPineTimeStyle.h"
4546

4647
#include "libs/lv_conf.h"
4748

@@ -272,7 +273,7 @@ void DisplayApp::Refresh() {
272273
}
273274

274275
void DisplayApp::RunningState() {
275-
if (!currentScreen->Refresh()) {
276+
if (!currentScreen->IsRunning()) {
276277
LoadApp(returnToApp, returnDirection);
277278
}
278279
lv_task_handler();
@@ -367,6 +368,10 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
367368
currentScreen = std::make_unique<Screens::SettingSteps>(this, settingsController);
368369
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
369370
break;
371+
case Apps::SettingPineTimeStyle:
372+
currentScreen = std::make_unique<Screens::SettingPineTimeStyle>(this, settingsController);
373+
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
374+
break;
370375
case Apps::BatteryInfo:
371376
currentScreen = std::make_unique<Screens::BatteryInfo>(this, batteryController);
372377
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);

src/displayapp/screens/ApplicationList.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ ApplicationList::~ApplicationList() {
3434
lv_obj_clean(lv_scr_act());
3535
}
3636

37-
bool ApplicationList::Refresh() {
38-
if (running)
39-
running = screens.Refresh();
40-
return running;
41-
}
42-
4337
bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
4438
return screens.OnTouchEvent(event);
4539
}

src/displayapp/screens/ApplicationList.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ namespace Pinetime {
1818
Pinetime::Controllers::Battery& batteryController,
1919
Controllers::DateTime& dateTimeController);
2020
~ApplicationList() override;
21-
bool Refresh() override;
2221
bool OnTouchEvent(TouchEvents event) override;
2322

2423
private:
@@ -33,4 +32,4 @@ namespace Pinetime {
3332
};
3433
}
3534
}
36-
}
35+
}

src/displayapp/screens/BatteryInfo.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44

55
using namespace Pinetime::Applications::Screens;
66

7-
static void lv_update_task(struct _lv_task_t* task) {
8-
auto user_data = static_cast<BatteryInfo*>(task->user_data);
9-
user_data->UpdateScreen();
10-
}
11-
127
BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Battery& batteryController)
138
: Screen(app), batteryController {batteryController} {
149

@@ -49,16 +44,17 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont
4944
lv_obj_set_pos(backgroundLabel, 0, 0);
5045
lv_label_set_text_static(backgroundLabel, "");
5146

52-
taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_LOW, this);
53-
UpdateScreen();
47+
taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this);
48+
Refresh();
5449
}
5550

5651
BatteryInfo::~BatteryInfo() {
57-
lv_task_del(taskUpdate);
52+
lv_task_del(taskRefresh);
5853
lv_obj_clean(lv_scr_act());
5954
}
6055

61-
void BatteryInfo::UpdateScreen() {
56+
void BatteryInfo::Refresh() {
57+
6258
batteryPercent = batteryController.PercentRemaining();
6359
batteryVoltage = batteryController.Voltage();
6460

@@ -82,7 +78,3 @@ void BatteryInfo::UpdateScreen() {
8278
lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10);
8379
lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON);
8480
}
85-
86-
bool BatteryInfo::Refresh() {
87-
return running;
88-
}

src/displayapp/screens/BatteryInfo.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ namespace Pinetime {
1919
BatteryInfo(DisplayApp* app, Pinetime::Controllers::Battery& batteryController);
2020
~BatteryInfo() override;
2121

22-
bool Refresh() override;
23-
24-
void UpdateScreen();
22+
void Refresh() override;
2523

2624
private:
2725
Pinetime::Controllers::Battery& batteryController;
@@ -31,7 +29,7 @@ namespace Pinetime {
3129
lv_obj_t* charging_bar;
3230
lv_obj_t* status;
3331

34-
lv_task_t* taskUpdate;
32+
lv_task_t* taskRefresh;
3533

3634
uint8_t batteryPercent = 0;
3735
uint16_t batteryVoltage = 0;

0 commit comments

Comments
 (0)