Settings : use enums instead of ints to store colors. Group all PTS settings into a struct.
PTS/SettingsPTS : Convert to/from LVGL color and Settings::Color, add functions to reduce code duplication. Adapt SettingPineTimeStyle with the last Screen Interface
This commit is contained in:
parent
ef9f809e14
commit
31bc47d1cb
|
@ -418,6 +418,7 @@ list(APPEND SOURCE_FILES
|
||||||
displayapp/screens/BatteryInfo.cpp
|
displayapp/screens/BatteryInfo.cpp
|
||||||
displayapp/screens/Steps.cpp
|
displayapp/screens/Steps.cpp
|
||||||
displayapp/screens/Timer.cpp
|
displayapp/screens/Timer.cpp
|
||||||
|
displayapp/Colors.cpp
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
displayapp/screens/settings/QuickSettings.cpp
|
displayapp/screens/settings/QuickSettings.cpp
|
||||||
|
@ -611,6 +612,7 @@ set(INCLUDE_FILES
|
||||||
displayapp/screens/Metronome.h
|
displayapp/screens/Metronome.h
|
||||||
displayapp/screens/Motion.h
|
displayapp/screens/Motion.h
|
||||||
displayapp/screens/Timer.h
|
displayapp/screens/Timer.h
|
||||||
|
displayapp/Colors.h
|
||||||
drivers/St7789.h
|
drivers/St7789.h
|
||||||
drivers/SpiNorFlash.h
|
drivers/SpiNorFlash.h
|
||||||
drivers/SpiMaster.h
|
drivers/SpiMaster.h
|
||||||
|
|
|
@ -17,6 +17,14 @@ namespace Pinetime {
|
||||||
DoubleTap = 1,
|
DoubleTap = 1,
|
||||||
RaiseWrist = 2,
|
RaiseWrist = 2,
|
||||||
};
|
};
|
||||||
|
enum class Colors : uint8_t {
|
||||||
|
White, Silver, Gray, Black, Red, Maroon, Yellow, Olive, Lime, Green, Cyan, Teal, Blue, Navy, Magenta, Purple, Orange
|
||||||
|
};
|
||||||
|
struct PineTimeStyle {
|
||||||
|
Colors ColorTime = Colors::Teal;
|
||||||
|
Colors ColorBar = Colors::Teal;
|
||||||
|
Colors ColorBG = Colors::Black;
|
||||||
|
};
|
||||||
|
|
||||||
Settings(Pinetime::Controllers::FS& fs);
|
Settings(Pinetime::Controllers::FS& fs);
|
||||||
|
|
||||||
|
@ -33,37 +41,38 @@ namespace Pinetime {
|
||||||
return settings.clockFace;
|
return settings.clockFace;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetPTSColorTime(uint8_t colorTime) {
|
void SetPTSColorTime(Colors colorTime) {
|
||||||
if (colorTime != settings.PTSColorTime)
|
if (colorTime != settings.PTS.ColorTime)
|
||||||
settingsChanged = true;
|
settingsChanged = true;
|
||||||
settings.PTSColorTime = colorTime;
|
settings.PTS.ColorTime = colorTime;
|
||||||
};
|
};
|
||||||
uint8_t GetPTSColorTime() const {
|
Colors GetPTSColorTime() const {
|
||||||
return settings.PTSColorTime;
|
return settings.PTS.ColorTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetPTSColorBar(uint8_t colorBar) {
|
void SetPTSColorBar(Colors colorBar) {
|
||||||
if (colorBar != settings.PTSColorBar)
|
if (colorBar != settings.PTS.ColorBar)
|
||||||
settingsChanged = true;
|
settingsChanged = true;
|
||||||
settings.PTSColorBar = colorBar;
|
settings.PTS.ColorBar = colorBar;
|
||||||
};
|
};
|
||||||
uint8_t GetPTSColorBar() const {
|
Colors GetPTSColorBar() const {
|
||||||
return settings.PTSColorBar;
|
return settings.PTS.ColorBar;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetPTSColorBG(uint8_t colorBG) {
|
void SetPTSColorBG(Colors colorBG) {
|
||||||
if (colorBG != settings.PTSColorBG)
|
if (colorBG != settings.PTS.ColorBG)
|
||||||
settingsChanged = true;
|
settingsChanged = true;
|
||||||
settings.PTSColorBG = colorBG;
|
settings.PTS.ColorBG = colorBG;
|
||||||
};
|
};
|
||||||
uint8_t GetPTSColorBG() const {
|
Colors GetPTSColorBG() const {
|
||||||
return settings.PTSColorBG;
|
return settings.PTS.ColorBG;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetAppMenu(uint8_t menu) {
|
void SetAppMenu(uint8_t menu) {
|
||||||
appMenu = menu;
|
appMenu = menu;
|
||||||
};
|
};
|
||||||
uint8_t GetAppMenu() {
|
|
||||||
|
uint8_t GetAppMenu() const {
|
||||||
return appMenu;
|
return appMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -156,7 +165,6 @@ namespace Pinetime {
|
||||||
|
|
||||||
static constexpr uint32_t settingsVersion = 0x0002;
|
static constexpr uint32_t settingsVersion = 0x0002;
|
||||||
struct SettingsData {
|
struct SettingsData {
|
||||||
|
|
||||||
uint32_t version = settingsVersion;
|
uint32_t version = settingsVersion;
|
||||||
uint32_t stepsGoal = 10000;
|
uint32_t stepsGoal = 10000;
|
||||||
uint32_t screenTimeOut = 15000;
|
uint32_t screenTimeOut = 15000;
|
||||||
|
@ -166,9 +174,7 @@ namespace Pinetime {
|
||||||
|
|
||||||
uint8_t clockFace = 0;
|
uint8_t clockFace = 0;
|
||||||
|
|
||||||
uint8_t PTSColorTime = 11;
|
PineTimeStyle PTS;
|
||||||
uint8_t PTSColorBar = 11;
|
|
||||||
uint8_t PTSColorBG = 3;
|
|
||||||
|
|
||||||
std::bitset<3> wakeUpMode {0};
|
std::bitset<3> wakeUpMode {0};
|
||||||
|
|
||||||
|
|
27
src/displayapp/Colors.cpp
Normal file
27
src/displayapp/Colors.cpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#include "Colors.h"
|
||||||
|
|
||||||
|
using namespace Pinetime::Applications;
|
||||||
|
using namespace Pinetime::Controllers;
|
||||||
|
|
||||||
|
lv_color_t Pinetime::Applications::Convert(Pinetime::Controllers::Settings::Colors color) {
|
||||||
|
switch (color) {
|
||||||
|
case Pinetime::Controllers::Settings::Colors::White: return LV_COLOR_WHITE;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Silver: return LV_COLOR_SILVER;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Gray: return LV_COLOR_GRAY;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Black: return LV_COLOR_BLACK;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Red: return LV_COLOR_RED;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Maroon: return LV_COLOR_MAROON;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Yellow: return LV_COLOR_YELLOW;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Olive: return LV_COLOR_OLIVE;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Lime: return LV_COLOR_LIME;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Green: return LV_COLOR_GREEN;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Cyan: return LV_COLOR_CYAN;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Teal: return LV_COLOR_TEAL;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Blue: return LV_COLOR_BLUE;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Navy: return LV_COLOR_NAVY;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Magenta: return LV_COLOR_MAGENTA;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Purple: return LV_COLOR_PURPLE;
|
||||||
|
case Pinetime::Controllers::Settings::Colors::Orange: return LV_COLOR_ORANGE;
|
||||||
|
default: return LV_COLOR_WHITE;
|
||||||
|
}
|
||||||
|
}
|
10
src/displayapp/Colors.h
Normal file
10
src/displayapp/Colors.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <lvgl/src/lv_misc/lv_color.h>
|
||||||
|
#include <components/settings/Settings.h>
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
namespace Applications {
|
||||||
|
lv_color_t Convert(Controllers::Settings::Colors color);
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,6 +23,7 @@
|
||||||
#include <date/date.h>
|
#include <date/date.h>
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <displayapp/Colors.h>
|
||||||
#include "BatteryIcon.h"
|
#include "BatteryIcon.h"
|
||||||
#include "BleIcon.h"
|
#include "BleIcon.h"
|
||||||
#include "NotificationIcon.h"
|
#include "NotificationIcon.h"
|
||||||
|
@ -63,7 +64,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
|
|
||||||
//Create a 200px wide background rectangle
|
//Create a 200px wide background rectangle
|
||||||
timebar = lv_obj_create(lv_scr_act(), nullptr);
|
timebar = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBG()]);
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
|
||||||
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
lv_obj_set_size(timebar, 200, 240);
|
lv_obj_set_size(timebar, 200, 240);
|
||||||
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
|
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
|
||||||
|
@ -71,25 +72,25 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
// Display the time
|
// Display the time
|
||||||
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
|
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
||||||
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
lv_label_set_text(timeDD1, "12");
|
lv_label_set_text(timeDD1, "12");
|
||||||
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
|
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
|
||||||
|
|
||||||
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
|
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
||||||
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
lv_label_set_text(timeDD2, "34");
|
lv_label_set_text(timeDD2, "34");
|
||||||
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
|
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
|
||||||
|
|
||||||
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
|
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
|
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
|
||||||
lv_label_set_text(timeAMPM, "");
|
lv_label_set_text(timeAMPM, "");
|
||||||
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
|
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
|
||||||
|
|
||||||
// Create a 40px wide bar down the right side of the screen
|
// Create a 40px wide bar down the right side of the screen
|
||||||
sidebar = lv_obj_create(lv_scr_act(), nullptr);
|
sidebar = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBar()]);
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
|
||||||
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
lv_obj_set_size(sidebar, 40, 240);
|
lv_obj_set_size(sidebar, 40, 240);
|
||||||
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
||||||
|
|
|
@ -68,11 +68,6 @@ namespace Pinetime {
|
||||||
lv_obj_t* notificationIcon;
|
lv_obj_t* notificationIcon;
|
||||||
lv_obj_t* stepGauge;
|
lv_obj_t* stepGauge;
|
||||||
lv_color_t needle_colors[1];
|
lv_color_t needle_colors[1];
|
||||||
lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK,
|
|
||||||
LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE,
|
|
||||||
LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL,
|
|
||||||
LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE,
|
|
||||||
LV_COLOR_ORANGE};
|
|
||||||
|
|
||||||
Controllers::DateTime& dateTimeController;
|
Controllers::DateTime& dateTimeController;
|
||||||
Controllers::Battery& batteryController;
|
Controllers::Battery& batteryController;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "SettingPineTimeStyle.h"
|
#include "SettingPineTimeStyle.h"
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
|
#include <displayapp/Colors.h>
|
||||||
#include "displayapp/DisplayApp.h"
|
#include "displayapp/DisplayApp.h"
|
||||||
#include "displayapp/screens/Symbols.h"
|
#include "displayapp/screens/Symbols.h"
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ namespace {
|
||||||
SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
|
SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
|
||||||
: Screen(app), settingsController {settingsController} {
|
: Screen(app), settingsController {settingsController} {
|
||||||
timebar = lv_obj_create(lv_scr_act(), nullptr);
|
timebar = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBG()]);
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
|
||||||
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
lv_obj_set_size(timebar, 200, 240);
|
lv_obj_set_size(timebar, 200, 240);
|
||||||
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
|
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
|
||||||
|
@ -24,18 +25,18 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a
|
||||||
|
|
||||||
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
|
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
||||||
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
lv_label_set_text(timeDD1, "12");
|
lv_label_set_text(timeDD1, "12");
|
||||||
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
|
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
|
||||||
|
|
||||||
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
|
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
||||||
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
lv_label_set_text(timeDD2, "34");
|
lv_label_set_text(timeDD2, "34");
|
||||||
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
|
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
|
||||||
|
|
||||||
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
|
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
|
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
|
||||||
lv_label_set_text(timeAMPM, "A\nM");
|
lv_label_set_text(timeAMPM, "A\nM");
|
||||||
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
|
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
|
||||||
|
@ -43,7 +44,7 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a
|
||||||
// Create a 40px wide bar down the right side of the screen
|
// Create a 40px wide bar down the right side of the screen
|
||||||
|
|
||||||
sidebar = lv_obj_create(lv_scr_act(), nullptr);
|
sidebar = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBar()]);
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
|
||||||
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
lv_obj_set_size(sidebar, 40, 240);
|
lv_obj_set_size(sidebar, 40, 240);
|
||||||
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
||||||
|
@ -215,91 +216,60 @@ SettingPineTimeStyle::~SettingPineTimeStyle() {
|
||||||
settingsController.SaveSettings();
|
settingsController.SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingPineTimeStyle::Refresh() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
uint8_t valueTime = settingsController.GetPTSColorTime();
|
auto valueTime = settingsController.GetPTSColorTime();
|
||||||
uint8_t valueBar = settingsController.GetPTSColorBar();
|
auto valueBar = settingsController.GetPTSColorBar();
|
||||||
uint8_t valueBG = settingsController.GetPTSColorBG();
|
auto valueBG = settingsController.GetPTSColorBG();
|
||||||
|
|
||||||
if (event == LV_EVENT_CLICKED) {
|
if (event == LV_EVENT_CLICKED) {
|
||||||
if (object == btnNextTime) {
|
if (object == btnNextTime) {
|
||||||
if (valueTime < 16) {
|
valueTime = GetNext(valueTime);
|
||||||
valueTime += 1;
|
|
||||||
} else {
|
|
||||||
valueTime = 0;
|
|
||||||
}
|
|
||||||
settingsController.SetPTSColorTime(valueTime);
|
settingsController.SetPTSColorTime(valueTime);
|
||||||
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
||||||
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
||||||
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
||||||
}
|
}
|
||||||
if (object == btnPrevTime) {
|
if (object == btnPrevTime) {
|
||||||
if (valueTime > 0) {
|
valueTime = GetPrevious(valueTime);
|
||||||
valueTime -= 1;
|
|
||||||
} else {
|
|
||||||
valueTime = 16;
|
|
||||||
}
|
|
||||||
settingsController.SetPTSColorTime(valueTime);
|
settingsController.SetPTSColorTime(valueTime);
|
||||||
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
||||||
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
||||||
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
||||||
}
|
}
|
||||||
if (object == btnNextBar) {
|
if (object == btnNextBar) {
|
||||||
if (valueBar < 16) {
|
valueBar = GetNext(valueBar);
|
||||||
valueBar += 1;
|
if(valueBar == Controllers::Settings::Colors::Black)
|
||||||
// Avoid setting the sidebar black
|
valueBar = GetNext(valueBar);
|
||||||
if (valueBar == 3) {
|
|
||||||
valueBar += 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
valueBar = 0;
|
|
||||||
}
|
|
||||||
settingsController.SetPTSColorBar(valueBar);
|
settingsController.SetPTSColorBar(valueBar);
|
||||||
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]);
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
|
||||||
}
|
}
|
||||||
if (object == btnPrevBar) {
|
if (object == btnPrevBar) {
|
||||||
if (valueBar > 0) {
|
valueBar = GetPrevious(valueBar);
|
||||||
valueBar -= 1;
|
if(valueBar == Controllers::Settings::Colors::Black)
|
||||||
// Avoid setting the sidebar black
|
valueBar = GetPrevious(valueBar);
|
||||||
if (valueBar == 3) {
|
|
||||||
valueBar -= 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
valueBar = 16;
|
|
||||||
}
|
|
||||||
settingsController.SetPTSColorBar(valueBar);
|
settingsController.SetPTSColorBar(valueBar);
|
||||||
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]);
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
|
||||||
}
|
}
|
||||||
if (object == btnNextBG) {
|
if (object == btnNextBG) {
|
||||||
if (valueBG < 16) {
|
valueBG = GetNext(valueBG);
|
||||||
valueBG += 1;
|
|
||||||
} else {
|
|
||||||
valueBG = 0;
|
|
||||||
}
|
|
||||||
settingsController.SetPTSColorBG(valueBG);
|
settingsController.SetPTSColorBG(valueBG);
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]);
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
||||||
}
|
}
|
||||||
if (object == btnPrevBG) {
|
if (object == btnPrevBG) {
|
||||||
if (valueBG > 0) {
|
valueBG = GetPrevious(valueBG);
|
||||||
valueBG -= 1;
|
|
||||||
} else {
|
|
||||||
valueBG = 16;
|
|
||||||
}
|
|
||||||
settingsController.SetPTSColorBG(valueBG);
|
settingsController.SetPTSColorBG(valueBG);
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]);
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
||||||
}
|
}
|
||||||
if (object == btnReset) {
|
if (object == btnReset) {
|
||||||
settingsController.SetPTSColorTime(11);
|
settingsController.SetPTSColorTime(Controllers::Settings::Colors::Teal);
|
||||||
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]);
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
|
||||||
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]);
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
|
||||||
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]);
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
|
||||||
settingsController.SetPTSColorBar(11);
|
settingsController.SetPTSColorBar(Controllers::Settings::Colors::Teal);
|
||||||
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]);
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
|
||||||
settingsController.SetPTSColorBG(3);
|
settingsController.SetPTSColorBG(Controllers::Settings::Colors::Black);
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[3]);
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black));
|
||||||
}
|
}
|
||||||
if (object == btnRandom) {
|
if (object == btnRandom) {
|
||||||
uint8_t randTime = rand() % 17;
|
uint8_t randTime = rand() % 17;
|
||||||
|
@ -312,14 +282,37 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
if (randBar == 3) {
|
if (randBar == 3) {
|
||||||
randBar -= 1;
|
randBar -= 1;
|
||||||
}
|
}
|
||||||
settingsController.SetPTSColorTime(randTime);
|
settingsController.SetPTSColorTime(static_cast<Controllers::Settings::Colors>(randTime));
|
||||||
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]);
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
|
||||||
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]);
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
|
||||||
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]);
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
|
||||||
settingsController.SetPTSColorBar(randBar);
|
settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(randBar));
|
||||||
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBar]);
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBar)));
|
||||||
settingsController.SetPTSColorBG(randBG);
|
settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(randBG));
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBG]);
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBG)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
|
||||||
|
auto colorAsInt = static_cast<uint8_t>(color);
|
||||||
|
Pinetime::Controllers::Settings::Colors nextColor;
|
||||||
|
if (colorAsInt < 16) {
|
||||||
|
nextColor = static_cast<Controllers::Settings::Colors>(colorAsInt + 1);
|
||||||
|
} else {
|
||||||
|
nextColor = static_cast<Controllers::Settings::Colors>(0);
|
||||||
|
}
|
||||||
|
return nextColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
|
||||||
|
auto colorAsInt = static_cast<uint8_t>(color);
|
||||||
|
Pinetime::Controllers::Settings::Colors prevColor;
|
||||||
|
|
||||||
|
if (colorAsInt > 0) {
|
||||||
|
prevColor = static_cast<Controllers::Settings::Colors>(colorAsInt - 1);
|
||||||
|
} else {
|
||||||
|
prevColor = static_cast<Controllers::Settings::Colors>(16);
|
||||||
|
}
|
||||||
|
return prevColor;
|
||||||
|
}
|
||||||
|
|
|
@ -15,12 +15,14 @@ namespace Pinetime {
|
||||||
SettingPineTimeStyle(DisplayApp* app, Pinetime::Controllers::Settings &settingsController);
|
SettingPineTimeStyle(DisplayApp* app, Pinetime::Controllers::Settings &settingsController);
|
||||||
~SettingPineTimeStyle() override;
|
~SettingPineTimeStyle() override;
|
||||||
|
|
||||||
bool Refresh() override;
|
|
||||||
void UpdateSelected(lv_obj_t *object, lv_event_t event);
|
void UpdateSelected(lv_obj_t *object, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Controllers::Settings& settingsController;
|
Controllers::Settings& settingsController;
|
||||||
|
|
||||||
|
Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color);
|
||||||
|
Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color);
|
||||||
|
|
||||||
lv_obj_t * btnNextTime;
|
lv_obj_t * btnNextTime;
|
||||||
lv_obj_t * btnPrevTime;
|
lv_obj_t * btnPrevTime;
|
||||||
lv_obj_t * btnNextBar;
|
lv_obj_t * btnNextBar;
|
||||||
|
@ -29,9 +31,6 @@ namespace Pinetime {
|
||||||
lv_obj_t * btnPrevBG;
|
lv_obj_t * btnPrevBG;
|
||||||
lv_obj_t * btnReset;
|
lv_obj_t * btnReset;
|
||||||
lv_obj_t * btnRandom;
|
lv_obj_t * btnRandom;
|
||||||
lv_obj_t * timeColor;
|
|
||||||
lv_obj_t * barColor;
|
|
||||||
lv_obj_t * bgColor;
|
|
||||||
lv_obj_t * timebar;
|
lv_obj_t * timebar;
|
||||||
lv_obj_t * sidebar;
|
lv_obj_t * sidebar;
|
||||||
lv_obj_t * timeDD1;
|
lv_obj_t * timeDD1;
|
||||||
|
@ -51,11 +50,6 @@ namespace Pinetime {
|
||||||
lv_obj_t * calendarCrossBar2;
|
lv_obj_t * calendarCrossBar2;
|
||||||
lv_obj_t * stepGauge;
|
lv_obj_t * stepGauge;
|
||||||
lv_color_t needle_colors[1];
|
lv_color_t needle_colors[1];
|
||||||
lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK,
|
|
||||||
LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE,
|
|
||||||
LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL,
|
|
||||||
LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE,
|
|
||||||
LV_COLOR_ORANGE};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user