From ef9bb53274d7adeb735c0bbf6a0bf7256d6abffe Mon Sep 17 00:00:00 2001 From: sebhajek Date: Mon, 19 Dec 2022 19:16:50 +0100 Subject: [PATCH] better display of values --- M2/M2.ino | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/M2/M2.ino b/M2/M2.ino index bf1cfc6..1d39246 100644 --- a/M2/M2.ino +++ b/M2/M2.ino @@ -212,10 +212,21 @@ void writeScreenData(dataMode DATA_MODE, screenMode COLOR_MODE, int data[4]){ } else { M5.Lcd.fillRect(132,116,64,64,COLORS[DARK]); } - M5.Lcd.drawString(String(data[DATA_MODE]), 132, 128, 4); + M5.Lcd.drawString(String(data[DATA_MODE]), 148 - ((countDigit(data[DATA_MODE]) - 1) * 5), 128, 4); } } +int countDigit(int n) { + if (n == 0) + return 1; + int count = 0; + while (n != 0) { + n = n / 10; + ++count; + } + return count; +} + String stringReceived = ""; int valuesReceived[4]/* = {0,0,0,0}*/;