From 592dd73fca18553aa3e1d8a2af73ee6b251cb61b Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Wed, 18 Jan 2023 21:34:20 +0100 Subject: [PATCH] Implement _dispX as function local variable --- include/Display_Graphic.h | 1 - src/Display_Graphic.cpp | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/Display_Graphic.h b/include/Display_Graphic.h index f216c38a..02c70cfa 100644 --- a/include/Display_Graphic.h +++ b/include/Display_Graphic.h @@ -22,7 +22,6 @@ private: uint8_t _mExtra; uint8_t _display_type = 0; - uint16_t _dispX = 0; uint16_t _dispY = 0; uint16_t _period = 1000; uint16_t _interval = 60000; // interval at which to power save (milliseconds) diff --git a/src/Display_Graphic.cpp b/src/Display_Graphic.cpp index 5a74babe..4c768c07 100644 --- a/src/Display_Graphic.cpp +++ b/src/Display_Graphic.cpp @@ -91,18 +91,19 @@ void DisplayGraphicClass::printText(const char* text, uint8_t line) break; } - // get the font height, to calculate the textheight + // get the font height, to calculate the textheight _dispY += (_display->getMaxCharHeight()) + 1; // calculate the starting position of the text + uint16_t dispX; if (line == 1) { - _dispX = 20 + ex; + dispX = 20 + ex; } else { - _dispX = 5 + ex; + dispX = 5 + ex; } // draw the Text, on the calculated pos - _display->drawStr(_dispX, _dispY, text); + _display->drawStr(dispX, _dispY, text); } void DisplayGraphicClass::loop() @@ -191,7 +192,6 @@ void DisplayGraphicClass::loop() } _display->sendBuffer(); - _dispX = 0; _dispY = 0; _mExtra++; _lastDisplayUpdate = millis();