2021-06-29 14:20:27 -04:00
|
|
|
/*
|
2021-10-15 12:03:10 -04:00
|
|
|
* This file is part of the Infinitime distribution (https://github.com/InfiniTimeOrg/Infinitime).
|
2021-06-29 14:20:27 -04:00
|
|
|
* Copyright (c) 2021 Kieran Cawthray.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* PineTimeStyle watchface for Infinitime created by Kieran Cawthray
|
|
|
|
* Based on WatchFaceDigital
|
|
|
|
* Style/layout copied from TimeStyle for Pebble by Dan Tilden (github.com/tilden)
|
|
|
|
*/
|
|
|
|
|
2021-10-13 16:08:35 -04:00
|
|
|
#include "displayapp/screens/PineTimeStyle.h"
|
2021-06-29 14:20:27 -04:00
|
|
|
#include <date/date.h>
|
|
|
|
#include <lvgl/lvgl.h>
|
|
|
|
#include <cstdio>
|
2021-08-28 15:02:11 -04:00
|
|
|
#include <displayapp/Colors.h>
|
2021-10-13 16:08:35 -04:00
|
|
|
#include "displayapp/screens/BatteryIcon.h"
|
|
|
|
#include "displayapp/screens/BleIcon.h"
|
|
|
|
#include "displayapp/screens/NotificationIcon.h"
|
|
|
|
#include "displayapp/screens/Symbols.h"
|
2021-06-29 14:20:27 -04:00
|
|
|
#include "components/battery/BatteryController.h"
|
|
|
|
#include "components/ble/BleController.h"
|
|
|
|
#include "components/ble/NotificationManager.h"
|
|
|
|
#include "components/motion/MotionController.h"
|
|
|
|
#include "components/settings/Settings.h"
|
2021-10-13 16:08:35 -04:00
|
|
|
#include "displayapp/DisplayApp.h"
|
2021-06-29 14:20:27 -04:00
|
|
|
|
|
|
|
using namespace Pinetime::Applications::Screens;
|
|
|
|
|
2021-10-03 14:01:46 -04:00
|
|
|
namespace {
|
2021-11-13 06:11:32 -05:00
|
|
|
void event_handler(lv_obj_t* obj, lv_event_t event) {
|
|
|
|
auto* screen = static_cast<PineTimeStyle*>(obj->user_data);
|
2021-10-03 14:01:46 -04:00
|
|
|
screen->UpdateSelected(obj, event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-29 14:20:27 -04:00
|
|
|
PineTimeStyle::PineTimeStyle(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},
|
|
|
|
batteryController {batteryController},
|
|
|
|
bleController {bleController},
|
|
|
|
notificatioManager {notificatioManager},
|
|
|
|
settingsController {settingsController},
|
|
|
|
motionController {motionController} {
|
2021-05-18 09:25:38 -04:00
|
|
|
|
2021-10-03 14:01:46 -04:00
|
|
|
// Create a 200px wide background rectangle
|
2021-06-29 14:20:27 -04:00
|
|
|
timebar = lv_obj_create(lv_scr_act(), nullptr);
|
2021-08-28 15:02:11 -04:00
|
|
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
|
|
lv_obj_set_size(timebar, 200, 240);
|
2021-12-06 04:55:45 -05:00
|
|
|
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
2021-06-29 14:20:27 -04:00
|
|
|
|
2021-07-25 16:18:39 -04:00
|
|
|
// Display the time
|
2021-06-29 14:20:27 -04:00
|
|
|
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);
|
2021-08-28 15:02:11 -04:00
|
|
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(timeDD1, "00");
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
|
|
|
|
|
|
|
|
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
|
|
|
|
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
2021-08-28 15:02:11 -04:00
|
|
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(timeDD2, "00");
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
|
|
|
|
|
|
|
|
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
|
2021-08-28 15:02:11 -04:00
|
|
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(timeAMPM, "");
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
|
|
|
|
|
2021-07-25 16:18:39 -04:00
|
|
|
// Create a 40px wide bar down the right side of the screen
|
2021-06-29 14:20:27 -04:00
|
|
|
sidebar = lv_obj_create(lv_scr_act(), nullptr);
|
2021-08-28 15:02:11 -04:00
|
|
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
|
|
lv_obj_set_size(sidebar, 40, 240);
|
|
|
|
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
|
|
|
|
2021-07-25 16:18:39 -04:00
|
|
|
// Display icons
|
2021-06-29 14:20:27 -04:00
|
|
|
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
|
2021-10-03 14:01:46 -04:00
|
|
|
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(batteryIcon, Symbols::batteryFull);
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
|
2021-09-03 07:35:38 -04:00
|
|
|
lv_obj_set_auto_realign(batteryIcon, true);
|
2021-06-29 14:20:27 -04:00
|
|
|
|
|
|
|
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));
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(bleIcon, "");
|
2021-06-29 14:20:27 -04:00
|
|
|
|
|
|
|
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(0x000000));
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(notificationIcon, "");
|
2021-06-29 14:20:27 -04:00
|
|
|
|
2021-07-25 16:18:39 -04:00
|
|
|
// Calendar icon
|
2021-06-29 14:20:27 -04:00
|
|
|
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
|
2021-10-03 14:01:46 -04:00
|
|
|
lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
|
|
lv_obj_set_size(calendarOuter, 34, 34);
|
|
|
|
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
|
|
|
|
|
|
|
|
calendarInner = lv_obj_create(lv_scr_act(), nullptr);
|
2021-10-03 14:01:46 -04:00
|
|
|
lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
|
|
lv_obj_set_size(calendarInner, 27, 27);
|
|
|
|
lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0);
|
|
|
|
|
|
|
|
calendarBar1 = lv_obj_create(lv_scr_act(), nullptr);
|
2021-10-03 14:01:46 -04:00
|
|
|
lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
|
|
lv_obj_set_size(calendarBar1, 3, 12);
|
|
|
|
lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3);
|
|
|
|
|
|
|
|
calendarBar2 = lv_obj_create(lv_scr_act(), nullptr);
|
2021-10-03 14:01:46 -04:00
|
|
|
lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
|
|
lv_obj_set_size(calendarBar2, 3, 12);
|
|
|
|
lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3);
|
|
|
|
|
|
|
|
calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr);
|
2021-10-03 14:01:46 -04:00
|
|
|
lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
|
|
lv_obj_set_size(calendarCrossBar1, 8, 3);
|
|
|
|
lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
|
|
|
|
|
|
|
calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr);
|
2021-10-03 14:01:46 -04:00
|
|
|
lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
|
|
lv_obj_set_size(calendarCrossBar2, 8, 3);
|
|
|
|
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
|
|
|
|
2021-07-25 16:18:39 -04:00
|
|
|
// Display date
|
2021-06-29 14:20:27 -04:00
|
|
|
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
|
2021-10-03 14:01:46 -04:00
|
|
|
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(dateDayOfWeek, "THU");
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
|
|
|
|
|
|
|
|
dateDay = lv_label_create(lv_scr_act(), nullptr);
|
2021-10-03 14:01:46 -04:00
|
|
|
lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(dateDay, "25");
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
|
|
|
|
|
|
|
|
dateMonth = lv_label_create(lv_scr_act(), nullptr);
|
2021-10-03 14:01:46 -04:00
|
|
|
lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(dateMonth, "MAR");
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
|
|
|
|
|
|
|
|
// Step count gauge
|
2021-10-18 18:22:45 -04:00
|
|
|
if (settingsController.GetPTSColorBar() == Pinetime::Controllers::Settings::Colors::White) {
|
2021-11-13 06:11:32 -05:00
|
|
|
needle_colors[0] = LV_COLOR_BLACK;
|
|
|
|
} else {
|
2021-10-18 18:22:45 -04:00
|
|
|
needle_colors[0] = LV_COLOR_WHITE;
|
|
|
|
}
|
2021-06-29 14:20:27 -04:00
|
|
|
stepGauge = lv_gauge_create(lv_scr_act(), nullptr);
|
|
|
|
lv_gauge_set_needle_count(stepGauge, 1, needle_colors);
|
|
|
|
lv_obj_set_size(stepGauge, 40, 40);
|
|
|
|
lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
|
|
|
lv_gauge_set_scale(stepGauge, 360, 11, 0);
|
|
|
|
lv_gauge_set_angle_offset(stepGauge, 180);
|
2021-07-11 09:08:23 -04:00
|
|
|
lv_gauge_set_critical_value(stepGauge, 100);
|
|
|
|
lv_gauge_set_range(stepGauge, 0, 100);
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_gauge_set_value(stepGauge, 0, 0);
|
|
|
|
|
|
|
|
lv_obj_set_style_local_pad_right(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
|
|
|
lv_obj_set_style_local_pad_left(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
|
|
|
lv_obj_set_style_local_pad_bottom(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
|
|
|
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
|
|
|
|
lv_obj_set_style_local_scale_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
|
|
|
|
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
|
|
|
|
lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
|
|
|
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
|
2021-06-25 09:09:18 -04:00
|
|
|
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
|
2021-06-29 14:20:27 -04:00
|
|
|
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);
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(backgroundLabel, "");
|
2021-07-19 09:26:12 -04:00
|
|
|
|
2021-10-03 14:01:46 -04:00
|
|
|
btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
|
|
|
|
btnNextTime->user_data = this;
|
|
|
|
lv_obj_set_size(btnNextTime, 60, 60);
|
|
|
|
lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, -80);
|
|
|
|
lv_obj_set_style_local_bg_opa(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
|
|
|
lv_obj_set_style_local_value_str(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
|
|
|
|
lv_obj_set_event_cb(btnNextTime, event_handler);
|
|
|
|
lv_obj_set_hidden(btnNextTime, true);
|
|
|
|
|
|
|
|
btnPrevTime = lv_btn_create(lv_scr_act(), nullptr);
|
|
|
|
btnPrevTime->user_data = this;
|
|
|
|
lv_obj_set_size(btnPrevTime, 60, 60);
|
|
|
|
lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, -80);
|
|
|
|
lv_obj_set_style_local_bg_opa(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
|
|
|
lv_obj_set_style_local_value_str(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
|
|
|
|
lv_obj_set_event_cb(btnPrevTime, event_handler);
|
|
|
|
lv_obj_set_hidden(btnPrevTime, true);
|
|
|
|
|
|
|
|
btnNextBar = lv_btn_create(lv_scr_act(), nullptr);
|
|
|
|
btnNextBar->user_data = this;
|
|
|
|
lv_obj_set_size(btnNextBar, 60, 60);
|
|
|
|
lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0);
|
|
|
|
lv_obj_set_style_local_bg_opa(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
|
|
|
lv_obj_set_style_local_value_str(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
|
|
|
|
lv_obj_set_event_cb(btnNextBar, event_handler);
|
|
|
|
lv_obj_set_hidden(btnNextBar, true);
|
|
|
|
|
|
|
|
btnPrevBar = lv_btn_create(lv_scr_act(), nullptr);
|
|
|
|
btnPrevBar->user_data = this;
|
|
|
|
lv_obj_set_size(btnPrevBar, 60, 60);
|
|
|
|
lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0);
|
|
|
|
lv_obj_set_style_local_bg_opa(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
|
|
|
lv_obj_set_style_local_value_str(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
|
|
|
|
lv_obj_set_event_cb(btnPrevBar, event_handler);
|
|
|
|
lv_obj_set_hidden(btnPrevBar, true);
|
|
|
|
|
|
|
|
btnNextBG = lv_btn_create(lv_scr_act(), nullptr);
|
|
|
|
btnNextBG->user_data = this;
|
|
|
|
lv_obj_set_size(btnNextBG, 60, 60);
|
|
|
|
lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 80);
|
|
|
|
lv_obj_set_style_local_bg_opa(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
|
|
|
lv_obj_set_style_local_value_str(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
|
|
|
|
lv_obj_set_event_cb(btnNextBG, event_handler);
|
|
|
|
lv_obj_set_hidden(btnNextBG, true);
|
|
|
|
|
|
|
|
btnPrevBG = lv_btn_create(lv_scr_act(), nullptr);
|
|
|
|
btnPrevBG->user_data = this;
|
|
|
|
lv_obj_set_size(btnPrevBG, 60, 60);
|
|
|
|
lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 80);
|
|
|
|
lv_obj_set_style_local_bg_opa(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
|
|
|
lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
|
|
|
|
lv_obj_set_event_cb(btnPrevBG, event_handler);
|
|
|
|
lv_obj_set_hidden(btnPrevBG, true);
|
|
|
|
|
|
|
|
btnReset = lv_btn_create(lv_scr_act(), nullptr);
|
|
|
|
btnReset->user_data = this;
|
|
|
|
lv_obj_set_size(btnReset, 60, 60);
|
|
|
|
lv_obj_align(btnReset, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
|
|
|
|
lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
|
|
|
lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst");
|
|
|
|
lv_obj_set_event_cb(btnReset, event_handler);
|
|
|
|
lv_obj_set_hidden(btnReset, true);
|
|
|
|
|
|
|
|
btnRandom = lv_btn_create(lv_scr_act(), nullptr);
|
|
|
|
btnRandom->user_data = this;
|
|
|
|
lv_obj_set_size(btnRandom, 60, 60);
|
|
|
|
lv_obj_align(btnRandom, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
|
|
|
lv_obj_set_style_local_bg_opa(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
|
|
|
lv_obj_set_style_local_value_str(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rnd");
|
|
|
|
lv_obj_set_event_cb(btnRandom, event_handler);
|
|
|
|
lv_obj_set_hidden(btnRandom, true);
|
|
|
|
|
|
|
|
btnClose = lv_btn_create(lv_scr_act(), nullptr);
|
|
|
|
btnClose->user_data = this;
|
|
|
|
lv_obj_set_size(btnClose, 60, 60);
|
|
|
|
lv_obj_align(btnClose, lv_scr_act(), LV_ALIGN_CENTER, 0, -80);
|
|
|
|
lv_obj_set_style_local_bg_opa(btnClose, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
|
|
|
lv_obj_set_style_local_value_str(btnClose, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "X");
|
|
|
|
lv_obj_set_event_cb(btnClose, event_handler);
|
|
|
|
lv_obj_set_hidden(btnClose, true);
|
|
|
|
|
|
|
|
btnSet = lv_btn_create(lv_scr_act(), nullptr);
|
|
|
|
btnSet->user_data = this;
|
|
|
|
lv_obj_set_height(btnSet, 150);
|
|
|
|
lv_obj_set_width(btnSet, 150);
|
|
|
|
lv_obj_align(btnSet, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
|
|
|
lv_obj_set_style_local_radius(btnSet, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 30);
|
|
|
|
lv_obj_set_style_local_bg_opa(btnSet, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
|
|
|
lv_obj_set_event_cb(btnSet, event_handler);
|
|
|
|
lbl_btnSet = lv_label_create(btnSet, nullptr);
|
|
|
|
lv_obj_set_style_local_text_font(lbl_btnSet, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
|
|
|
|
lv_label_set_text_static(lbl_btnSet, Symbols::settings);
|
|
|
|
lv_obj_set_hidden(btnSet, true);
|
|
|
|
|
2021-07-19 09:26:12 -04:00
|
|
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
|
|
|
Refresh();
|
2021-06-29 14:20:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
PineTimeStyle::~PineTimeStyle() {
|
2021-07-19 09:26:12 -04:00
|
|
|
lv_task_del(taskRefresh);
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_clean(lv_scr_act());
|
|
|
|
}
|
|
|
|
|
2021-10-03 14:01:46 -04:00
|
|
|
bool PineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
2021-11-16 12:10:34 -05:00
|
|
|
if ((event == Pinetime::Applications::TouchEvents::LongTap) && lv_obj_get_hidden(btnRandom)) {
|
2021-10-03 14:01:46 -04:00
|
|
|
lv_obj_set_hidden(btnSet, false);
|
|
|
|
savedTick = lv_tick_get();
|
|
|
|
return true;
|
|
|
|
}
|
2021-11-16 12:10:34 -05:00
|
|
|
if ((event == Pinetime::Applications::TouchEvents::DoubleTap) && (lv_obj_get_hidden(btnRandom) == false)) {
|
2021-10-18 17:04:12 -04:00
|
|
|
return true;
|
|
|
|
}
|
2021-10-03 14:01:46 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-11-13 06:02:00 -05:00
|
|
|
void PineTimeStyle::CloseMenu() {
|
|
|
|
settingsController.SaveSettings();
|
|
|
|
lv_obj_set_hidden(btnNextTime, true);
|
|
|
|
lv_obj_set_hidden(btnPrevTime, true);
|
|
|
|
lv_obj_set_hidden(btnNextBar, true);
|
|
|
|
lv_obj_set_hidden(btnPrevBar, true);
|
|
|
|
lv_obj_set_hidden(btnNextBG, true);
|
|
|
|
lv_obj_set_hidden(btnPrevBG, true);
|
|
|
|
lv_obj_set_hidden(btnReset, true);
|
|
|
|
lv_obj_set_hidden(btnRandom, true);
|
|
|
|
lv_obj_set_hidden(btnClose, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PineTimeStyle::OnButtonPushed() {
|
|
|
|
if (!lv_obj_get_hidden(btnClose)) {
|
|
|
|
CloseMenu();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-09-03 07:35:38 -04:00
|
|
|
void PineTimeStyle::SetBatteryIcon() {
|
|
|
|
auto batteryPercent = batteryPercentRemaining.Get();
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
|
2021-09-03 07:35:38 -04:00
|
|
|
}
|
|
|
|
|
2021-12-06 16:01:49 -05:00
|
|
|
void PineTimeStyle::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);
|
|
|
|
} 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-19 09:26:12 -04:00
|
|
|
void PineTimeStyle::Refresh() {
|
2021-09-03 07:35:38 -04:00
|
|
|
isCharging = batteryController.IsCharging();
|
|
|
|
if (isCharging.IsUpdated()) {
|
|
|
|
if (isCharging.Get()) {
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(batteryIcon, Symbols::plug);
|
2021-06-29 14:20:27 -04:00
|
|
|
} else {
|
2021-09-03 07:35:38 -04:00
|
|
|
SetBatteryIcon();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!isCharging.Get()) {
|
|
|
|
batteryPercentRemaining = batteryController.PercentRemaining();
|
|
|
|
if (batteryPercentRemaining.IsUpdated()) {
|
|
|
|
SetBatteryIcon();
|
2021-06-29 14:20:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bleState = bleController.IsConnected();
|
2021-11-16 12:10:34 -05:00
|
|
|
if (bleState.IsUpdated()) {
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
|
2021-12-06 16:01:49 -05:00
|
|
|
AlignIcons();
|
2021-06-29 14:20:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
notificationState = notificatioManager.AreNewNotificationsAvailable();
|
2021-11-16 12:10:34 -05:00
|
|
|
if (notificationState.IsUpdated()) {
|
2022-01-20 09:04:26 -05:00
|
|
|
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
|
2021-12-06 16:01:49 -05:00
|
|
|
AlignIcons();
|
2021-06-29 14:20:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
currentDateTime = dateTimeController.CurrentDateTime();
|
|
|
|
if (currentDateTime.IsUpdated()) {
|
|
|
|
auto newDateTime = currentDateTime.Get();
|
|
|
|
|
|
|
|
auto dp = date::floor<date::days>(newDateTime);
|
|
|
|
auto time = date::make_time(newDateTime - dp);
|
|
|
|
auto yearMonthDay = date::year_month_day(dp);
|
|
|
|
|
2021-07-24 07:01:11 -04:00
|
|
|
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());
|
2021-06-29 14:20:27 -04:00
|
|
|
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
|
|
|
|
|
2022-01-20 09:04:26 -05:00
|
|
|
uint8_t hour = time.hours().count();
|
|
|
|
uint8_t minute = time.minutes().count();
|
2021-06-29 14:20:27 -04:00
|
|
|
|
2022-01-20 09:04:26 -05:00
|
|
|
if (displayedHour != hour || displayedMinute != minute) {
|
|
|
|
displayedHour = hour;
|
|
|
|
displayedMinute = minute;
|
2021-06-29 14:20:27 -04:00
|
|
|
|
2021-07-25 10:54:05 -04:00
|
|
|
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
2022-01-20 09:04:26 -05:00
|
|
|
char ampmChar[4] = "A\nM";
|
|
|
|
if (hour == 0) {
|
|
|
|
hour = 12;
|
|
|
|
} else if (hour == 12) {
|
|
|
|
ampmChar[0] = 'P';
|
|
|
|
} else if (hour > 12) {
|
|
|
|
hour = hour - 12;
|
|
|
|
ampmChar[0] = 'P';
|
|
|
|
}
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_label_set_text(timeAMPM, ampmChar);
|
2022-01-20 09:04:26 -05:00
|
|
|
// Should be padded with blank spaces, but the space character doesn't exist in the font
|
|
|
|
lv_label_set_text_fmt(timeDD1, "%02d", hour);
|
|
|
|
lv_label_set_text_fmt(timeDD2, "%02d", minute);
|
|
|
|
} else {
|
|
|
|
lv_label_set_text_fmt(timeDD1, "%02d", hour);
|
|
|
|
lv_label_set_text_fmt(timeDD2, "%02d", minute);
|
2021-07-25 10:54:05 -04:00
|
|
|
}
|
2021-06-29 14:20:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
|
2021-07-24 07:01:11 -04:00
|
|
|
lv_label_set_text_fmt(dateDayOfWeek, "%s", dateTimeController.DayOfWeekShortToString());
|
|
|
|
lv_label_set_text_fmt(dateDay, "%d", day);
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_realign(dateDay);
|
2021-07-24 07:01:11 -04:00
|
|
|
lv_label_set_text_fmt(dateMonth, "%s", dateTimeController.MonthShortToString());
|
2021-06-29 14:20:27 -04:00
|
|
|
|
|
|
|
currentYear = year;
|
|
|
|
currentMonth = month;
|
|
|
|
currentDayOfWeek = dayOfWeek;
|
|
|
|
currentDay = day;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stepCount = motionController.NbSteps();
|
|
|
|
motionSensorOk = motionController.IsSensorOk();
|
|
|
|
if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) {
|
2021-07-11 09:08:23 -04:00
|
|
|
lv_gauge_set_value(stepGauge, 0, (stepCount.Get() / (settingsController.GetStepsGoal() / 100)));
|
2021-06-29 14:20:27 -04:00
|
|
|
lv_obj_realign(stepGauge);
|
|
|
|
if (stepCount.Get() > settingsController.GetStepsGoal()) {
|
|
|
|
lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
|
|
|
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
|
|
|
}
|
|
|
|
}
|
2021-11-13 06:11:32 -05:00
|
|
|
if (!lv_obj_get_hidden(btnSet)) {
|
2021-10-18 16:52:53 -04:00
|
|
|
if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) {
|
2021-10-03 14:01:46 -04:00
|
|
|
lv_obj_set_hidden(btnSet, true);
|
|
|
|
savedTick = 0;
|
|
|
|
}
|
|
|
|
}
|
2021-07-19 09:26:12 -04:00
|
|
|
}
|
2021-10-03 14:01:46 -04:00
|
|
|
|
|
|
|
void PineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
|
|
|
auto valueTime = settingsController.GetPTSColorTime();
|
|
|
|
auto valueBar = settingsController.GetPTSColorBar();
|
|
|
|
auto valueBG = settingsController.GetPTSColorBG();
|
|
|
|
|
|
|
|
if (event == LV_EVENT_CLICKED) {
|
|
|
|
if (object == btnNextTime) {
|
|
|
|
valueTime = GetNext(valueTime);
|
2021-11-13 06:11:32 -05:00
|
|
|
if (valueTime == valueBG) {
|
2021-10-18 16:52:53 -04:00
|
|
|
valueTime = GetNext(valueTime);
|
2021-11-13 06:11:32 -05:00
|
|
|
}
|
2021-10-03 14:01:46 -04:00
|
|
|
settingsController.SetPTSColorTime(valueTime);
|
|
|
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
|
|
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
|
|
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
|
|
|
}
|
|
|
|
if (object == btnPrevTime) {
|
|
|
|
valueTime = GetPrevious(valueTime);
|
2021-11-13 06:11:32 -05:00
|
|
|
if (valueTime == valueBG) {
|
2021-10-18 16:52:53 -04:00
|
|
|
valueTime = GetPrevious(valueTime);
|
2021-11-13 06:11:32 -05:00
|
|
|
}
|
2021-10-03 14:01:46 -04:00
|
|
|
settingsController.SetPTSColorTime(valueTime);
|
|
|
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
|
|
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
|
|
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
|
|
|
}
|
|
|
|
if (object == btnNextBar) {
|
|
|
|
valueBar = GetNext(valueBar);
|
2021-11-13 06:11:32 -05:00
|
|
|
if (valueBar == Controllers::Settings::Colors::Black) {
|
2021-10-03 14:01:46 -04:00
|
|
|
valueBar = GetNext(valueBar);
|
2021-11-13 06:11:32 -05:00
|
|
|
}
|
|
|
|
if (valueBar == Controllers::Settings::Colors::White) {
|
|
|
|
needle_colors[0] = LV_COLOR_BLACK;
|
|
|
|
} else {
|
2021-10-18 18:22:45 -04:00
|
|
|
needle_colors[0] = LV_COLOR_WHITE;
|
|
|
|
}
|
2021-10-03 14:01:46 -04:00
|
|
|
settingsController.SetPTSColorBar(valueBar);
|
|
|
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
|
|
|
|
}
|
|
|
|
if (object == btnPrevBar) {
|
|
|
|
valueBar = GetPrevious(valueBar);
|
2021-11-13 06:11:32 -05:00
|
|
|
if (valueBar == Controllers::Settings::Colors::Black) {
|
2021-10-03 14:01:46 -04:00
|
|
|
valueBar = GetPrevious(valueBar);
|
2021-11-13 06:11:32 -05:00
|
|
|
}
|
|
|
|
if (valueBar == Controllers::Settings::Colors::White) {
|
|
|
|
needle_colors[0] = LV_COLOR_BLACK;
|
|
|
|
} else {
|
2021-10-18 18:22:45 -04:00
|
|
|
needle_colors[0] = LV_COLOR_WHITE;
|
|
|
|
}
|
2021-10-03 14:01:46 -04:00
|
|
|
settingsController.SetPTSColorBar(valueBar);
|
|
|
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
|
|
|
|
}
|
|
|
|
if (object == btnNextBG) {
|
|
|
|
valueBG = GetNext(valueBG);
|
2021-11-13 06:11:32 -05:00
|
|
|
if (valueBG == valueTime) {
|
2021-10-18 16:52:53 -04:00
|
|
|
valueBG = GetNext(valueBG);
|
2021-11-13 06:11:32 -05:00
|
|
|
}
|
2021-10-03 14:01:46 -04:00
|
|
|
settingsController.SetPTSColorBG(valueBG);
|
|
|
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
|
|
|
}
|
|
|
|
if (object == btnPrevBG) {
|
|
|
|
valueBG = GetPrevious(valueBG);
|
2021-11-13 06:11:32 -05:00
|
|
|
if (valueBG == valueTime) {
|
2021-10-18 16:52:53 -04:00
|
|
|
valueBG = GetPrevious(valueBG);
|
2021-11-13 06:11:32 -05:00
|
|
|
}
|
2021-10-03 14:01:46 -04:00
|
|
|
settingsController.SetPTSColorBG(valueBG);
|
|
|
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
|
|
|
}
|
|
|
|
if (object == btnReset) {
|
2021-10-20 05:30:06 -04:00
|
|
|
needle_colors[0] = LV_COLOR_WHITE;
|
2021-10-03 14:01:46 -04:00
|
|
|
settingsController.SetPTSColorTime(Controllers::Settings::Colors::Teal);
|
|
|
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
|
|
|
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
|
|
|
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
|
|
|
|
settingsController.SetPTSColorBar(Controllers::Settings::Colors::Teal);
|
|
|
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
|
|
|
|
settingsController.SetPTSColorBG(Controllers::Settings::Colors::Black);
|
|
|
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black));
|
|
|
|
}
|
|
|
|
if (object == btnRandom) {
|
2021-10-20 11:44:10 -04:00
|
|
|
valueTime = static_cast<Controllers::Settings::Colors>(rand() % 17);
|
|
|
|
valueBar = static_cast<Controllers::Settings::Colors>(rand() % 17);
|
|
|
|
valueBG = static_cast<Controllers::Settings::Colors>(rand() % 17);
|
|
|
|
if (valueTime == valueBG) {
|
|
|
|
valueBG = GetNext(valueBG);
|
2021-10-03 14:01:46 -04:00
|
|
|
}
|
2021-10-20 11:44:10 -04:00
|
|
|
if (valueBar == Controllers::Settings::Colors::Black) {
|
|
|
|
valueBar = GetPrevious(valueBar);
|
2021-10-03 14:01:46 -04:00
|
|
|
}
|
2021-10-20 11:44:10 -04:00
|
|
|
if (valueBar == Controllers::Settings::Colors::White) {
|
2021-10-20 05:30:06 -04:00
|
|
|
needle_colors[0] = LV_COLOR_BLACK;
|
|
|
|
} else {
|
|
|
|
needle_colors[0] = LV_COLOR_WHITE;
|
|
|
|
}
|
2021-10-20 11:44:10 -04:00
|
|
|
settingsController.SetPTSColorTime(static_cast<Controllers::Settings::Colors>(valueTime));
|
|
|
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
2021-11-13 06:11:32 -05:00
|
|
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
|
|
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
2021-10-20 11:44:10 -04:00
|
|
|
settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(valueBar));
|
2021-11-13 06:11:32 -05:00
|
|
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
|
2021-10-20 11:44:10 -04:00
|
|
|
settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(valueBG));
|
2021-11-13 06:11:32 -05:00
|
|
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
2021-10-03 14:01:46 -04:00
|
|
|
}
|
|
|
|
if (object == btnClose) {
|
2021-11-13 06:02:00 -05:00
|
|
|
CloseMenu();
|
2021-10-03 14:01:46 -04:00
|
|
|
}
|
|
|
|
if (object == btnSet) {
|
|
|
|
lv_obj_set_hidden(btnSet, true);
|
|
|
|
lv_obj_set_hidden(btnNextTime, false);
|
|
|
|
lv_obj_set_hidden(btnPrevTime, false);
|
|
|
|
lv_obj_set_hidden(btnNextBar, false);
|
|
|
|
lv_obj_set_hidden(btnPrevBar, false);
|
|
|
|
lv_obj_set_hidden(btnNextBG, false);
|
|
|
|
lv_obj_set_hidden(btnPrevBG, false);
|
|
|
|
lv_obj_set_hidden(btnReset, false);
|
|
|
|
lv_obj_set_hidden(btnRandom, false);
|
|
|
|
lv_obj_set_hidden(btnClose, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Pinetime::Controllers::Settings::Colors PineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
|
|
|
|
auto colorAsInt = static_cast<uint8_t>(color);
|
|
|
|
Pinetime::Controllers::Settings::Colors nextColor;
|
2021-10-23 12:12:41 -04:00
|
|
|
if (colorAsInt < 16) {
|
|
|
|
nextColor = static_cast<Controllers::Settings::Colors>(colorAsInt + 1);
|
|
|
|
} else {
|
|
|
|
nextColor = static_cast<Controllers::Settings::Colors>(0);
|
|
|
|
}
|
2021-10-03 14:01:46 -04:00
|
|
|
return nextColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
Pinetime::Controllers::Settings::Colors PineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
|
|
|
|
auto colorAsInt = static_cast<uint8_t>(color);
|
|
|
|
Pinetime::Controllers::Settings::Colors prevColor;
|
2021-10-23 12:12:41 -04:00
|
|
|
|
|
|
|
if (colorAsInt > 0) {
|
|
|
|
prevColor = static_cast<Controllers::Settings::Colors>(colorAsInt - 1);
|
|
|
|
} else {
|
|
|
|
prevColor = static_cast<Controllers::Settings::Colors>(16);
|
|
|
|
}
|
2021-10-03 14:01:46 -04:00
|
|
|
return prevColor;
|
2021-11-13 06:02:00 -05:00
|
|
|
}
|