Added sunrise text, fixed timezone

This commit is contained in:
CommanderRedYT
2022-03-27 19:07:55 +02:00
parent c7573b90a6
commit 1040ebe4a1
4 changed files with 27 additions and 2 deletions

View File

@ -194,6 +194,7 @@ struct LedstripBrightnessAccessor : public NewSettingsAccessor<uint8_t> { Config
struct LedstripEnableBlinkAnimationAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.enableAnimBlink; } };
struct LedstripOtaAnimationAccessor : public NewSettingsAccessor<OtaAnimationModes> { ConfigWrapper<OtaAnimationModes> &getConfig() const override { return configs.ledstrip.otaMode; } };
struct LedstripEnableVisualizeBlinkAnimationAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.enableVisualizeBlink; } };
struct LedstripAutomaticLightAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.automaticLight; } };
// Battery
struct BatterySeriesCellsAccessor : public NewSettingsAccessor<uint8_t> { ConfigWrapper<uint8_t> &getConfig() const override { return configs.battery.cellsSeries; } };

View File

@ -42,6 +42,7 @@ constexpr char TEXT_LEDSTRIP_STVO[] = "Enable StVO";
constexpr char TEXT_STVO_FRONTOFFSET[] = "StVO Front Offset";
constexpr char TEXT_STVO_FRONTLENGTH[] = "StVO Front Length";
constexpr char TEXT_STVO_ENABLEFRONTLIGHT[] = "StVO Front Enable";
constexpr char TEXT_AUTOMATIC_LIGHTS[] = "Automatic Lights";
constexpr char TEXT_ANIMATION_MULTIPLIER[] = "Animation Multiplier";
constexpr char TEXT_LEDSTRIP_BRIGHTNESS[] = "Ledstrip Brightness";
constexpr char TEXT_LEDSTRIP_ALLCUSTOMOFF[] = "All custom off";
@ -150,6 +151,7 @@ LedstripMenu::LedstripMenu()
if (!simplified) { constructMenuItem<makeComponent<MenuItem, espgui::StaticText<TEXT_LEDSTRIP_STVO>, BobbyCheckbox, EnableLedstripStVOAccessor>>(); }
constructMenuItem<makeComponent<MenuItem, espgui::StaticText<TEXT_STVO_ENABLEFRONTLIGHT>, BobbyCheckbox, EnableLedstripStVOFrontlight>>();
constructMenuItem<makeComponent<MenuItem, espgui::StaticText<TEXT_AUTOMATIC_LIGHTS>, BobbyCheckbox, LedstripAutomaticLightAccessor>>();
constructMenuItem<makeComponent<MenuItem, espgui::StaticText<TEXT_LEDANIMATION>, BobbyCheckbox, EnableLedAnimationAccessor>>();
constructMenuItem<SwitchScreenTypeSafeChangeMenuItem<LedstripAnimation, LedstripMenu, TEXT_SELECTANIMATION>>(&configs.ledstrip.animationType);

View File

@ -13,6 +13,7 @@
#include "actions/dummyaction.h"
#include "icons/back.h"
#include "espstrutils.h"
#include <sunset.h>
// local includes
#include "displays/bobbychangevaluedisplay.h"
@ -53,6 +54,26 @@ public:
}
};
class SuntimeText : public virtual espgui::TextInterface
{
public:
std::string text() const override
{
SunSet sunSet;
sunSet.setPosition(47.076668, 15.421371, 2); // Vienna
sunSet.setTZOffset(2);
const auto today = toDateTime(espchrono::utc_clock::now());
sunSet.setCurrentDate(static_cast<int>(today.date.year()), static_cast<uint>(today.date.month()), static_cast<uint>(today.date.day()));
const auto sunrise = static_cast<int>(sunSet.calcSunrise());
const auto sunset = static_cast<int>(sunSet.calcSunset());
const int sunriseHour = sunrise / 60;
const int sunriseMinute = sunrise % 60;
const int sunsetHour = sunset / 60;
const int sunsetMinute = sunset % 60;
return fmt::format("sunrise: {}:{:02d} sunset: {}:{:02d}", sunriseHour, sunriseMinute, sunsetHour, sunsetMinute);
}
};
using TimezoneOffsetChangeDisplay = espgui::makeComponent<
BobbyChangeValueDisplay<int32_t>,
espgui::StaticText<TEXT_OFFSET>,
@ -108,6 +129,7 @@ TimeSettingsMenu::TimeSettingsMenu()
using namespace espgui;
constructMenuItem<makeComponent<MenuItem, CurrentUtcDateTimeText, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, CurrentLocalDateTimeText, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, SuntimeText, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_OFFSET>, SwitchScreenAction<TimezoneOffsetChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DAYLIGHTSAVINGMODE>, SwitchScreenAction<DaylightSavingModeChangeDisplay>>>();
if (configs.feature.ntp.isEnabled.value)

View File

@ -362,8 +362,8 @@ void showCustomColor()
if (!configs.ledstrip.automaticLight.value)
return false;
SunSet sunSet;
sunSet.setPosition(47.076668, 15.421371, 1); // Vienna
sunSet.setTZOffset(1);
sunSet.setPosition(47.076668, 15.421371, 0); // Vienna
sunSet.setTZOffset(0);
const auto today = toDateTime(espchrono::utc_clock::now());
sunSet.setCurrentDate(static_cast<int>(today.date.year()), static_cast<uint>(today.date.month()), static_cast<uint>(today.date.day()));
const auto sunrise = static_cast<int>(sunSet.calcSunrise()) / 60;