From 21cf917906eccf66abbead3f3eb5357e5f94e4bc Mon Sep 17 00:00:00 2001 From: Nicu Hodos Date: Mon, 10 Feb 2025 16:02:17 +0100 Subject: [PATCH 1/4] extract timer and generic callback in dedicated files --- include/devices.h | 12 ++--- include/display.h | 127 ++++++++++++++-------------------------------- include/helper.h | 12 +++++ include/timer.h | 31 +++++++++++ 4 files changed, 88 insertions(+), 94 deletions(-) create mode 100644 include/helper.h create mode 100644 include/timer.h diff --git a/include/devices.h b/include/devices.h index 9c1e90c..562fdad 100644 --- a/include/devices.h +++ b/include/devices.h @@ -49,7 +49,7 @@ namespace Devices { Number* displayTimerMqtt = Builder::instance(new Number{ "Timer duration", "timer_duration", [](const char* msg) { auto value = String{ msg }.toInt(); - Display::Timer::timer = value; + timer = value; displayTimerMqtt->updateState(value); } }).withMin(0).withMax(90).withStep(5).restoreStateFromCommand().build(); @@ -58,10 +58,10 @@ namespace Devices { Switch* timerMqtt = Builder::instance(new Switch{"Timer", "timer", [](const char* msg) { if (strcmp("ON", msg) == 0) { - Display::Timer::start(); + Display::tTimer.restart(); timerMqtt->updateState(true); } else { - Display::Timer::stop(); + Display::tTimer.disable(); timerMqtt->updateState(false); } } @@ -97,8 +97,8 @@ namespace Devices { .addSecondary( Builder