Skip to content

Commit 6550db1

Browse files
committed
renamed to PrimeTime and moved font to external storage
1 parent 2d207db commit 6550db1

11 files changed

Lines changed: 65 additions & 34 deletions

File tree

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ list(APPEND SOURCE_FILES
427427
displayapp/screens/WatchFaceTerminal.cpp
428428
displayapp/screens/WatchFacePineTimeStyle.cpp
429429
displayapp/screens/WatchFaceCasioStyleG7710.cpp
430-
displayapp/screens/WatchFacePrime.cpp
430+
displayapp/screens/WatchFacePrimeTime.cpp
431431

432432
##
433433

src/displayapp/UserApps.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "displayapp/screens/Tile.h"
1010
#include "displayapp/screens/ApplicationList.h"
1111
#include "displayapp/screens/WatchFaceDigital.h"
12-
#include "displayapp/screens/WatchFacePrime.h"
12+
#include "displayapp/screens/WatchFacePrimeTime.h"
1313
#include "displayapp/screens/WatchFaceAnalog.h"
1414
#include "displayapp/screens/WatchFaceCasioStyleG7710.h"
1515
#include "displayapp/screens/WatchFaceInfineat.h"

src/displayapp/apps/Apps.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace Pinetime {
5353
Terminal,
5454
Infineat,
5555
CasioStyleG7710,
56-
Prime,
56+
PrimeTime,
5757
};
5858

5959
template <Apps>

src/displayapp/apps/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ else()
2828
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Terminal")
2929
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Infineat")
3030
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::CasioStyleG7710")
31-
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Prime")
31+
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::PrimeTime")
3232
set(WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}" CACHE STRING "List of watch faces to build into the firmware")
3333
endif()
3434

src/displayapp/fonts/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
set(FONTS jetbrains_mono_42 jetbrains_mono_76 jetbrains_mono_bold_20
22
jetbrains_mono_extrabold_compressed lv_font_sys_48
3-
open_sans_light fontawesome_weathericons prime)
3+
open_sans_light fontawesome_weathericons)
44
find_program(LV_FONT_CONV "lv_font_conv" NO_CACHE REQUIRED
55
HINTS "${CMAKE_SOURCE_DIR}/node_modules/.bin")
66
message(STATUS "Using ${LV_FONT_CONV} to generate font files")

src/displayapp/fonts/fonts.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,5 @@
7373
],
7474
"bpp": 1,
7575
"size": 25
76-
},
77-
"prime": {
78-
"sources": [
79-
{
80-
"file": "Karnivore.ttf",
81-
"symbols": "0123456789:"
82-
}
83-
],
84-
"bpp": 1,
85-
"size": 85
8676
}
8777
}

src/displayapp/screens/WatchFacePrime.cpp renamed to src/displayapp/screens/WatchFacePrimeTime.cpp

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "displayapp/screens/WatchFacePrime.h"
1+
#include "displayapp/screens/WatchFacePrimeTime.h"
22

33
#include <lvgl/lvgl.h>
44
#include <cstdio>
@@ -18,7 +18,7 @@
1818

1919
using namespace Pinetime::Applications::Screens;
2020

