Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 10 additions & 29 deletions src/components/settings/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "components/brightness/BrightnessController.h"
#include "components/fs/FS.h"
#include "displayapp/apps/Apps.h"
#include "displayapp/Colors.h"
#include <nrf_log.h>

namespace Pinetime {
Expand All @@ -15,35 +16,15 @@ namespace Pinetime {
enum class Notification : uint8_t { On, Off, Sleep };
enum class ChimesOption : uint8_t { None, Hours, HalfHours };
enum class WakeUpMode : uint8_t { SingleTap = 0, DoubleTap = 1, RaiseWrist = 2, Shake = 3, LowerWrist = 4 };
enum class Colors : uint8_t {
White,
Silver,
Gray,
Black,
Red,
Maroon,
Yellow,
Olive,
Lime,
Green,
Cyan,
Teal,
Blue,
Navy,
Magenta,
Purple,
Orange,
Pink
};
enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric };
enum class PTSWeather : uint8_t { On, Off };
enum class PrideFlag : uint8_t { Gay, Trans, Bi, Lesbian };
enum class DfuAndFsMode : uint8_t { Disabled, Enabled, EnabledTillReboot };

struct PineTimeStyle {
Colors ColorTime = Colors::Teal;
Colors ColorBar = Colors::Teal;
Colors ColorBG = Colors::Black;
Colors::Color ColorTime = Colors::Teal;
Colors::Color ColorBar = Colors::Teal;
Colors::Color ColorBG = Colors::Black;
PTSGaugeStyle gaugeStyle = PTSGaugeStyle::Full;
PTSWeather weatherEnable = PTSWeather::Off;
};
Expand Down Expand Up @@ -85,33 +66,33 @@ namespace Pinetime {
return settings.chimesOption;
};

void SetPTSColorTime(Colors colorTime) {
void SetPTSColorTime(Colors::Color colorTime) {
if (colorTime != settings.PTS.ColorTime)
settingsChanged = true;
settings.PTS.ColorTime = colorTime;
};

Colors GetPTSColorTime() const {
Colors::Color GetPTSColorTime() const {
return settings.PTS.ColorTime;
};

void SetPTSColorBar(Colors colorBar) {
void SetPTSColorBar(Colors::Color colorBar) {
if (colorBar != settings.PTS.ColorBar)
settingsChanged = true;
settings.PTS.ColorBar = colorBar;
};

Colors GetPTSColorBar() const {
Colors::Color GetPTSColorBar() const {
return settings.PTS.ColorBar;
};

void SetPTSColorBG(Colors colorBG) {
void SetPTSColorBG(Colors::Color colorBG) {
if (colorBG != settings.PTS.ColorBG)
settingsChanged = true;
settings.PTS.ColorBG = colorBG;
};

Colors GetPTSColorBG() const {
Colors::Color GetPTSColorBG() const {
return settings.PTS.ColorBG;
};

Expand Down
49 changes: 6 additions & 43 deletions src/displayapp/Colors.cpp
Original file line number Diff line number Diff line change
@@ -1,47 +1,10 @@
#include "displayapp/Colors.h"

using namespace Pinetime::Applications;
using namespace Pinetime::Controllers;
#include <limits>

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_MAKE(0xb0, 0x0, 0x0);
case Pinetime::Controllers::Settings::Colors::Yellow:
return LV_COLOR_YELLOW;
case Pinetime::Controllers::Settings::Colors::Olive:
return LV_COLOR_MAKE(0xb0, 0xb0, 0x0);
case Pinetime::Controllers::Settings::Colors::Lime:
return LV_COLOR_LIME;
case Pinetime::Controllers::Settings::Colors::Green:
return LV_COLOR_MAKE(0x0, 0xb0, 0x0);
case Pinetime::Controllers::Settings::Colors::Cyan:
return LV_COLOR_CYAN;
case Pinetime::Controllers::Settings::Colors::Teal:
return LV_COLOR_MAKE(0x0, 0xb0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Blue:
return LV_COLOR_BLUE;
case Pinetime::Controllers::Settings::Colors::Navy:
return LV_COLOR_MAKE(0x0, 0x0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Magenta:
return LV_COLOR_MAGENTA;
case Pinetime::Controllers::Settings::Colors::Purple:
return LV_COLOR_MAKE(0xb0, 0x0, 0xb0);
case Pinetime::Controllers::Settings::Colors::Orange:
return LV_COLOR_ORANGE;
case Pinetime::Controllers::Settings::Colors::Pink:
return LV_COLOR_MAKE(0xFF, 0xAE, 0xC9);
default:
return LV_COLOR_WHITE;
}
Colors::Color Colors::linear_gradient(Colors::Color startingColor, Colors::Color endingColor, uint8_t progress) {
constexpr decltype(progress) maxProgress = std::numeric_limits<decltype(progress)>::max();
return Colors::Color(((maxProgress - progress) * startingColor.red() + progress * endingColor.red()) / maxProgress,
((maxProgress - progress) * startingColor.green() + progress * endingColor.green()) / maxProgress,
((maxProgress - progress) * startingColor.blue() + progress * endingColor.blue()) / maxProgress);
}
70 changes: 64 additions & 6 deletions src/displayapp/Colors.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,68 @@
#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);
}
}
namespace Colors {

class Color {
public:
constexpr Color(uint32_t color) : data {color} {
}

constexpr operator uint32_t() const {
return data;
}

constexpr Color(uint8_t r, uint8_t g, uint8_t b)
: data {(static_cast<uint32_t>(r) << 16) | (static_cast<uint32_t>(g) << 8) | static_cast<uint32_t>(b)} {
}

operator lv_color_t() const {
return lv_color_hex(data);
}

uint8_t red() const {
return (data & 0xFF0000) >> 16;
}

uint8_t green() const {
return (data & 0x00FF00) >> 8;
}

uint8_t blue() const {
return (data & 0x0000FF);
}

private:
uint32_t data;
};

Color linear_gradient(Color startingColor, Color endingColor, uint8_t progress);

static constexpr Color White = 0xFFFFFF;
static constexpr Color Silver = 0xC0C0C0;
static constexpr Color LightGray = 0xB0B0B0;
static constexpr Color Gray = 0x808080;
static constexpr Color DarkGray = 0x1B1B1B;
static constexpr Color Black = 0x000000;
static constexpr Color Red = 0xFF0000;
static constexpr Color Maroon = 0xB00000;
static constexpr Color Yellow = 0xFFFF00;
static constexpr Color Olive = 0xB0B000;
static constexpr Color Lime = 0x00FF00;
static constexpr Color Green = 0x00B000;
static constexpr Color Cyan = 0x00FFFF;
static constexpr Color Teal = 0x00B0B0;
static constexpr Color Blue = 0x0000FF;
static constexpr Color Navy = 0x0000B0;
static constexpr Color Magenta = 0xFF00FF;
static constexpr Color Purple = 0xB000B0;
static constexpr Color Orange = 0xFFA500;
static constexpr Color DeepOrange = 0xFF4000;
static constexpr Color Pink = 0xFFAEC9;
static constexpr Color Platinum = 0xE5E5E2;
static constexpr Color Gold = 0xFFD700;
static constexpr Color Copper = 0xB87333;
static constexpr Color Violet = 0x6000FF;
static constexpr Color Aqua = 0x00FFF;
}
Loading
Loading