I'm trying to set character display width with lcd.begin() function but I get unexpected results. It does not matter if I call "lcd.begin(24, 4)" or "lcd.begin(16, 4)", width remains 20 anyway. What am I doing wrong?
In LiquidCrystal.cpp this function is declared as "void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize)" but it seems like cols variable is ignored (never used in the code). But how LiquidCrystal determines display width then?
Here is detailed description of my problem. I have 24x4 character LCD (HDM24416L-1-L30P, datasheet and full spec.), it uses "HD44780 or equivalent".
I tried with LiquidCrystal.h but I get unexpected result. This is my code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,10,4,5,6,7);
void setup() {
lcd.begin(24, 4);
// Print a message to the lcd.
lcd.print("abcdefghijklmopqrstuvwxy"); // 24 characters
lcd.print("ABCDEFGHIJKLMOPQRSTUVWXY"); // 24 characters
lcd.print("0123456789_-.,9876543210"); // 24 characters
lcd.print("ZYXWVUTSRQPONMLKJIHGFEDC"); // 24 characters
}
void loop() {}
Expected result:
abcdefghijklmopqrstuvwxy
ABCDEFGHIJKLMOPQRSTUVWXY
0123456789_-.,9876543210
ZYXWVUTSRQPONMLKJIHGFEDC
But instead I see the following on the LCD:
RQPONMLKJIHGFEDCrstuRQPO
vwxyABCDEFGHIJKLMOPQvwxy
RSTUVWXY0123456789_-RSTU
.,9876543210ZYXWVUTS.,98
Basically it "works" like 20x4 display. 4 last characters on the right are always like 4 characters on the left. According to full spec., address space for first row is 0x00..0x17. I do not know why characters written to 0x00..0x03 are copied to 0x14..0x17 (same for other rows). HD44780 is not supposed to support more than 80 characters but obviously this LCD have some HD44780-compatible controller capable of this.
At the moment my biggest problem is that I do not see a way to set display width of 24 characters instead of 20. I even tried lcd.begin(24, 2), but this did not change anything.