summaryrefslogtreecommitdiff
path: root/src/displayapp
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp')
-rw-r--r--src/displayapp/DisplayApp.cpp1
-rw-r--r--src/displayapp/screens/BatteryIcon.cpp8
-rw-r--r--src/displayapp/screens/Clock.cpp20
-rw-r--r--src/displayapp/screens/Clock.h7
-rw-r--r--src/displayapp/screens/Metronome.cpp119
-rw-r--r--src/displayapp/screens/Metronome.h48
-rw-r--r--src/displayapp/screens/PineTimeStyle.cpp60
-rw-r--r--src/displayapp/screens/PineTimeStyle.h5
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.cpp52
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.h2
-rw-r--r--src/displayapp/screens/WatchFaceDigital.cpp45
-rw-r--r--src/displayapp/screens/WatchFaceDigital.h5
12 files changed, 123 insertions, 249 deletions
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index bdd703ee..5150162a 100644
--- a/src/displayapp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -414,6 +414,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
break;
case Apps::Metronome:
currentScreen = std::make_unique<Screens::Metronome>(this, motorController, *systemTask);
+ ReturnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::None);
break;
case Apps::Motion:
currentScreen = std::make_unique<Screens::Motion>(this, motionController);
diff --git a/src/displayapp/screens/BatteryIcon.cpp b/src/displayapp/screens/BatteryIcon.cpp
index bb6626a5..c67bcb23 100644
--- a/src/displayapp/screens/BatteryIcon.cpp
+++ b/src/displayapp/screens/BatteryIcon.cpp
@@ -5,13 +5,13 @@
using namespace Pinetime::Applications::Screens;
const char* BatteryIcon::GetBatteryIcon(uint8_t batteryPercent) {
- if (batteryPercent > 90)
+ if (batteryPercent > 87)
return Symbols::batteryFull;
- if (batteryPercent > 75)
+ if (batteryPercent > 62)
return Symbols::batteryThreeQuarter;
- if (batteryPercent > 50)
+ if (batteryPercent > 37)
return Symbols::batteryHalf;
- if (batteryPercent > 25)
+ if (batteryPercent > 12)
return Symbols::batteryOneQuarter;
return Symbols::batteryEmpty;
}
diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp
index e0684976..86afee0c 100644
--- a/src/displayapp/screens/Clock.cpp
+++ b/src/displayapp/screens/Clock.cpp
@@ -2,11 +2,6 @@
#include <date/date.h>
#include <lvgl/lvgl.h>
-#include <cstdio>
-#include "BatteryIcon.h"
-#include "BleIcon.h"
-#include "NotificationIcon.h"
-#include "Symbols.h"
#include "components/battery/BatteryController.h"
#include "components/motion/MotionController.h"
#include "components/ble/BleController.h"
@@ -88,17 +83,4 @@ std::unique_ptr<Screen> Clock::PineTimeStyleScreen() {
notificatioManager,
settingsController,
motionController);
-}
-
-/*
-// Examples for more watch faces
-std::unique_ptr<Screen> Clock::WatchFaceMinimalScreen() {
- return std::make_unique<Screens::WatchFaceMinimal>(app, dateTimeController, batteryController, bleController, notificatioManager,
-settingsController);
-}
-
-std::unique_ptr<Screen> Clock::WatchFaceCustomScreen() {
- return std::make_unique<Screens::WatchFaceCustom>(app, dateTimeController, batteryController, bleController, notificatioManager,
-settingsController);
-}
-*/ \ No newline at end of file
+} \ No newline at end of file
diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h
index a48feea1..7968cced 100644
--- a/src/displayapp/screens/Clock.h
+++ b/src/displayapp/screens/Clock.h
@@ -9,9 +9,6 @@
#include "components/datetime/DateTimeController.h"
namespace Pinetime {
- namespace Drivers {
- class BMA421;
- }
namespace Controllers {
class Settings;
class Battery;
@@ -51,10 +48,6 @@ namespace Pinetime {
std::unique_ptr<Screen> WatchFaceDigitalScreen();
std::unique_ptr<Screen> WatchFaceAnalogScreen();
std::unique_ptr<Screen> PineTimeStyleScreen();
-
- // Examples for more watch faces
- // std::unique_ptr<Screen> WatchFaceMinimalScreen();
- // std::unique_ptr<Screen> WatchFaceCustomScreen();
};
}
}
diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp
index 16c34f45..66f8f621 100644
--- a/src/displayapp/screens/Metronome.cpp
+++ b/src/displayapp/screens/Metronome.cpp
@@ -1,35 +1,15 @@
#include "Metronome.h"
-
-#include "Screen.h"
#include "Symbols.h"
-#include "lvgl/lvgl.h"
-#include "FreeRTOSConfig.h"
-#include "task.h"
-
-#include <string>
-#include <tuple>
using namespace Pinetime::Applications::Screens;
namespace {
- float 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 static_cast<float>(delta) / static_cast<float>(configTICK_RATE_HZ);
- }
-
- static void eventHandler(lv_obj_t* obj, lv_event_t event) {
- Metronome* screen = static_cast<Metronome*>(obj->user_data);
+ void eventHandler(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<Metronome*>(obj->user_data);
screen->OnEvent(obj, event);
}
- lv_obj_t* createLabel(const char* name, lv_obj_t* reference, lv_align_t align, lv_font_t* font, uint8_t x = 0, uint8_t y = 0) {
+ 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);
@@ -41,7 +21,7 @@ namespace {
}
Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask)
- : Screen(app), running {true}, currentState {States::Stopped}, startTime {}, motorController {motorController}, systemTask {systemTask} {
+ : Screen(app), motorController {motorController}, systemTask {systemTask} {
bpmArc = lv_arc_create(lv_scr_act(), nullptr);
bpmArc->user_data = this;
@@ -52,10 +32,10 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl
lv_arc_set_value(bpmArc, bpm);
lv_obj_set_size(bpmArc, 210, 210);
lv_arc_set_adjustable(bpmArc, true);
- lv_obj_align(bpmArc, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 7);
+ lv_obj_align(bpmArc, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0);
- bpmValue = createLabel(std::to_string(lv_arc_get_value(bpmArc)).c_str(), bpmArc, LV_ALIGN_IN_TOP_MID, &jetbrains_mono_76, 0, 55);
- bpmLegend = createLabel("bpm", bpmValue, LV_ALIGN_OUT_BOTTOM_MID, &jetbrains_mono_bold_20, 0, 0);
+ bpmValue = createLabel("120", bpmArc, LV_ALIGN_IN_TOP_MID, &jetbrains_mono_76, 0, 55);
+ createLabel("bpm", bpmValue, LV_ALIGN_OUT_BOTTOM_MID, &jetbrains_mono_bold_20, 0, 0);
bpmTap = lv_btn_create(lv_scr_act(), nullptr);
bpmTap->user_data = this;
@@ -69,20 +49,23 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl
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_align(bpbDropdown, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 15, -4);
+ lv_obj_set_size(bpbDropdown, 115, 50);
+ lv_obj_align(bpbDropdown, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_dropdown_set_options(bpbDropdown, "1\n2\n3\n4\n5\n6\n7\n8\n9");
lv_dropdown_set_selected(bpbDropdown, bpb - 1);
- bpbLegend = lv_label_create(bpbDropdown, nullptr);
- lv_label_set_text(bpbLegend, "bpb");
- lv_obj_align(bpbLegend, bpbDropdown, LV_ALIGN_IN_RIGHT_MID, -15, 0);
+ lv_dropdown_set_show_selected(bpbDropdown, false);
+ lv_dropdown_set_text(bpbDropdown, "");
+
+ currentBpbText = lv_label_create(bpbDropdown, nullptr);
+ lv_label_set_text_fmt(currentBpbText, "%d bpb", bpb);
+ lv_obj_align(currentBpbText, bpbDropdown, LV_ALIGN_CENTER, 0, 0);
playPause = lv_btn_create(lv_scr_act(), nullptr);
playPause->user_data = this;
lv_obj_set_event_cb(playPause, eventHandler);
- lv_obj_align(playPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -15, -10);
- lv_obj_set_height(playPause, 39);
- playPauseLabel = lv_label_create(playPause, nullptr);
- lv_label_set_text(playPauseLabel, Symbols::play);
+ lv_obj_set_size(playPause, 115, 50);
+ lv_obj_align(playPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
+ lv_obj_set_style_local_value_str(playPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Symbols::play);
app->SetTouchMode(DisplayApp::TouchModes::Polling);
}
@@ -93,28 +76,17 @@ Metronome::~Metronome() {
lv_obj_clean(lv_scr_act());
}
-bool Metronome::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
- return true;
-}
-
bool Metronome::Refresh() {
- switch (currentState) {
- case States::Stopped: {
- break;
- }
- case States::Running: {
- if (calculateDelta(startTime, xTaskGetTickCount()) >= (60.0 / bpm)) {
- counter--;
- startTime -= 60.0 / bpm;
- startTime = xTaskGetTickCount();
- if (counter == 0) {
- counter = bpb;
- motorController.RunForDuration(90);
- } else {
- motorController.RunForDuration(30);
- }
+ if (metronomeStarted) {
+ if (xTaskGetTickCount() - startTime > 60 * configTICK_RATE_HZ / bpm) {
+ startTime += 60 * configTICK_RATE_HZ / bpm;
+ counter--;
+ if (counter == 0) {
+ counter = bpb;
+ motorController.RunForDuration(90);
+ } else {
+ motorController.RunForDuration(30);
}
- break;
}
}
return running;
@@ -128,42 +100,39 @@ void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
lv_label_set_text_fmt(bpmValue, "%03d", bpm);
} else if (obj == bpbDropdown) {
bpb = lv_dropdown_get_selected(obj) + 1;
+ lv_label_set_text_fmt(currentBpbText, "%d bpb", bpb);
+ lv_obj_realign(currentBpbText);
}
break;
}
case LV_EVENT_PRESSED: {
if (obj == bpmTap) {
- float timeDelta = calculateDelta(tappedTime, xTaskGetTickCount());
- if (tappedTime == 0 || timeDelta > 3) {
- tappedTime = xTaskGetTickCount();
- } else {
- bpm = ceil(60.0 / timeDelta);
+ TickType_t delta = xTaskGetTickCount() - tappedTime;
+ if (tappedTime != 0 && delta < configTICK_RATE_HZ * 3) {
+ bpm = configTICK_RATE_HZ * 60 / delta;
lv_arc_set_value(bpmArc, bpm);
lv_label_set_text_fmt(bpmValue, "%03d", bpm);
- tappedTime = xTaskGetTickCount();
}
+ tappedTime = xTaskGetTickCount();
}
break;
}
case LV_EVENT_CLICKED: {
if (obj == playPause) {
- currentState = (currentState == States::Stopped ? States::Running : States::Stopped);
- switch (currentState) {
- case States::Stopped: {
- lv_label_set_text(playPauseLabel, Symbols::play);
- systemTask.PushMessage(System::Messages::EnableSleeping);
- break;
- }
- case States::Running: {
- lv_label_set_text(playPauseLabel, Symbols::pause);
- systemTask.PushMessage(System::Messages::DisableSleeping);
- startTime = xTaskGetTickCount();
- counter = 1;
- break;
- }
+ metronomeStarted = !metronomeStarted;
+ if (metronomeStarted) {
+ lv_obj_set_style_local_value_str(playPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Symbols::pause);
+ systemTask.PushMessage(System::Messages::DisableSleeping);
+ startTime = xTaskGetTickCount();
+ counter = 1;
+ } else {
+ lv_obj_set_style_local_value_str(playPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Symbols::play);
+ systemTask.PushMessage(System::Messages::EnableSleeping);
}
}
break;
}
+ default:
+ break;
}
}
diff --git a/src/displayapp/screens/Metronome.h b/src/displayapp/screens/Metronome.h
index 3a1f1084..a4baa096 100644
--- a/src/displayapp/screens/Metronome.h
+++ b/src/displayapp/screens/Metronome.h
@@ -3,32 +3,32 @@
#include "systemtask/SystemTask.h"
#include "components/motor/MotorController.h"
-#include <array>
+namespace Pinetime {
+ namespace Applications {
+ namespace Screens {
-namespace Pinetime::Applications::Screens {
+ class Metronome : public Screen {
+ public:
+ Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask);
+ ~Metronome() override;
+ bool Refresh() override;
+ void OnEvent(lv_obj_t* obj, lv_event_t event);
- class Metronome : public Screen {
- public:
- Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask);
- ~Metronome() override;
- bool Refresh() override;
- bool OnTouchEvent(TouchEvents event) override;
- void OnEvent(lv_obj_t* obj, lv_event_t event);
- enum class States { Running, Stopped };
+ private:
+ TickType_t startTime = 0;
+ TickType_t tappedTime = 0;
+ Controllers::MotorController& motorController;
+ System::SystemTask& systemTask;
+ int16_t bpm = 120;
+ uint8_t bpb = 4;
+ uint8_t counter = 1;
- private:
- bool running;
- States currentState;
- TickType_t startTime;
- TickType_t tappedTime = 0;
- Controllers::MotorController& motorController;
- System::SystemTask& systemTask;
- uint16_t bpm = 120;
- uint8_t bpb = 4;
- uint8_t counter = 1;
+ bool metronomeStarted = false;
- lv_obj_t *bpmArc, *bpmTap, *bpmValue, *bpmLegend;
- lv_obj_t *bpbDropdown, *bpbLegend;
- lv_obj_t *playPause, *playPauseLabel;
- };
+ lv_obj_t *bpmArc, *bpmTap, *bpmValue;
+ lv_obj_t *bpbDropdown, *currentBpbText;
+ lv_obj_t *playPause;
+ };
+ }
+ }
}
diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp
index 0efb4dc3..98fd976c 100644
--- a/src/displayapp/screens/PineTimeStyle.cpp
+++ b/src/displayapp/screens/PineTimeStyle.cpp
@@ -51,7 +51,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
notificatioManager {notificatioManager},
settingsController {settingsController},
motionController {motionController} {
-
/* This sets the watchface number to return to after leaving the menu */
settingsController.SetClockFace(2);
@@ -62,7 +61,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
displayedChar[4] = 0;
/* Create a 200px wide background rectangle */
-
timebar = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
@@ -70,7 +68,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
/* Display the time */
-
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
@@ -90,7 +87,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
/* Create a 40px wide bar down the right side of the screen */
-
sidebar = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
@@ -98,7 +94,6 @@ 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_hex(0x000000));
lv_label_set_text(batteryIcon, Symbols::batteryFull);
@@ -117,7 +112,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 40);
/* Calendar icon */
-
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
@@ -155,7 +149,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
/* Display date */
-
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
lv_label_set_text(dateDayOfWeek, "THU");
@@ -223,26 +216,17 @@ bool PineTimeStyle::Refresh() {
bleState = bleController.IsConnected();
if (bleState.IsUpdated()) {
- if (bleState.Get() == true) {
- lv_label_set_text(bleIcon, BleIcon::GetIcon(true));
- lv_obj_realign(bleIcon);
- } else {
- lv_label_set_text(bleIcon, BleIcon::GetIcon(false));
- }
+ lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
+ lv_obj_realign(bleIcon);
}
notificationState = notificatioManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
- if (notificationState.Get() == true) {
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(true));
- lv_obj_realign(notificationIcon);
- } else {
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
- }
+ lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
+ lv_obj_realign(notificationIcon);
}
currentDateTime = dateTimeController.CurrentDateTime();
-
if (currentDateTime.IsUpdated()) {
auto newDateTime = currentDateTime.Get();
@@ -250,9 +234,9 @@ bool PineTimeStyle::Refresh() {
auto time = date::make_time(newDateTime - dp);
auto yearMonthDay = date::year_month_day(dp);
- auto year = (int) yearMonthDay.year();
- auto month = static_cast<Pinetime::Controllers::DateTime::Months>((unsigned) yearMonthDay.month());
- auto day = (unsigned) yearMonthDay.day();
+ auto year = static_cast<int>(yearMonthDay.year());
+ auto month = static_cast<Pinetime::Controllers::DateTime::Months>(static_cast<unsigned>(yearMonthDay.month()));
+ auto day = static_cast<unsigned>(yearMonthDay.day());
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
int hour = time.hours().count();
@@ -263,9 +247,8 @@ bool PineTimeStyle::Refresh() {
char hoursChar[3];
char ampmChar[5];
-
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
- sprintf(hoursChar, "%02d", hour);
+ sprintf(hoursChar, "%02d", hour);
} else {
if (hour == 0 && hour != 12) {
hour = 12;
@@ -282,41 +265,26 @@ bool PineTimeStyle::Refresh() {
sprintf(hoursChar, "%02d", hour);
}
- if (hoursChar[0] != displayedChar[0] || hoursChar[1] != displayedChar[1] || minutesChar[0] != displayedChar[2] ||
+ if (hoursChar[0] != displayedChar[0] or hoursChar[1] != displayedChar[1] or minutesChar[0] != displayedChar[2] or
minutesChar[1] != displayedChar[3]) {
displayedChar[0] = hoursChar[0];
displayedChar[1] = hoursChar[1];
displayedChar[2] = minutesChar[0];
displayedChar[3] = minutesChar[1];
- char hourStr[3];
- char minStr[3];
-
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
lv_label_set_text(timeAMPM, ampmChar);
}
- /* Display the time as 2 pairs of digits */
- sprintf(hourStr, "%c%c", hoursChar[0], hoursChar[1]);
- lv_label_set_text(timeDD1, hourStr);
-
- sprintf(minStr, "%c%c", minutesChar[0], minutesChar[1]);
- lv_label_set_text(timeDD2, minStr);
+ lv_label_set_text_fmt(timeDD1, "%s", hoursChar);
+ lv_label_set_text_fmt(timeDD2, "%s", minutesChar);
}
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
- char dayOfWeekStr[4];
- char dayStr[3];
- char monthStr[4];
-
- sprintf(dayOfWeekStr, "%s", dateTimeController.DayOfWeekShortToString());
- sprintf(dayStr, "%d", day);
- sprintf(monthStr, "%s", dateTimeController.MonthShortToString());
-
- lv_label_set_text(dateDayOfWeek, dayOfWeekStr);
- lv_label_set_text(dateDay, dayStr);
+ lv_label_set_text_fmt(dateDayOfWeek, "%s", dateTimeController.DayOfWeekShortToString());
+ lv_label_set_text_fmt(dateDay, "%d", day);
lv_obj_realign(dateDay);
- lv_label_set_text(dateMonth, monthStr);
+ lv_label_set_text_fmt(dateMonth, "%s", dateTimeController.MonthShortToString());
currentYear = year;
currentMonth = month;
diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h
index 3b4ded1e..f4cd28e4 100644
--- a/src/displayapp/screens/PineTimeStyle.h
+++ b/src/displayapp/screens/PineTimeStyle.h
@@ -32,8 +32,6 @@ namespace Pinetime {
bool Refresh() override;
- void OnObjectEvent(lv_obj_t* pObj, lv_event_t i);
-
private:
char displayedChar[5];
@@ -67,9 +65,6 @@ namespace Pinetime {
lv_obj_t* calendarBar2;
lv_obj_t* calendarCrossBar1;
lv_obj_t* calendarCrossBar2;
- lv_obj_t* heartbeatIcon;
- lv_obj_t* heartbeatValue;
- lv_obj_t* heartbeatBpm;
lv_obj_t* notificationIcon;
lv_obj_t* stepGauge;
lv_color_t needle_colors[1];
diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp
index f1889379..621929b8 100644
--- a/src/displayapp/screens/WatchFaceAnalog.cpp
+++ b/src/displayapp/screens/WatchFaceAnalog.cpp
@@ -10,38 +10,37 @@ LV_IMG_DECLARE(bg_clock);
using namespace Pinetime::Applications::Screens;
namespace {
-
-constexpr auto HOUR_LENGTH = 70;
-constexpr auto MINUTE_LENGTH = 90;
-constexpr auto SECOND_LENGTH = 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);
-int16_t cosine(int16_t angle) {
+int16_t Cosine(int16_t angle) {
return _lv_trigo_sin(angle + 90);
}
-int16_t sine(int16_t angle) {
+int16_t Sine(int16_t angle) {
return _lv_trigo_sin(angle);
}
-int16_t coordinate_x_relocate(int16_t x) {
+int16_t CoordinateXRelocate(int16_t x) {
return (x + LV_HOR_RES / 2);
}
-int16_t coordinate_y_relocate(int16_t y) {
+int16_t CoordinateYRelocate(int16_t y) {
return std::abs(y - LV_HOR_RES / 2);
}
-lv_point_t coordinate_relocate(int16_t radius, int16_t angle) {
+lv_point_t CoordinateRelocate(int16_t radius, int16_t angle) {
return lv_point_t{
- .x = coordinate_x_relocate(radius * static_cast<int32_t>(sine(angle)) / LV_TRIG_SCALE),
- .y = coordinate_y_relocate(radius * static_cast<int32_t>(cosine(angle)) / LV_TRIG_SCALE)
+ .x = CoordinateXRelocate(radius * static_cast<int32_t>(Sine(angle)) / LV_TRIG_SCALE),
+ .y = CoordinateYRelocate(radius * static_cast<int32_t>(Cosine(angle)) / LV_TRIG_SCALE)
};
}
-} // namespace
+}
WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
Controllers::DateTime& dateTimeController,
@@ -123,7 +122,6 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
}
WatchFaceAnalog::~WatchFaceAnalog() {
-
lv_style_reset(&hour_line_style);
lv_style_reset(&hour_line_style_trace);
lv_style_reset(&minute_line_style);
@@ -134,18 +132,17 @@ WatchFaceAnalog::~WatchFaceAnalog() {
}
void WatchFaceAnalog::UpdateClock() {
-
hour = dateTimeController.Hours();
minute = dateTimeController.Minutes();
second = dateTimeController.Seconds();
if (sMinute != minute) {
auto const angle = minute * 6;
- minute_point[0] = coordinate_relocate(30, angle);
- minute_point[1] = coordinate_relocate(MINUTE_LENGTH, angle);
+ minute_point[0] = CoordinateRelocate(30, angle);
+ minute_point[1] = CoordinateRelocate(MinuteLength, angle);
- minute_point_trace[0] = coordinate_relocate(5, angle);
- minute_point_trace[1] = coordinate_relocate(31, angle);
+ minute_point_trace[0] = CoordinateRelocate(5, angle);
+ minute_point_trace[1] = CoordinateRelocate(31, angle);
lv_line_set_points(minute_body, minute_point, 2);
lv_line_set_points(minute_body_trace, minute_point_trace, 2);
@@ -156,11 +153,11 @@ void WatchFaceAnalog::UpdateClock() {
sMinute = minute;
auto const angle = (hour * 30 + minute / 2);
- hour_point[0] = coordinate_relocate(30, angle);
- hour_point[1] = coordinate_relocate(HOUR_LENGTH, angle);
+ hour_point[0] = CoordinateRelocate(30, angle);
+ hour_point[1] = CoordinateRelocate(HourLength, angle);
- hour_point_trace[0] = coordinate_relocate(5, angle);
- hour_point_trace[1] = coordinate_relocate(31, angle);
+ hour_point_trace[0] = CoordinateRelocate(5, angle);
+ hour_point_trace[1] = CoordinateRelocate(31, angle);
lv_line_set_points(hour_body, hour_point, 2);
lv_line_set_points(hour_body_trace, hour_point_trace, 2);
@@ -170,8 +167,8 @@ void WatchFaceAnalog::UpdateClock() {
sSecond = second;
auto const angle = second * 6;
- second_point[0] = coordinate_relocate(-20, angle);
- second_point[1] = coordinate_relocate(SECOND_LENGTH, angle);
+ second_point[0] = CoordinateRelocate(-20, angle);
+ second_point[1] = CoordinateRelocate(SecondLength, angle);
lv_line_set_points(second_body, second_point, 2);
}
}
@@ -186,16 +183,12 @@ bool WatchFaceAnalog::Refresh() {
notificationState = notificationManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
- if (notificationState.Get() == true)
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(true));
- else
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
+ lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
}
currentDateTime = dateTimeController.CurrentDateTime();
if (currentDateTime.IsUpdated()) {
-
month = dateTimeController.Month();
day = dateTimeController.Day();
dayOfWeek = dateTimeController.DayOfWeek();
@@ -203,7 +196,6 @@ bool WatchFaceAnalog::Refresh() {
UpdateClock();
if ((month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
-
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), day);
currentMonth = month;
diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h
index ac7f0ac5..5d8c6a24 100644
--- a/src/displayapp/screens/WatchFaceAnalog.h
+++ b/src/displayapp/screens/WatchFaceAnalog.h
@@ -58,14 +58,12 @@ namespace Pinetime {
lv_obj_t* minute_body_trace;
lv_obj_t* second_body;
- // ##
lv_point_t hour_point[2];
lv_point_t hour_point_trace[2];
lv_point_t minute_point[2];
lv_point_t minute_point_trace[2];
lv_point_t second_point[2];
- // ##
lv_style_t hour_line_style;
lv_style_t hour_line_style_trace;
lv_style_t minute_line_style;
diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp
index f1285eaf..7a240f1f 100644
--- a/src/displayapp/screens/WatchFaceDigital.cpp
+++ b/src/displayapp/screens/WatchFaceDigital.cpp
@@ -12,9 +12,6 @@
#include "components/ble/NotificationManager.h"
#include "components/heartrate/HeartRateController.h"
#include "components/motion/MotionController.h"
-#include "components/settings/Settings.h"
-#include "../DisplayApp.h"
-
using namespace Pinetime::Applications::Screens;
WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
@@ -36,12 +33,6 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
motionController {motionController} {
settingsController.SetClockFace(0);
- displayedChar[0] = 0;
- displayedChar[1] = 0;
- displayedChar[2] = 0;
- displayedChar[3] = 0;
- displayedChar[4] = 0;
-
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(batteryIcon, Symbols::batteryFull);
lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, -5, 2);
@@ -56,7 +47,7 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
lv_label_set_text(bleIcon, Symbols::bluetooth);
lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
- notificationIcon = lv_label_create(lv_scr_act(), NULL);
+ notificationIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00));
lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 10, 0);
@@ -111,17 +102,13 @@ bool WatchFaceDigital::Refresh() {
if (batteryPercentRemaining.IsUpdated()) {
auto batteryPercent = batteryPercentRemaining.Get();
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
- auto isCharging = batteryController.IsCharging() || batteryController.IsPowerPresent();
+ auto isCharging = batteryController.IsCharging() or batteryController.IsPowerPresent();
lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging));
}
bleState = bleController.IsConnected();
if (bleState.IsUpdated()) {
- if (bleState.Get() == true) {
- lv_label_set_text(bleIcon, BleIcon::GetIcon(true));
- } else {
- lv_label_set_text(bleIcon, BleIcon::GetIcon(false));
- }
+ lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
}
lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, -5, 5);
lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
@@ -129,10 +116,7 @@ bool WatchFaceDigital::Refresh() {
notificationState = notificatioManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
- if (notificationState.Get() == true)
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(true));
- else
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
+ lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
}
currentDateTime = dateTimeController.CurrentDateTime();
@@ -144,9 +128,9 @@ bool WatchFaceDigital::Refresh() {
auto time = date::make_time(newDateTime - dp);
auto yearMonthDay = date::year_month_day(dp);
- auto year = (int) yearMonthDay.year();
- auto month = static_cast<Pinetime::Controllers::DateTime::Months>((unsigned) yearMonthDay.month());
- auto day = (unsigned) yearMonthDay.day();
+ auto year = static_cast<int>(yearMonthDay.year());
+ auto month = static_cast<Pinetime::Controllers::DateTime::Months>(static_cast<unsigned>(yearMonthDay.month()));
+ auto day = static_cast<unsigned>(yearMonthDay.day());
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
int hour = time.hours().count();
@@ -175,15 +159,13 @@ bool WatchFaceDigital::Refresh() {
sprintf(hoursChar, "%02d", hour);
}
- if (hoursChar[0] != displayedChar[0] || hoursChar[1] != displayedChar[1] || minutesChar[0] != displayedChar[2] ||
- minutesChar[1] != displayedChar[3]) {
+ if ((hoursChar[0] != displayedChar[0]) or (hoursChar[1] != displayedChar[1]) or (minutesChar[0] != displayedChar[2]) or
+ (minutesChar[1] != displayedChar[3])) {
displayedChar[0] = hoursChar[0];
displayedChar[1] = hoursChar[1];
displayedChar[2] = minutesChar[0];
displayedChar[3] = minutesChar[1];
- char timeStr[6];
-
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
lv_label_set_text(label_time_ampm, ampmChar);
if (hoursChar[0] == '0') {
@@ -191,8 +173,7 @@ bool WatchFaceDigital::Refresh() {
}
}
- sprintf(timeStr, "%c%c:%c%c", hoursChar[0], hoursChar[1], minutesChar[0], minutesChar[1]);
- lv_label_set_text(label_time, timeStr);
+ lv_label_set_text_fmt(label_time, "%s:%s", hoursChar, minutesChar);
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);
@@ -202,13 +183,11 @@ bool WatchFaceDigital::Refresh() {
}
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
- char dateStr[22];
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
- sprintf(dateStr, "%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 {
- sprintf(dateStr, "%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_label_set_text(label_date, dateStr);
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
currentYear = year;
diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h
index 76c8d3dc..6a6e1ac6 100644
--- a/src/displayapp/screens/WatchFaceDigital.h
+++ b/src/displayapp/screens/WatchFaceDigital.h
@@ -35,10 +35,8 @@ namespace Pinetime {
bool Refresh() override;
- void OnObjectEvent(lv_obj_t* pObj, lv_event_t i);
-
private:
- char displayedChar[5];
+ char displayedChar[5] {};
uint16_t currentYear = 1970;
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
@@ -63,7 +61,6 @@ namespace Pinetime {
lv_obj_t* batteryPlug;
lv_obj_t* heartbeatIcon;
lv_obj_t* heartbeatValue;
- lv_obj_t* heartbeatBpm;
lv_obj_t* stepIcon;
lv_obj_t* stepValue;
lv_obj_t* notificationIcon;