Skip to content

Added a function to LiquidCrystal to tweak the memory offset of the rows... #2273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions libraries/LiquidCrystal/LiquidCrystal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
}
_numlines = lines;
_currline = 0;
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
setRowOffsets(row_offsets);

// for some 1 line displays you can select a 10 pixel high font
if ((dotsize != 0) && (lines == 1)) {
Expand Down Expand Up @@ -172,12 +174,17 @@ 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
}

command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
command(LCD_SETDDRAMADDR | (col + _row_offsets[row]));
}

// Allows the tweaking of the memory offsets for each row.
void LiquidCrystal::setRowOffsets(int row_offsets[])
{
_row_offsets = row_offsets;
}

// Turn the display on/off (quickly)
Expand Down
5 changes: 4 additions & 1 deletion libraries/LiquidCrystal/LiquidCrystal.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class LiquidCrystal : public Print {
void noAutoscroll();

void createChar(uint8_t, uint8_t[]);
void setCursor(uint8_t, uint8_t);
void setCursor(uint8_t, uint8_t);
void setRowOffsets(int[]);
virtual size_t write(uint8_t);
void command(uint8_t);

Expand All @@ -101,6 +102,8 @@ class LiquidCrystal : public Print {
uint8_t _initialized;

uint8_t _numlines,_currline;

int *_row_offsets; // array of memory offsets for the start of each row
};

#endif
1 change: 1 addition & 0 deletions libraries/LiquidCrystal/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ rightToLeft KEYWORD2
scrollDisplayLeft KEYWORD2
scrollDisplayRight KEYWORD2
createChar KEYWORD2
setRowOffsets KEYWORD2

#######################################
# Constants (LITERAL1)
Expand Down