Merge branch 'wb/fuzzy-analog' of github.com:zyphlar/InfiniTime into wb/fuzzy-analog
This commit is contained in:
commit
77667c6391
|
@ -1,7 +1,7 @@
|
||||||
#include "displayapp/screens/WatchFaceAnalog.h"
|
#include "displayapp/screens/WatchFaceAnalog.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
//#include <nrf_log.h>
|
// #include <nrf_log.h>
|
||||||
#include "displayapp/screens/BatteryIcon.h"
|
#include "displayapp/screens/BatteryIcon.h"
|
||||||
#include "displayapp/screens/BleIcon.h"
|
#include "displayapp/screens/BleIcon.h"
|
||||||
#include "displayapp/screens/Symbols.h"
|
#include "displayapp/screens/Symbols.h"
|
||||||
|
@ -15,9 +15,12 @@ namespace {
|
||||||
int16_t HourLength = 70;
|
int16_t HourLength = 70;
|
||||||
constexpr int16_t MinuteLength = 90;
|
constexpr int16_t MinuteLength = 90;
|
||||||
constexpr int16_t SecondLength = 110;
|
constexpr int16_t SecondLength = 110;
|
||||||
|
constexpr int16_t SunDialVerticalOffset = 40;
|
||||||
|
|
||||||
// sin(90) = 1 so the value of _lv_trigo_sin(90) is the scaling factor
|
// sin(90) = 1 so the value of _lv_trigo_sin(90) is the scaling factor
|
||||||
const auto LV_TRIG_SCALE = _lv_trigo_sin(90);
|
const auto LV_TRIG_SCALE = _lv_trigo_sin(90);
|
||||||
|
const lv_color_t DARK_GRAY = lv_color_make(48, 48, 48);
|
||||||
|
const lv_color_t DARK_ORANGE = lv_color_make(48, 26, 0);
|
||||||
|
|
||||||
int16_t Cosine(int16_t angle) {
|
int16_t Cosine(int16_t angle) {
|
||||||
return _lv_trigo_sin(angle + 90);
|
return _lv_trigo_sin(angle + 90);
|
||||||
|
@ -41,7 +44,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CoordinateYRelocateSundial(int16_t y) {
|
int16_t CoordinateYRelocateSundial(int16_t y) {
|
||||||
return std::abs(y - 10);
|
return std::abs(y - SunDialVerticalOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
lv_point_t CoordinateRelocateSundial(int16_t radius, int16_t angle) {
|
lv_point_t CoordinateRelocateSundial(int16_t radius, int16_t angle) {
|
||||||
|
@ -74,32 +77,28 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
|
||||||
minutesNighttime = (1440 - minutesDaytime);
|
minutesNighttime = (1440 - minutesDaytime);
|
||||||
|
|
||||||
// begin sundial
|
// begin sundial
|
||||||
if (sMinute>100) { // temporary
|
if (settingsController.GetClockType() == Controllers::Settings::ClockType::Fuzzy) {
|
||||||
major_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
major_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
||||||
lv_linemeter_set_scale(major_scales, 180, 13);
|
lv_linemeter_set_scale(major_scales, 165, 11);
|
||||||
lv_linemeter_set_angle_offset(major_scales, 180);
|
lv_linemeter_set_angle_offset(major_scales, 180);
|
||||||
lv_obj_set_size(major_scales, 240, 240);
|
lv_obj_set_size(major_scales, 240, 240);
|
||||||
lv_obj_align(major_scales, nullptr, LV_ALIGN_IN_TOP_MID, 0, 0);
|
lv_obj_align(major_scales, nullptr, LV_ALIGN_IN_TOP_MID, 0, -LV_HOR_RES/2+SunDialVerticalOffset);
|
||||||
lv_obj_set_style_local_bg_opa(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
lv_obj_set_style_local_bg_opa(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||||
lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 6);
|
lv_obj_set_style_local_scale_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 40);
|
||||||
lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4);
|
lv_obj_set_style_local_scale_end_line_width(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 1);
|
||||||
lv_obj_set_style_local_scale_end_color(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
lv_obj_set_style_local_scale_end_color(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
|
|
||||||
large_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
one = lv_label_create(lv_scr_act(), NULL);
|
||||||
lv_linemeter_set_scale(large_scales, 180, 1);
|
lv_label_set_align(one, LV_LABEL_ALIGN_LEFT);
|
||||||
lv_linemeter_set_angle_offset(large_scales, 180);
|
lv_label_set_text(one, "I");
|
||||||
lv_obj_set_size(large_scales, 240, 240);
|
lv_obj_align(one, NULL, LV_ALIGN_IN_TOP_LEFT, 20, SunDialVerticalOffset-20);
|
||||||
lv_obj_align(large_scales, nullptr, LV_ALIGN_IN_TOP_MID, 0, 0);
|
lv_obj_set_style_local_text_color(one, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
lv_obj_set_style_local_bg_opa(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
|
||||||
lv_obj_set_style_local_scale_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 20);
|
|
||||||
lv_obj_set_style_local_scale_end_line_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4);
|
|
||||||
lv_obj_set_style_local_scale_end_color(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA);
|
|
||||||
|
|
||||||
twelve = lv_label_create(lv_scr_act(), nullptr);
|
twelve = lv_label_create(lv_scr_act(), NULL);
|
||||||
lv_label_set_align(twelve, LV_ALIGN_IN_BOTTOM_MID);
|
lv_label_set_align(twelve, LV_LABEL_ALIGN_RIGHT);
|
||||||
lv_label_set_text_static(twelve, "VI");
|
lv_label_set_text(twelve, "XII");
|
||||||
lv_obj_set_pos(twelve, 0, 10);
|
lv_obj_align(twelve, NULL, LV_ALIGN_IN_TOP_RIGHT, -20, SunDialVerticalOffset-20);
|
||||||
lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA);
|
lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
} else {
|
} else {
|
||||||
minor_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
minor_scales = lv_linemeter_create(lv_scr_act(), nullptr);
|
||||||
lv_linemeter_set_scale(minor_scales, 300, 51);
|
lv_linemeter_set_scale(minor_scales, 300, 51);
|
||||||
|
@ -155,7 +154,6 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
|
||||||
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
||||||
|
|
||||||
// Date - Day / Week day
|
// Date - Day / Week day
|
||||||
|
|
||||||
label_date_day = lv_label_create(lv_scr_act(), nullptr);
|
label_date_day = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
|
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_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
|
||||||
|
@ -220,31 +218,37 @@ void WatchFaceAnalog::drawWatchFaceModeNight(){
|
||||||
uint8_t hour = dateTimeController.Hours();
|
uint8_t hour = dateTimeController.Hours();
|
||||||
uint8_t minute = dateTimeController.Minutes();
|
uint8_t minute = dateTimeController.Minutes();
|
||||||
minutesBeforeSunset = minutesSunset - (hour * 60 + minute); // i.e.zero degrees
|
minutesBeforeSunset = minutesSunset - (hour * 60 + minute); // i.e.zero degrees
|
||||||
HourLength = 110;
|
HourLength = 90; // sundial hand length
|
||||||
|
|
||||||
//if(minutesBeforeSunset > 0 ) {
|
int16_t hourAngle;
|
||||||
auto const hourAngle = 180.0 * minutesBeforeSunset / minutesDaytime + 90;
|
|
||||||
//Serial.print("daytime ");
|
if(minutesBeforeSunset > 0 && minutesBeforeSunset < minutesDaytime) { // day (after sunrise)
|
||||||
// switch(mode) {
|
hourAngle = 180.0 * minutesBeforeSunset / minutesDaytime + 90;
|
||||||
// case 1:
|
} else { // night (before sunrise or after sunset)
|
||||||
// drawWatchFaceModeNight();
|
lv_style_set_line_color(&hour_line_style, LV_STATE_DEFAULT, DARK_GRAY);
|
||||||
// break;
|
lv_style_set_line_color(&hour_line_style_trace, LV_STATE_DEFAULT, DARK_GRAY);
|
||||||
// case 2:
|
lv_obj_set_style_local_scale_end_color(major_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, DARK_GRAY);
|
||||||
// drawWatchFaceModeModern();
|
lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, DARK_ORANGE);
|
||||||
// break;
|
lv_obj_set_style_local_text_color(one, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, DARK_GRAY);
|
||||||
// default:
|
lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, DARK_GRAY);
|
||||||
// drawWatchFaceModeNight();
|
|
||||||
// }
|
if(minutesBeforeSunset > minutesDaytime) { // before sunrise
|
||||||
//}
|
hourAngle = 180.0 * (minutesBeforeSunset - minutesDaytime) / minutesNighttime + 90;
|
||||||
|
} else { // after sunset
|
||||||
|
hourAngle = 180 + 180.0 * minutesBeforeSunset / minutesNighttime + 90;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//NRF_LOG_INFO("angle : %d, sun %d day %d len %d", hourAngle, minutesBeforeSunset, minutesDaytime, HourLength);
|
||||||
|
|
||||||
if (sHour != hour || sMinute != minute) {
|
if (sHour != hour || sMinute != minute) {
|
||||||
sHour = hour;
|
sHour = hour;
|
||||||
sMinute = minute;
|
sMinute = minute;
|
||||||
hour_point[0] = CoordinateRelocateSundial(5, hourAngle);
|
|
||||||
hour_point[1] = CoordinateRelocateSundial(HourLength, hourAngle);
|
|
||||||
|
|
||||||
hour_point_trace[0] = CoordinateRelocateSundial(5, hourAngle);
|
hour_point_trace[0] = CoordinateRelocateSundial(HourLength*.75, hourAngle);
|
||||||
hour_point_trace[1] = CoordinateRelocateSundial(31, hourAngle);
|
hour_point_trace[1] = CoordinateRelocateSundial(HourLength, hourAngle);
|
||||||
|
|
||||||
|
hour_point[0] = CoordinateRelocateSundial(0, hourAngle);
|
||||||
|
hour_point[1] = CoordinateRelocateSundial(HourLength*.75, hourAngle);
|
||||||
|
|
||||||
lv_line_set_points(hour_body, hour_point, 2);
|
lv_line_set_points(hour_body, hour_point, 2);
|
||||||
lv_line_set_points(hour_body_trace, hour_point_trace, 2);
|
lv_line_set_points(hour_body_trace, hour_point_trace, 2);
|
||||||
|
@ -252,7 +256,7 @@ void WatchFaceAnalog::drawWatchFaceModeNight(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchFaceAnalog::UpdateClock() {
|
void WatchFaceAnalog::UpdateClock() {
|
||||||
if (sMinute<100) { // temporary
|
if (settingsController.GetClockType() == Controllers::Settings::ClockType::Fuzzy) {
|
||||||
drawWatchFaceModeNight();
|
drawWatchFaceModeNight();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -344,7 +348,18 @@ void WatchFaceAnalog::Refresh() {
|
||||||
|
|
||||||
currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
|
currentDate = std::chrono::time_point_cast<days>(currentDateTime.Get());
|
||||||
if (currentDate.IsUpdated()) {
|
if (currentDate.IsUpdated()) {
|
||||||
|
if (settingsController.GetClockType() == Controllers::Settings::ClockType::Fuzzy) {
|
||||||
|
char const* MonthsString[] = {"--", "IANUARIUS","FEBRUARIUS","MARTIUS","APRILIS","MARTIUSIUNIUS","QUINTILIS","SEXTILIS","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"};
|
||||||
|
char const* DaysString[] = {"--", "LUNAE", "MARTIS", "MERCURII", "IOVIS", "VENERIS", "SATURNI", "SOLIS"};
|
||||||
|
char const* RomanNumeralsString[] = {"--", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII"};
|
||||||
|
lv_label_set_text_fmt(label_date_day, "%s\n%s %s",
|
||||||
|
DaysString[static_cast<uint8_t>(dateTimeController.DayOfWeek())],
|
||||||
|
RomanNumeralsString[static_cast<uint8_t>(dateTimeController.Day())],
|
||||||
|
MonthsString[static_cast<uint8_t>(dateTimeController.Month())]);
|
||||||
|
lv_obj_align(label_date_day, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, -20);
|
||||||
|
} else {
|
||||||
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
|
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -49,6 +49,7 @@ namespace Pinetime {
|
||||||
lv_obj_t* minor_scales;
|
lv_obj_t* minor_scales;
|
||||||
lv_obj_t* major_scales;
|
lv_obj_t* major_scales;
|
||||||
lv_obj_t* large_scales;
|
lv_obj_t* large_scales;
|
||||||
|
lv_obj_t* one;
|
||||||
lv_obj_t* twelve;
|
lv_obj_t* twelve;
|
||||||
|
|
||||||
lv_obj_t* hour_body;
|
lv_obj_t* hour_body;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user