Skip to content

Explicitly cast numeric literals to type byte to avoid ESP32 and ESP8266 compile errors #8

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

Merged
merged 5 commits into from
Apr 20, 2020
Merged
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
6 changes: 3 additions & 3 deletions src/SerLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,15 @@ void SerLCD::home()
* column - byte 0 to 19
* row - byte 0 to 3
*
* returns: boolean true if cursor set.
*/
void SerLCD::setCursor(byte col, byte row)
{
int row_offsets[] = {0x00, 0x40, 0x14, 0x54};

//kepp variables in bounds
row = max(0, row); //row cannot be less than 0
row = min(row, MAX_ROWS - 1); //row cannot be greater than max rows
//Explicitly cast numeric literals to type byte to avoid ESP32 and ESP8266 compile errors
row = max((byte) 0, row); //row cannot be less than 0
row = min(row, (byte)(MAX_ROWS - 1)); //row cannot be greater than max rows

//send the command
specialCommand(LCD_SETDDRAMADDR | (col + row_offsets[row]));
Expand Down