From 2664ee34c768a28b6827329d4f69ef5520e4a021 Mon Sep 17 00:00:00 2001 From: Petr Mikhalicin Date: Sun, 30 Jun 2024 00:14:17 +0500 Subject: [PATCH] Fix clothing of SettingSetter if timer run --- src/SettingsSetter.cpp | 4 ++++ src/SettingsSetter.h | 2 ++ src/main.cpp | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/SettingsSetter.cpp b/src/SettingsSetter.cpp index e95f749..47e3936 100644 --- a/src/SettingsSetter.cpp +++ b/src/SettingsSetter.cpp @@ -109,3 +109,7 @@ void SettingsSetter::process() { break; } } + +bool SettingsSetter::couldBeClosed() const { + return m_timer.state() == Timer::STOPPED; +} diff --git a/src/SettingsSetter.h b/src/SettingsSetter.h index 5ba3aa8..33bdfce 100644 --- a/src/SettingsSetter.h +++ b/src/SettingsSetter.h @@ -13,6 +13,8 @@ class SettingsSetter final { void process(); + bool couldBeClosed() const; + private: void processSetLagTime(); void processSetBacklight(); diff --git a/src/main.cpp b/src/main.cpp index bdfbafc..65d6f10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -71,6 +71,8 @@ void loop() { if (gRelayState == LOW && gTimer.state() != Timer::RUNNING && gSettingBtn.hold()) { if (gSettingsSetter) { + if (!gSettingsSetter->couldBeClosed()) + return; delete gSettingsSetter; gSettingsSetter = nullptr; } else {