summaryrefslogtreecommitdiff
path: root/src/displayapp/screens
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp/screens')
-rw-r--r--src/displayapp/screens/Alarm.cpp12
-rw-r--r--src/displayapp/screens/Alarm.h4
-rw-r--r--src/displayapp/screens/BatteryIcon.cpp35
-rw-r--r--src/displayapp/screens/BatteryIcon.h14
-rw-r--r--src/displayapp/screens/BatteryInfo.cpp10
-rw-r--r--src/displayapp/screens/Brightness.cpp103
-rw-r--r--src/displayapp/screens/Brightness.h33
-rw-r--r--src/displayapp/screens/Clock.cpp23
-rw-r--r--src/displayapp/screens/Clock.h2
-rw-r--r--src/displayapp/screens/Error.cpp3
-rw-r--r--src/displayapp/screens/Error.h1
-rw-r--r--src/displayapp/screens/FirmwareUpdate.cpp27
-rw-r--r--src/displayapp/screens/FirmwareValidation.cpp12
-rw-r--r--src/displayapp/screens/FlashLight.cpp12
-rw-r--r--src/displayapp/screens/HeartRate.cpp14
-rw-r--r--src/displayapp/screens/InfiniPaint.cpp2
-rw-r--r--src/displayapp/screens/Label.cpp2
-rw-r--r--src/displayapp/screens/List.cpp15
-rw-r--r--src/displayapp/screens/List.h2
-rw-r--r--src/displayapp/screens/Meter.cpp36
-rw-r--r--src/displayapp/screens/Meter.h29
-rw-r--r--src/displayapp/screens/Metronome.cpp4
-rw-r--r--src/displayapp/screens/Metronome.h2
-rw-r--r--src/displayapp/screens/Motion.cpp6
-rw-r--r--src/displayapp/screens/Music.cpp58
-rw-r--r--src/displayapp/screens/Music.h6
-rw-r--r--src/displayapp/screens/Navigation.cpp2
-rw-r--r--src/displayapp/screens/Notifications.cpp22
-rw-r--r--src/displayapp/screens/Paddle.cpp11
-rw-r--r--src/displayapp/screens/PassKey.cpp8
-rw-r--r--src/displayapp/screens/PassKey.h1
-rw-r--r--src/displayapp/screens/Screen.h2
-rw-r--r--src/displayapp/screens/ScreenList.h8
-rw-r--r--src/displayapp/screens/Steps.cpp8
-rw-r--r--src/displayapp/screens/StopWatch.cpp88
-rw-r--r--src/displayapp/screens/StopWatch.h6
-rw-r--r--src/displayapp/screens/Styles.cpp2
-rw-r--r--src/displayapp/screens/Symbols.h7
-rw-r--r--src/displayapp/screens/SystemInfo.cpp42
-rw-r--r--src/displayapp/screens/Tile.cpp33
-rw-r--r--src/displayapp/screens/Tile.h4
-rw-r--r--src/displayapp/screens/Timer.cpp55
-rw-r--r--src/displayapp/screens/Timer.h1
-rw-r--r--src/displayapp/screens/Twos.cpp6
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.cpp73
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.h5
-rw-r--r--src/displayapp/screens/WatchFaceDigital.cpp38
-rw-r--r--src/displayapp/screens/WatchFaceDigital.h5
-rw-r--r--src/displayapp/screens/WatchFacePineTimeStyle.cpp (renamed from src/displayapp/screens/PineTimeStyle.cpp)74
-rw-r--r--src/displayapp/screens/WatchFacePineTimeStyle.h (renamed from src/displayapp/screens/PineTimeStyle.h)26
-rw-r--r--src/displayapp/screens/WatchFaceTerminal.cpp9
-rw-r--r--src/displayapp/screens/WatchFaceTerminal.h1
-rw-r--r--src/displayapp/screens/settings/QuickSettings.cpp30
-rw-r--r--src/displayapp/screens/settings/QuickSettings.h4
-rw-r--r--src/displayapp/screens/settings/SettingBluetooth.cpp5
-rw-r--r--src/displayapp/screens/settings/SettingChimes.cpp4
-rw-r--r--src/displayapp/screens/settings/SettingDisplay.cpp6
-rw-r--r--src/displayapp/screens/settings/SettingSetDate.cpp20
-rw-r--r--src/displayapp/screens/settings/SettingSetDate.h48
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.cpp12
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.h4
-rw-r--r--src/displayapp/screens/settings/SettingSteps.cpp27
-rw-r--r--src/displayapp/screens/settings/SettingTimeFormat.cpp4
-rw-r--r--src/displayapp/screens/settings/SettingWakeUp.cpp4
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.cpp4
-rw-r--r--src/displayapp/screens/settings/Settings.cpp32
66 files changed, 467 insertions, 741 deletions
diff --git a/src/displayapp/screens/Alarm.cpp b/src/displayapp/screens/Alarm.cpp
index 2557242..cfb151c 100644
--- a/src/displayapp/screens/Alarm.cpp
+++ b/src/displayapp/screens/Alarm.cpp
@@ -40,7 +40,7 @@ Alarm::Alarm(DisplayApp* app,
time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
- lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
alarmHours = alarmController.Hours();
alarmMinutes = alarmController.Minutes();
@@ -50,7 +50,7 @@ Alarm::Alarm(DisplayApp* app,
lblampm = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20);
- lv_obj_set_style_local_text_color(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_text_color(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_label_set_text_static(lblampm, " ");
lv_label_set_align(lblampm, LV_LABEL_ALIGN_CENTER);
lv_obj_align(lblampm, lv_scr_act(), LV_ALIGN_CENTER, 0, 30);
@@ -300,8 +300,12 @@ void Alarm::ShowInfo() {
auto minToAlarm = (timeToAlarm % 3600) / 60;
auto secToAlarm = timeToAlarm % 60;
- lv_label_set_text_fmt(
- txtMessage, "Time to\nalarm:\n%2lu Days\n%2lu Hours\n%2lu Minutes\n%2lu Seconds", daysToAlarm, hrsToAlarm, minToAlarm, secToAlarm);
+ lv_label_set_text_fmt(txtMessage,
+ "Time to\nalarm:\n%2lu Days\n%2lu Hours\n%2lu Minutes\n%2lu Seconds",
+ daysToAlarm,
+ hrsToAlarm,
+ minToAlarm,
+ secToAlarm);
} else {
lv_label_set_text_static(txtMessage, "Alarm\nis not\nset.");
}
diff --git a/src/displayapp/screens/Alarm.h b/src/displayapp/screens/Alarm.h
index f74dd68..80e446f 100644
--- a/src/displayapp/screens/Alarm.h
+++ b/src/displayapp/screens/Alarm.h
@@ -45,8 +45,8 @@ namespace Pinetime {
Controllers::Settings& settingsController;
System::SystemTask& systemTask;
- lv_obj_t *time, *lblampm, *btnStop, *txtStop, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp,
- *txtMinDown, *txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo, *enableSwitch;
+ lv_obj_t *time, *lblampm, *btnStop, *txtStop, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp, *txtMinDown,
+ *txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo, *enableSwitch;
lv_obj_t* txtMessage = nullptr;
lv_obj_t* btnMessage = nullptr;
lv_task_t* taskStopAlarm = nullptr;
diff --git a/src/displayapp/screens/BatteryIcon.cpp b/src/displayapp/screens/BatteryIcon.cpp
index 08aaab7..2fe7c25 100644
--- a/src/displayapp/screens/BatteryIcon.cpp
+++ b/src/displayapp/screens/BatteryIcon.cpp
@@ -1,23 +1,34 @@
#include "displayapp/screens/BatteryIcon.h"
#include <cstdint>
#include "displayapp/screens/Symbols.h"
+#include "displayapp/icons/battery/batteryicon.c"
using namespace Pinetime::Applications::Screens;
-const char* BatteryIcon::GetBatteryIcon(uint8_t batteryPercent) {
- if (batteryPercent > 87)
- return Symbols::batteryFull;
- if (batteryPercent > 62)
- return Symbols::batteryThreeQuarter;
- if (batteryPercent > 37)
- return Symbols::batteryHalf;
- if (batteryPercent > 12)
- return Symbols::batteryOneQuarter;
- return Symbols::batteryEmpty;
+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);
+
+ batteryJuice = lv_obj_create(batteryImg, nullptr);
+ lv_obj_set_width(batteryJuice, 8);
+ lv_obj_align(batteryJuice, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, -2, -2);
+ lv_obj_set_style_local_radius(batteryJuice, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0);
+}
+
+lv_obj_t* BatteryIcon::GetObject() {
+ return batteryImg;
+}
+
+void BatteryIcon::SetBatteryPercentage(uint8_t percentage) {
+ lv_obj_set_height(batteryJuice, percentage * 14 / 100);
+ lv_obj_realign(batteryJuice);
}
-const char* BatteryIcon::GetUnknownIcon() {
- return Symbols::batteryEmpty;
+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);
}
const char* BatteryIcon::GetPlugIcon(bool isCharging) {
diff --git a/src/displayapp/screens/BatteryIcon.h b/src/displayapp/screens/BatteryIcon.h
index bec2e4e..45d8f0e 100644
--- a/src/displayapp/screens/BatteryIcon.h
+++ b/src/displayapp/screens/BatteryIcon.h
@@ -1,15 +1,25 @@
#pragma once
#include <cstdint>
+#include <lvgl/src/lv_core/lv_obj.h>
namespace Pinetime {
namespace Applications {
namespace Screens {
class BatteryIcon {
public:
+ void Create(lv_obj_t* parent);
+
+ void SetColor(lv_color_t);
+ void SetBatteryPercentage(uint8_t percentage);
+ lv_obj_t* GetObject();
+
static const char* GetUnknownIcon();
- static const char* GetBatteryIcon(uint8_t batteryPercent);
static const char* GetPlugIcon(bool isCharging);
+
+ private:
+ lv_obj_t* batteryImg;
+ lv_obj_t* batteryJuice;
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp
index e17de9a..d9d479f 100644
--- a/src/displayapp/screens/BatteryInfo.cpp
+++ b/src/displayapp/screens/BatteryInfo.cpp
@@ -33,17 +33,11 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont
lv_obj_align(percent, nullptr, LV_ALIGN_CENTER, 0, -60);
voltage = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(voltage, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xC6A600));
+ lv_obj_set_style_local_text_color(voltage, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xff, 0xb0, 0x0));
lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10);
lv_label_set_align(voltage, LV_LABEL_ALIGN_CENTER);
lv_obj_align(voltage, nullptr, LV_ALIGN_CENTER, 0, 95);
- lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text_static(backgroundLabel, "");
-
taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this);
Refresh();
}
@@ -68,7 +62,7 @@ void BatteryInfo::Refresh() {
lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
lv_label_set_text_static(status, "Battery low");
} else {
- lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_GREEN);
+ lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x0, 0xb0, 0x0));
lv_label_set_text_static(status, "Discharging");
}
diff --git a/src/displayapp/screens/Brightness.cpp b/src/displayapp/screens/Brightness.cpp
deleted file mode 100644
index d9901ae..0000000
--- a/src/displayapp/screens/Brightness.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-#include "displayapp/screens/Brightness.h"
-#include <lvgl/lvgl.h>
-
-using namespace Pinetime::Applications::Screens;
-
-void slider_event_cb(lv_obj_t* slider, lv_event_t event) {
- if (event == LV_EVENT_VALUE_CHANGED) {
- auto* brightnessSlider = static_cast<Brightness*>(slider->user_data);
- brightnessSlider->OnValueChanged();
- }
-}
-
-Brightness::Brightness(Pinetime::Applications::DisplayApp* app, Controllers::BrightnessController& brightness)
- : Screen(app), brightness {brightness} {
- slider = lv_slider_create(lv_scr_act(), nullptr);
- lv_obj_set_user_data(slider, this);
- lv_obj_set_width(slider, LV_DPI * 2);
- lv_obj_align(slider, nullptr, LV_ALIGN_CENTER, 0, 0);
- lv_obj_set_event_cb(slider, slider_event_cb);
- lv_slider_set_range(slider, 0, 2);
- lv_slider_set_value(slider, LevelToInt(brightness.Level()), LV_ANIM_OFF);
-
- slider_label = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(slider_label, LevelToString(brightness.Level()));
- lv_obj_set_auto_realign(slider_label, true);
- lv_obj_align(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 30);
-}
-
-Brightness::~Brightness() {
- lv_obj_clean(lv_scr_act());
-}
-
-const char* Brightness::LevelToString(Pinetime::Controllers::BrightnessController::Levels level) {
- switch (level) {
- case Pinetime::Controllers::BrightnessController::Levels::Off:
- return "Off";
- case Pinetime::Controllers::BrightnessController::Levels::Low:
- return "Low";
- case Pinetime::Controllers::BrightnessController::Levels::Medium:
- return "Medium";
- case Pinetime::Controllers::BrightnessController::Levels::High:
- return "High";
- default:
- return "???";
- }
-}
-
-void Brightness::OnValueChanged() {
- SetValue(lv_slider_get_value(slider));
-}
-
-void Brightness::SetValue(uint8_t value) {
- switch (value) {
- case 0:
- brightness.Set(Controllers::BrightnessController::Levels::Low);
- break;
- case 1:
- brightness.Set(Controllers::BrightnessController::Levels::Medium);
- break;
- case 2:
- brightness.Set(Controllers::BrightnessController::Levels::High);
- break;
- }
- lv_label_set_text(slider_label, LevelToString(brightness.Level()));
-}
-
-uint8_t Brightness::LevelToInt(Pinetime::Controllers::BrightnessController::Levels level) {
- switch (level) {
- case Pinetime::Controllers::BrightnessController::Levels::Off:
- return 0;
- case Pinetime::Controllers::BrightnessController::Levels::Low:
- return 0;
- case Pinetime::Controllers::BrightnessController::Levels::Medium:
- return 1;
- case Pinetime::Controllers::BrightnessController::Levels::High:
- return 2;
- default:
- return 0;
- }
-}
-
-bool Brightness::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
- switch (event) {
- case TouchEvents::SwipeLeft:
- brightness.Lower();
- if (brightness.Level() == Pinetime::Controllers::BrightnessController::Levels::Off) {
- brightness.Set(Controllers::BrightnessController::Levels::Low);
- }
- SetValue();
- return true;
- case TouchEvents::SwipeRight:
- brightness.Higher();
- SetValue();
- return true;
- default:
- return false;
- }
-}
-
-void Brightness::SetValue() {
- lv_slider_set_value(slider, LevelToInt(brightness.Level()), LV_ANIM_OFF);
- lv_label_set_text(slider_label, LevelToString(brightness.Level()));
-}
diff --git a/src/displayapp/screens/Brightness.h b/src/displayapp/screens/Brightness.h
deleted file mode 100644
index 693570c..0000000
--- a/src/displayapp/screens/Brightness.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#pragma once
-
-#include <lvgl/src/lv_core/lv_obj.h>
-#include <cstdint>
-#include "displayapp/screens/Screen.h"
-#include "components/brightness/BrightnessController.h"
-
-namespace Pinetime {
- namespace Applications {
- namespace Screens {
- class Brightness : public Screen {
- public:
- Brightness(DisplayApp* app, Controllers::BrightnessController& brightness);
- ~Brightness() override;
-
- bool OnTouchEvent(TouchEvents event) override;
-
- void OnValueChanged();
-
- private:
- Controllers::BrightnessController& brightness;
-
- lv_obj_t* slider_label;
- lv_obj_t* slider;
-
- const char* LevelToString(Controllers::BrightnessController::Levels level);
- uint8_t LevelToInt(Controllers::BrightnessController::Levels level);
- void SetValue(uint8_t value);
- void SetValue();
- };
- }
- }
-}
diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp
index 67598c0..6e4e9af 100644
--- a/src/displayapp/screens/Clock.cpp
+++ b/src/displayapp/screens/Clock.cpp
@@ -12,7 +12,7 @@
#include "displayapp/screens/WatchFaceTerminal.h"
#include "displayapp/screens/WatchFaceAnalog.h"
#include "displayapp/screens/WatchFaceAnalog24.h"
-#include "displayapp/screens/PineTimeStyle.h"
+#include "displayapp/screens/WatchFacePineTimeStyle.h"
using namespace Pinetime::Applications::Screens;
@@ -44,7 +44,7 @@ Clock::Clock(DisplayApp* app,
return WatchFaceAnalog24Screen();
break;
case 3:
- return PineTimeStyleScreen();
+ return WatchFacePineTimeStyleScreen();
break;
case 4:
return WatchFaceTerminalScreen();
@@ -79,8 +79,12 @@ std::unique_ptr<Screen> Clock::WatchFaceDigitalScreen() {
}
std::unique_ptr<Screen> Clock::WatchFaceAnalogScreen() {
- return std::make_unique<Screens::WatchFaceAnalog>(
- app, dateTimeController, batteryController, bleController, notificatioManager, settingsController);
+ return std::make_unique<Screens::WatchFaceAnalog>(app,
+ dateTimeController,
+ batteryController,
+ bleController,
+ notificatioManager,
+ settingsController);
}
std::unique_ptr<Screen> Clock::WatchFaceAnalog24Screen() {
@@ -94,9 +98,14 @@ std::unique_ptr<Screen> Clock::WatchFaceAnalog24Screen() {
motionController);
}
-std::unique_ptr<Screen> Clock::PineTimeStyleScreen() {
- return std::make_unique<Screens::PineTimeStyle>(
- app, dateTimeController, batteryController, bleController, notificatioManager, settingsController, motionController);
+std::unique_ptr<Screen> Clock::WatchFacePineTimeStyleScreen() {
+ return std::make_unique<Screens::WatchFacePineTimeStyle>(app,
+ dateTimeController,
+ batteryController,
+ bleController,
+ notificatioManager,
+ settingsController,
+ motionController);
}
std::unique_ptr<Screen> Clock::WatchFaceTerminalScreen() {
diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h
index 2fcb1e6..3b5d896 100644
--- a/src/displayapp/screens/Clock.h
+++ b/src/displayapp/screens/Clock.h
@@ -47,7 +47,7 @@ namespace Pinetime {
std::unique_ptr<Screen> WatchFaceDigitalScreen();
std::unique_ptr<Screen> WatchFaceAnalogScreen();
std::unique_ptr<Screen> WatchFaceAnalog24Screen();
- std::unique_ptr<Screen> PineTimeStyleScreen();
+ std::unique_ptr<Screen> WatchFacePineTimeStyleScreen();
std::unique_ptr<Screen> WatchFaceTerminalScreen();
};
}
diff --git a/src/displayapp/screens/Error.cpp b/src/displayapp/screens/Error.cpp
index d546d61..82cb706 100644
--- a/src/displayapp/screens/Error.cpp
+++ b/src/displayapp/screens/Error.cpp
@@ -9,8 +9,7 @@ namespace {
}
}
-Error::Error(Pinetime::Applications::DisplayApp* app, System::BootErrors error)
- : Screen(app) {
+Error::Error(Pinetime::Applications::DisplayApp* app, System::BootErrors error) : Screen(app) {
lv_obj_t* warningLabel = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(warningLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
diff --git a/src/displayapp/screens/Error.h b/src/displayapp/screens/Error.h
index 2316754..6dbcc38 100644
--- a/src/displayapp/screens/Error.h
+++ b/src/displayapp/screens/Error.h
@@ -13,6 +13,7 @@ namespace Pinetime {
~Error() override;
void ButtonEventHandler();
+
private:
lv_obj_t* btnOk;
};
diff --git a/src/displayapp/screens/FirmwareUpdate.cpp b/src/displayapp/screens/FirmwareUpdate.cpp
index 0a8544b..01530e1 100644
--- a/src/displayapp/screens/FirmwareUpdate.cpp
+++ b/src/displayapp/screens/FirmwareUpdate.cpp
@@ -8,26 +8,19 @@ using namespace Pinetime::Applications::Screens;
FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Ble& bleController)
: Screen(app), bleController {bleController} {
- lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text_static(backgroundLabel, "");
-
titleLabel = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(titleLabel, "Firmware update");
- lv_obj_set_auto_realign(titleLabel, true);
lv_obj_align(titleLabel, nullptr, LV_ALIGN_IN_TOP_MID, 0, 50);
bar1 = lv_bar_create(lv_scr_act(), nullptr);
lv_obj_set_size(bar1, 200, 30);
lv_obj_align(bar1, nullptr, LV_ALIGN_CENTER, 0, 0);
- lv_bar_set_anim_time(bar1, 10);
- lv_bar_set_range(bar1, 0, 100);
+ lv_bar_set_range(bar1, 0, 1000);
lv_bar_set_value(bar1, 0, LV_ANIM_OFF);
percentLabel = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(percentLabel, "Waiting...");
+ lv_label_set_recolor(percentLabel, true);
lv_obj_set_auto_realign(percentLabel, true);
lv_obj_align(percentLabel, bar1, LV_ALIGN_OUT_TOP_MID, 0, 60);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
@@ -55,8 +48,9 @@ void FirmwareUpdate::Refresh() {
}
break;
case Pinetime::Controllers::Ble::FirmwareUpdateStates::Running:
- if (state != States::Running)
+ if (state != States::Running) {
state = States::Running;
+ }
DisplayProgression();
break;
case Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated:
@@ -78,21 +72,20 @@ void FirmwareUpdate::Refresh() {
}
void FirmwareUpdate::DisplayProgression() const {
- float current = bleController.FirmwareUpdateCurrentBytes() / 1024.0f;
- float total = bleController.FirmwareUpdateTotalBytes() / 1024.0f;
- int16_t pc = (current / total) * 100.0f;
- lv_label_set_text_fmt(percentLabel, "%d %%", pc);
+ const uint32_t current = bleController.FirmwareUpdateCurrentBytes();
+ const uint32_t total = bleController.FirmwareUpdateTotalBytes();
+ const int16_t permille = current / (total / 1000);
- lv_bar_set_value(bar1, pc, LV_ANIM_OFF);
+ lv_label_set_text_fmt(percentLabel, "%d %%", permille / 10);
+
+ lv_bar_set_value(bar1, permille, LV_ANIM_OFF);
}
void FirmwareUpdate::UpdateValidated() {
- lv_label_set_recolor(percentLabel, true);
lv_label_set_text_static(percentLabel, "#00ff00 Image Ok!#");
}
void FirmwareUpdate::UpdateError() {
- lv_label_set_recolor(percentLabel, true);
lv_label_set_text_static(percentLabel, "#ff0000 Error!#");
startTime = xTaskGetTickCount();
}
diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp
index 16244ad..a3c9761 100644
--- a/src/displayapp/screens/FirmwareValidation.cpp
+++ b/src/displayapp/screens/FirmwareValidation.cpp
@@ -7,11 +7,10 @@
using namespace Pinetime::Applications::Screens;
namespace {
- static void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) {
- FirmwareValidation* screen = static_cast<FirmwareValidation*>(obj->user_data);
+ void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<FirmwareValidation*>(obj->user_data);
screen->OnButtonEvent(obj, event);
}
-
}
FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::FirmwareValidator& validator)
@@ -35,14 +34,15 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app,
if (validator.IsValidated())
lv_label_set_text_static(labelIsValidated, "You have already\n#00ff00 validated# this firmware#");
else {
- lv_label_set_text_static(labelIsValidated, "Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version.");
+ lv_label_set_text_static(labelIsValidated,
+ "Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version.");
buttonValidate = lv_btn_create(lv_scr_act(), nullptr);
buttonValidate->user_data = this;
lv_obj_set_size(buttonValidate, 115, 50);
lv_obj_align(buttonValidate, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_obj_set_event_cb(buttonValidate, ButtonEventHandler);
- lv_obj_set_style_local_bg_color(buttonValidate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x009900));
+ lv_obj_set_style_local_bg_color(buttonValidate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x0, 0xb0, 0x0));
labelButtonValidate = lv_label_create(buttonValidate, nullptr);
lv_label_set_text_static(labelButtonValidate, "Validate");
@@ -51,7 +51,7 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app,
buttonReset->user_data = this;
lv_obj_set_size(buttonReset, 115, 50);
lv_obj_align(buttonReset, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
- lv_obj_set_style_local_bg_color(buttonReset, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x990000));
+ lv_obj_set_style_local_bg_color(buttonReset, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0x0, 0x0));
lv_obj_set_event_cb(buttonReset, ButtonEventHandler);
labelButtonReset = lv_label_create(buttonReset, nullptr);
diff --git a/src/displayapp/screens/FlashLight.cpp b/src/displayapp/screens/FlashLight.cpp
index 0634187..2a1884f 100644
--- a/src/displayapp/screens/FlashLight.cpp
+++ b/src/displayapp/screens/FlashLight.cpp
@@ -28,7 +28,7 @@ FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
lv_label_set_text_static(flashLight, Symbols::highlight);
lv_obj_align(flashLight, nullptr, LV_ALIGN_CENTER, 0, 0);
- for (auto & i : indicators) {
+ for (auto& i : indicators) {
i = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_size(i, 15, 10);
lv_obj_set_style_local_border_width(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 2);
@@ -63,16 +63,16 @@ FlashLight::~FlashLight() {
void FlashLight::SetColors() {
if (isOn) {
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
- lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
- for (auto & i : indicators) {
- lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
+ for (auto& i : indicators) {
+ lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DISABLED, LV_COLOR_WHITE);
- lv_obj_set_style_local_border_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_border_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
}
} else {
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
- for (auto & i : indicators) {
+ for (auto& i : indicators) {
lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DISABLED, LV_COLOR_BLACK);
lv_obj_set_style_local_border_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
diff --git a/src/displayapp/screens/HeartRate.cpp b/src/displayapp/screens/HeartRate.cpp
index 89b43bb..35e06bb 100644
--- a/src/displayapp/screens/HeartRate.cpp
+++ b/src/displayapp/screens/HeartRate.cpp
@@ -21,8 +21,8 @@ namespace {
return "";
}
- static void btnStartStopEventHandler(lv_obj_t* obj, lv_event_t event) {
- HeartRate* screen = static_cast<HeartRate*>(obj->user_data);
+ void btnStartStopEventHandler(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<HeartRate*>(obj->user_data);
screen->OnStartStopEvent(event);
}
}
@@ -37,9 +37,9 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
lv_obj_set_style_local_text_font(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
if (isHrRunning)
- lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
+ lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x0, 0xb0, 0x0));
else
- lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_label_set_text_static(label_hr, "000");
lv_obj_align(label_hr, nullptr, LV_ALIGN_CENTER, 0, -40);
@@ -49,7 +49,7 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
lv_obj_align(label_bpm, label_hr, LV_ALIGN_OUT_TOP_MID, 0, -20);
label_status = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(label_status, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222));
+ lv_obj_set_style_local_text_color(label_status, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
lv_label_set_text_static(label_status, ToString(Pinetime::Controllers::HeartRateController::States::NotEnoughData));
lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
@@ -97,12 +97,12 @@ void HeartRate::OnStartStopEvent(lv_event_t event) {
heartRateController.Start();
UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped);
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
- lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
+ lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x0, 0xb0, 0x0));
} else {
heartRateController.Stop();
UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped);
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
- lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
}
}
}
diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp
index d279faf..733b4e2 100644
--- a/src/displayapp/screens/InfiniPaint.cpp
+++ b/src/displayapp/screens/InfiniPaint.cpp
@@ -26,7 +26,7 @@ bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
selectColor = LV_COLOR_MAGENTA;
break;
case 1:
- selectColor = LV_COLOR_GREEN;
+ selectColor = LV_COLOR_MAKE(0x0, 0xb0, 0x0);
break;
case 2:
selectColor = LV_COLOR_WHITE;
diff --git a/src/displayapp/screens/Label.cpp b/src/displayapp/screens/Label.cpp
index 62ec1f0..4486d6f 100644
--- a/src/displayapp/screens/Label.cpp
+++ b/src/displayapp/screens/Label.cpp
@@ -27,7 +27,7 @@ Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::Displ
pageIndicator = lv_line_create(lv_scr_act(), NULL);
lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_obj_set_style_local_line_rounded(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true);
lv_line_set_points(pageIndicator, pageIndicatorPoints, 2);
}
diff --git a/src/displayapp/screens/List.cpp b/src/displayapp/screens/List.cpp
index af3f30f..0bc7da8 100644
--- a/src/displayapp/screens/List.cpp
+++ b/src/displayapp/screens/List.cpp
@@ -5,11 +5,10 @@
using namespace Pinetime::Applications::Screens;
namespace {
- static void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) {
- List* screen = static_cast<List*>(obj->user_data);
+ void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<List*>(obj->user_data);
screen->OnButtonEvent(obj, event);
}
-
}
List::List(uint8_t screenID,
@@ -45,7 +44,7 @@ List::List(uint8_t screenID,
pageIndicator = lv_line_create(lv_scr_act(), NULL);
lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_line_set_points(pageIndicator, pageIndicatorPoints, 2);
}
@@ -68,7 +67,7 @@ List::List(uint8_t screenID,
if (applications[i].application != Apps::None) {
itemApps[i] = lv_btn_create(container1, nullptr);
- lv_obj_set_style_local_bg_opa(itemApps[i], LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_20);
+ lv_obj_set_style_local_bg_opa(itemApps[i], LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
lv_obj_set_style_local_radius(itemApps[i], LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 57);
lv_obj_set_style_local_bg_color(itemApps[i], LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA);
@@ -86,12 +85,6 @@ List::List(uint8_t screenID,
lv_label_set_text_fmt(labelBt, " %s", applications[i].name);
}
}
-
- lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, LV_HOR_RES, LV_VER_RES);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text_static(backgroundLabel, "");
}
List::~List() {
diff --git a/src/displayapp/screens/List.h b/src/displayapp/screens/List.h
index 023de3a..88ef28e 100644
--- a/src/displayapp/screens/List.h
+++ b/src/displayapp/screens/List.h
@@ -2,7 +2,7 @@
#include <lvgl/lvgl.h>
#include <cstdint>
-#include <memory>
+#include <array>
#include "displayapp/screens/Screen.h"
#include "displayapp/Apps.h"
#include "components/settings/Settings.h"
diff --git a/src/displayapp/screens/Meter.cpp b/src/displayapp/screens/Meter.cpp
deleted file mode 100644
index 9c85310..0000000
--- a/src/displayapp/screens/Meter.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "displayapp/screens/Meter.h"
-#include <lvgl/lvgl.h>
-#include "displayapp/DisplayApp.h"
-
-using namespace Pinetime::Applications::Screens;
-
-Meter::Meter(Pinetime::Applications::DisplayApp* app) : Screen(app) {
-
- /*Create a line meter */
- lmeter = lv_linemeter_create(lv_scr_act(), nullptr);
- lv_linemeter_set_range(lmeter, 0, 60); /*Set the range*/
- lv_linemeter_set_value(lmeter, value); /*Set the current value*/
- lv_linemeter_set_angle_offset(lmeter, 180);
- lv_linemeter_set_scale(lmeter, 360, 60); /*Set the angle and number of lines*/
-
- lv_obj_set_style_local_scale_end_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(255, 0, 0));
- lv_obj_set_style_local_scale_grad_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(160, 0, 0));
- lv_obj_set_style_local_line_width(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 2);
- lv_obj_set_style_local_line_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_SILVER);
-
- lv_obj_set_size(lmeter, 200, 200);
- lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0);
-
- taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
-}
-
-Meter::~Meter() {
- lv_task_del(taskRefresh);
- lv_obj_clean(lv_scr_act());
-}
-
-void Meter::Refresh() {
- lv_linemeter_set_value(lmeter, value++); /*Set the current value*/
- if (value >= 60)
- value = 0;
-}
diff --git a/src/displayapp/screens/Meter.h b/src/displayapp/screens/Meter.h
deleted file mode 100644
index 50d9f83..0000000
--- a/src/displayapp/screens/Meter.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#pragma once
-
-#include <cstdint>
-#include "displayapp/screens/Screen.h"
-#include <lvgl/src/lv_core/lv_style.h>
-#include <lvgl/src/lv_core/lv_obj.h>
-
-namespace Pinetime {
- namespace Applications {
- namespace Screens {
-
- class Meter : public Screen {
- public:
- Meter(DisplayApp* app);
- ~Meter() override;
-
- void Refresh() override;
-
- private:
- lv_style_t style_lmeter;
- lv_obj_t* lmeter;
-
- uint32_t value = 0;
-
- lv_task_t* taskRefresh;
- };
- }
- }
-}
diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp
index 8b511ca..734910b 100644
--- a/src/displayapp/screens/Metronome.cpp
+++ b/src/displayapp/screens/Metronome.cpp
@@ -12,7 +12,7 @@ namespace {
lv_obj_t* createLabel(const char* name, lv_obj_t* reference, lv_align_t align, lv_font_t* font, uint8_t x, uint8_t y) {
lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font);
- lv_obj_set_style_local_text_color(label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_text_color(label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_label_set_text(label, name);
lv_obj_align(label, reference, align, x, y);
@@ -47,8 +47,6 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl
bpbDropdown = lv_dropdown_create(lv_scr_act(), nullptr);
bpbDropdown->user_data = this;
lv_obj_set_event_cb(bpbDropdown, eventHandler);
- lv_obj_set_style_local_pad_left(bpbDropdown, LV_DROPDOWN_PART_MAIN, LV_STATE_DEFAULT, 20);
- lv_obj_set_style_local_pad_left(bpbDropdown, LV_DROPDOWN_PART_LIST, LV_STATE_DEFAULT, 20);
lv_obj_set_size(bpbDropdown, 115, 50);
lv_obj_align(bpbDropdown, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_dropdown_set_options(bpbDropdown, "1\n2\n3\n4\n5\n6\n7\n8\n9");
diff --git a/src/displayapp/screens/Metronome.h b/src/displayapp/screens/Metronome.h
index 6e6589f..8933b17 100644
--- a/src/displayapp/screens/Metronome.h
+++ b/src/displayapp/screens/Metronome.h
@@ -30,7 +30,7 @@ namespace Pinetime {
lv_obj_t *bpmArc, *bpmTap, *bpmValue;
lv_obj_t *bpbDropdown, *currentBpbText;
- lv_obj_t *playPause;
+ lv_obj_t* playPause;
lv_task_t* taskRefresh;
};
diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp
index 799dcb3..f7ffcc7 100644
--- a/src/displayapp/screens/Motion.cpp
+++ b/src/displayapp/screens/Motion.cpp
@@ -19,7 +19,7 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr
/*Add 3 data series*/
ser1 = lv_chart_add_series(chart, LV_COLOR_RED);
- ser2 = lv_chart_add_series(chart, LV_COLOR_GREEN);
+ ser2 = lv_chart_add_series(chart, LV_COLOR_MAKE(0x0, 0xb0, 0x0));
ser3 = lv_chart_add_series(chart, LV_COLOR_YELLOW);
lv_chart_init_points(chart, ser1, 0);
@@ -28,7 +28,7 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr
lv_chart_refresh(chart); /*Required after direct set*/
label = lv_label_create(lv_scr_act(), NULL);
- lv_label_set_text_fmt(label, "X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#", 0, 0, 0);
+ lv_label_set_text_fmt(label, "X #FF0000 %d# Y #00B000 %d# Z #FFFF00 %d#", 0, 0, 0);
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
lv_label_set_recolor(label, true);
@@ -53,7 +53,7 @@ void Motion::Refresh() {
lv_label_set_text_fmt(labelStep, "Steps %lu", motionController.NbSteps());
lv_label_set_text_fmt(label,
- "X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#",
+ "X #FF0000 %d# Y #00B000 %d# Z #FFFF00 %d#",
motionController.X() / 0x10,
motionController.Y() / 0x10,
motionController.Z() / 0x10);
diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp
index d14ae3a..1abb16a 100644
--- a/src/displayapp/screens/Music.cpp
+++ b/src/displayapp/screens/Music.cpp
@@ -20,9 +20,9 @@
#include <cstdint>
#include "displayapp/DisplayApp.h"
#include "components/ble/MusicService.h"
-#include "displayapp/icons/music/disc.cpp"
-#include "displayapp/icons/music/disc_f_1.cpp"
-#include "displayapp/icons/music/disc_f_2.cpp"
+#include "displayapp/icons/music/disc.c"
+#include "displayapp/icons/music/disc_f_1.c"
+#include "displayapp/icons/music/disc_f_2.c"
using namespace Pinetime::Applications::Screens;
@@ -53,7 +53,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus
lv_style_init(&btn_style);
lv_style_set_radius(&btn_style, LV_STATE_DEFAULT, 20);
lv_style_set_bg_color(&btn_style, LV_STATE_DEFAULT, LV_COLOR_AQUA);
- lv_style_set_bg_opa(&btn_style, LV_STATE_DEFAULT, LV_OPA_20);
+ lv_style_set_bg_opa(&btn_style, LV_STATE_DEFAULT, LV_OPA_50);
btnVolDown = lv_btn_create(lv_scr_act(), nullptr);
btnVolDown->user_data = this;
@@ -152,32 +152,24 @@ Music::~Music() {
void Music::Refresh() {
if (artist != musicService.getArtist()) {
artist = musicService.getArtist();
- currentLength = 0;
lv_label_set_text(txtArtist, artist.data());
}
if (track != musicService.getTrack()) {
track = musicService.getTrack();
- currentLength = 0;
lv_label_set_text(txtTrack, track.data());
}
if (album != musicService.getAlbum()) {
album = musicService.getAlbum();
- currentLength = 0;
}
if (playing != musicService.isPlaying()) {
playing = musicService.isPlaying();
}
- // Because we increment this ourselves,
- // we can't compare with the old data directly
- // have to update it when there's actually new data
- // just to avoid unnecessary draws that make UI choppy
- if (lastLength != musicService.getProgress()) {
- currentLength = musicService.getProgress();
- lastLength = currentLength;
+ if (currentPosition != musicService.getProgress()) {
+ currentPosition = musicService.getProgress();
UpdateLength();
}
@@ -186,7 +178,7 @@ void Music::Refresh() {
UpdateLength();
}
- if (playing == Pinetime::Controllers::MusicService::MusicStatus::Playing) {
+ if (playing) {
lv_label_set_text_static(txtPlayPause, Symbols::pause);
if (xTaskGetTickCount() - 1024 >= lastIncrement) {
@@ -197,18 +189,12 @@ void Music::Refresh() {
}
frameB = !frameB;
- if (currentLength < totalLength) {
- currentLength +=
- static_cast<int>((static_cast<float>(xTaskGetTickCount() - lastIncrement) / 1024.0f) * musicService.getPlaybackSpeed());
- } else {
+ if (currentPosition >= totalLength) {
// Let's assume the getTrack finished, paused when the timer ends
// and there's no new getTrack being sent to us
- // TODO: ideally this would be configurable
playing = false;
}
lastIncrement = xTaskGetTickCount();
-
- UpdateLength();
}
} else {
lv_label_set_text_static(txtPlayPause, Symbols::play);
@@ -219,23 +205,19 @@ void Music::UpdateLength() {
if (totalLength > (99 * 60 * 60)) {
lv_label_set_text_static(txtTrackDuration, "Inf/Inf");
} else if (totalLength > (99 * 60)) {
- char timer[12];
- sprintf(timer,
- "%02d:%02d/%02d:%02d",
- (currentLength / (60 * 60)) % 100,
- ((currentLength % (60 * 60)) / 60) % 100,
- (totalLength / (60 * 60)) % 100,
- ((totalLength % (60 * 60)) / 60) % 100);
- lv_label_set_text(txtTrackDuration, timer);
+ lv_label_set_text_fmt(txtTrackDuration,
+ "%02d:%02d/%02d:%02d",
+ (currentPosition / (60 * 60)) % 100,
+ ((currentPosition % (60 * 60)) / 60) % 100,
+ (totalLength / (60 * 60)) % 100,
+ ((totalLength % (60 * 60)) / 60) % 100);
} else {
- char timer[12];
- sprintf(timer,
- "%02d:%02d/%02d:%02d",
- (currentLength / 60) % 100,
- (currentLength % 60) % 100,
- (totalLength / 60) % 100,
- (totalLength % 60) % 100);
- lv_label_set_text(txtTrackDuration, timer);
+ lv_label_set_text_fmt(txtTrackDuration,
+ "%02d:%02d/%02d:%02d",
+ (currentPosition / 60) % 100,
+ (currentPosition % 60) % 100,
+ (totalLength / 60) % 100,
+ (totalLength % 60) % 100);
}
}
diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h
index 27b2d3d..258a402 100644
--- a/src/displayapp/screens/Music.h
+++ b/src/displayapp/screens/Music.h
@@ -70,10 +70,8 @@ namespace Pinetime {
/** Total length in seconds */
int totalLength = 0;
- /** Current length in seconds */
- int currentLength;
- /** Last length */
- int lastLength;
+ /** Current position in seconds */
+ int currentPosition;
/** Last time an animation update or timer was incremented */
TickType_t lastIncrement = 0;
diff --git a/src/displayapp/screens/Navigation.cpp b/src/displayapp/screens/Navigation.cpp
index 0dd0d30..5779df3 100644
--- a/src/displayapp/screens/Navigation.cpp
+++ b/src/displayapp/screens/Navigation.cpp
@@ -192,7 +192,7 @@ void Navigation::Refresh() {
if (progress > 90) {
lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED);
} else {
- lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
+ lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xff, 0xb0, 0x0));
}
}
}
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index 600f748..d7fe93a 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -181,7 +181,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
: mode {mode}, alertNotificationService {alertNotificationService}, motorController {motorController} {
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL);
- lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222));
+ lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x38, 0x38, 0x38));
lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10);
lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5);
lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
@@ -197,13 +197,13 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_align(alert_count, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 16);
lv_obj_t* alert_type = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x888888));
- if(title == nullptr) {
+ lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
+ if (title == nullptr) {
lv_label_set_text_static(alert_type, "Notification");
} else {
// copy title to label and replace newlines with spaces
lv_label_set_text(alert_type, title);
- char *pchar = strchr(lv_label_get_text(alert_type), '\n');
+ char* pchar = strchr(lv_label_get_text(alert_type), '\n');
while (pchar != nullptr) {
*pchar = ' ';
pchar = strchr(pchar + 1, '\n');
@@ -218,7 +218,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
switch (category) {
default: {
lv_obj_t* alert_subject = lv_label_create(container1, nullptr);
- lv_obj_set_style_local_text_color(alert_subject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
+ lv_obj_set_style_local_text_color(alert_subject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xff, 0xb0, 0x0));
lv_label_set_long_mode(alert_subject, LV_LABEL_LONG_BREAK);
lv_obj_set_width(alert_subject, LV_HOR_RES - 20);
lv_label_set_text(alert_subject, msg);
@@ -226,7 +226,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
case Controllers::NotificationManager::Categories::IncomingCall: {
lv_obj_set_height(container1, 108);
lv_obj_t* alert_subject = lv_label_create(container1, nullptr);
- lv_obj_set_style_local_text_color(alert_subject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
+ lv_obj_set_style_local_text_color(alert_subject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xff, 0xb0, 0x0));
lv_label_set_long_mode(alert_subject, LV_LABEL_LONG_BREAK);
lv_obj_set_width(alert_subject, LV_HOR_RES - 20);
lv_label_set_text_static(alert_subject, "Incoming call from");
@@ -244,7 +244,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_align(bt_accept, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
label_accept = lv_label_create(bt_accept, nullptr);
lv_label_set_text_static(label_accept, Symbols::phone);
- lv_obj_set_style_local_bg_color(bt_accept, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
+ lv_obj_set_style_local_bg_color(bt_accept, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x0, 0xb0, 0x0));
bt_reject = lv_btn_create(lv_scr_act(), nullptr);
bt_reject->user_data = this;
@@ -262,15 +262,9 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_align(bt_mute, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
label_mute = lv_label_create(bt_mute, nullptr);
lv_label_set_text_static(label_mute, Symbols::volumMute);
- lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
} break;
}
-
- lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text_static(backgroundLabel, "");
}
void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_t event) {
diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp
index 79401ff..1fb2508 100644
--- a/src/displayapp/screens/Paddle.cpp
+++ b/src/displayapp/screens/Paddle.cpp
@@ -53,7 +53,7 @@ void Paddle::Refresh() {
if (ballX >= LV_HOR_RES - ballSize - 1) {
dx *= -1;
dy += rand() % 3 - 1; // add a little randomization in wall bounce direction, one of [-1, 0, 1]
- if (dy > 5) { // limit dy to be in range [-5 to 5]
+ if (dy > 5) { // limit dy to be in range [-5 to 5]
dy = 5;
}
if (dy < -5) {
@@ -85,7 +85,14 @@ bool Paddle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
bool Paddle::OnTouchEvent(uint16_t x, uint16_t y) {
// sets the center paddle pos. (30px offset) with the the y_coordinate of the finger
- lv_obj_set_pos(paddle, 0, y - 30);
+ // but clamp it such that the paddle never clips off screen
+ if (y < 31) {
+ lv_obj_set_pos(paddle, 0, 1);
+ } else if (y > LV_VER_RES - 31) {
+ lv_obj_set_pos(paddle, 0, LV_VER_RES - 61);
+ } else {
+ lv_obj_set_pos(paddle, 0, y - 30);
+ }
paddlePos = y;
return true;
}
diff --git a/src/displayapp/screens/PassKey.cpp b/src/displayapp/screens/PassKey.cpp
index e9715cd..4057a7e 100644
--- a/src/displayapp/screens/PassKey.cpp
+++ b/src/displayapp/screens/PassKey.cpp
@@ -9,16 +9,8 @@ PassKey::PassKey(Pinetime::Applications::DisplayApp* app, uint32_t key) : Screen
lv_obj_set_style_local_text_font(passkeyLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_fmt(passkeyLabel, "%06u", key);
lv_obj_align(passkeyLabel, nullptr, LV_ALIGN_CENTER, 0, -20);
-
- backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_click(backgroundLabel, true);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text_static(backgroundLabel, "");
}
PassKey::~PassKey() {
lv_obj_clean(lv_scr_act());
}
-
diff --git a/src/displayapp/screens/PassKey.h b/src/displayapp/screens/PassKey.h
index 16e72a3..82735b5 100644
--- a/src/displayapp/screens/PassKey.h
+++ b/src/displayapp/screens/PassKey.h
@@ -14,7 +14,6 @@ namespace Pinetime {
private:
lv_obj_t* passkeyLabel;
- lv_obj_t* backgroundLabel;
};
}
}
diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h
index 04bb152..e72a236 100644
--- a/src/displayapp/screens/Screen.h
+++ b/src/displayapp/screens/Screen.h
@@ -35,7 +35,7 @@ namespace Pinetime {
private:
T value {}; // NSDMI - default initialise type
- bool isUpdated {true}; // NSDMI - use brace initilisation
+ bool isUpdated {true}; // NSDMI - use brace initialisation
};
class Screen {
diff --git a/src/displayapp/screens/ScreenList.h b/src/displayapp/screens/ScreenList.h
index e316e36..ad88294 100644
--- a/src/displayapp/screens/ScreenList.h
+++ b/src/displayapp/screens/ScreenList.h
@@ -17,8 +17,12 @@ namespace Pinetime {
uint8_t initScreen,
const std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens,
ScreenListModes mode)
- : Screen(app), initScreen {initScreen}, screens {std::move(screens)}, mode {mode}, screenIndex{initScreen}, current {this->screens[initScreen]()} {
-
+ : Screen(app),
+ initScreen {initScreen},
+ screens {std::move(screens)},
+ mode {mode},
+ screenIndex {initScreen},
+ current {this->screens[initScreen]()} {
}
ScreenList(const ScreenList&) = delete;
diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp
index 411b73d..de24354 100644
--- a/src/displayapp/screens/Steps.cpp
+++ b/src/displayapp/screens/Steps.cpp
@@ -38,7 +38,7 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40);
lv_obj_t* lstepsL = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(lstepsL, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111));
+ lv_obj_set_style_local_text_color(lstepsL, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
lv_label_set_text_static(lstepsL, "Steps");
lv_obj_align(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
@@ -48,12 +48,6 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
lv_label_set_align(lstepsGoal, LV_LABEL_ALIGN_CENTER);
lv_obj_align(lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
- lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text_static(backgroundLabel, "");
-
resetBtn = lv_btn_create(lv_scr_act(), nullptr);
resetBtn->user_data = this;
lv_obj_set_event_cb(resetBtn, lap_event_handler);
diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp
index ca479b5..10825ff 100644
--- a/src/displayapp/screens/StopWatch.cpp
+++ b/src/displayapp/screens/StopWatch.cpp
@@ -8,38 +8,26 @@
using namespace Pinetime::Applications::Screens;
-// Anonymous namespace for local functions
namespace {
TimeSeparated_t convertTicksToTimeSegments(const TickType_t timeElapsed) {
- const int timeElapsedMillis = (static_cast<float>(timeElapsed) / static_cast<float>(configTICK_RATE_HZ)) * 1000;
+ // Centiseconds
+ const int timeElapsedCentis = timeElapsed * 100 / configTICK_RATE_HZ;
- const int hundredths = (timeElapsedMillis % 1000) / 10; // Get only the first two digits and ignore the last
- const int secs = (timeElapsedMillis / 1000) % 60;
- const int mins = (timeElapsedMillis / 1000) / 60;
+ const int hundredths = (timeElapsedCentis % 100);
+ const int secs = (timeElapsedCentis / 100) % 60;
+ const int mins = (timeElapsedCentis / 100) / 60;
return TimeSeparated_t {mins, secs, hundredths};
}
- TickType_t calculateDelta(const TickType_t startTime, const TickType_t currentTime) {
- TickType_t delta = 0;
- // Take care of overflow
- if (startTime > currentTime) {
- delta = 0xffffffff - startTime;
- delta += (currentTime + 1);
- } else {
- delta = currentTime - startTime;
- }
- return delta;
+ void play_pause_event_handler(lv_obj_t* obj, lv_event_t event) {
+ auto* stopWatch = static_cast<StopWatch*>(obj->user_data);
+ stopWatch->playPauseBtnEventHandler(event);
}
-}
-static void play_pause_event_handler(lv_obj_t* obj, lv_event_t event) {
- auto stopWatch = static_cast<StopWatch*>(obj->user_data);
- stopWatch->playPauseBtnEventHandler(event);
-}
-
-static void stop_lap_event_handler(lv_obj_t* obj, lv_event_t event) {
- auto stopWatch = static_cast<StopWatch*>(obj->user_data);
- stopWatch->stopLapBtnEventHandler(event);
+ void stop_lap_event_handler(lv_obj_t* obj, lv_event_t event) {
+ auto* stopWatch = static_cast<StopWatch*>(obj->user_data);
+ stopWatch->stopLapBtnEventHandler(event);
+ }
}
StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
@@ -54,21 +42,20 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
- lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_label_set_text_static(time, "00:00");
- lv_obj_align(time, nullptr, LV_ALIGN_CENTER, 0, -45);
+ lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -45);
msecTime = lv_label_create(lv_scr_act(), nullptr);
// lv_obj_set_style_local_text_font(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20);
- lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_label_set_text_static(msecTime, "00");
- lv_obj_align(msecTime, nullptr, LV_ALIGN_CENTER, 0, 3);
+ lv_obj_align(msecTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 3);
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
btnPlayPause->user_data = this;
lv_obj_set_event_cb(btnPlayPause, play_pause_event_handler);
- lv_obj_set_height(btnPlayPause, 50);
- lv_obj_set_width(btnPlayPause, 115);
+ lv_obj_set_size(btnPlayPause, 115, 50);
lv_obj_align(btnPlayPause, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
txtPlayPause = lv_label_create(btnPlayPause, nullptr);
lv_label_set_text_static(txtPlayPause, Symbols::play);
@@ -76,12 +63,11 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
btnStopLap = lv_btn_create(lv_scr_act(), nullptr);
btnStopLap->user_data = this;
lv_obj_set_event_cb(btnStopLap, stop_lap_event_handler);
- lv_obj_set_height(btnStopLap, 50);
- lv_obj_set_width(btnStopLap, 115);
+ lv_obj_set_size(btnStopLap, 115, 50);
lv_obj_align(btnStopLap, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
- lv_obj_set_style_local_bg_color(btnStopLap, LV_BTN_PART_MAIN, LV_STATE_DISABLED, lv_color_hex(0x080808));
+ lv_obj_set_style_local_bg_color(btnStopLap, LV_BTN_PART_MAIN, LV_STATE_DISABLED, LV_COLOR_MAKE(0x18, 0x18, 0x18));
txtStopLap = lv_label_create(btnStopLap, nullptr);
- lv_obj_set_style_local_text_color(txtStopLap, LV_BTN_PART_MAIN, LV_STATE_DISABLED, lv_color_hex(0x888888));
+ lv_obj_set_style_local_text_color(txtStopLap, LV_BTN_PART_MAIN, LV_STATE_DISABLED, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_label_set_text_static(txtStopLap, Symbols::stop);
lv_obj_set_state(btnStopLap, LV_STATE_DISABLED);
lv_obj_set_state(txtStopLap, LV_STATE_DISABLED);
@@ -107,11 +93,11 @@ StopWatch::~StopWatch() {
lv_obj_clean(lv_scr_act());
}
-void StopWatch::reset() {
+void StopWatch::Reset() {
currentState = States::Init;
oldTimeElapsed = 0;
- lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
- lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
+ lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_label_set_text_static(time, "00:00");
lv_label_set_text_static(msecTime, "00");
@@ -124,11 +110,11 @@ void StopWatch::reset() {
lv_obj_set_state(txtStopLap, LV_STATE_DISABLED);
}
-void StopWatch::start() {
+void StopWatch::Start() {
lv_obj_set_state(btnStopLap, LV_STATE_DEFAULT);
lv_obj_set_state(txtStopLap, LV_STATE_DEFAULT);
- lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
- lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
+ lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x0, 0xb0, 0x0));
+ lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x0, 0xb0, 0x0));
lv_label_set_text_static(txtPlayPause, Symbols::pause);
lv_label_set_text_static(txtStopLap, Symbols::lapsFlag);
startTime = xTaskGetTickCount();
@@ -136,7 +122,7 @@ void StopWatch::start() {
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
}
-void StopWatch::pause() {
+void StopWatch::Pause() {
startTime = 0;
// Store the current time elapsed in cache
oldTimeElapsed += timeElapsed;
@@ -150,7 +136,7 @@ void StopWatch::pause() {
void StopWatch::Refresh() {
if (currentState == States::Running) {
- timeElapsed = calculateDelta(startTime, xTaskGetTickCount());
+ timeElapsed = xTaskGetTickCount() - startTime;
currentTimeSeparated = convertTicksToTimeSegments((oldTimeElapsed + timeElapsed));
lv_label_set_text_fmt(time, "%02d:%02d", currentTimeSeparated.mins, currentTimeSeparated.secs);
@@ -163,11 +149,11 @@ void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
return;
}
if (currentState == States::Init) {
- start();
+ Start();
} else if (currentState == States::Running) {
- pause();
+ Pause();
} else if (currentState == States::Halted) {
- start();
+ Start();
}
}
@@ -180,20 +166,24 @@ void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
lapBuffer.addLaps(currentTimeSeparated);
lapNr++;
if (lapBuffer[1]) {
- lv_label_set_text_fmt(
- lapOneText, "#%2d %2d:%02d.%02d", (lapNr - 1), lapBuffer[1]->mins, lapBuffer[1]->secs, lapBuffer[1]->hundredths);
+ lv_label_set_text_fmt(lapOneText,
+ "#%2d %2d:%02d.%02d",
+ (lapNr - 1),
+ lapBuffer[1]->mins,
+ lapBuffer[1]->secs,
+ lapBuffer[1]->hundredths);
}
if (lapBuffer[0]) {
lv_label_set_text_fmt(lapTwoText, "#%2d %2d:%02d.%02d", lapNr, lapBuffer[0]->mins, lapBuffer[0]->secs, lapBuffer[0]->hundredths);
}
} else if (currentState == States::Halted) {
- reset();
+ Reset();
}
}
bool StopWatch::OnButtonPushed() {
if (currentState == States::Running) {
- pause();
+ Pause();
return true;
}
return false;
diff --git a/src/displayapp/screens/StopWatch.h b/src/displayapp/screens/StopWatch.h
index 06193f6..ef55e2d 100644
--- a/src/displayapp/screens/StopWatch.h
+++ b/src/displayapp/screens/StopWatch.h
@@ -70,9 +70,9 @@ namespace Pinetime::Applications::Screens {
void stopLapBtnEventHandler(lv_event_t event);
bool OnButtonPushed() override;
- void reset();
- void start();
- void pause();
+ void Reset();
+ void Start();
+ void Pause();
private:
Pinetime::System::SystemTask& systemTask;
diff --git a/src/displayapp/screens/Styles.cpp b/src/displayapp/screens/Styles.cpp
index 7f43fb9..bcfd584 100644
--- a/src/displayapp/screens/Styles.cpp
+++ b/src/displayapp/screens/Styles.cpp
@@ -3,6 +3,6 @@
void Pinetime::Applications::Screens::SetRadioButtonStyle(lv_obj_t* checkbox) {
lv_obj_set_style_local_radius(checkbox, LV_CHECKBOX_PART_BULLET, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_obj_set_style_local_border_width(checkbox, LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, 9);
- lv_obj_set_style_local_border_color(checkbox, LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, LV_COLOR_GREEN);
+ lv_obj_set_style_local_border_color(checkbox, LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, LV_COLOR_MAKE(0x0, 0xb0, 0x0));
lv_obj_set_style_local_bg_color(checkbox, LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, LV_COLOR_WHITE);
}
diff --git a/src/displayapp/screens/Symbols.h b/src/displayapp/screens/Symbols.h
index e68a7af..f973181 100644
--- a/src/displayapp/screens/Symbols.h
+++ b/src/displayapp/screens/Symbols.h
@@ -5,13 +5,8 @@ namespace Pinetime {
namespace Screens {
namespace Symbols {
static constexpr const char* none = "";
- static constexpr const char* batteryFull = "\xEF\x89\x80";
- static constexpr const char* batteryEmpty = "\xEF\x89\x84";
- static constexpr const char* batteryThreeQuarter = "\xEF\x89\x81";
static constexpr const char* batteryHalf = "\xEF\x89\x82";
- static constexpr const char* batteryOneQuarter = "\xEF\x89\x83";
static constexpr const char* heartBeat = "\xEF\x88\x9E";
- static constexpr const char* bluetoothFull = "\xEF\x8A\x93";
static constexpr const char* bluetooth = "\xEF\x8A\x94";
static constexpr const char* plug = "\xEF\x87\xA6";
static constexpr const char* shoe = "\xEF\x95\x8B";
@@ -22,11 +17,9 @@ namespace Pinetime {
static constexpr const char* check = "\xEF\x95\xA0";
static constexpr const char* music = "\xEF\x80\x81";
static constexpr const char* tachometer = "\xEF\x8F\xBD";
- static constexpr const char* asterisk = "\xEF\x81\xA9";
static constexpr const char* paintbrush = "\xEF\x87\xBC";
static constexpr const char* paddle = "\xEF\x91\x9D";
static constexpr const char* map = "\xEF\x96\xa0";
- static constexpr const char* qrcode = "\xEF\x80\xa9";
static constexpr const char* phone = "\xEF\x82\x95";
static constexpr const char* phoneSlash = "\xEF\x8F\x9D";
static constexpr const char* volumMute = "\xEF\x9A\xA9";
diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp
index 0586877..65961d5 100644
--- a/src/displayapp/screens/SystemInfo.cpp
+++ b/src/displayapp/screens/SystemInfo.cpp
@@ -78,12 +78,12 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
lv_label_set_recolor(label, true);
lv_label_set_text_fmt(label,
"#FFFF00 InfiniTime#\n\n"
- "#444444 Version# %ld.%ld.%ld\n"
- "#444444 Short Ref# %s\n"
- "#444444 Build date#\n"
+ "#808080 Version# %ld.%ld.%ld\n"
+ "#808080 Short Ref# %s\n"
+ "#808080 Build date#\n"
"%s\n"
"%s\n\n"
- "#444444 Bootloader# %s",
+ "#808080 Bootloader# %s",
Version::Major(),
Version::Minor(),
Version::Patch(),
@@ -139,14 +139,14 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(label, true);
lv_label_set_text_fmt(label,
- "#444444 Date# %02d/%02d/%04d\n"
- "#444444 Time# %02d:%02d:%02d\n"
- "#444444 Uptime#\n %02lud %02lu:%02lu:%02lu\n"
- "#444444 Battery# %d%%/%03imV\n"
- "#444444 Backlight# %s\n"
- "#444444 Last reset# %s\n"
- "#444444 Accel.# %s\n"
- "#444444 Touch.# %x.%x.%x\n",
+ "#808080 Date# %02d/%02d/%04d\n"
+ "#808080 Time# %02d:%02d:%02d\n"
+ "#808080 Uptime#\n %02lud %02lu:%02lu:%02lu\n"
+ "#808080 Battery# %d%%/%03imV\n"
+ "#808080 Backlight# %s\n"
+ "#808080 Last reset# %s\n"
+ "#808080 Accel.# %s\n"
+ "#808080 Touch.# %x.%x.%x\n",
dateTimeController.Day(),
static_cast<uint8_t>(dateTimeController.Month()),
dateTimeController.Year(),
@@ -177,14 +177,14 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
lv_label_set_recolor(label, true);
auto& bleAddr = bleController.Address();
lv_label_set_text_fmt(label,
- "#444444 BLE MAC#\n"
+ "#808080 BLE MAC#\n"
" %02x:%02x:%02x:%02x:%02x:%02x"
"\n"
- "#444444 LVGL Memory#\n"
- " #444444 used# %d (%d%%)\n"
- " #444444 max used# %lu\n"
- " #444444 frag# %d%%\n"
- " #444444 free# %d",
+ "#808080 LVGL Memory#\n"
+ " #808080 used# %d (%d%%)\n"
+ " #808080 max used# %lu\n"
+ " #808080 frag# %d%%\n"
+ " #808080 free# %d",
bleAddr[5],
bleAddr[4],
bleAddr[3],
@@ -212,7 +212,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
lv_table_set_col_cnt(infoTask, 4);
lv_table_set_row_cnt(infoTask, maxTaskCount + 1);
lv_obj_set_style_local_pad_all(infoTask, LV_TABLE_PART_CELL1, LV_STATE_DEFAULT, 0);
- lv_obj_set_style_local_border_color(infoTask, LV_TABLE_PART_CELL1, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_border_color(infoTask, LV_TABLE_PART_CELL1, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_table_set_cell_value(infoTask, 0, 0, "#");
lv_table_set_col_width(infoTask, 0, 30);
@@ -269,11 +269,11 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
"under the terms of\n"
"the GNU General\n"
"Public License v3\n"
- "#444444 Source code#\n"
+ "#808080 Source code#\n"
"#FFFF00 https://github.com/#\n"
"#FFFF00 InfiniTimeOrg/#\n"
"#FFFF00 InfiniTime#");
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, nullptr, LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(4, 5, app, label);
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp
index 4df69fe..cce1d2e 100644
--- a/src/displayapp/screens/Tile.cpp
+++ b/src/displayapp/screens/Tile.cpp
@@ -5,13 +5,15 @@
using namespace Pinetime::Applications::Screens;
namespace {
- static void lv_update_task(struct _lv_task_t* task) {
+ void lv_update_task(struct _lv_task_t* task) {
auto* user_data = static_cast<Tile*>(task->user_data);
user_data->UpdateScreen();
}
- static void event_handler(lv_obj_t* obj, lv_event_t event) {
- if (event != LV_EVENT_VALUE_CHANGED) return;
+ void event_handler(lv_obj_t* obj, lv_event_t event) {
+ if (event != LV_EVENT_VALUE_CHANGED) {
+ return;
+ }
Tile* screen = static_cast<Tile*>(obj->user_data);
auto* eventDataPtr = (uint32_t*) lv_event_get_data();
@@ -33,14 +35,12 @@ Tile::Tile(uint8_t screenID,
// Time
label_time = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label_time, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
// Battery
- batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
- lv_obj_align(batteryIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, -8, 0);
+ batteryIcon.Create(lv_scr_act());
+ lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_RIGHT, -8, 0);
if (numScreens > 1) {
pageIndicatorBasePoints[0].x = LV_HOR_RES - 1;
@@ -63,7 +63,7 @@ Tile::Tile(uint8_t screenID,
pageIndicator = lv_line_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
lv_line_set_points(pageIndicator, pageIndicatorPoints, 2);
}
@@ -87,9 +87,9 @@ Tile::Tile(uint8_t screenID,
lv_obj_align(btnm1, NULL, LV_ALIGN_CENTER, 0, 10);
lv_obj_set_style_local_radius(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DEFAULT, 20);
- lv_obj_set_style_local_bg_opa(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DEFAULT, LV_OPA_20);
+ lv_obj_set_style_local_bg_opa(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DEFAULT, LV_OPA_50);
lv_obj_set_style_local_bg_color(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DEFAULT, LV_COLOR_AQUA);
- lv_obj_set_style_local_bg_opa(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DISABLED, LV_OPA_20);
+ lv_obj_set_style_local_bg_opa(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DISABLED, LV_OPA_50);
lv_obj_set_style_local_bg_color(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DISABLED, lv_color_hex(0x111111));
lv_obj_set_style_local_pad_all(btnm1, LV_BTNMATRIX_PART_BG, LV_STATE_DEFAULT, 0);
lv_obj_set_style_local_pad_inner(btnm1, LV_BTNMATRIX_PART_BG, LV_STATE_DEFAULT, 10);
@@ -104,13 +104,9 @@ Tile::Tile(uint8_t screenID,
btnm1->user_data = this;
lv_obj_set_event_cb(btnm1, event_handler);
- lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text_static(backgroundLabel, "");
-
taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_MID, this);
+
+ UpdateScreen();
}
Tile::~Tile() {
@@ -120,11 +116,12 @@ Tile::~Tile() {
void Tile::UpdateScreen() {
lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
- lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
+ batteryIcon.SetBatteryPercentage(batteryController.PercentRemaining());
}
void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) {
- if(obj != btnm1) return;
+ if (obj != btnm1)
+ return;
app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up);
running = false;
diff --git a/src/displayapp/screens/Tile.h b/src/displayapp/screens/Tile.h
index 4869fef..4874714 100644
--- a/src/displayapp/screens/Tile.h
+++ b/src/displayapp/screens/Tile.h
@@ -9,6 +9,7 @@
#include "components/settings/Settings.h"
#include "components/datetime/DateTimeController.h"
#include "components/battery/BatteryController.h"
+#include <displayapp/screens/BatteryIcon.h>
namespace Pinetime {
namespace Applications {
@@ -40,13 +41,14 @@ namespace Pinetime {
lv_task_t* taskUpdate;
lv_obj_t* label_time;
- lv_obj_t* batteryIcon;
lv_point_t pageIndicatorBasePoints[2];
lv_point_t pageIndicatorPoints[2];
lv_obj_t* pageIndicatorBase;
lv_obj_t* pageIndicator;
lv_obj_t* btnm1;
+ BatteryIcon batteryIcon;
+
const char* btnmMap[8];
Pinetime::Applications::Apps apps[6];
};
diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp
index 3b41446..9ef620a 100644
--- a/src/displayapp/screens/Timer.cpp
+++ b/src/displayapp/screens/Timer.cpp
@@ -14,68 +14,57 @@ void Timer::CreateButtons() {
btnMinutesUp = lv_btn_create(lv_scr_act(), nullptr);
btnMinutesUp->user_data = this;
lv_obj_set_event_cb(btnMinutesUp, btnEventHandler);
- lv_obj_align(btnMinutesUp, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, -80);
- lv_obj_set_height(btnMinutesUp, 40);
- lv_obj_set_width(btnMinutesUp, 60);
+ lv_obj_set_size(btnMinutesUp, 60, 40);
+ lv_obj_align(btnMinutesUp, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, -85);
txtMUp = lv_label_create(btnMinutesUp, nullptr);
- lv_label_set_text(txtMUp, "+");
+ lv_label_set_text_static(txtMUp, "+");
btnMinutesDown = lv_btn_create(lv_scr_act(), nullptr);
btnMinutesDown->user_data = this;
lv_obj_set_event_cb(btnMinutesDown, btnEventHandler);
- lv_obj_align(btnMinutesDown, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, +40);
- lv_obj_set_height(btnMinutesDown, 40);
- lv_obj_set_width(btnMinutesDown, 60);
+ lv_obj_set_size(btnMinutesDown, 60, 40);
+ lv_obj_align(btnMinutesDown, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, 35);
txtMDown = lv_label_create(btnMinutesDown, nullptr);
- lv_label_set_text(txtMDown, "-");
+ lv_label_set_text_static(txtMDown, "-");
btnSecondsUp = lv_btn_create(lv_scr_act(), nullptr);
btnSecondsUp->user_data = this;
lv_obj_set_event_cb(btnSecondsUp, btnEventHandler);
- lv_obj_align(btnSecondsUp, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 10, -80);
- lv_obj_set_height(btnSecondsUp, 40);
- lv_obj_set_width(btnSecondsUp, 60);
+ lv_obj_set_size(btnSecondsUp, 60, 40);
+ lv_obj_align(btnSecondsUp, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -20, -85);
txtSUp = lv_label_create(btnSecondsUp, nullptr);
- lv_label_set_text(txtSUp, "+");
+ lv_label_set_text_static(txtSUp, "+");
btnSecondsDown = lv_btn_create(lv_scr_act(), nullptr);
btnSecondsDown->user_data = this;
lv_obj_set_event_cb(btnSecondsDown, btnEventHandler);
- lv_obj_align(btnSecondsDown, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 10, +40);
- lv_obj_set_height(btnSecondsDown, 40);
- lv_obj_set_width(btnSecondsDown, 60);
+ lv_obj_set_size(btnSecondsDown, 60, 40);
+ lv_obj_align(btnSecondsDown, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -20, 35);
txtSDown = lv_label_create(btnSecondsDown, nullptr);
- lv_label_set_text(txtSDown, "-");
+ lv_label_set_text_static(txtSDown, "-");
}
Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
: Screen(app), running {true}, timerController {timerController} {
- backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_click(backgroundLabel, true);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text_static(backgroundLabel, "");
time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
- lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xb0, 0xb0, 0xb0));
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60);
-
- lv_obj_align(time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
+ lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -25);
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
btnPlayPause->user_data = this;
lv_obj_set_event_cb(btnPlayPause, btnEventHandler);
- lv_obj_align(btnPlayPause, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, -10);
- lv_obj_set_height(btnPlayPause, 40);
+ lv_obj_set_size(btnPlayPause, 120, 50);
+ lv_obj_align(btnPlayPause, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
txtPlayPause = lv_label_create(btnPlayPause, nullptr);
if (timerController.IsRunning()) {
- lv_label_set_text(txtPlayPause, Symbols::pause);
+ lv_label_set_text_static(txtPlayPause, Symbols::pause);
} else {
- lv_label_set_text(txtPlayPause, Symbols::play);
+ lv_label_set_text_static(txtPlayPause, Symbols::play);
CreateButtons();
}
@@ -98,7 +87,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
if (event == LV_EVENT_CLICKED) {
if (obj == btnPlayPause) {
if (timerController.IsRunning()) {
- lv_label_set_text(txtPlayPause, Symbols::play);
+ lv_label_set_text_static(txtPlayPause, Symbols::play);
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
minutesToSet = seconds / 60;
secondsToSet = seconds % 60;
@@ -106,7 +95,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
CreateButtons();
} else if (secondsToSet + minutesToSet > 0) {
- lv_label_set_text(txtPlayPause, Symbols::pause);
+ lv_label_set_text_static(txtPlayPause, Symbols::pause);
timerController.StartTimer((secondsToSet + minutesToSet * 60) * 1000);
lv_obj_del(btnSecondsDown);
@@ -158,8 +147,8 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
}
void Timer::SetDone() {
- lv_label_set_text(time, "00:00");
- lv_label_set_text(txtPlayPause, Symbols::play);
+ lv_label_set_text_static(time, "00:00");
+ lv_label_set_text_static(txtPlayPause, Symbols::play);
secondsToSet = 0;
minutesToSet = 0;
CreateButtons();
diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h
index 93e84c8..c1f7f9e 100644
--- a/src/displayapp/screens/Timer.h
+++ b/src/displayapp/screens/Timer.h
@@ -24,7 +24,6 @@ namespace Pinetime::Applications::Screens {
uint8_t secondsToSet = 0;
uint8_t minutesToSet = 0;
Controllers::TimerController& timerController;
- lv_obj_t* backgroundLabel;
lv_obj_t* time;
lv_obj_t* msecTime;
lv_obj_t* btnPlayPause;
diff --git a/src/displayapp/screens/Twos.cpp b/src/displayapp/screens/Twos.cpp
index ca9295d..7e465fc 100644
--- a/src/displayapp/screens/Twos.cpp
+++ b/src/displayapp/screens/Twos.cpp
@@ -85,12 +85,6 @@ Twos::Twos(Pinetime::Applications::DisplayApp* app) : Screen(app) {
lv_obj_align(scoreText, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 10);
lv_label_set_recolor(scoreText, true);
lv_label_set_text_fmt(scoreText, "Score #FFFF00 %i#", score);
-
- lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text_static(backgroundLabel, "");
}
Twos::~Twos() {
diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp
index 4cfc969..251a560 100644
--- a/src/displayapp/screens/WatchFaceAnalog.cpp
+++ b/src/displayapp/screens/WatchFaceAnalog.cpp
@@ -12,35 +12,33 @@ LV_IMG_DECLARE(bg_clock);
using namespace Pinetime::Applications::Screens;
namespace {
-constexpr int16_t HourLength = 70;
-constexpr int16_t MinuteLength = 90;
-constexpr int16_t SecondLength = 110;
+ constexpr int16_t HourLength = 70;
+ constexpr int16_t MinuteLength = 90;
+ constexpr int16_t SecondLength = 110;
-// sin(90) = 1 so the value of _lv_trigo_sin(90) is the scaling factor
-const auto LV_TRIG_SCALE = _lv_trigo_sin(90);
+ // sin(90) = 1 so the value of _lv_trigo_sin(90) is the scaling factor
+ const auto LV_TRIG_SCALE = _lv_trigo_sin(90);
-int16_t Cosine(int16_t angle) {
- return _lv_trigo_sin(angle + 90);
-}
+ int16_t Cosine(int16_t angle) {
+ return _lv_trigo_sin(angle + 90);
+ }
-int16_t Sine(int16_t angle) {
- return _lv_trigo_sin(angle);
-}
+ int16_t Sine(int16_t angle) {
+ return _lv_trigo_sin(angle);
+ }
-int16_t CoordinateXRelocate(int16_t x) {
- return (x + LV_HOR_RES / 2);
-}
+ int16_t CoordinateXRelocate(int16_t x) {
+ return (x + LV_HOR_RES / 2);
+ }
-int16_t CoordinateYRelocate(int16_t y) {
- return std::abs(y - LV_HOR_RES / 2);
-}
+ int16_t CoordinateYRelocate(int16_t y) {
+ return std::abs(y - LV_HOR_RES / 2);
+ }
-lv_point_t CoordinateRelocate(int16_t radius, int16_t angle) {
- return lv_point_t{
- .x = CoordinateXRelocate(radius * static_cast<int32_t>(Sine(angle)) / LV_TRIG_SCALE),
- .y = CoordinateYRelocate(radius * static_cast<int32_t>(Cosine(angle)) / LV_TRIG_SCALE)
- };
-}
+ lv_point_t CoordinateRelocate(int16_t radius, int16_t angle) {
+ return lv_point_t {.x = CoordinateXRelocate(radius * static_cast<int32_t>(Sine(angle)) / LV_TRIG_SCALE),
+ .y = CoordinateYRelocate(radius * static_cast<int32_t>(Cosine(angle)) / LV_TRIG_SCALE)};
+ }
}
@@ -66,10 +64,13 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
lv_img_set_src(bg_clock_img, &bg_clock);
lv_obj_align(bg_clock_img, NULL, LV_ALIGN_CENTER, 0, 0);
- batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text_static(batteryIcon, Symbols::batteryHalf);
- lv_obj_align(batteryIcon, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
- lv_obj_set_auto_realign(batteryIcon, true);
+ batteryIcon.Create(lv_scr_act());
+ lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
+
+ plugIcon = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text_static(plugIcon, Symbols::plug);
+ lv_obj_set_style_local_text_color(plugIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
+ lv_obj_align(plugIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
notificationIcon = lv_label_create(lv_scr_act(), NULL);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00));
@@ -79,7 +80,7 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
// Date - Day / Week day
label_date_day = lv_label_create(lv_scr_act(), NULL);
- lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xf0a500));
+ lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xff, 0xb0, 0x0));
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
lv_label_set_align(label_date_day, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label_date_day, NULL, LV_ALIGN_CENTER, 50, 0);
@@ -121,7 +122,8 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
- UpdateClock();
+
+ Refresh();
}
WatchFaceAnalog::~WatchFaceAnalog() {
@@ -180,21 +182,18 @@ void WatchFaceAnalog::UpdateClock() {
void WatchFaceAnalog::SetBatteryIcon() {
auto batteryPercent = batteryPercentRemaining.Get();
- if (batteryPercent == 100) {
- lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
- } else {
- lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
- }
- lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+ batteryIcon.SetBatteryPercentage(batteryPercent);
}
void WatchFaceAnalog::Refresh() {
isCharging = batteryController.IsCharging();
if (isCharging.IsUpdated()) {
if (isCharging.Get()) {
- lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
- lv_label_set_text_static(batteryIcon, Symbols::plug);
+ lv_obj_set_hidden(batteryIcon.GetObject(), true);
+ lv_obj_set_hidden(plugIcon, false);
} else {
+ lv_obj_set_hidden(batteryIcon.GetObject(), false);
+ lv_obj_set_hidden(plugIcon, true);
SetBatteryIcon();
}
}
diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h
index 4d76298..04d9e71 100644
--- a/src/displayapp/screens/WatchFaceAnalog.h
+++ b/src/displayapp/screens/WatchFaceAnalog.h
@@ -9,6 +9,7 @@
#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
#include "components/ble/NotificationManager.h"
+#include <displayapp/screens/BatteryIcon.h>
namespace Pinetime {
namespace Controllers {
@@ -64,9 +65,11 @@ namespace Pinetime {
lv_style_t second_line_style;
lv_obj_t* label_date_day;
- lv_obj_t* batteryIcon;
+ lv_obj_t* plugIcon;
lv_obj_t* notificationIcon;
+ BatteryIcon batteryIcon;
+
const Controllers::DateTime& dateTimeController;
Controllers::Battery& batteryController;
Controllers::Ble& bleController;
diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp
index 34a73c3..fb88f60 100644
--- a/src/displayapp/screens/WatchFaceDigital.cpp
+++ b/src/displayapp/screens/WatchFaceDigital.cpp
@@ -33,14 +33,13 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
heartRateController {heartRateController},
motionController {motionController} {
- batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text_static(batteryIcon, Symbols::batteryFull);
- lv_obj_align(batteryIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
+ batteryIcon.Create(lv_scr_act());
+ lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
batteryPlug = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFF0000));
lv_label_set_text_static(batteryPlug, Symbols::plug);
- lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
+ lv_obj_align(batteryPlug, batteryIcon.GetObject(), LV_ALIGN_OUT_LEFT_MID, -5, 0);
bleIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x0082FC));
@@ -65,13 +64,6 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
lv_label_set_text_static(label_time_ampm, "");
lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55);
- backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_click(backgroundLabel, true);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text_static(backgroundLabel, "");
-
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
@@ -110,19 +102,13 @@ void WatchFaceDigital::Refresh() {
batteryPercentRemaining = batteryController.PercentRemaining();
if (batteryPercentRemaining.IsUpdated()) {
auto batteryPercent = batteryPercentRemaining.Get();
- if (batteryPercent == 100) {
- lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
- } else {
- lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
- }
- lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+ batteryIcon.SetBatteryPercentage(batteryPercent);
}
bleState = bleController.IsConnected();
if (bleState.IsUpdated()) {
lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
}
- lv_obj_realign(batteryIcon);
lv_obj_realign(batteryPlug);
lv_obj_realign(bleIcon);
@@ -173,11 +159,19 @@ void WatchFaceDigital::Refresh() {
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
- lv_label_set_text_fmt(
- label_date, "%s %d %s %d", dateTimeController.DayOfWeekShortToString(), day, dateTimeController.MonthShortToString(), year);
+ lv_label_set_text_fmt(label_date,
+ "%s %d %s %d",
+ dateTimeController.DayOfWeekShortToString(),
+ day,
+ dateTimeController.MonthShortToString(),
+ year);
} else {
- lv_label_set_text_fmt(
- label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year);
+ lv_label_set_text_fmt(label_date,
+ "%s %s %d %d",
+ dateTimeController.DayOfWeekShortToString(),
+ dateTimeController.MonthShortToString(),
+ day,
+ year);
}
lv_obj_realign(label_date);
diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h
index 3b436c3..71602fc 100644
--- a/src/displayapp/screens/WatchFaceDigital.h
+++ b/src/displayapp/screens/WatchFaceDigital.h
@@ -1,5 +1,6 @@
#pragma once
+#include <displayapp/screens/BatteryIcon.h>
#include <lvgl/src/lv_core/lv_obj.h>
#include <chrono>
#include <cstdint>
@@ -57,8 +58,6 @@ namespace Pinetime {
lv_obj_t* label_time;
lv_obj_t* label_time_ampm;
lv_obj_t* label_date;
- lv_obj_t* backgroundLabel;
- lv_obj_t* batteryIcon;
lv_obj_t* bleIcon;
lv_obj_t* batteryPlug;
lv_obj_t* heartbeatIcon;
@@ -67,6 +66,8 @@ namespace Pinetime {
lv_obj_t* stepValue;
lv_obj_t* notificationIcon;
+ BatteryIcon batteryIcon;
+
Controllers::DateTime& dateTimeController;
Controllers::Battery& batteryController;
Controllers::Ble& bleController;
diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/WatchFacePineTimeStyle.cpp
index c82ef80..0343c0a 100644
--- a/src/displayapp/screens/PineTimeStyle.cpp
+++ b/src/displayapp/screens/WatchFacePineTimeStyle.cpp
@@ -19,7 +19,7 @@
* Style/layout copied from TimeStyle for Pebble by Dan Tilden (github.com/tilden)
*/
-#include "displayapp/screens/PineTimeStyle.h"
+#include "displayapp/screens/WatchFacePineTimeStyle.h"
#include <date/date.h>
#include <lvgl/lvgl.h>
#include <cstdio>
@@ -39,25 +39,25 @@ using namespace Pinetime::Applications::Screens;
namespace {
void event_handler(lv_obj_t* obj, lv_event_t event) {
- auto* screen = static_cast<PineTimeStyle*>(obj->user_data);
+ auto* screen = static_cast<WatchFacePineTimeStyle*>(obj->user_data);
screen->UpdateSelected(obj, event);
}
bool IsBleIconVisible(bool isRadioEnabled, bool isConnected) {
- if(!isRadioEnabled) {
+ if (!isRadioEnabled) {
return true;
}
return isConnected;
}
}
-PineTimeStyle::PineTimeStyle(DisplayApp* app,
- Controllers::DateTime& dateTimeController,
- Controllers::Battery& batteryController,
- Controllers::Ble& bleController,
- Controllers::NotificationManager& notificatioManager,
- Controllers::Settings& settingsController,
- Controllers::MotionController& motionController)
+WatchFacePineTimeStyle::WatchFacePineTimeStyle(DisplayApp* app,
+ Controllers::DateTime& dateTimeController,
+ Controllers::Battery& batteryController,
+ Controllers::Ble& bleController,
+ Controllers::NotificationManager& notificatioManager,
+ Controllers::Settings& settingsController,
+ Controllers::MotionController& motionController)
: Screen(app),
currentDateTime {{}},
dateTimeController {dateTimeController},
@@ -101,11 +101,14 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
// Display icons
- batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
- lv_label_set_text_static(batteryIcon, Symbols::batteryFull);
- lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
- lv_obj_set_auto_realign(batteryIcon, true);
+ batteryIcon.Create(sidebar);
+ batteryIcon.SetColor(LV_COLOR_BLACK);
+ lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_MID, 0, 2);
+
+ plugIcon = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text_static(plugIcon, Symbols::plug);
+ lv_obj_set_style_local_text_color(plugIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+ lv_obj_align(plugIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
bleIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
@@ -195,13 +198,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
- backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_click(backgroundLabel, true);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text_static(backgroundLabel, "");
-
btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
btnNextTime->user_data = this;
lv_obj_set_size(btnNextTime, 60, 60);
@@ -300,12 +296,12 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
Refresh();
}
-PineTimeStyle::~PineTimeStyle() {
+WatchFacePineTimeStyle::~WatchFacePineTimeStyle() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool PineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
+bool WatchFacePineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
if ((event == Pinetime::Applications::TouchEvents::LongTap) && lv_obj_get_hidden(btnRandom)) {
lv_obj_set_hidden(btnSet, false);
savedTick = lv_tick_get();
@@ -317,7 +313,7 @@ bool PineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return false;
}
-void PineTimeStyle::CloseMenu() {
+void WatchFacePineTimeStyle::CloseMenu() {
settingsController.SaveSettings();
lv_obj_set_hidden(btnNextTime, true);
lv_obj_set_hidden(btnPrevTime, true);
@@ -330,7 +326,7 @@ void PineTimeStyle::CloseMenu() {
lv_obj_set_hidden(btnClose, true);
}
-bool PineTimeStyle::OnButtonPushed() {
+bool WatchFacePineTimeStyle::OnButtonPushed() {
if (!lv_obj_get_hidden(btnClose)) {
CloseMenu();
return true;
@@ -338,13 +334,12 @@ bool PineTimeStyle::OnButtonPushed() {
return false;
}
-void PineTimeStyle::SetBatteryIcon() {
+void WatchFacePineTimeStyle::SetBatteryIcon() {
auto batteryPercent = batteryPercentRemaining.Get();
- lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+ batteryIcon.SetBatteryPercentage(batteryPercent);
}
-
-void PineTimeStyle::AlignIcons() {
+void WatchFacePineTimeStyle::AlignIcons() {
if (notificationState.Get() && bleState.Get()) {
lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 8, 25);
lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, -8, 25);
@@ -355,12 +350,15 @@ void PineTimeStyle::AlignIcons() {
}
}
-void PineTimeStyle::Refresh() {
+void WatchFacePineTimeStyle::Refresh() {
isCharging = batteryController.IsCharging();
if (isCharging.IsUpdated()) {
if (isCharging.Get()) {
- lv_label_set_text_static(batteryIcon, Symbols::plug);
+ lv_obj_set_hidden(batteryIcon.GetObject(), true);
+ lv_obj_set_hidden(plugIcon, false);
} else {
+ lv_obj_set_hidden(batteryIcon.GetObject(), false);
+ lv_obj_set_hidden(plugIcon, true);
SetBatteryIcon();
}
}
@@ -373,7 +371,7 @@ void PineTimeStyle::Refresh() {
bleState = bleController.IsConnected();
if (bleState.IsUpdated()) {
- lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
+ lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
AlignIcons();
}
@@ -424,10 +422,10 @@ void PineTimeStyle::Refresh() {
}
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
- lv_label_set_text_fmt(dateDayOfWeek, "%s", dateTimeController.DayOfWeekShortToString());
+ lv_label_set_text_static(dateDayOfWeek, dateTimeController.DayOfWeekShortToString());
lv_label_set_text_fmt(dateDay, "%d", day);
lv_obj_realign(dateDay);
- lv_label_set_text_fmt(dateMonth, "%s", dateTimeController.MonthShortToString());
+ lv_label_set_text_static(dateMonth, dateTimeController.MonthShortToString());
currentYear = year;
currentMonth = month;
@@ -454,7 +452,7 @@ void PineTimeStyle::Refresh() {
}
}
-void PineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
+void WatchFacePineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
auto valueTime = settingsController.GetPTSColorTime();
auto valueBar = settingsController.GetPTSColorBar();
auto valueBG = settingsController.GetPTSColorBG();
@@ -575,7 +573,7 @@ void PineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
}
}
-Pinetime::Controllers::Settings::Colors PineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
+Pinetime::Controllers::Settings::Colors WatchFacePineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
auto colorAsInt = static_cast<uint8_t>(color);
Pinetime::Controllers::Settings::Colors nextColor;
if (colorAsInt < 16) {
@@ -586,7 +584,7 @@ Pinetime::Controllers::Settings::Colors PineTimeStyle::GetNext(Pinetime::Control
return nextColor;
}
-Pinetime::Controllers::Settings::Colors PineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
+Pinetime::Controllers::Settings::Colors WatchFacePineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
auto colorAsInt = static_cast<uint8_t>(color);
Pinetime::Controllers::Settings::Colors prevColor;
diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/WatchFacePineTimeStyle.h
index 9e52844..217b92b 100644
--- a/src/displayapp/screens/PineTimeStyle.h
+++ b/src/displayapp/screens/WatchFacePineTimeStyle.h
@@ -8,6 +8,7 @@
#include "displayapp/Colors.h"
#include "components/datetime/DateTimeController.h"
#include "components/ble/BleController.h"
+#include <displayapp/screens/BatteryIcon.h>
namespace Pinetime {
namespace Controllers {
@@ -21,23 +22,23 @@ namespace Pinetime {
namespace Applications {
namespace Screens {
- class PineTimeStyle : public Screen {
+ class WatchFacePineTimeStyle : public Screen {
public:
- PineTimeStyle(DisplayApp* app,
- Controllers::DateTime& dateTimeController,
- Controllers::Battery& batteryController,
- Controllers::Ble& bleController,
- Controllers::NotificationManager& notificatioManager,
- Controllers::Settings& settingsController,
- Controllers::MotionController& motionController);
- ~PineTimeStyle() override;
+ WatchFacePineTimeStyle(DisplayApp* app,
+ Controllers::DateTime& dateTimeController,
+ Controllers::Battery& batteryController,
+ Controllers::Ble& bleController,
+ Controllers::NotificationManager& notificatioManager,
+ Controllers::Settings& settingsController,
+ Controllers::MotionController& motionController);
+ ~WatchFacePineTimeStyle() override;
bool OnTouchEvent(TouchEvents event) override;
bool OnButtonPushed() override;
void Refresh() override;
- void UpdateSelected(lv_obj_t *object, lv_event_t event);
+ void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
uint8_t displayedHour = -1;
@@ -77,8 +78,7 @@ namespace Pinetime {
lv_obj_t* dateDayOfWeek;
lv_obj_t* dateDay;
lv_obj_t* dateMonth;
- lv_obj_t* backgroundLabel;
- lv_obj_t* batteryIcon;
+ lv_obj_t* plugIcon;
lv_obj_t* bleIcon;
lv_obj_t* calendarOuter;
lv_obj_t* calendarInner;
@@ -92,6 +92,8 @@ namespace Pinetime {
lv_obj_t* lbl_btnSet;
lv_color_t needle_colors[1];
+ BatteryIcon batteryIcon;
+
Controllers::DateTime& dateTimeController;
Controllers::Battery& batteryController;
Controllers::Ble& bleController;
diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp
index 57395b7..63ea2e7 100644
--- a/src/displayapp/screens/WatchFaceTerminal.cpp
+++ b/src/displayapp/screens/WatchFaceTerminal.cpp
@@ -31,13 +31,6 @@ WatchFaceTerminal::WatchFaceTerminal(DisplayApp* app,
heartRateController {heartRateController},
motionController {motionController} {
- backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_click(backgroundLabel, true);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text_static(backgroundLabel, "");
-
uint16_t y = -100;
for (auto& line : lines) {
line = lv_label_create(lv_scr_act(), nullptr);
@@ -76,7 +69,7 @@ void WatchFaceTerminal::Refresh() {
bleState = bleController.IsConnected();
bleRadioEnabled = bleController.IsRadioEnabled();
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
- if(!bleRadioEnabled.Get()) {
+ if (!bleRadioEnabled.Get()) {
lv_label_set_text_static(connectState, "[STAT]#0082fc Disabled#");
} else {
if (bleState.Get()) {
diff --git a/src/displayapp/screens/WatchFaceTerminal.h b/src/displayapp/screens/WatchFaceTerminal.h
index d01e50f..056b51e 100644
--- a/src/displayapp/screens/WatchFaceTerminal.h
+++ b/src/displayapp/screens/WatchFaceTerminal.h
@@ -70,7 +70,6 @@ namespace Pinetime {
};
lv_obj_t *lines[9]; // This should match exactly the number of labels in the struct above!
};
- lv_obj_t* backgroundLabel;
Controllers::DateTime& dateTimeController;
Controllers::Battery& batteryController;
diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp
index 388525b..708d510 100644
--- a/src/displayapp/screens/settings/QuickSettings.cpp
+++ b/src/displayapp/screens/settings/QuickSettings.cpp
@@ -6,12 +6,12 @@
using namespace Pinetime::Applications::Screens;
namespace {
- static void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) {
+ void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) {
auto* screen = static_cast<QuickSettings*>(obj->user_data);
screen->OnButtonEvent(obj, event);
}
- static void lv_update_task(struct _lv_task_t* task) {
+ void lv_update_task(struct _lv_task_t* task) {
auto* user_data = static_cast<QuickSettings*>(task->user_data);
user_data->UpdateScreen();
}
@@ -35,23 +35,21 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
// Time
label_time = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 0);
- batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
- lv_obj_align(batteryIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
+ batteryIcon.Create(lv_scr_act());
+ lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
static constexpr uint8_t barHeight = 20 + innerDistance;
static constexpr uint8_t buttonHeight = (LV_VER_RES_MAX - barHeight - innerDistance) / 2;
static constexpr uint8_t buttonWidth = (LV_HOR_RES_MAX - innerDistance) / 2; // wide buttons
- //static constexpr uint8_t buttonWidth = buttonHeight; // square buttons
+ // static constexpr uint8_t buttonWidth = buttonHeight; // square buttons
static constexpr uint8_t buttonXOffset = (LV_HOR_RES_MAX - buttonWidth * 2 - innerDistance) / 2;
lv_style_init(&btn_style);
lv_style_set_radius(&btn_style, LV_STATE_DEFAULT, buttonHeight / 4);
- lv_style_set_bg_color(&btn_style, LV_STATE_DEFAULT, lv_color_hex(0x111111));
+ lv_style_set_bg_color(&btn_style, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x38, 0x38, 0x38));
btn1 = lv_btn_create(lv_scr_act(), nullptr);
btn1->user_data = this;
@@ -69,7 +67,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
lv_obj_set_event_cb(btn2, ButtonEventHandler);
lv_obj_add_style(btn2, LV_BTN_PART_MAIN, &btn_style);
lv_obj_set_size(btn2, buttonWidth, buttonHeight);
- lv_obj_align(btn2, nullptr, LV_ALIGN_IN_TOP_RIGHT, - buttonXOffset, barHeight);
+ lv_obj_align(btn2, nullptr, LV_ALIGN_IN_TOP_RIGHT, -buttonXOffset, barHeight);
lv_obj_t* lbl_btn;
lbl_btn = lv_label_create(btn2, nullptr);
@@ -81,7 +79,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
lv_obj_set_event_cb(btn3, ButtonEventHandler);
lv_btn_set_checkable(btn3, true);
lv_obj_add_style(btn3, LV_BTN_PART_MAIN, &btn_style);
- lv_obj_set_style_local_bg_color(btn3, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
+ lv_obj_set_style_local_bg_color(btn3, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_MAKE(0x0, 0xb0, 0x0));
lv_obj_set_size(btn3, buttonWidth, buttonHeight);
lv_obj_align(btn3, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, buttonXOffset, 0);
@@ -100,19 +98,15 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
lv_obj_set_event_cb(btn4, ButtonEventHandler);
lv_obj_add_style(btn4, LV_BTN_PART_MAIN, &btn_style);
lv_obj_set_size(btn4, buttonWidth, buttonHeight);
- lv_obj_align(btn4, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, - buttonXOffset, 0);
+ lv_obj_align(btn4, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, -buttonXOffset, 0);
lbl_btn = lv_label_create(btn4, nullptr);
lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
lv_label_set_text_static(lbl_btn, Symbols::settings);
- lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text_static(backgroundLabel, "");
-
taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_MID, this);
+
+ UpdateScreen();
}
QuickSettings::~QuickSettings() {
@@ -124,7 +118,7 @@ QuickSettings::~QuickSettings() {
void QuickSettings::UpdateScreen() {
lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
+ batteryIcon.SetBatteryPercentage(batteryController.PercentRemaining());
}
void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
diff --git a/src/displayapp/screens/settings/QuickSettings.h b/src/displayapp/screens/settings/QuickSettings.h
index 7913898..40a2a2e 100644
--- a/src/displayapp/screens/settings/QuickSettings.h
+++ b/src/displayapp/screens/settings/QuickSettings.h
@@ -8,6 +8,7 @@
#include "components/motor/MotorController.h"
#include "components/settings/Settings.h"
#include "components/battery/BatteryController.h"
+#include <displayapp/screens/BatteryIcon.h>
namespace Pinetime {
@@ -37,7 +38,6 @@ namespace Pinetime {
Controllers::Settings& settingsController;
lv_task_t* taskUpdate;
- lv_obj_t* batteryIcon;
lv_obj_t* label_time;
lv_style_t btn_style;
@@ -48,6 +48,8 @@ namespace Pinetime {
lv_obj_t* btn3;
lv_obj_t* btn3_lvl;
lv_obj_t* btn4;
+
+ BatteryIcon batteryIcon;
};
}
}
diff --git a/src/displayapp/screens/settings/SettingBluetooth.cpp b/src/displayapp/screens/settings/SettingBluetooth.cpp
index ed7fbee..09556c4 100644
--- a/src/displayapp/screens/settings/SettingBluetooth.cpp
+++ b/src/displayapp/screens/settings/SettingBluetooth.cpp
@@ -9,12 +9,12 @@
using namespace Pinetime::Applications::Screens;
namespace {
- static void OnBluetoothDisabledEvent(lv_obj_t* obj, lv_event_t event) {
+ void OnBluetoothDisabledEvent(lv_obj_t* obj, lv_event_t event) {
auto* screen = static_cast<SettingBluetooth*>(obj->user_data);
screen->OnBluetoothDisabled(obj, event);
}
- static void OnBluetoothEnabledEvent(lv_obj_t* obj, lv_event_t event) {
+ void OnBluetoothEnabledEvent(lv_obj_t* obj, lv_event_t event) {
auto* screen = static_cast<SettingBluetooth*>(obj->user_data);
screen->OnBluetoothEnabled(obj, event);
}
@@ -108,4 +108,3 @@ void SettingBluetooth::OnBluetoothPasskeyEnableToggle(lv_obj_t* object, lv_event
lv_checkbox_set_checked(cbPasskey, enabled);
}
}
-
diff --git a/src/displayapp/screens/settings/SettingChimes.cpp b/src/displayapp/screens/settings/SettingChimes.cpp
index ae89a49..d07b0d4 100644
--- a/src/displayapp/screens/settings/SettingChimes.cpp
+++ b/src/displayapp/screens/settings/SettingChimes.cpp
@@ -8,8 +8,8 @@
using namespace Pinetime::Applications::Screens;
namespace {
- static void event_handler(lv_obj_t* obj, lv_event_t event) {
- SettingChimes* screen = static_cast<SettingChimes*>(obj->user_data);
+ void event_handler(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingChimes*>(obj->user_data);
screen->UpdateSelected(obj, event);
}
}
diff --git a/src/displayapp/screens/settings/SettingDisplay.cpp b/src/displayapp/screens/settings/SettingDisplay.cpp
index 9e972af..bf2087a 100644
--- a/src/displayapp/screens/settings/SettingDisplay.cpp
+++ b/src/displayapp/screens/settings/SettingDisplay.cpp
@@ -9,8 +9,8 @@
using namespace Pinetime::Applications::Screens;
namespace {
- static void event_handler(lv_obj_t* obj, lv_event_t event) {
- SettingDisplay* screen = static_cast<SettingDisplay*>(obj->user_data);
+ void event_handler(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingDisplay*>(obj->user_data);
screen->UpdateSelected(obj, event);
}
}
@@ -46,7 +46,7 @@ SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime
char buffer[12];
for (unsigned int i = 0; i < options.size(); i++) {
cbOption[i] = lv_checkbox_create(container1, nullptr);
- sprintf(buffer, "%3d seconds", options[i] / 1000);
+ sprintf(buffer, "%3d seconds", options[i] / 1000);
lv_checkbox_set_text(cbOption[i], buffer);
cbOption[i]->user_data = this;
lv_obj_set_event_cb(cbOption[i], event_handler);
diff --git a/src/displayapp/screens/settings/SettingSetDate.cpp b/src/displayapp/screens/settings/SettingSetDate.cpp
index 8bfded3..7acf0c1 100644
--- a/src/displayapp/screens/settings/SettingSetDate.cpp
+++ b/src/displayapp/screens/settings/SettingSetDate.cpp
@@ -15,23 +15,22 @@ namespace {
constexpr int16_t POS_Y_TEXT = -6;
constexpr int16_t POS_Y_MINUS = 40;
- void event_handler(lv_obj_t * obj, lv_event_t event) {
- auto* screen = static_cast<SettingSetDate *>(obj->user_data);
+ void event_handler(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingSetDate*>(obj->user_data);
screen->HandleButtonPress(obj, event);
}
}
-SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::DateTime &dateTimeController) :
- Screen(app),
- dateTimeController {dateTimeController} {
- lv_obj_t * title = lv_label_create(lv_scr_act(), nullptr);
+SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::DateTime& dateTimeController)
+ : Screen(app), dateTimeController {dateTimeController} {
+ lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(title, "Set current date");
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15);
- lv_obj_t * icon = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
-
+
lv_label_set_text_static(icon, Symbols::clock);
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
@@ -113,7 +112,7 @@ SettingSetDate::~SettingSetDate() {
lv_obj_clean(lv_scr_act());
}
-void SettingSetDate::HandleButtonPress(lv_obj_t *object, lv_event_t event) {
+void SettingSetDate::HandleButtonPress(lv_obj_t* object, lv_event_t event) {
if (event != LV_EVENT_CLICKED)
return;
@@ -194,5 +193,6 @@ void SettingSetDate::CheckDay() {
void SettingSetDate::UpdateMonthLabel() {
lv_label_set_text_static(
- lblMonth, Pinetime::Controllers::DateTime::MonthShortToStringLow(static_cast<Pinetime::Controllers::DateTime::Months>(monthValue)));
+ lblMonth,
+ Pinetime::Controllers::DateTime::MonthShortToStringLow(static_cast<Pinetime::Controllers::DateTime::Months>(monthValue)));
}
diff --git a/src/displayapp/screens/settings/SettingSetDate.h b/src/displayapp/screens/settings/SettingSetDate.h
index 477337f..a179594 100644
--- a/src/displayapp/screens/settings/SettingSetDate.h
+++ b/src/displayapp/screens/settings/SettingSetDate.h
@@ -8,33 +8,33 @@
namespace Pinetime {
namespace Applications {
namespace Screens {
- class SettingSetDate : public Screen{
- public:
- SettingSetDate(DisplayApp* app, Pinetime::Controllers::DateTime &dateTimeController);
- ~SettingSetDate() override;
+ class SettingSetDate : public Screen {
+ public:
+ SettingSetDate(DisplayApp* app, Pinetime::Controllers::DateTime& dateTimeController);
+ ~SettingSetDate() override;
- void HandleButtonPress(lv_obj_t *object, lv_event_t event);
-
- private:
- Controllers::DateTime& dateTimeController;
+ void HandleButtonPress(lv_obj_t* object, lv_event_t event);
- int dayValue;
- int monthValue;
- int yearValue;
- lv_obj_t * lblDay;
- lv_obj_t * lblMonth;
- lv_obj_t * lblYear;
- lv_obj_t * btnDayPlus;
- lv_obj_t * btnDayMinus;
- lv_obj_t * btnMonthPlus;
- lv_obj_t * btnMonthMinus;
- lv_obj_t * btnYearPlus;
- lv_obj_t * btnYearMinus;
- lv_obj_t * btnSetTime;
+ private:
+ Controllers::DateTime& dateTimeController;
- int MaximumDayOfMonth() const;
- void CheckDay();
- void UpdateMonthLabel();
+ int dayValue;
+ int monthValue;
+ int yearValue;
+ lv_obj_t* lblDay;
+ lv_obj_t* lblMonth;
+ lv_obj_t* lblYear;
+ lv_obj_t* btnDayPlus;
+ lv_obj_t* btnDayMinus;
+ lv_obj_t* btnMonthPlus;
+ lv_obj_t* btnMonthMinus;
+ lv_obj_t* btnYearPlus;
+ lv_obj_t* btnYearMinus;
+ lv_obj_t* btnSetTime;
+
+ int MaximumDayOfMonth() const;
+ void CheckDay();
+ void UpdateMonthLabel();
};
}
}
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.cpp b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
index c354bdc..aac1eaf 100644
--- a/src/displayapp/screens/settings/SettingShakeThreshold.cpp
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
@@ -64,9 +64,9 @@ SettingShakeThreshold::SettingShakeThreshold(DisplayApp* app,
vDecay = xTaskGetTickCount();
calibrating = false;
EnableForCal = false;
- if(!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake)){
+ if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake)) {
EnableForCal = true;
- settingsController.setWakeUpMode(Pinetime::Controllers::Settings::WakeUpMode::Shake,true);
+ settingsController.setWakeUpMode(Pinetime::Controllers::Settings::WakeUpMode::Shake, true);
}
refreshTask = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
@@ -74,8 +74,8 @@ SettingShakeThreshold::SettingShakeThreshold(DisplayApp* app,
SettingShakeThreshold::~SettingShakeThreshold() {
settingsController.SetShakeThreshold(lv_arc_get_value(positionArc));
- if(EnableForCal){
- settingsController.setWakeUpMode(Pinetime::Controllers::Settings::WakeUpMode::Shake,false);
+ if (EnableForCal) {
+ settingsController.setWakeUpMode(Pinetime::Controllers::Settings::WakeUpMode::Shake, false);
EnableForCal = false;
}
lv_task_del(refreshTask);
@@ -123,8 +123,8 @@ void SettingShakeThreshold::UpdateSelected(lv_obj_t* object, lv_event_t event) {
vCalTime = xTaskGetTickCount();
lv_label_set_text_static(calLabel, "Ready!");
lv_obj_set_click(positionArc, false);
- lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
- lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
+ lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_MAKE(0x0, 0xb0, 0x0));
+ lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_MAKE(0x0, 0xb0, 0x0));
} else if (lv_btn_get_state(calButton) == LV_BTN_STATE_RELEASED) {
calibrating = 0;
lv_obj_set_click(positionArc, true);
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.h b/src/displayapp/screens/settings/SettingShakeThreshold.h
index 37f4a65..4331946 100644
--- a/src/displayapp/screens/settings/SettingShakeThreshold.h
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.h
@@ -28,8 +28,8 @@ namespace Pinetime {
System::SystemTask& systemTask;
uint8_t calibrating;
bool EnableForCal;
- uint32_t vDecay,vCalTime;
- lv_obj_t *positionArc, *animArc,*calButton, *calLabel;
+ uint32_t vDecay, vCalTime;
+ lv_obj_t *positionArc, *animArc, *calButton, *calLabel;
lv_task_t* refreshTask;
};
}
diff --git a/src/displayapp/screens/settings/SettingSteps.cpp b/src/displayapp/screens/settings/SettingSteps.cpp
index 5ca3eec..e92600c 100644
--- a/src/displayapp/screens/settings/SettingSteps.cpp
+++ b/src/displayapp/screens/settings/SettingSteps.cpp
@@ -12,15 +12,12 @@ namespace {
}
}
-SettingSteps::SettingSteps(
- Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) :
- Screen(app),
- settingsController{settingsController}
-{
+SettingSteps::SettingSteps(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
+ : Screen(app), settingsController {settingsController} {
- lv_obj_t * container1 = lv_cont_create(lv_scr_act(), nullptr);
+ lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
- //lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111));
+ // lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111));
lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10);
lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5);
@@ -31,13 +28,13 @@ SettingSteps::SettingSteps(
lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT);
lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text_static(title,"Daily steps goal");
+ lv_label_set_text_static(title, "Daily steps goal");
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15);
lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
-
+
lv_label_set_text_static(icon, Symbols::shoe);
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
@@ -61,7 +58,6 @@ SettingSteps::SettingSteps(
lv_obj_set_event_cb(btnMinus, event_handler);
lv_obj_align(btnMinus, lv_scr_act(), LV_ALIGN_CENTER, -55, 80);
lv_obj_set_style_local_value_str(btnMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");
-
}
SettingSteps::~SettingSteps() {
@@ -69,24 +65,23 @@ SettingSteps::~SettingSteps() {
settingsController.SaveSettings();
}
-void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) {
+void SettingSteps::UpdateSelected(lv_obj_t* object, lv_event_t event) {
uint32_t value = settingsController.GetStepsGoal();
- if(object == btnPlus && (event == LV_EVENT_PRESSED)) {
+ if (object == btnPlus && (event == LV_EVENT_PRESSED)) {
value += 1000;
- if ( value <= 500000 ) {
+ if (value <= 500000) {
settingsController.SetStepsGoal(value);
lv_label_set_text_fmt(stepValue, "%lu", settingsController.GetStepsGoal());
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10);
}
}
- if(object == btnMinus && (event == LV_EVENT_PRESSED)) {
+ if (object == btnMinus && (event == LV_EVENT_PRESSED)) {
value -= 1000;
- if ( value >= 1000 ) {
+ if (value >= 1000) {
settingsController.SetStepsGoal(value);
lv_label_set_text_fmt(stepValue, "%lu", settingsController.GetStepsGoal());
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10);
}
}
-
}
diff --git a/src/displayapp/screens/settings/SettingTimeFormat.cpp b/src/displayapp/screens/settings/SettingTimeFormat.cpp
index bd9af15..5502794 100644
--- a/src/displayapp/screens/settings/SettingTimeFormat.cpp
+++ b/src/displayapp/screens/settings/SettingTimeFormat.cpp
@@ -8,8 +8,8 @@
using namespace Pinetime::Applications::Screens;
namespace {
- static void event_handler(lv_obj_t* obj, lv_event_t event) {
- SettingTimeFormat* screen = static_cast<SettingTimeFormat*>(obj->user_data);
+ void event_handler(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingTimeFormat*>(obj->user_data);
screen->UpdateSelected(obj, event);
}
}
diff --git a/src/displayapp/screens/settings/SettingWakeUp.cpp b/src/displayapp/screens/settings/SettingWakeUp.cpp
index e1b6e36..4a4b60f 100644
--- a/src/displayapp/screens/settings/SettingWakeUp.cpp
+++ b/src/displayapp/screens/settings/SettingWakeUp.cpp
@@ -8,8 +8,8 @@
using namespace Pinetime::Applications::Screens;
namespace {
- static void event_handler(lv_obj_t* obj, lv_event_t event) {
- SettingWakeUp* screen = static_cast<SettingWakeUp*>(obj->user_data);
+ void event_handler(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingWakeUp*>(obj->user_data);
screen->UpdateSelected(obj, event);
}
}
diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp
index 9e2748c..e6f940a 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.cpp
+++ b/src/displayapp/screens/settings/SettingWatchFace.cpp
@@ -8,8 +8,8 @@
using namespace Pinetime::Applications::Screens;
namespace {
- static void event_handler(lv_obj_t* obj, lv_event_t event) {
- SettingWatchFace* screen = static_cast<SettingWatchFace*>(obj->user_data);
+ void event_handler(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingWatchFace*>(obj->user_data);
screen->UpdateSelected(obj, event);
}
}
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp
index bc7efcc..a91b8f7 100644
--- a/src/displayapp/screens/settings/Settings.cpp
+++ b/src/displayapp/screens/settings/Settings.cpp
@@ -13,18 +13,19 @@ Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controller
settingsController {settingsController},
screens {app,
settingsController.GetSettingsMenu(),
- {[this]() -> std::unique_ptr<Screen> {
- return CreateScreen1();
- },
- [this]() -> std::unique_ptr<Screen> {
- return CreateScreen2();
- },
- [this]() -> std::unique_ptr<Screen> {
- return CreateScreen3();
- },
- [this]() -> std::unique_ptr<Screen> {
- return CreateScreen4();
- },
+ {
+ [this]() -> std::unique_ptr<Screen> {
+ return CreateScreen1();
+ },
+ [this]() -> std::unique_ptr<Screen> {
+ return CreateScreen2();
+ },
+ [this]() -> std::unique_ptr<Screen> {
+ return CreateScreen3();
+ },
+ [this]() -> std::unique_ptr<Screen> {
+ return CreateScreen4();
+ },
},
Screens::ScreenListModes::UpDown} {
}
@@ -53,7 +54,8 @@ std::unique_ptr<Screen> Settings::CreateScreen2() {
{Symbols::shoe, "Steps", Apps::SettingSteps},
{Symbols::clock, "Set date", Apps::SettingSetDate},
{Symbols::clock, "Set time", Apps::SettingSetTime},
- {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}}};
+ {Symbols::batteryHalf, "Battery", Apps::BatteryInfo},
+ }};
return std::make_unique<Screens::List>(1, 4, app, settingsController, applications);
}
@@ -64,7 +66,7 @@ std::unique_ptr<Screen> Settings::CreateScreen3() {
{Symbols::clock, "Chimes", Apps::SettingChimes},
{Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
{Symbols::check, "Firmware", Apps::FirmwareValidation},
- {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth}
+ {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth},
}};
return std::make_unique<Screens::List>(2, 4, app, settingsController, applications);
@@ -76,7 +78,7 @@ std::unique_ptr<Screen> Settings::CreateScreen4() {
{Symbols::list, "About", Apps::SysInfo},
{Symbols::none, "None", Apps::None},
{Symbols::none, "None", Apps::None},
- {Symbols::none, "None", Apps::None}
+ {Symbols::none, "None", Apps::None},
}};
return std::make_unique<Screens::List>(3, 4, app, settingsController, applications);