Skip to content

Commit

Permalink
StarTrek watchface
Browse files Browse the repository at this point in the history
  • Loading branch information
ljahn committed Dec 15, 2024
1 parent 2105a7b commit 85d4456
Show file tree
Hide file tree
Showing 20 changed files with 1,357 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ list(APPEND SOURCE_FILES
displayapp/screens/WatchFaceTerminal.cpp
displayapp/screens/WatchFacePineTimeStyle.cpp
displayapp/screens/WatchFaceCasioStyleG7710.cpp
displayapp/screens/WatchFaceStarTrek.cpp

##

Expand Down
56 changes: 55 additions & 1 deletion src/components/settings/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace Pinetime {
};
enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric };
enum class PTSWeather : uint8_t { On, Off };
enum class StarTrekAnimateType { None, Start, Continuous, All };

struct PineTimeStyle {
Colors ColorTime = Colors::Teal;
Expand All @@ -50,6 +51,13 @@ namespace Pinetime {
int colorIndex = 0;
};

struct WatchFaceStarTrek {
bool useSystemFont = false;
StarTrekAnimateType animate = StarTrekAnimateType::All;
bool displaySeconds = false;
bool weather = true;
};

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

Settings(const Settings&) = delete;
Expand Down Expand Up @@ -154,6 +162,50 @@ namespace Pinetime {
return settings.PTS.weatherEnable;
};

bool GetStarTrekUseSystemFont() const {
return settings.watchFaceStarTrek.useSystemFont;
};

void SetStarTrekUseSystemFont(bool useSystemFont) {
if (useSystemFont != settings.watchFaceStarTrek.useSystemFont) {
settings.watchFaceStarTrek.useSystemFont = useSystemFont;
settingsChanged = true;
}
};

StarTrekAnimateType GetStarTrekAnimate() const {
return settings.watchFaceStarTrek.animate;
};

void SetStarTrekAnimate(StarTrekAnimateType animate) {
if (animate != settings.watchFaceStarTrek.animate) {
settings.watchFaceStarTrek.animate = animate;
settingsChanged = true;
}
};

bool GetStarTrekDisplaySeconds() const {
return settings.watchFaceStarTrek.displaySeconds;
};

void SetStarTrekDisplaySeconds(bool displaySeconds) {
if (displaySeconds != settings.watchFaceStarTrek.displaySeconds) {
settings.watchFaceStarTrek.displaySeconds = displaySeconds;
settingsChanged = true;
}
};

bool GetStarTrekWeather() const {
return settings.watchFaceStarTrek.weather;
};

void SetStarTrekWeather(bool weather) {
if (weather != settings.watchFaceStarTrek.weather) {
settings.watchFaceStarTrek.weather = weather;
settingsChanged = true;
}
};

void SetAppMenu(uint8_t menu) {
appMenu = menu;
};
Expand Down Expand Up @@ -301,7 +353,7 @@ namespace Pinetime {
private:
Pinetime::Controllers::FS& fs;

static constexpr uint32_t settingsVersion = 0x0008;
static constexpr uint32_t settingsVersion = 0x0009;

struct SettingsData {
uint32_t version = settingsVersion;
Expand All @@ -321,6 +373,8 @@ namespace Pinetime {

WatchFaceInfineat watchFaceInfineat;

WatchFaceStarTrek watchFaceStarTrek;

std::bitset<5> wakeUpMode {0};
uint16_t shakeWakeThreshold = 150;

Expand Down
7 changes: 7 additions & 0 deletions src/displayapp/DisplayApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,19 @@ void DisplayApp::Refresh() {
// display activity timer causing the screen to never sleep after timeout
lvgl.ClearTouchState();
if (msg == Messages::GoToAOD) {
currentScreen->OnLCDSleep(true); // prepare for low power while still fast
lv_task_handler();
vTaskDelay(100);
lcd.LowPowerOn();
// Record idle entry time
alwaysOnFrameCount = 0;
alwaysOnStartTime = xTaskGetTickCount();
PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskAOD);
state = States::AOD;
} else {
currentScreen->OnLCDSleep(false);
lv_task_handler(); // call to update display, will not be called again in Idle mode
vTaskDelay(100); // give time for display refresh
lcd.Sleep();
PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping);
state = States::Idle;
Expand All @@ -354,6 +360,7 @@ void DisplayApp::Refresh() {
lv_disp_trig_activity(nullptr);
ApplyBrightness();
state = States::Running;
currentScreen->OnLCDWakeup(settingsController.GetAlwaysOnDisplay());
break;
case Messages::UpdateBleConnection:
// Only used for recovery firmware
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/UserApps.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "displayapp/screens/WatchFaceInfineat.h"
#include "displayapp/screens/WatchFacePineTimeStyle.h"
#include "displayapp/screens/WatchFaceTerminal.h"
#include "displayapp/screens/WatchFaceStarTrek.h"

namespace Pinetime {
namespace Applications {
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/apps/Apps.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace Pinetime {
Terminal,
Infineat,
CasioStyleG7710,
StarTrek,
};

template <Apps>
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ else()
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Terminal")
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Infineat")
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::CasioStyleG7710")
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::StarTrek")
set(WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}" CACHE STRING "List of watch faces to build into the firmware")
endif()

Expand Down
4 changes: 4 additions & 0 deletions src/displayapp/fonts/fonts.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
{
"file": "FontAwesome5-Solid+Brands+Regular.woff",
"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"
},
{
"file": "material-design-icons/MaterialIcons-Regular.ttf",
"range": "0xe7f6, 0xef44"
}
],
"bpp": 1,
Expand Down
26 changes: 26 additions & 0 deletions src/displayapp/icons/watchfacestartrek/bracket_left.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "lvgl/lvgl.h"

#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif

#ifndef LV_ATTRIBUTE_IMG_BRACKET_LEFT
#define LV_ATTRIBUTE_IMG_BRACKET_LEFT
#endif

const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_BRACKET_LEFT uint8_t bracket_left_map[] = {
0x00, 0x00, 0x00, 0xff, /*Color of index 0*/
0x10, 0x5d, 0xd5, 0xff, /*Color of index 1*/
0xfe, 0xdd, 0x82, 0xff, /*Color of index 2*/
0x6b, 0x61, 0x4a, 0xff, /*Color of index 3*/

0x00, 0xaa, 0xaa, 0xaa, 0x02, 0xaa, 0xaa, 0xaa, 0x02, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xaa, 0xa8, 0x00, 0x00, 0xaa, 0xa8,
0x00, 0x00, 0xaa, 0xa8, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x03, 0xfc,
0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x54, 0x00, 0x00, 0x01, 0x54, 0x00, 0x00, 0x01, 0x54, 0x00, 0x00,
0x01, 0x54, 0x00, 0x00, 0x01, 0x54, 0x00, 0x00, 0x01, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0x02, 0xa8,
0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0x02, 0xa8, 0x00, 0x00, 0xaa, 0xa8, 0x00, 0x00, 0xaa, 0xa8, 0x00, 0x00,
0xaa, 0xa8, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x02, 0xaa, 0xaa, 0xaa, 0x02, 0xaa, 0xaa, 0xaa, 0x00, 0xaa, 0xaa, 0xaa,
};

const lv_img_dsc_t bracket_left = {{LV_IMG_CF_INDEXED_2BIT, 0, 0, 16, 38}, 168, bracket_left_map};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions src/displayapp/icons/watchfacestartrek/bracket_right.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "lvgl/lvgl.h"

#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif

#ifndef LV_ATTRIBUTE_IMG_BRACKET_RIGHT
#define LV_ATTRIBUTE_IMG_BRACKET_RIGHT
#endif

const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_BRACKET_RIGHT uint8_t bracket_right_map[] = {
0x00, 0x00, 0x00, 0xff, /*Color of index 0*/
0x10, 0x5d, 0xd5, 0xff, /*Color of index 1*/
0xfe, 0xdd, 0x82, 0xff, /*Color of index 2*/
0x6b, 0x61, 0x4a, 0xff, /*Color of index 3*/

0xaa, 0xaa, 0xaa, 0x00, 0xaa, 0xaa, 0xaa, 0x80, 0xaa, 0xaa, 0xaa, 0x80, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x2a, 0xaa, 0x00, 0x00,
0x2a, 0xaa, 0x00, 0x00, 0x2a, 0xaa, 0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x2a, 0x80,
0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x40, 0x00, 0x00, 0x15, 0x40, 0x00, 0x00, 0x15, 0x40, 0x00, 0x00,
0x15, 0x40, 0x00, 0x00, 0x15, 0x40, 0x00, 0x00, 0x15, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x3f, 0xc0,
0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x2a, 0x80, 0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x2a, 0x80, 0x00, 0x00, 0x2a, 0xaa, 0x00, 0x00, 0x2a, 0xaa,
0x00, 0x00, 0x2a, 0xaa, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x80, 0xaa, 0xaa, 0xaa, 0x80, 0xaa, 0xaa, 0xaa, 0x00,
};

const lv_img_dsc_t bracket_right = {{LV_IMG_CF_INDEXED_2BIT, 0, 0, 16, 38}, 168, bracket_right_map};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 14 additions & 4 deletions src/displayapp/screens/BatteryIcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BatteryIcon::BatteryIcon(bool colorOnLowBattery) : colorOnLowBattery {colorOnLow
void BatteryIcon::Create(lv_obj_t* parent) {
batteryImg = lv_img_create(parent, nullptr);
lv_img_set_src(batteryImg, &batteryicon);
lv_obj_set_style_local_image_recolor(batteryImg, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_image_recolor(batteryImg, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, baseColor);

batteryJuice = lv_obj_create(batteryImg, nullptr);
lv_obj_set_width(batteryJuice, 8);
Expand All @@ -30,21 +30,31 @@ void BatteryIcon::SetBatteryPercentage(uint8_t percentage) {
static constexpr int lowBatteryThreshold = 15;
static constexpr int criticalBatteryThreshold = 5;
if (percentage > lowBatteryThreshold) {
SetColor(LV_COLOR_WHITE);
_SetColor(baseColor);
} else if (percentage > criticalBatteryThreshold) {
SetColor(LV_COLOR_ORANGE);
_SetColor(LV_COLOR_ORANGE);
} else {
SetColor(Colors::deepOrange);
_SetColor(Colors::deepOrange);
}
}
}

void BatteryIcon::SetColor(lv_color_t color) {
baseColor = color;
_SetColor(color);
}

void BatteryIcon::_SetColor(lv_color_t color) {
lv_obj_set_style_local_image_recolor(batteryImg, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, color);
lv_obj_set_style_local_image_recolor_opa(batteryImg, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_obj_set_style_local_bg_color(batteryJuice, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, color);
}

void BatteryIcon::SetVisible(bool visible) {
lv_obj_set_hidden(batteryImg, !visible);
lv_obj_set_hidden(batteryJuice, !visible);
}

const char* BatteryIcon::GetPlugIcon(bool isCharging) {
if (isCharging)
return Symbols::plug;
Expand Down
4 changes: 4 additions & 0 deletions src/displayapp/screens/BatteryIcon.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Pinetime {
public:
explicit BatteryIcon(bool colorOnLowBattery);
void Create(lv_obj_t* parent);
void SetVisible(bool visible);

void SetColor(lv_color_t);
void SetBatteryPercentage(uint8_t percentage);
Expand All @@ -21,6 +22,9 @@ namespace Pinetime {
lv_obj_t* batteryImg;
lv_obj_t* batteryJuice;
bool colorOnLowBattery = false;

lv_color_t baseColor = LV_COLOR_WHITE;
void _SetColor(lv_color_t color);
};
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/displayapp/screens/Screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ namespace Pinetime {
return false;
}

virtual void OnLCDWakeup([[maybe_unused]] bool aodMode) {
}

virtual void OnLCDSleep([[maybe_unused]] bool aodMode) {
}

protected:
bool running = true;
};
Expand Down
Loading

0 comments on commit 85d4456

Please sign in to comment.