Commit 2e1f4124 authored by Matthijs Kooijman's avatar Matthijs Kooijman
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

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:
parent 70e0205d
......@@ -79,8 +79,6 @@ void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t en
_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;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment