Working face watchface

This commit is contained in:
Josh 2023-10-22 23:34:22 -04:00 committed by tofasthacker
parent dd5d65d315
commit d758394ce9
2 changed files with 37 additions and 24 deletions

View File

@ -1,4 +1,4 @@
#include "displayapp/screens/WatchFaceAnalog.h"
#include "displayapp/screens/WatchFaceFace.h"
#include <cmath>
#include <lvgl/lvgl.h>
#include "displayapp/screens/BatteryIcon.h"
@ -11,7 +11,7 @@
using namespace Pinetime::Applications::Screens;
namespace {
constexpr int16_t HourLength = 70;
constexpr int16_t HourLength = 100;
constexpr int16_t MinuteLength = 90;
constexpr int16_t SecondLength = 110;
@ -41,7 +41,7 @@ namespace {
}
WatchFaceAnalog::WatchFaceFace(Controllers::DateTime& dateTimeController,
WatchFaceFace::WatchFaceFace(Controllers::DateTime& dateTimeController,
const Controllers::Battery& batteryController,
const Controllers::Ble& bleController,
Controllers::NotificationManager& notificationManager,
@ -58,6 +58,23 @@ WatchFaceAnalog::WatchFaceFace(Controllers::DateTime& dateTimeController,
sMinute = 99;
sSecond = 99;
mouth = lv_arc_create(lv_scr_act(), nullptr);
lv_arc_set_angles(mouth, 30, 110);
lv_arc_set_bg_angles(mouth, 45, 135);
lv_obj_set_size(mouth, 130, 130);
lv_obj_align(mouth, nullptr, LV_ALIGN_CENTER, 0, 0);
leye = lv_arc_create(lv_scr_act(), nullptr);
lv_arc_set_angles(leye, 0, 360);
lv_obj_set_size(leye, 30, 30);
lv_obj_align(leye, nullptr, LV_ALIGN_CENTER, -35, -35);
reye = lv_arc_create(lv_scr_act(), nullptr);
lv_arc_set_angles(reye, 0, 360);
lv_obj_set_size(reye, 30, 30);
lv_obj_align(reye, nullptr, LV_ALIGN_CENTER, 35, -35);
minor_scales = lv_linemeter_create(lv_scr_act(), nullptr);
lv_linemeter_set_scale(minor_scales, 300, 51);
lv_linemeter_set_angle_offset(minor_scales, 180);
@ -116,7 +133,7 @@ WatchFaceAnalog::WatchFaceFace(Controllers::DateTime& dateTimeController,
lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
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, nullptr, LV_ALIGN_CENTER, 50, 0);
lv_obj_align(label_date_day, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
minute_body = lv_line_create(lv_scr_act(), nullptr);
minute_body_trace = lv_line_create(lv_scr_act(), nullptr);
@ -131,7 +148,7 @@ WatchFaceAnalog::WatchFaceFace(Controllers::DateTime& dateTimeController,
lv_obj_add_style(second_body, LV_LINE_PART_MAIN, &second_line_style);
lv_style_init(&minute_line_style);
lv_style_set_line_width(&minute_line_style, LV_STATE_DEFAULT, 7);
lv_style_set_line_width(&minute_line_style, LV_STATE_DEFAULT, 3);
lv_style_set_line_color(&minute_line_style, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_style_set_line_rounded(&minute_line_style, LV_STATE_DEFAULT, true);
lv_obj_add_style(minute_body, LV_LINE_PART_MAIN, &minute_line_style);
@ -171,21 +188,18 @@ WatchFaceFace::~WatchFaceFace() {
lv_obj_clean(lv_scr_act());
}
void WatchFaceAnalog::UpdateClock() {
void WatchFaceFace::UpdateClock() {
uint8_t hour = dateTimeController.Hours();
uint8_t minute = dateTimeController.Minutes();
uint8_t second = dateTimeController.Seconds();
if (sMinute != minute) {
auto const angle = minute * 6;
minute_point[0] = CoordinateRelocate(30, angle);
minute_point[0] = CoordinateRelocate(10, angle - 90);
minute_point[1] = CoordinateRelocate(MinuteLength, angle);
minute_point[2] = CoordinateRelocate(10, angle + 90);
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);
lv_line_set_points(minute_body, minute_point, 3);
}
if (sHour != hour || sMinute != minute) {
@ -193,32 +207,28 @@ void WatchFaceAnalog::UpdateClock() {
sMinute = minute;
auto const angle = (hour * 30 + minute / 2);
hour_point[0] = CoordinateRelocate(30, angle);
hour_point[0] = CoordinateRelocate(90, angle);
hour_point[1] = CoordinateRelocate(HourLength, 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);
}
if (sSecond != second) {
sSecond = second;
auto const angle = second * 6;
second_point[0] = CoordinateRelocate(-20, angle);
second_point[0] = CoordinateRelocate(105, angle);
second_point[1] = CoordinateRelocate(SecondLength, angle);
lv_line_set_points(second_body, second_point, 2);
}
}//TODO: redo seconds
}
void WatchFaceAnalog::SetBatteryIcon() {
void WatchFaceFace::SetBatteryIcon() {
auto batteryPercent = batteryPercentRemaining.Get();
batteryIcon.SetBatteryPercentage(batteryPercent);
}
void WatchFaceAnalog::Refresh() {
void WatchFaceFace::Refresh() {
isCharging = batteryController.IsCharging();
if (isCharging.IsUpdated()) {
if (isCharging.Get()) {

View File

@ -58,9 +58,7 @@ namespace Pinetime {
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 minute_point[3];
lv_point_t second_point[2];
lv_style_t hour_line_style;
@ -74,6 +72,11 @@ namespace Pinetime {
lv_obj_t* notificationIcon;
lv_obj_t* bleIcon;
lv_obj_t* mouth;
lv_obj_t* leye;
lv_obj_t* reye;
BatteryIcon batteryIcon;
const Controllers::DateTime& dateTimeController;