writeDisplay als eigene Funktion ausgelagert

This commit is contained in:
sven 2021-03-19 12:57:13 +01:00
parent ae78a24959
commit d07f251b04

View file

@ -116,17 +116,11 @@ pinMode(MISO, INPUT);
void loop() { void loop() {
unsigned long currentMillis = millis(); unsigned long currentMillis = millis();
UP = digitalRead(SCK); UP = digitalRead(SCK);
DOWN = digitalRead(MOSI); DOWN = digitalRead(MOSI);
ENTER = digitalRead(MISO); 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){ if (MotorDelay != MotorDelayOld){
display.clearDisplay(); writeDisplay();
display.println(F("Delay: ")); display.println(MotorDelay); display.println(MotorDelayEEPROM);
display.display();
MotorDelayOld = MotorDelay; MotorDelayOld = MotorDelay;
} }
if(UP == 1 && UP != UP_OLD){ if(UP == 1 && UP != UP_OLD){
@ -141,9 +135,7 @@ void loop() {
previousMillis = currentMillis; previousMillis = currentMillis;
EEPROM.write(0, MotorDelay); EEPROM.write(0, MotorDelay);
MotorDelayEEPROM = EEPROM.read(0); MotorDelayEEPROM = EEPROM.read(0);
display.clearDisplay(); writeDisplay();
display.println(F("Delay: ")); display.println(MotorDelay); display.println(MotorDelayEEPROM);
display.display();
MotorDelayOld = MotorDelay; MotorDelayOld = MotorDelay;
} }
} }
@ -164,3 +156,12 @@ void testdrawbitmap(void) {
logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1); logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);
display.display(); 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();
}