Public Access
59 lines
1.9 KiB
C
59 lines
1.9 KiB
C
#pragma once
|
|||
|
|
|
||
|
|
#include <stdint.h>
|
||
|
|
|
||
|
|
// Everything that can be changed in the web UI. Stored in NVS (system/settings_store),
|
||
|
|
// the defaults are the original behaviour. Pure logic, tested in test/test_esp32.
|
||
|
|
//
|
||
|
|
// Times are minutes since midnight (8:00 = 480).
|
||
|
|
|
||
|
|
struct ScheduleSettings
|
||
|
|
{
|
||
|
|
bool enabled = true; // false: the display is always on
|
||
|
|
uint16_t day_start = 8 * 60; // display on from
|
||
|
|
uint16_t late_start = 22 * 60; // from here only at the quarter hours (see quarter_hours)
|
||
|
|
bool quarter_hours = true; // false: on all the time until night_start
|
||
|
|
uint16_t night_start = 23 * 60 + 31; // display off from (up to 24:00 = never)
|
||
|
|
};
|
||
|
|
|
||
|
|
struct ClockSettings
|
||
|
|
{
|
||
|
|
bool evening_enabled = true; // yawning Pikachu in the evening
|
||
|
|
uint16_t evening_start = 17 * 60;
|
||
|
|
bool no_wifi_screen = true; // "No WiFi" instead of the clock when WiFi is down
|
||
|
|
};
|
||
|
|
|
||
|
|
struct HomeAssistantSettings
|
||
|
|
{
|
||
|
|
bool enabled = true;
|
||
|
|
char host[64] = ""; // empty: BROKER_ADDR from secrets.h
|
||
|
|
uint16_t port = 1883;
|
||
|
|
char user[32] = "";
|
||
|
|
char password[64] = "";
|
||
|
|
};
|
||
|
|
|
||
|
|
// What is shown during the day: "clock" or the name of a bitmap
|
||
|
|
const int PAGE_NAME_SIZE = 25;
|
||
|
|
#define PAGE_CLOCK "clock"
|
||
|
|
|
||
|
|
struct Settings
|
||
|
|
{
|
||
|
|
char page[PAGE_NAME_SIZE] = PAGE_CLOCK;
|
||
|
|
ScheduleSettings schedule;
|
||
|
|
ClockSettings clock;
|
||
|
|
HomeAssistantSettings home_assistant;
|
||
|
|
uint16_t flip_time = 225; // flip pulse length in us, sent to the Nano
|
||
|
|
bool status_led = true;
|
||
|
|
};
|
||
|
|
|
||
|
|
const uint16_t MINUTES_PER_DAY = 24 * 60;
|
||
|
|
const uint16_t SETTINGS_FLIP_TIME_MIN = 50;
|
||
|
|
const uint16_t SETTINGS_FLIP_TIME_MAX = 2000;
|
||
|
|
|
||
|
|
// Checks the values. Returns nullptr when they are fine, otherwise a message for the user.
|
||
|
|
const char *validateSettings(const Settings &settings);
|
||
|
|
|
||
|
|
// "HH:MM" (00:00 - 24:00) <-> minutes since midnight
|
||
|
|
bool parseTime(const char *text, uint16_t &minutes);
|
||
|
|
// out must hold 6 characters
|
||
|
|
void formatTime(uint16_t minutes, char *out);
|