소스 검색

TimerManager status added

!!!RELEASE CANDITATE!!!
master
gituser 2 주 전
부모
커밋
656c0de214
7개의 변경된 파일52개의 추가작업 그리고 26개의 파일을 삭제
  1. 5
    0
      Commands.h
  2. 8
    6
      ConfigManager.cpp
  3. 8
    4
      ConfigManager.h
  4. 16
    10
      LEDLamp.ino
  5. 13
    5
      TimerManager.cpp
  6. 1
    0
      TimerManager.h
  7. 1
    1
      sloeber.ino.cpp

+ 5
- 0
Commands.h 파일 보기

CMD_CHG_COLOR, CMD_CHG_COLOR,
CMD_CHG_BRIGHTNESS, CMD_CHG_BRIGHTNESS,
CMD_CHG_CFG_PARAM, CMD_CHG_CFG_PARAM,
CMD_CHG_TIMER,
CMD_CHG_TIMER_INTERVAL, CMD_CHG_TIMER_INTERVAL,
CMD_RESET_WIFI_CFG, CMD_RESET_WIFI_CFG,
CMD_GET_CONFIG, CMD_GET_CONFIG,
return "CHG_BRIGHTNESS"; return "CHG_BRIGHTNESS";
case CMD_CHG_CFG_PARAM: case CMD_CHG_CFG_PARAM:
return "CHG_CFG_PARAM"; return "CHG_CFG_PARAM";
case CMD_CHG_TIMER:
return "CHG_TIMER";
case CMD_CHG_TIMER_INTERVAL: case CMD_CHG_TIMER_INTERVAL:
return "CHG_TIMER_INTERVAL"; return "CHG_TIMER_INTERVAL";
case CMD_RESET_WIFI_CFG: case CMD_RESET_WIFI_CFG:
return CMD_CHG_BRIGHTNESS; return CMD_CHG_BRIGHTNESS;
if (strcmp(cmd, "CHG_CFG_PARAM") == 0) if (strcmp(cmd, "CHG_CFG_PARAM") == 0)
return CMD_CHG_CFG_PARAM; return CMD_CHG_CFG_PARAM;
if (strcmp(cmd, "CHG_TIMER") == 0)
return CMD_CHG_TIMER;
if (strcmp(cmd, "CHG_TIMER_INTERVAL") == 0) if (strcmp(cmd, "CHG_TIMER_INTERVAL") == 0)
return CMD_CHG_TIMER_INTERVAL; return CMD_CHG_TIMER_INTERVAL;
if (strcmp(cmd, "RESET_WIFI_CFG") == 0) if (strcmp(cmd, "RESET_WIFI_CFG") == 0)

+ 8
- 6
ConfigManager.cpp 파일 보기

} }


Config& ConfigManager::setToDefaultTimerConfig(Config &config) { Config& ConfigManager::setToDefaultTimerConfig(Config &config) {
config.timeInterval1.start = 0;
config.timeInterval1.end = 0;
config.timeInterval2.start = 0;
config.timeInterval2.end = 0;
config.timer.on = false;
config.timer.timeInterval1.start = 0;
config.timer.timeInterval1.end = 0;
config.timer.timeInterval2.start = 0;
config.timer.timeInterval2.end = 0;


return config; return config;
} }
doc["flashOnTime"] = _config.flashOnTime; doc["flashOnTime"] = _config.flashOnTime;
doc["flashOffTime"] = _config.flashOffTime; doc["flashOffTime"] = _config.flashOffTime;


timeIntervalToJson(_config.timeInterval1, doc["timeInterval1"].to<JsonObject>());
timeIntervalToJson(_config.timeInterval2, doc["timeInterval2"].to<JsonObject>());
doc["timer"]["on"] = _config.timer.on;
timeIntervalToJson(_config.timer.timeInterval1, doc["timer"]["timeInterval1"].to<JsonObject>());
timeIntervalToJson(_config.timer.timeInterval2, doc["timer"]["timeInterval2"].to<JsonObject>());
} }


