Added setRowOffsets to LiquidCrystal library

Original commit by Mark Sproul, but cleaned up by Matthijs Kooijman.
This commit is contained in:
Mark Sproul 2011-12-04 16:54:32 -05:00 committed by Matthijs Kooijman
parent a1c4809105
commit 03a6b2c54a
2 changed files with 14 additions and 3 deletions

View File

@ -79,6 +79,8 @@ 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);
}
@ -157,6 +159,14 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
}
void LiquidCrystal::setRowOffsets(int row0, int row1, int row2, int row3)
{
_row_offsets[0] = row0;
_row_offsets[1] = row1;
_row_offsets[2] = row2;
_row_offsets[3] = row3;
}
/********** high level commands, for the user! */
void LiquidCrystal::clear()
{
@ -172,12 +182,11 @@ void LiquidCrystal::home()
void LiquidCrystal::setCursor(uint8_t col, uint8_t row)
{
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
if ( row >= _numlines ) {
row = _numlines-1; // we count rows starting w/0
row = _numlines - 1; // we count rows starting w/0
}
command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
command(LCD_SETDDRAMADDR | (col + _row_offsets[row]));
}
// Turn the display on/off (quickly)

View File

@ -77,6 +77,7 @@ public:
void autoscroll();
void noAutoscroll();
void setRowOffsets(int row1, int row2, int row3, int row4);
void createChar(uint8_t, uint8_t[]);
void setCursor(uint8_t, uint8_t);
virtual size_t write(uint8_t);
@ -101,6 +102,7 @@ private:
uint8_t _initialized;
uint8_t _numlines,_currline;
int _row_offsets[4];
};
#endif