Skip to content
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

Compatibility row offset for 16 and 20 columns LCD #17

Merged
merged 1 commit into from
Dec 18, 2019
Merged
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
18 changes: 16 additions & 2 deletions LiquidTWI2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ void LiquidTWI2::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
Wire.begin();

uint8_t result;

if (cols == 20 && lines == 4 ) {
_row_offsets [0] = 0x00;
_row_offsets [1] = 0x40;
_row_offsets [2] = 0x14;
_row_offsets [3] = 0x54;
} else{
_row_offsets [0] = 0x00;
_row_offsets [1] = 0x40;
_row_offsets [2] = 0x10;
_row_offsets [3] = 0x50;
}



#if defined(MCP23017)&&defined(MCP23008)
if (_mcpType == LTI_TYPE_MCP23017) {
#endif
Expand Down Expand Up @@ -344,9 +359,8 @@ void LiquidTWI2::setCursor(uint8_t col, uint8_t row)
#ifdef DETECT_DEVICE
if (!_deviceDetected) return;
#endif
int row_offsets[] = { 0x00, 0x40, 0x10, 0x50 };
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]));
}

// Turn the display on/off (quickly)
Expand Down
1 change: 1 addition & 0 deletions LiquidTWI2.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class LiquidTWI2 : public Print {
uint8_t _numlines,_currline;
uint8_t _i2cAddr;
uint8_t _backlightInverted;
uint16_t _row_offsets[4];
#ifdef DETECT_DEVICE
uint8_t _deviceDetected;
#endif // DETECT_DEVICE
Expand Down