Skip to content

Commit

Permalink
#167 Update condition to check if cursor is at the top and bottom.
Browse files Browse the repository at this point in the history
This change modifies the code to include a check for both top and bottom positions before printing the down arrow.
  • Loading branch information
forntoh committed May 3, 2024
1 parent 0f81a3e commit f19e78b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/LcdMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class LcdMenu {
//
// determine if cursor is at the top
//
if (top == 1) {
if (top == 1 && bottom == maxRows) {
//
// Print the down arrow only
//
Expand Down
4 changes: 3 additions & 1 deletion src/MenuItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ class ItemHeader : public MenuItem {

MenuItem** getSubMenu() override { return this->parent; };

MenuItem* operator[](const uint8_t index) override { return parent[index]; }
MenuItem* operator[](const uint8_t index) override {
return getSubMenu()[index];
}
};

/**
Expand Down
16 changes: 16 additions & 0 deletions src/utils/commandProccesors.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
#include <Arduino.h>

#ifdef MenuItem_H
/**
* Processes the given command on the LcdMenu object.
*
* @param menu The LcdMenu object on which the command is to be processed.
* @param cmd The command to be processed.
* @param upCmd The command for moving up in the menu.
* @param downCmd The command for moving down in the menu.
* @param enterCmd The command for entering/editing a value.
* @param backCmd The command for going back in the menu.
* @param leftCmd The command for moving left in the menu.
* @param rightCmd The command for moving right in the menu.
*
* @return true if the command is consumed, false otherwise.
*
* @throws None
*/
bool processCommand(LcdMenu& menu, byte cmd, byte upCmd, byte downCmd,
byte enterCmd, byte backCmd, byte leftCmd, byte rightCmd) {
if (cmd == upCmd) {
Expand Down

0 comments on commit f19e78b

Please sign in to comment.