From 47df29c8d8b128e5de7bd5e9579a73c6d27f94d2 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 4 Jun 2024 07:06:43 +0200 Subject: [PATCH] adds funny restart animation --- src/states.cpp | 11 ++++++++++- src/timer.cpp | 10 ++++++++++ src/timer.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/states.cpp b/src/states.cpp index 6e30087..7ba3e29 100644 --- a/src/states.cpp +++ b/src/states.cpp @@ -460,7 +460,16 @@ State* Restarting::update(const Context context) String Restarting::updateDisplay(const Context& context) { - return "RESTARTING......"; // todo + String animLine = ""; + const String full = ".-`-._.-`-._. :)"; + const float percent = static_cast(timer.getCurrentTime()) / static_cast(timer.getDuration()); + Serial.println(String("updating display ") + percent); + for (int i = 0; i < full.length() * percent; i++) + { + Serial.println(String("i: ") + i + "len " + (full.length() * percent)); + animLine = animLine + full[i]; + } + return "RESTARTING " + animLine; } void Restarting::activated(const Context context) diff --git a/src/timer.cpp b/src/timer.cpp index c3b12eb..2003585 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -44,3 +44,13 @@ bool Timer::isRunning() const { return this->running; } + +unsigned long Timer::getDuration() const +{ + return this->duration; +} + +unsigned long Timer::getCurrentTime() const +{ + return this->currentTime; +} diff --git a/src/timer.h b/src/timer.h index 9667847..33b3709 100644 --- a/src/timer.h +++ b/src/timer.h @@ -14,4 +14,6 @@ public: void start(); bool update(unsigned long delta); bool isRunning() const; + unsigned long getDuration() const; + unsigned long getCurrentTime() const; };