LCD4Bit for 20x4 displays!

In my 4x20 display, line 3 starts just after the 20th position of line 1 and line 4 starts just after the 20th position of line 2.

So this code in the cursor position method works for me on a 4x20 display, you will need to find the right values for a display with a different width

switch (line_num){ // lines start from 1, no offset needed for x if displaying on line 1
case 2:
x+= 40 ; break;
case 3:
x+= 20 ; break;
case 4:
x+= 60 ; break;
}

You will need to search the cpp file to modify any code that is aware of the total number of lines. In the 4bit library I think there is a global variable called g_num_lines, search on that and modify the code as necessary to respect values from 1 to 4 as valid.

So something like:
if (g_num_lines < 1 || g_num_lines > 2)
g_num_lines = 1;

becomes:
if (g_num_lines != 1 && g_num_lines != 2 && g_num_lines != 4)
g_num_lines = 1;

and
int num_lines_ptn = g_num_lines - 1 << 3;

becomes:
int num_lines_ptn ;
if (g_num_lines != 4)
num_lines_ptn = g_num_lines - 1 << 3;
else
num_lines_ptn = 2 - 1 << 3; // control the 4 lines display as if 2 lines