21-
WatchFacePrime::WatchFacePrime(Controllers::DateTime& dateTimeController,
21+
WatchFacePrimeTime::WatchFacePrimeTime(Controllers::DateTime& dateTimeController,
2222
const Controllers::Battery& batteryController,
2323
const Controllers::Ble& bleController,
2424
const Controllers::AlarmController& alarmController,
@@ -27,7 +27,8 @@ WatchFacePrime::WatchFacePrime(Controllers::DateTime& dateTimeController,
2727
Controllers::HeartRateController& heartRateController,
2828
Controllers::MotionController& motionController,
2929
Controllers::SimpleWeatherService& weatherService,
30-
Controllers::MusicService& music)
30+
Controllers::MusicService& music,
31+
Controllers::FS& filesystem)
3132
: currentDateTime {{}},
3233
dateTimeController {dateTimeController},
3334
notificationManager {notificationManager},
@@ -38,6 +39,12 @@ WatchFacePrime::WatchFacePrime(Controllers::DateTime& dateTimeController,
3839
musicService(music),
3940
statusIcons(batteryController, bleController, alarmController) {
4041

42+
lfs_file f = {};
43+
if (filesystem.FileOpen(&f, "/fonts/primetime.bin", LFS_O_RDONLY) >= 0) {
44+
filesystem.FileClose(&f);
45+
font_primetime = lv_font_load("F:/fonts/primetime.bin");
46+
}
47+
4148
statusIcons.Create();
4249

4350
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
@@ -70,7 +77,7 @@ WatchFacePrime::WatchFacePrime(Controllers::DateTime& dateTimeController,
7077
lv_obj_align(label_music, lv_scr_act(), LV_ALIGN_CENTER, 0, 78);
7178

7279
label_time = lv_label_create(lv_scr_act(), nullptr);
73-
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &prime);
80+
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_primetime);
7481
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);
7582

7683
label_time_ampm = lv_label_create(lv_scr_act(), nullptr);
@@ -101,12 +108,17 @@ WatchFacePrime::WatchFacePrime(Controllers::DateTime& dateTimeController,
101108
Refresh();
102109
}
103110

104-
WatchFacePrime::~WatchFacePrime() {
111+
WatchFacePrimeTime::~WatchFacePrimeTime() {
105112
lv_task_del(taskRefresh);
113+
114+
if (font_primetime != nullptr) {
115+
lv_font_free(font_primetime);
116+
}
117+
106118
lv_obj_clean(lv_scr_act());
107119
}
108120

109-
void WatchFacePrime::Refresh() {
121+
void WatchFacePrimeTime::Refresh() {
110122
statusIcons.Update();
111123

112124
notificationState = notificationManager.AreNewNotificationsAvailable();
@@ -219,3 +231,14 @@ void WatchFacePrime::Refresh() {
219231
lv_obj_realign(label_music);
220232
}
221233
}
234+
235+
bool WatchFacePrimeTime::IsAvailable(Pinetime::Controllers::FS& filesystem) {
236+
lfs_file file = {};
237+
238+
if (filesystem.FileOpen(&file, "/fonts/primetime.bin", LFS_O_RDONLY) < 0) {
239+
return false;
240+
}
241+
242+
filesystem.FileClose(&file);
243+
return true;
244+
}

src/displayapp/screens/WatchFacePrime.h renamed to src/displayapp/screens/WatchFacePrimeTime.h

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ namespace Pinetime {
2727
namespace Applications {
2828
namespace Screens {
2929

30-
class WatchFacePrime : public Screen {
30+
class WatchFacePrimeTime : public Screen {
3131
public:
32-
WatchFacePrime(Controllers::DateTime& dateTimeController,
32+
WatchFacePrimeTime(Controllers::DateTime& dateTimeController,
3333
const Controllers::Battery& batteryController,
3434
const Controllers::Ble& bleController,
3535
const Controllers::AlarmController& alarmController,
@@ -38,11 +38,15 @@ namespace Pinetime {
3838
Controllers::HeartRateController& heartRateController,
3939
Controllers::MotionController& motionController,
4040
Controllers::SimpleWeatherService& weather,
41-
Controllers::MusicService& music);
42-
~WatchFacePrime() override;
41+
Controllers::MusicService& music,
42+
Controllers::FS& filesystem);
43+
~WatchFacePrimeTime() override;
4344

4445
void Refresh() override;
4546

47+
static bool IsAvailable(Pinetime::Controllers::FS& filesystem);
48+
49+
4650
private:
4751
uint8_t displayedHour = -1;
4852
uint8_t displayedMinute = -1;
@@ -80,18 +84,20 @@ namespace Pinetime {
8084
Controllers::SimpleWeatherService& weatherService;
8185
Controllers::MusicService& musicService;
8286

87+
lv_font_t* font_primetime = nullptr;
88+
8389
lv_task_t* taskRefresh;
8490
Widgets::StatusIcons statusIcons;
8591
};
8692
}
8793

8894
template <>
89-
struct WatchFaceTraits<WatchFace::Prime> {
90-
static constexpr WatchFace watchFace = WatchFace::Prime;
91-
static constexpr const char* name = "Prime";
95+
struct WatchFaceTraits<WatchFace::PrimeTime> {
96+
static constexpr WatchFace watchFace = WatchFace::PrimeTime;
97+
static constexpr const char* name = "PrimeTime";
9298

9399
static Screens::Screen* Create(AppControllers& controllers) {
94-
return new Screens::WatchFacePrime(controllers.dateTimeController,
100+
return new Screens::WatchFacePrimeTime(controllers.dateTimeController,
95101
controllers.batteryController,
96102
controllers.bleController,
97103
controllers.alarmController,
@@ -100,11 +106,12 @@ namespace Pinetime {
100106
controllers.heartRateController,
101107
controllers.motionController,
102108
*controllers.weatherController,
103-
*controllers.musicService);
109+
*controllers.musicService,
110+
controllers.filesystem);
104111
};
105112

106-
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
107-
return true;
113+
static bool IsAvailable(Pinetime::Controllers::FS& filesystem) {
114+
return Screens::WatchFacePrimeTime::IsAvailable(filesystem);
108115
}
109116
};
110117
}

src/libs/lv_conf.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ typedef void* lv_indev_drv_user_data_t; /*Type of user data in the in
419419
LV_FONT_DECLARE(jetbrains_mono_76) \
420420
LV_FONT_DECLARE(open_sans_light) \
421421
LV_FONT_DECLARE(fontawesome_weathericons) \
422-
LV_FONT_DECLARE(lv_font_sys_48) \
423-
LV_FONT_DECLARE(prime)
422+
LV_FONT_DECLARE(lv_font_sys_48)
424423

425424
/* Enable it if you have fonts with a lot of characters.
426425
* The limit depends on the font size, font face and bpp

src/resources/fonts.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,17 @@
5858
"size": 115,
5959
"format": "bin",
6060
"target_path": "/fonts/"
61+
},
62+
"primetime" : {
63+
"sources": [
64+
{
65+
"file": "fonts/Karnivore.ttf",
66+
"symbols": "0123456789:"
67+
}
68+
],
69+
"bpp": 1,
70+
"size": 85,
71+
"format": "bin",
72+
"target_path": "/fonts/"
6173
}
6274
}

0 commit comments

Comments
 (0)