Skip to content

Commit 265ac7b

Browse files
Support more LiquidCrystal displays out of the box
Previously, the row offsets were hardcoded to the ones used for 20x4 displays (which woudl also work for all 2-line displays). Now, the number of columns given is used to calculate the offsets most likely to apply. For 2-line displays and 20x4 displays, the (used) offsets are completel unchanged. With this change, common 16x4 displays and (if they even exist) other 4-line and 3-line displays might also work (depending on the hardware configuration used, of course). See this page for some info on common LCD sizes and configurations encountered in practice: http://web.alfredstate.edu/weimandn/lcd/lcd_addressing/lcd_addressing_index.html
1 parent 1786716 commit 265ac7b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libraries/LiquidCrystal/src/LiquidCrystal.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t en
7979
else
8080
_displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS;
8181

82-
setRowOffsets(0x00, 0x40, 0x14, 0x54);
83-
8482
begin(16, 1);
8583
}
8684

@@ -91,6 +89,8 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
9189
_numlines = lines;
9290
_currline = 0;
9391

92+
setRowOffsets(0x00, 0x40, 0x00 + cols, 0x40 + cols);
93+
9494
// for some 1 line displays you can select a 10 pixel high font
9595
if ((dotsize != 0) && (lines == 1)) {
9696
_displayfunction |= LCD_5x10DOTS;

0 commit comments

Comments
 (0)