add simulation to UI
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "ui/ClockScreenSaver.h"
|
||||
#include "hal_esp32/PersistenceManager.h"
|
||||
#include "simulator.h"
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
@@ -37,22 +38,23 @@ void ClockScreenSaver::updateTextDimensions()
|
||||
|
||||
void ClockScreenSaver::getCurrentTimeString(char *buffer, size_t bufferSize) const
|
||||
{
|
||||
char *simulated_time = get_time();
|
||||
if (simulated_time != nullptr)
|
||||
if (m_options && m_options->persistenceManager->GetValue("light_active", false))
|
||||
{
|
||||
strncpy(buffer, simulated_time, bufferSize);
|
||||
char *simulated_time = get_time();
|
||||
if (simulated_time != nullptr)
|
||||
{
|
||||
strncpy(buffer, simulated_time, bufferSize);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
time_t rawtime;
|
||||
struct tm *timeinfo;
|
||||
time_t rawtime;
|
||||
struct tm *timeinfo;
|
||||
|
||||
time(&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
time(&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
|
||||
// Format time as HH:MM:SS
|
||||
strftime(buffer, bufferSize, "%H:%M:%S", timeinfo);
|
||||
}
|
||||
// Format time as HH:MM:SS
|
||||
strftime(buffer, bufferSize, "%H:%M:%S", timeinfo);
|
||||
}
|
||||
|
||||
void ClockScreenSaver::Update(const uint64_t dt)
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "ui/LightMenu.h"
|
||||
|
||||
#include "led_strip_ws2812.h"
|
||||
#include "simulator.h"
|
||||
|
||||
/**
|
||||
* @namespace LightMenuItem
|
||||
@@ -54,19 +55,12 @@ void LightMenu::onButtonPressed(const MenuItem &menuItem, const ButtonType butto
|
||||
{
|
||||
toggle(menuItem);
|
||||
const auto value = getItem(menuItem.getId()).getValue() == "1";
|
||||
if (value)
|
||||
{
|
||||
led_strip_update(LED_STATE_DAY, rgb_t{});
|
||||
}
|
||||
else
|
||||
{
|
||||
led_strip_update(LED_STATE_OFF, rgb_t{});
|
||||
}
|
||||
|
||||
if (m_options && m_options->persistenceManager)
|
||||
{
|
||||
m_options->persistenceManager->SetValue(LightMenuOptions::LIGHT_ACTIVE, value);
|
||||
}
|
||||
|
||||
start_simulation();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -83,7 +77,7 @@ void LightMenu::onButtonPressed(const MenuItem &menuItem, const ButtonType butto
|
||||
m_options->persistenceManager->Save();
|
||||
}
|
||||
|
||||
led_strip_update(value == 0 ? LED_STATE_DAY : LED_STATE_NIGHT, rgb_t{});
|
||||
start_simulation();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user