Skip to content

Commit 85d4456

Browse files
committed
StarTrek watchface
1 parent 2105a7b commit 85d4456

File tree

20 files changed

+1357
-5
lines changed

20 files changed

+1357
-5
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ list(APPEND SOURCE_FILES
426426
displayapp/screens/WatchFaceTerminal.cpp
427427
displayapp/screens/WatchFacePineTimeStyle.cpp
428428
displayapp/screens/WatchFaceCasioStyleG7710.cpp
429+
displayapp/screens/WatchFaceStarTrek.cpp
429430

430431
##
431432

src/components/settings/Settings.h

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ namespace Pinetime {
3636
};
3737
enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric };
3838
enum class PTSWeather : uint8_t { On, Off };
39+
enum class StarTrekAnimateType { None, Start, Continuous, All };
3940

4041
struct PineTimeStyle {
4142
Colors ColorTime = Colors::Teal;
@@ -50,6 +51,13 @@ namespace Pinetime {
5051
int colorIndex = 0;
5152
};
5253

54+
struct WatchFaceStarTrek {
55+
bool useSystemFont = false;
56+
StarTrekAnimateType animate = StarTrekAnimateType::All;
57+
bool displaySeconds = false;
58+
bool weather = true;
59+
};
60+
5361
Settings(Pinetime::Controllers::FS& fs);
5462

5563
Settings(const Settings&) = delete;
@@ -154,6 +162,50 @@ namespace Pinetime {
154162
return settings.PTS.weatherEnable;
155163
};
156164

165+
bool GetStarTrekUseSystemFont() const {
166+
return settings.watchFaceStarTrek.useSystemFont;
167+
};
168+
169+
void SetStarTrekUseSystemFont(bool useSystemFont) {
170+
if (useSystemFont != settings.watchFaceStarTrek.useSystemFont) {
171+
settings.watchFaceStarTrek.useSystemFont = useSystemFont;
172+
settingsChanged = true;
173+
}
174+
};
175+
176+
StarTrekAnimateType GetStarTrekAnimate() const {
177+
return settings.watchFaceStarTrek.animate;
178+
};
179+
180+
void SetStarTrekAnimate(StarTrekAnimateType animate) {
181+
if (animate != settings.watchFaceStarTrek.animate) {
182+
settings.watchFaceStarTrek.animate = animate;
183+
settingsChanged = true;
184+
}
185+
};
186+
187+
bool GetStarTrekDisplaySeconds() const {
188+
return settings.watchFaceStarTrek.displaySeconds;
189+
};
190+
191+
void SetStarTrekDisplaySeconds(bool displaySeconds) {
192+
if (displaySeconds != settings.watchFaceStarTrek.displaySeconds) {
193+
settings.watchFaceStarTrek.displaySeconds = displaySeconds;
194+
settingsChanged = true;
195+
}
196+
};
197+
198+
bool GetStarTrekWeather() const {
199+
return settings.watchFaceStarTrek.weather;
200+
};
201+
202+
void SetStarTrekWeather(bool weather) {
203+
if (weather != settings.watchFaceStarTrek.weather) {
204+
settings.watchFaceStarTrek.weather = weather;
205+
settingsChanged = true;
206+
}
207+
};
208+
157209
void SetAppMenu(uint8_t menu) {
158210
appMenu = menu;
159211
};
@@ -301,7 +353,7 @@ namespace Pinetime {
301353
private:
302354
Pinetime::Controllers::FS& fs;
303355

304-
static constexpr uint32_t settingsVersion = 0x0008;
356+
static constexpr uint32_t settingsVersion = 0x0009;
305357

306358
struct SettingsData {
307359
uint32_t version = settingsVersion;
@@ -321,6 +373,8 @@ namespace Pinetime {
321373

322374
WatchFaceInfineat watchFaceInfineat;
323375

376+
WatchFaceStarTrek watchFaceStarTrek;
377+
324378
std::bitset<5> wakeUpMode {0};
325379
uint16_t shakeWakeThreshold = 150;
326380

src/displayapp/DisplayApp.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,19 @@ void DisplayApp::Refresh() {
324324
// display activity timer causing the screen to never sleep after timeout
325325
lvgl.ClearTouchState();
326326
if (msg == Messages::GoToAOD) {
327+
currentScreen->OnLCDSleep(true); // prepare for low power while still fast
328+
lv_task_handler();
329+
vTaskDelay(100);
327330
lcd.LowPowerOn();
328331
// Record idle entry time
329332
alwaysOnFrameCount = 0;
330333
alwaysOnStartTime = xTaskGetTickCount();
331334
PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskAOD);
332335
state = States::AOD;
333336
} else {
337+
currentScreen->OnLCDSleep(false);
338+
lv_task_handler(); // call to update display, will not be called again in Idle mode
339+
vTaskDelay(100); // give time for display refresh
334340
lcd.Sleep();
335341
PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping);
336342
state = States::Idle;
@@ -354,6 +360,7 @@ void DisplayApp::Refresh() {
354360
lv_disp_trig_activity(nullptr);
355361
ApplyBrightness();
356362
state = States::Running;
363+
currentScreen->OnLCDWakeup(settingsController.GetAlwaysOnDisplay());
357364
break;
358365
case Messages::UpdateBleConnection:
359366
// Only used for recovery firmware

src/displayapp/UserApps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "displayapp/screens/WatchFaceInfineat.h"
1515
#include "displayapp/screens/WatchFacePineTimeStyle.h"
1616
#include "displayapp/screens/WatchFaceTerminal.h"
17+
#include "displayapp/screens/WatchFaceStarTrek.h"
1718

1819
namespace Pinetime {
1920
namespace Applications {

src/displayapp/apps/Apps.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ namespace Pinetime {
5252
Terminal,
5353
Infineat,
5454
CasioStyleG7710,
55+
StarTrek,
5556
};
5657

5758
template <Apps>

src/displayapp/apps/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ else()
2727
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Terminal")
2828
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Infineat")
2929
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::CasioStyleG7710")
30+
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::StarTrek")
3031
set(WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}" CACHE STRING "List of watch faces to build into the firmware")
3132
endif()
3233

src/displayapp/fonts/fonts.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
{
99
"file": "FontAwesome5-Solid+Brands+Regular.woff",
1010
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf0f3, 0xf522, 0xf743"
11+
},
12+
{
13+
"file": "material-design-icons/MaterialIcons-Regular.ttf",
14+
"range": "0xe7f6, 0xef44"
1115
}
1216
],
1317
"bpp": 1,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "lvgl/lvgl.h"
2+
3+
#ifndef LV_ATTRIBUTE_MEM_ALIGN
4+
#define LV_ATTRIBUTE_MEM_ALIGN
5+
#endif
6+
7+
#ifndef LV_ATTRIBUTE_IMG_BRACKET_LEFT
8+
#define LV_ATTRIBUTE_IMG_BRACKET_LEFT
9+
#endif
10+
11+
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_BRACKET_LEFT uint8_t bracket_left_map[] = {
12+
0x00, 0x00, 0x00, 0xff, /*Color of index 0*/
13+
0x10, 0x5d, 0xd5, 0xff, /*Color of index 1*/
14+
0xfe, 0xdd, 0x82, 0xff, /*Color of index 2*/
15+
0x6b, 0x61, 0x4a, 0xff, /*Color of index 3*/
16+
17+
0x00, 0xaa, 0xaa, 0xaa, 0x02, 0xaa, 0xaa, 0xaa, 0x02, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xaa, 0xa8, 0x00, 0x00, 0xaa, 0xa8,
18+
0x00, 0x00, 0xaa, 0xa8, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00,
19+
0x00, 0x00, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x03, 0xfc,
20+
0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x54, 0x00, 0x00, 0x01, 0x54, 0x00, 0x00, 0x01, 0x54, 0x00, 0x00,
21+
0x01, 0x54, 0x00, 0x00, 0x01, 0x54, 0x00, 0x00, 0x01, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0x02, 0xa8,
22+
0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0xaa, 0xa8, 0x00, 0x00, 0xaa, 0xa8, 0x00, 0x00,
23+
0xaa, 0xa8, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x02, 0xaa, 0xaa, 0xaa, 0x02, 0xaa, 0xaa, 0xaa, 0x00, 0xaa, 0xaa, 0xaa,
24+
};
25+
26+
const lv_img_dsc_t bracket_left = {{LV_IMG_CF_INDEXED_2BIT, 0, 0, 16, 38}, 168, bracket_left_map};
Loading
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "lvgl/lvgl.h"
2+
3+
#ifndef LV_ATTRIBUTE_MEM_ALIGN
4+
#define LV_ATTRIBUTE_MEM_ALIGN
5+
#endif
6+
7+
#ifndef LV_ATTRIBUTE_IMG_BRACKET_RIGHT
8+
#define LV_ATTRIBUTE_IMG_BRACKET_RIGHT
9+
#endif
10+
11+
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_BRACKET_RIGHT uint8_t bracket_right_map[] = {
12+
0x00, 0x00, 0x00, 0xff, /*Color of index 0*/
13+
0x10, 0x5d, 0xd5, 0xff, /*Color of index 1*/
14+
0xfe, 0xdd, 0x82, 0xff, /*Color of index 2*/
15+
0x6b, 0x61, 0x4a, 0xff, /*Color of index 3*/
16+
17+
0xaa, 0xaa, 0xaa, 0x00, 0xaa, 0xaa, 0xaa, 0x80, 0xaa, 0xaa, 0xaa, 0x80, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x2a, 0xaa, 0x00, 0x00,
18+
0x2a, 0xaa, 0x00, 0x00, 0x2a, 0xaa, 0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x2a, 0x80,
19+
0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x40, 0x00, 0x00, 0x15, 0x40, 0x00, 0x00, 0x15, 0x40, 0x00, 0x00,
20+
0x15, 0x40, 0x00, 0x00, 0x15, 0x40, 0x00, 0x00, 0x15, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x3f, 0xc0,
21+
0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22+
0x2a, 0x80, 0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x2a, 0xaa, 0x00, 0x00, 0x2a, 0xaa,
23+
0x00, 0x00, 0x2a, 0xaa, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x80, 0xaa, 0xaa, 0xaa, 0x80, 0xaa, 0xaa, 0xaa, 0x00,
24+
};
25+
26+
const lv_img_dsc_t bracket_right = {{LV_IMG_CF_INDEXED_2BIT, 0, 0, 16, 38}, 168, bracket_right_map};
Loading

src/displayapp/screens/BatteryIcon.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ BatteryIcon::BatteryIcon(bool colorOnLowBattery) : colorOnLowBattery {colorOnLow
1111
void BatteryIcon::Create(lv_obj_t* parent) {
1212
batteryImg = lv_img_create(parent, nullptr);
1313
lv_img_set_src(batteryImg, &batteryicon);
14-
lv_obj_set_style_local_image_recolor(batteryImg, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
14+
lv_obj_set_style_local_image_recolor(batteryImg, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, baseColor);
1515

1616
batteryJuice = lv_obj_create(batteryImg, nullptr);
1717
lv_obj_set_width(batteryJuice, 8);
@@ -30,21 +30,31 @@ void BatteryIcon::SetBatteryPercentage(uint8_t percentage) {
3030
static constexpr int lowBatteryThreshold = 15;
3131
static constexpr int criticalBatteryThreshold = 5;
3232
if (percentage > lowBatteryThreshold) {
33-
SetColor(LV_COLOR_WHITE);
33+
_SetColor(baseColor);
3434
} else if (percentage > criticalBatteryThreshold) {
35-
SetColor(LV_COLOR_ORANGE);
35+
_SetColor(LV_COLOR_ORANGE);
3636
} else {
37-
SetColor(Colors::deepOrange);
37+
_SetColor(Colors::deepOrange);
3838
}
3939
}
4040
}
4141

4242
void BatteryIcon::SetColor(lv_color_t color) {
43+
baseColor = color;
44+
_SetColor(color);
45+
}
46+
47+
void BatteryIcon::_SetColor(lv_color_t color) {
4348
lv_obj_set_style_local_image_recolor(batteryImg, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, color);
4449
lv_obj_set_style_local_image_recolor_opa(batteryImg, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
4550
lv_obj_set_style_local_bg_color(batteryJuice, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, color);
4651
}
4752

53+
void BatteryIcon::SetVisible(bool visible) {
54+
lv_obj_set_hidden(batteryImg, !visible);
55+
lv_obj_set_hidden(batteryJuice, !visible);
56+
}
57+
4858
const char* BatteryIcon::GetPlugIcon(bool isCharging) {
4959
if (isCharging)
5060
return Symbols::plug;

src/displayapp/screens/BatteryIcon.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Pinetime {
99
public:
1010
explicit BatteryIcon(bool colorOnLowBattery);
1111
void Create(lv_obj_t* parent);
12+
void SetVisible(bool visible);
1213

1314
void SetColor(lv_color_t);
1415
void SetBatteryPercentage(uint8_t percentage);
@@ -21,6 +22,9 @@ namespace Pinetime {
2122
lv_obj_t* batteryImg;
2223
lv_obj_t* batteryJuice;
2324
bool colorOnLowBattery = false;
25+
26+
lv_color_t baseColor = LV_COLOR_WHITE;
27+
void _SetColor(lv_color_t color);
2428
};
2529
}
2630
}

src/displayapp/screens/Screen.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ namespace Pinetime {
4040
return false;
4141
}
4242

43+
virtual void OnLCDWakeup([[maybe_unused]] bool aodMode) {
44+
}
45+
46+
virtual void OnLCDSleep([[maybe_unused]] bool aodMode) {
47+
}
48+
4349
protected:
4450
bool running = true;
4551
};

0 commit comments

Comments
 (0)