/*
korrektheit von lcd.setCursor beweisen
https://forum.arduino.cc/t/liquidcrystal-lcd-setcursor-0-1-setzt-nicht-auf-1-zeichen/1234140
to be deleted 2024-06
*/
#include <LiquidCrystal_I2C.h> // if you don´t have I2C version of the display, use LiquidCrystal.h library instead
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void debug (String LCD_Msg_Line_1, String LCD_Msg_Line_2) {
//LiquidCrystal_I2C lcd(I2C_Address_LCD, LCD_Colums_16, LCD_Rows_2);
uint8_t LCD_Colums_16 = 16;
int8_t l; // temp. Variable zum Zentrieren
String s; // temp. Variable zum Zentrieren
// Ausgabe untere Zeile
lcd.backlight();
if (LCD_Msg_Line_2 == "") {
Serial.println(F("Zeile 1 - Nichts tun"));
}
else {
Serial.println(F("LCD_Msg_Line_2"));
lcd.setCursor(0, 1 );
lcd.backlight();
s = LCD_Msg_Line_2;
l = LCD_Colums_16 - s.length();
if (l <= 0) { // werden nur die ersten 16 Zeichen des Strings ausgegeben
lcd.print(s); // Ausgabe untere Zeile
Serial.println(s);
}
else {
lcd.setCursor(0, 1 );
lcd.print(F(". ")); // lösche untere Zeile - leerzeichen
lcd.setCursor(l / 2, 1 );
lcd.print(s); // Ausgabe untere Zeile
Serial.println(s);
};
};
}
void setup() {
Serial.begin(115200);
lcd.init(); // initialize the 16x2 lcd module
lcd.backlight(); // enable backlight for the LCD module
debug("abcdefgh", "ABCDEFGH");
}
void loop() {
}