Skip to content

Commit 03a6b2c

Browse files
msproulmatthijskooijman
authored andcommitted
Added setRowOffsets to LiquidCrystal library
Original commit by Mark Sproul, but cleaned up by Matthijs Kooijman.
1 parent a1c4809 commit 03a6b2c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

libraries/LiquidCrystal/src/LiquidCrystal.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ 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+
8284
begin(16, 1);
8385
}
8486

@@ -157,6 +159,14 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
157159

158160
}
159161

162+
void LiquidCrystal::setRowOffsets(int row0, int row1, int row2, int row3)
163+
{
164+
_row_offsets[0] = row0;
165+
_row_offsets[1] = row1;
166+
_row_offsets[2] = row2;
167+
_row_offsets[3] = row3;
168+
}
169+
160170
/********** high level commands, for the user! */
161171
void LiquidCrystal::clear()
162172
{
@@ -172,12 +182,11 @@ void LiquidCrystal::home()
172182

173183
void LiquidCrystal::setCursor(uint8_t col, uint8_t row)
174184
{
175-
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
176185
if ( row >= _numlines ) {
177-
row = _numlines-1; // we count rows starting w/0
186+
row = _numlines - 1; // we count rows starting w/0
178187
}
179188

180-
command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
189+
command(LCD_SETDDRAMADDR | (col + _row_offsets[row]));
181190
}
182191

183192
// Turn the display on/off (quickly)

libraries/LiquidCrystal/src/LiquidCrystal.h

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class LiquidCrystal : public Print {
7777
void autoscroll();
7878
void noAutoscroll();
7979

80+
void setRowOffsets(int row1, int row2, int row3, int row4);
8081
void createChar(uint8_t, uint8_t[]);
8182
void setCursor(uint8_t, uint8_t);
8283
virtual size_t write(uint8_t);
@@ -101,6 +102,7 @@ class LiquidCrystal : public Print {
101102
uint8_t _initialized;
102103

103104
uint8_t _numlines,_currline;
105+
int _row_offsets[4];
104106
};
105107

106108
#endif

0 commit comments

Comments
 (0)