I2C liquid crystal library

I’ve searched the forums for any reference to using a 20x4 LCD display with existing libraries and came up with the LiquidCrystal_I2C_Spark lib, which works well however, with the 20x4 display, my incoming data displays out of order, 1, 3, 2, 4. From reading through many, many web pages, articles, arduino forum posts, etc. it seems this is fairly normal behavior because of how the displays are designed and built, is there a way to correct this? Does anyone know of a different lib that works better for a 4 line display, or know of a way to account for it with incoming data? I’m trying to add a display to a circuit board we use to give a full readout of what’s going on.

I know that is a little late, also I hope that you find the workaround for this but just in case if you still struggle, and for future reference for others I’ll put my 3 cents here. You right that this issue is due the memory organization of 20x4 LCD’s so the first 20 characters in first line is mapped from 0x00 to 0x13 (in other words from 0 to 19 )but the addres of first element in second line didn’t start from 0x14 it’s starting from 0x40 instead and the address 0x14 is reserved for first element in 3th line. Here is some reference.

I don’t have an 20x4 disp. on my deck so i can’t really test my approach instead i just mark all wich is related to LCD and try just pure Serial prints to see if the idea is correct.

int printIncommingData(char *data, int len){
    char temp[20];
    int line = 0;
    int i = 0;
    bool clear_line = true;
           // lcd.setCursor(0,line);
                   clear_line = false;
                Serial.printf("\n too long len is %d back to line %d" , len-1, line+1);
                //return -1;
                // lcd.clear();
                // lcd.setCursor(8,1);
                // lcd.print("too long !");
                // delay(800);
                // lcd.clear();
                // lcd.setCursor(0,line);
                // lcd.print(temp);
            snprintf(temp, sizeof(temp)+1, "%s",  &data[i]);
            Serial.printf("\n So the i is %d and and elements to write is %d now in line %d is: %s ", i, len-1, line+1, temp);
           // lcd.print(temp);
        clear_line = true;
        return 1;

and results:

you can give it a try the full code can be found here:

Best regards.

1 Like

Thanks Arek, ill give this a shot as soon as i get some time to get back on it. We decided to skip ahead a little and use an spi touch display to get the info and also allow for easier programming than the stock functions using a two position 7-segment display and buttons. Haven’t been able to work on that either though.

1 Like