From d07f251b04ca3cb8052f48d104750ea994d71860 Mon Sep 17 00:00:00 2001 From: sven Date: Fri, 19 Mar 2021 12:57:13 +0100 Subject: [PATCH] writeDisplay als eigene Funktion ausgelagert --- Arduino/etima/etima.ino | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Arduino/etima/etima.ino b/Arduino/etima/etima.ino index 537d63b..2bcb068 100644 --- a/Arduino/etima/etima.ino +++ b/Arduino/etima/etima.ino @@ -116,17 +116,11 @@ pinMode(MISO, INPUT); void loop() { unsigned long currentMillis = millis(); - UP = digitalRead(SCK); DOWN = digitalRead(MOSI); ENTER = digitalRead(MISO); - display.setTextSize(2); - display.setTextColor(SSD1306_WHITE); // Draw white text - display.setCursor(0,0); // Start at top-left corner - if (MotorDelay != MotorDelayOld){ - display.clearDisplay(); - display.println(F("Delay: ")); display.println(MotorDelay); display.println(MotorDelayEEPROM); - display.display(); + if (MotorDelay != MotorDelayOld){ + writeDisplay(); MotorDelayOld = MotorDelay; } if(UP == 1 && UP != UP_OLD){ @@ -141,10 +135,8 @@ void loop() { previousMillis = currentMillis; EEPROM.write(0, MotorDelay); MotorDelayEEPROM = EEPROM.read(0); - display.clearDisplay(); - display.println(F("Delay: ")); display.println(MotorDelay); display.println(MotorDelayEEPROM); - display.display(); - MotorDelayOld = MotorDelay; + writeDisplay(); + MotorDelayOld = MotorDelay; } } else { @@ -164,3 +156,12 @@ void testdrawbitmap(void) { logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1); display.display(); } + +void writeDisplay(void) { + display.setTextSize(2); + display.setTextColor(SSD1306_WHITE); // Draw white text + display.setCursor(0,0); // Start at top-left corner + display.clearDisplay(); + display.println(F("Delay: ")); display.println(MotorDelay); display.println(F("EEPROM: ")); display.println(MotorDelayEEPROM); + display.display(); +}