@@ -87,10 +87,11 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
87
87
_displayfunction |= LCD_2LINE;
88
88
}
89
89
_numlines = lines;
90
- _currline = 0 ;
90
+
91
+ setRowOffsets (0x00 , 0x40 , 0x00 + cols, 0x40 + cols);
91
92
92
93
// for some 1 line displays you can select a 10 pixel high font
93
- if ((dotsize != 0 ) && (lines == 1 )) {
94
+ if ((dotsize != LCD_5x8DOTS ) && (lines == 1 )) {
94
95
_displayfunction |= LCD_5x10DOTS;
95
96
}
96
97
@@ -157,6 +158,14 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
157
158
158
159
}
159
160
161
+ void LiquidCrystal::setRowOffsets (int row0, int row1, int row2, int row3)
162
+ {
163
+ _row_offsets[0 ] = row0;
164
+ _row_offsets[1 ] = row1;
165
+ _row_offsets[2 ] = row2;
166
+ _row_offsets[3 ] = row3;
167
+ }
168
+
160
169
/* ********* high level commands, for the user! */
161
170
void LiquidCrystal::clear ()
162
171
{
@@ -172,12 +181,15 @@ void LiquidCrystal::home()
172
181
173
182
void LiquidCrystal::setCursor (uint8_t col, uint8_t row)
174
183
{
175
- int row_offsets[] = { 0x00 , 0x40 , 0x14 , 0x54 };
184
+ const size_t max_lines = sizeof (_row_offsets) / sizeof (*_row_offsets);
185
+ if ( row >= max_lines ) {
186
+ row = max_lines - 1 ; // we count rows starting w/0
187
+ }
176
188
if ( row >= _numlines ) {
177
- row = _numlines- 1 ; // we count rows starting w/0
189
+ row = _numlines - 1 ; // we count rows starting w/0
178
190
}
179
191
180
- command (LCD_SETDDRAMADDR | (col + row_offsets [row]));
192
+ command (LCD_SETDDRAMADDR | (col + _row_offsets [row]));
181
193
}
182
194
183
195
// Turn the display on/off (quickly)
0 commit comments