1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

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
This commit is contained in:
Matthijs Kooijman 2013-12-18 12:54:53 +01:00
parent 1786716a75
commit 265ac7b59e

View File

@ -79,8 +79,6 @@ void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t en
else
_displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS;
setRowOffsets(0x00, 0x40, 0x14, 0x54);
begin(16, 1);
}
@ -91,6 +89,8 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
_numlines = lines;
_currline = 0;
setRowOffsets(0x00, 0x40, 0x00 + cols, 0x40 + cols);
// for some 1 line displays you can select a 10 pixel high font
if ((dotsize != 0) && (lines == 1)) {
_displayfunction |= LCD_5x10DOTS;