This time the Hardware seams to work fine, but I do not get lucky with the code. I can not use more than 2 lines (1 and 3), the others (2 and 4) can only be used by filling the lines (1 and 3) with more than 20 characters.
What needs to be changed to address all 20x4?
It looks like that library doesn’t support 4 line displays. You could try to change the cursorTo method in the 3wire library to the following.
void LCD3Wire::cursorTo(int line_num, int x){
//first, put cursor home
commandWrite(CMD_HOME);
//if we are on a 1-line display, set line_num to 1st line, regardless of given
if (lcd_lines==1){
line_num = 1;
}
//offset 40 chars in if second line requested
if (line_num == 2){
x += 40;
}
// add the following code for 4 line display
if (line_num == 3) { // In fact, line 3 is an extension of the line 1 (beyond the 20 first characters)
x += 20;
}
if (line_num == 4) { // Line 4 is an extension of line 2
x += 60;
}
//advance the cursor to the right according to position. (second line starts at position 40).
for (int i=0; i<x; i++) {
commandWrite(0x14);
}
}