resolved merge conflict after renaming PineTimeStyle to WatchFacePineTimeStyle
This commit is contained in:
@@ -2,11 +2,7 @@
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
const char* BleIcon::GetIcon(bool isRadioEnabled, bool isConnected) {
|
||||
if(!isRadioEnabled) {
|
||||
return Symbols::airplane;
|
||||
}
|
||||
|
||||
const char* BleIcon::GetIcon(bool isConnected) {
|
||||
if (isConnected) {
|
||||
return Symbols::bluetooth;
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ namespace Pinetime {
|
||||
namespace Screens {
|
||||
class BleIcon {
|
||||
public:
|
||||
static const char* GetIcon(bool isRadioEnabled, bool isConnected);
|
||||
static const char* GetIcon(bool isConnected);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ namespace Pinetime {
|
||||
void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
|
||||
|
||||
private:
|
||||
bool OnTouchEvent(TouchEvents event);
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
|
||||
void UpdateLength();
|
||||
|
||||
|
@@ -44,7 +44,6 @@ namespace Pinetime {
|
||||
static constexpr const char* chartLine = "\xEF\x88\x81";
|
||||
static constexpr const char* eye = "\xEF\x81\xAE";
|
||||
static constexpr const char* home = "\xEF\x80\x95";
|
||||
static constexpr const char* airplane = "\xEF\x81\xB2";
|
||||
|
||||
// lv_font_sys_48.c
|
||||
static constexpr const char* settings = "\xEE\xA4\x82"; // e902
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#include "displayapp/screens/Timer.h"
|
||||
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
#include <lvgl/lvgl.h>
|
||||
@@ -7,11 +6,11 @@
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
|
||||
Timer* screen = static_cast<Timer*>(obj->user_data);
|
||||
auto* screen = static_cast<Timer*>(obj->user_data);
|
||||
screen->OnButtonEvent(obj, event);
|
||||
}
|
||||
|
||||
void Timer::createButtons() {
|
||||
void Timer::CreateButtons() {
|
||||
btnMinutesUp = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnMinutesUp->user_data = this;
|
||||
lv_obj_set_event_cb(btnMinutesUp, btnEventHandler);
|
||||
@@ -51,6 +50,12 @@ void Timer::createButtons() {
|
||||
|
||||
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(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);
|
||||
@@ -71,7 +76,7 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
|
||||
lv_label_set_text(txtPlayPause, Symbols::pause);
|
||||
} else {
|
||||
lv_label_set_text(txtPlayPause, Symbols::play);
|
||||
createButtons();
|
||||
CreateButtons();
|
||||
}
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||
@@ -98,7 +103,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
||||
minutesToSet = seconds / 60;
|
||||
secondsToSet = seconds % 60;
|
||||
timerController.StopTimer();
|
||||
createButtons();
|
||||
CreateButtons();
|
||||
|
||||
} else if (secondsToSet + minutesToSet > 0) {
|
||||
lv_label_set_text(txtPlayPause, Symbols::pause);
|
||||
@@ -152,10 +157,10 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
||||
}
|
||||
}
|
||||
|
||||
void Timer::setDone() {
|
||||
void Timer::SetDone() {
|
||||
lv_label_set_text(time, "00:00");
|
||||
lv_label_set_text(txtPlayPause, Symbols::play);
|
||||
secondsToSet = 0;
|
||||
minutesToSet = 0;
|
||||
createButtons();
|
||||
CreateButtons();
|
||||
}
|
||||
|
@@ -8,32 +8,35 @@
|
||||
#include "components/timer/TimerController.h"
|
||||
|
||||
namespace Pinetime::Applications::Screens {
|
||||
|
||||
class Timer : public Screen {
|
||||
public:
|
||||
enum class Modes { Normal, Done };
|
||||
|
||||
Timer(DisplayApp* app, Controllers::TimerController& timerController);
|
||||
|
||||
~Timer() override;
|
||||
|
||||
void Refresh() override;
|
||||
|
||||
void setDone();
|
||||
|
||||
void SetDone();
|
||||
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
|
||||
|
||||
private:
|
||||
void CreateButtons();
|
||||
bool running;
|
||||
uint8_t secondsToSet = 0;
|
||||
uint8_t minutesToSet = 0;
|
||||
Controllers::TimerController& timerController;
|
||||
|
||||
void createButtons();
|
||||
|
||||
lv_obj_t *time, *msecTime, *btnPlayPause, *txtPlayPause, *btnMinutesUp, *btnMinutesDown, *btnSecondsUp, *btnSecondsDown, *txtMUp,
|
||||
*txtMDown, *txtSUp, *txtSDown;
|
||||
|
||||
lv_obj_t* backgroundLabel;
|
||||
lv_obj_t* time;
|
||||
lv_obj_t* msecTime;
|
||||
lv_obj_t* btnPlayPause;
|
||||
lv_obj_t* txtPlayPause;
|
||||
lv_obj_t* btnMinutesUp;
|
||||
lv_obj_t* btnMinutesDown;
|
||||
lv_obj_t* btnSecondsUp;
|
||||
lv_obj_t* btnSecondsDown;
|
||||
lv_obj_t* txtMUp;
|
||||
lv_obj_t* txtMDown;
|
||||
lv_obj_t* txtSUp;
|
||||
lv_obj_t* txtSDown;
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
|
@@ -130,7 +130,7 @@ bool Twos::placeNewTile() {
|
||||
}
|
||||
|
||||
bool Twos::tryMerge(TwosTile grid[][4], int& newRow, int& newCol, int oldRow, int oldCol) {
|
||||
if ((grid[newRow][newCol].value == grid[oldRow][oldCol].value)) {
|
||||
if (grid[newRow][newCol].value == grid[oldRow][oldCol].value) {
|
||||
if ((newCol != oldCol) || (newRow != oldRow)) {
|
||||
if (!grid[newRow][newCol].merged) {
|
||||
unsigned int newVal = grid[oldRow][oldCol].value *= 2;
|
||||
|
@@ -137,9 +137,9 @@ WatchFaceAnalog::~WatchFaceAnalog() {
|
||||
}
|
||||
|
||||
void WatchFaceAnalog::UpdateClock() {
|
||||
hour = dateTimeController.Hours();
|
||||
minute = dateTimeController.Minutes();
|
||||
second = dateTimeController.Seconds();
|
||||
uint8_t hour = dateTimeController.Hours();
|
||||
uint8_t minute = dateTimeController.Minutes();
|
||||
uint8_t second = dateTimeController.Seconds();
|
||||
|
||||
if (sMinute != minute) {
|
||||
auto const angle = minute * 6;
|
||||
@@ -214,9 +214,9 @@ void WatchFaceAnalog::Refresh() {
|
||||
currentDateTime = dateTimeController.CurrentDateTime();
|
||||
|
||||
if (currentDateTime.IsUpdated()) {
|
||||
month = dateTimeController.Month();
|
||||
day = dateTimeController.Day();
|
||||
dayOfWeek = dateTimeController.DayOfWeek();
|
||||
Pinetime::Controllers::DateTime::Months month = dateTimeController.Month();
|
||||
uint8_t day = dateTimeController.Day();
|
||||
Pinetime::Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek();
|
||||
|
||||
UpdateClock();
|
||||
|
||||
|
@@ -35,13 +35,6 @@ namespace Pinetime {
|
||||
|
||||
private:
|
||||
uint8_t sHour, sMinute, sSecond;
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
uint8_t second;
|
||||
|
||||
Pinetime::Controllers::DateTime::Months month;
|
||||
uint8_t day;
|
||||
Pinetime::Controllers::DateTime::Days dayOfWeek;
|
||||
|
||||
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
|
||||
Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
|
||||
@@ -74,7 +67,7 @@ namespace Pinetime {
|
||||
lv_obj_t* batteryIcon;
|
||||
lv_obj_t* notificationIcon;
|
||||
|
||||
Controllers::DateTime& dateTimeController;
|
||||
const Controllers::DateTime& dateTimeController;
|
||||
Controllers::Battery& batteryController;
|
||||
Controllers::Ble& bleController;
|
||||
Controllers::NotificationManager& notificationManager;
|
||||
|
@@ -121,7 +121,7 @@ void WatchFaceDigital::Refresh() {
|
||||
bleState = bleController.IsConnected();
|
||||
bleRadioEnabled = bleController.IsRadioEnabled();
|
||||
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
|
||||
lv_label_set_text(bleIcon, BleIcon::GetIcon(bleRadioEnabled.Get(), bleState.Get()));
|
||||
lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
|
||||
}
|
||||
lv_obj_realign(batteryIcon);
|
||||
lv_obj_realign(batteryPlug);
|
||||
|
@@ -343,13 +343,11 @@ void WatchFacePineTimeStyle::SetBatteryIcon() {
|
||||
lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
|
||||
}
|
||||
|
||||
|
||||
void WatchFacePineTimeStyle::AlignIcons() {
|
||||
bool isBleIconVisible = IsBleIconVisible(bleRadioEnabled.Get(), bleState.Get());
|
||||
if (notificationState.Get() && isBleIconVisible) {
|
||||
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);
|
||||
} else if (notificationState.Get() && !isBleIconVisible) {
|
||||
} else if (notificationState.Get() && !bleState.Get()) {
|
||||
lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25);
|
||||
} else {
|
||||
lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25);
|
||||
@@ -375,7 +373,7 @@ void WatchFacePineTimeStyle::Refresh() {
|
||||
bleState = bleController.IsConnected();
|
||||
bleRadioEnabled = bleController.IsRadioEnabled();
|
||||
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
|
||||
lv_label_set_text(bleIcon, BleIcon::GetIcon(bleRadioEnabled.Get(), bleState.Get()));
|
||||
lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
|
||||
AlignIcons();
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include "displayapp/screens/settings/SettingAirplaneMode.h"
|
||||
#include "displayapp/screens/settings/SettingBluetooth.h"
|
||||
#include <lvgl/lvgl.h>
|
||||
#include "displayapp/DisplayApp.h"
|
||||
#include "displayapp/Messages.h"
|
||||
@@ -9,18 +9,18 @@
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
namespace {
|
||||
static void OnAirplaneModeEnabledEvent(lv_obj_t* obj, lv_event_t event) {
|
||||
auto* screen = static_cast<SettingAirplaneMode*>(obj->user_data);
|
||||
screen->OnAirplaneModeEnabled(obj, event);
|
||||
static void OnBluetoothDisabledEvent(lv_obj_t* obj, lv_event_t event) {
|
||||
auto* screen = static_cast<SettingBluetooth*>(obj->user_data);
|
||||
screen->OnBluetoothDisabled(obj, event);
|
||||
}
|
||||
|
||||
static void OnAirplaneModeDisabledEvent(lv_obj_t* obj, lv_event_t event) {
|
||||
auto* screen = static_cast<SettingAirplaneMode*>(obj->user_data);
|
||||
screen->OnAirplaneModeDisabled(obj, event);
|
||||
static void OnBluetoothEnabledEvent(lv_obj_t* obj, lv_event_t event) {
|
||||
auto* screen = static_cast<SettingBluetooth*>(obj->user_data);
|
||||
screen->OnBluetoothEnabled(obj, event);
|
||||
}
|
||||
}
|
||||
|
||||
SettingAirplaneMode::SettingAirplaneMode(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
|
||||
SettingBluetooth::SettingBluetooth(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
|
||||
: Screen(app), settingsController {settingsController} {
|
||||
|
||||
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
|
||||
@@ -36,38 +36,38 @@ SettingAirplaneMode::SettingAirplaneMode(Pinetime::Applications::DisplayApp* app
|
||||
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, "Airplane mode");
|
||||
lv_label_set_text_static(title, "Bluetooth");
|
||||
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::airplane);
|
||||
lv_label_set_text_static(icon, Symbols::bluetooth);
|
||||
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
|
||||
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
|
||||
|
||||
cbEnabled = lv_checkbox_create(container1, nullptr);
|
||||
lv_checkbox_set_text(cbEnabled, " Enable");
|
||||
lv_checkbox_set_text(cbEnabled, " Enabled");
|
||||
cbEnabled->user_data = this;
|
||||
lv_obj_set_event_cb(cbEnabled, OnAirplaneModeEnabledEvent);
|
||||
lv_obj_set_event_cb(cbEnabled, OnBluetoothEnabledEvent);
|
||||
SetRadioButtonStyle(cbEnabled);
|
||||
|
||||
cbDisabled = lv_checkbox_create(container1, nullptr);
|
||||
lv_checkbox_set_text(cbDisabled, " Disable");
|
||||
lv_checkbox_set_text(cbDisabled, " Disabled");
|
||||
cbDisabled->user_data = this;
|
||||
lv_obj_set_event_cb(cbDisabled, OnAirplaneModeDisabledEvent);
|
||||
lv_obj_set_event_cb(cbDisabled, OnBluetoothDisabledEvent);
|
||||
SetRadioButtonStyle(cbDisabled);
|
||||
|
||||
if (settingsController.GetBleRadioEnabled()) {
|
||||
lv_checkbox_set_checked(cbDisabled, true);
|
||||
lv_checkbox_set_checked(cbEnabled, true);
|
||||
priorMode = true;
|
||||
} else {
|
||||
lv_checkbox_set_checked(cbEnabled, true);
|
||||
lv_checkbox_set_checked(cbDisabled, true);
|
||||
priorMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
SettingAirplaneMode::~SettingAirplaneMode() {
|
||||
SettingBluetooth::~SettingBluetooth() {
|
||||
lv_obj_clean(lv_scr_act());
|
||||
// Do not call SaveSettings - see src/components/settings/Settings.h
|
||||
if (priorMode != settingsController.GetBleRadioEnabled()) {
|
||||
@@ -75,18 +75,18 @@ SettingAirplaneMode::~SettingAirplaneMode() {
|
||||
}
|
||||
}
|
||||
|
||||
void SettingAirplaneMode::OnAirplaneModeEnabled(lv_obj_t* object, lv_event_t event) {
|
||||
void SettingBluetooth::OnBluetoothDisabled(lv_obj_t* object, lv_event_t event) {
|
||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_checkbox_set_checked(cbEnabled, true);
|
||||
lv_checkbox_set_checked(cbDisabled, false);
|
||||
lv_checkbox_set_checked(cbEnabled, false);
|
||||
lv_checkbox_set_checked(cbDisabled, true);
|
||||
settingsController.SetBleRadioEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingAirplaneMode::OnAirplaneModeDisabled(lv_obj_t* object, lv_event_t event) {
|
||||
void SettingBluetooth::OnBluetoothEnabled(lv_obj_t* object, lv_event_t event) {
|
||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_checkbox_set_checked(cbEnabled, false);
|
||||
lv_checkbox_set_checked(cbDisabled, true);
|
||||
lv_checkbox_set_checked(cbEnabled, true);
|
||||
lv_checkbox_set_checked(cbDisabled, false);
|
||||
settingsController.SetBleRadioEnabled(true);
|
||||
}
|
||||
}
|
@@ -12,13 +12,13 @@ namespace Pinetime {
|
||||
namespace Applications {
|
||||
namespace Screens {
|
||||
|
||||
class SettingAirplaneMode : public Screen {
|
||||
class SettingBluetooth : public Screen {
|
||||
public:
|
||||
SettingAirplaneMode(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||
~SettingAirplaneMode() override;
|
||||
SettingBluetooth(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||
~SettingBluetooth() override;
|
||||
|
||||
void OnAirplaneModeEnabled(lv_obj_t* object, lv_event_t event);
|
||||
void OnAirplaneModeDisabled(lv_obj_t* object, lv_event_t event);
|
||||
void OnBluetoothEnabled(lv_obj_t* object, lv_event_t event);
|
||||
void OnBluetoothDisabled(lv_obj_t* object, lv_event_t event);
|
||||
|
||||
private:
|
||||
Controllers::Settings& settingsController;
|
@@ -64,7 +64,7 @@ std::unique_ptr<Screen> Settings::CreateScreen3() {
|
||||
{Symbols::clock, "Chimes", Apps::SettingChimes},
|
||||
{Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
|
||||
{Symbols::check, "Firmware", Apps::FirmwareValidation},
|
||||
{Symbols::airplane, "Airplane mode", Apps::SettingAirplaneMode}
|
||||
{Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth}
|
||||
}};
|
||||
|
||||
return std::make_unique<Screens::List>(2, 4, app, settingsController, applications);
|
||||
|
Reference in New Issue
Block a user