void ConfigManager::rgbwToJson(const RGBWColor &c, JsonObject obj) { void ConfigManager::rgbwToJson(const RGBWColor &c, JsonObject obj) {

+ 8
- 4
ConfigManager.h 파일 보기

#include <EEPROM.h> #include <EEPROM.h>
#include "LEDModes.h" #include "LEDModes.h"


#define CONFIG_VERSION 4
#define CONFIG_VERSION 5


typedef struct __attribute__((packed)) { typedef struct __attribute__((packed)) {
uint8_t r; uint8_t r;
uint32_t end; uint32_t end;
} TimeInterval; } TimeInterval;


typedef struct __attribute__((packed)) {
bool on;
TimeInterval timeInterval1;
TimeInterval timeInterval2;
} Timer;

typedef struct __attribute__((packed)) { typedef struct __attribute__((packed)) {
uint8_t version; uint8_t version;


uint32_t fadingFadeTime; uint32_t fadingFadeTime;
uint32_t flashOnTime; uint32_t flashOnTime;
uint32_t flashOffTime; uint32_t flashOffTime;

TimeInterval timeInterval1;
TimeInterval timeInterval2;
Timer timer;
} Config; } Config;


class ConfigManager { class ConfigManager {

+ 16
- 10
LEDLamp.ino 파일 보기

if (sscanf(amount, "%u", &amountVal) == 1) { if (sscanf(amount, "%u", &amountVal) == 1) {
ledMngr.onCfgParamChange(value, amountVal); ledMngr.onCfgParamChange(value, amountVal);
} }
} else if (strToCommand(cmd) == CMD_CHG_TIMER) {
const char *status = doc["status"];
timerManager.onTimerStatusChange(status);

} else if (strToCommand(cmd) == CMD_CHG_TIMER_INTERVAL) { } else if (strToCommand(cmd) == CMD_CHG_TIMER_INTERVAL) {
const char *interval = doc["interval"]; const char *interval = doc["interval"];
const char *timerange = doc["timerange"]; const char *timerange = doc["timerange"];
MDNS.update(); MDNS.update();


static uint32_t lastNtpCheck = 0; static uint32_t lastNtpCheck = 0;
uint32_t now = millis();


if (WiFi.status() != WL_CONNECTED) { if (WiFi.status() != WL_CONNECTED) {
Serial.println("WLAN verloren"); Serial.println("WLAN verloren");
return; return;
} }


uint32_t now = millis();
if (now - lastNtpCheck >= 5000) {
lastNtpCheck = now;
if (timerManager.isNowInTimeInterval()) {
if (ledMngr.isOn()) {
ledMngr.off();
}
} else {
if (!ledMngr.isOn()) {
ledMngr.on();
if (configManager.getConfig().timer.on) {
if (now - lastNtpCheck >= 5000) {
lastNtpCheck = now;
if (timerManager.isNowInTimeInterval()) {
if (ledMngr.isOn()) {
ledMngr.off();
}
} else {
if (!ledMngr.isOn()) {
ledMngr.on();
}
} }
} }
} }

+ 13
- 5
TimerManager.cpp 파일 보기

ntpClient.begin(); ntpClient.begin();
} }


void TimerManager::onTimerStatusChange(const char *timerStatus) {
Config cfg = configManager.getConfig();
cfg.timer.on = String(timerStatus).equalsIgnoreCase("on");
configManager.saveConfig(cfg);
}


void TimerManager::onTimerIntervalChange(String timerIntervalName, const char *timerInterval) { void TimerManager::onTimerIntervalChange(String timerIntervalName, const char *timerInterval) {
TimeInterval interval; TimeInterval interval;
parseTimeInterval(timerInterval, interval); parseTimeInterval(timerInterval, interval);
void TimerManager::saveTimerInterval(String timerIntervalName, uint32_t start, uint32_t end) { void TimerManager::saveTimerInterval(String timerIntervalName, uint32_t start, uint32_t end) {
Config cfg = configManager.getConfig(); Config cfg = configManager.getConfig();
if (timerIntervalName.equals("timeInterval1")) { if (timerIntervalName.equals("timeInterval1")) {
cfg.timeInterval1.start = start;
cfg.timeInterval1.end = end;
cfg.timer.timeInterval1.start = start;
cfg.timer.timeInterval1.end = end;
} else if (timerIntervalName.equals("timeInterval2")) { } else if (timerIntervalName.equals("timeInterval2")) {
cfg.timeInterval2.start = start;
cfg.timeInterval2.end = end;
cfg.timer.timeInterval2.start = start;
cfg.timer.timeInterval2.end = end;
} }


configManager.saveConfig(cfg); configManager.saveConfig(cfg);
Serial.print("localTime: "); Serial.print("localTime: ");
Serial.println(secondsToFormatedTime(localTime)); Serial.println(secondsToFormatedTime(localTime));


return (isInInterval(localTime, cfg.timeInterval1) || isInInterval(localTime, cfg.timeInterval2));
return (isInInterval(localTime, cfg.timer.timeInterval1) || isInInterval(localTime, cfg.timer.timeInterval2));
} }


bool TimerManager::isDST(int month, int day, int weekday) { bool TimerManager::isDST(int month, int day, int weekday) {


return String(buffer); return String(buffer);
} }


+ 1
- 0
TimerManager.h 파일 보기

virtual ~TimerManager(); virtual ~TimerManager();


void begin(); void begin();
void onTimerStatusChange(const char *timerStatus);
void onTimerIntervalChange(String timerIntervalName, const char *timerInterval); void onTimerIntervalChange(String timerIntervalName, const char *timerInterval);
void saveTimerInterval(String timerIntervalName, uint32_t start, uint32_t end); void saveTimerInterval(String timerIntervalName, uint32_t start, uint32_t end);
bool isNowInTimeInterval(); bool isNowInTimeInterval();

+ 1
- 1
sloeber.ino.cpp 파일 보기

//This is a automatic generated file //This is a automatic generated file
//Please do not modify this file //Please do not modify this file
//If you touch this file your change will be overwritten during the next build //If you touch this file your change will be overwritten during the next build
//This file has been generated on 2026-07-16 22:35:32
//This file has been generated on 2026-07-16 22:59:44


#include "Arduino.h" #include "Arduino.h"
#include "Arduino.h" #include "Arduino.h"

Loading…
취소
저장