Skip to content

Commit

Permalink
Merge pull request #165 from forntoh/bugfix/setcursorposition-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
forntoh authored Mar 8, 2024
2 parents 581adf0 + daff011 commit 46375a4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/LcdMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,20 @@ class LcdMenu {
* @param position
*/
void setCursorPosition(uint8_t position) {
this->cursorPosition = position;
uint8_t bottom = position;
bool isNotEnd = false;

do {
isNotEnd = currentMenuTable[++bottom]->getType() !=
MENU_ITEM_END_OF_MENU &&
bottom < maxRows + 20;
} while (isNotEnd);

uint8_t max = maxRows - 1;

this->cursorPosition = position + 1;
this->bottom = constrain(cursorPosition + max, max, bottom - 1);
this->top = this->bottom - max;
}
/**
* Update timer and turn off display on timeout
Expand Down

0 comments on commit 46375a4

Please sign in to comment.