From 5763c30007599b5c50cbf8ad5ec0eee5849358b5 Mon Sep 17 00:00:00 2001 From: Sieren Date: Thu, 13 Feb 2020 08:58:23 +0100 Subject: [PATCH] Alternative between Time and IP Address Alternate between Time and IP Address in 4 second intervals so users can see the IP they need to connect to for accessing the web interface. --- main/ui/UIStatusBarWidget.cpp | 4 +++- main/ui/UIStatusBarWidget.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/main/ui/UIStatusBarWidget.cpp b/main/ui/UIStatusBarWidget.cpp index 008d49f..fd361f3 100644 --- a/main/ui/UIStatusBarWidget.cpp +++ b/main/ui/UIStatusBarWidget.cpp @@ -61,6 +61,7 @@ namespace gfx { mLastUpdate = std::chrono::system_clock::now(); mNeedsRedraw = true; + mIsWifiDisplayed = !mIsWifiDisplayed; } if (mNeedsRedraw == false) { @@ -78,7 +79,8 @@ namespace gfx mpScreen->drawJpg(util::GetIconFilePath(mMqttImage), mMqttImageFrame.position); auto textLabelFrame = mFrame; - const auto textLabel = mTextLabel == "" ? ntp::util::GetCurrentTime() : mTextLabel; + const auto timeIpAddrLabel = mIsWifiDisplayed ? mIpAddressLabel : ntp::util::GetCurrentTime(); + const auto textLabel = mTextLabel == "" ? timeIpAddrLabel : mTextLabel; const auto textWidth = mpScreen->getTextWidth(textLabel.c_str()); const auto centerPoint = mFrame.getCenterPoint(); textLabelFrame.position.x = centerPoint.x - textWidth / 2; diff --git a/main/ui/UIStatusBarWidget.h b/main/ui/UIStatusBarWidget.h index 3b03c86..ab12cd4 100644 --- a/main/ui/UIStatusBarWidget.h +++ b/main/ui/UIStatusBarWidget.h @@ -32,5 +32,6 @@ namespace gfx std::string mTimeLabel = "0:00"; std::string mTextLabel = ""; std::chrono::system_clock::time_point mLastUpdate; + bool mIsWifiDisplayed = false; }; } // namespace gfx