From 265ac7b59eac643f8ef39990168f0cec2ef510d2 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 18 Dec 2013 12:54:53 +0100 Subject: [PATCH] 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 --- libraries/LiquidCrystal/src/LiquidCrystal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/LiquidCrystal/src/LiquidCrystal.cpp b/libraries/LiquidCrystal/src/LiquidCrystal.cpp index 27b53772f..582594520 100644 --- a/libraries/LiquidCrystal/src/LiquidCrystal.cpp +++ b/libraries/LiquidCrystal/src/LiquidCrystal.cpp @@ -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;