From 79b4f006be8732663706f1177e17e52829eb661f Mon Sep 17 00:00:00 2001 From: JF Date: Sun, 16 Feb 2020 18:37:18 +0100 Subject: [PATCH] Prevent unnecessary refresh in Clock screen. --- src/DisplayApp/Screens/Clock.cpp | 7 ++++--- src/DisplayApp/Screens/Clock.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/DisplayApp/Screens/Clock.cpp b/src/DisplayApp/Screens/Clock.cpp index 155cb581..16f4cfeb 100644 --- a/src/DisplayApp/Screens/Clock.cpp +++ b/src/DisplayApp/Screens/Clock.cpp @@ -91,9 +91,10 @@ void Clock::Refresh(bool fullRefresh) { } if(fullRefresh || version.IsUpdated()) { - char version[20]; - sprintf(version, "VERSION: %d.%d.%d", Version::Major(), Version::Minor(), Version::Patch()); - gfx.DrawString(20, 220, 0xffff, version, &smallFont, false); + auto dummy = version.Get(); + char versionStr[20]; + sprintf(versionStr, "VERSION: %d.%d.%d", Version::Major(), Version::Minor(), Version::Patch()); + gfx.DrawString(20, 220, 0xffff, versionStr, &smallFont, false); } } diff --git a/src/DisplayApp/Screens/Clock.h b/src/DisplayApp/Screens/Clock.h index 12dd8850..75ea34dd 100644 --- a/src/DisplayApp/Screens/Clock.h +++ b/src/DisplayApp/Screens/Clock.h @@ -19,7 +19,7 @@ namespace Pinetime { explicit DirtyValue(T v) { value = v; } explicit DirtyValue(T& v) { value = v; } bool IsUpdated() const { return isUpdated; } - T& Get() { return value; this->isUpdated = false;} + T& Get() { this->isUpdated = false; return value;} DirtyValue& operator=(const T& other) { this->value = other;