Skip to content

Commit

Permalink
Merge pull request #155 from forntoh/logging/improvements
Browse files Browse the repository at this point in the history
Add more logging functions
  • Loading branch information
forntoh authored Jan 29, 2024
2 parents 6318414 + 0b9f5f5 commit c115305
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/LcdMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ class LcdMenu {
if (isAtTheStart() || isEditModeEnabled) return;
cursorPosition--;
// Log
printCmd(F("UP"));
printCmd(F("UP"), cursorPosition);
//
// determine if cursor is at the top of the screen
//
Expand All @@ -434,7 +434,7 @@ class LcdMenu {
if (isAtTheEnd() || isEditModeEnabled) return;
cursorPosition++;
// Log
printCmd(F("DOWN"));
printCmd(F("DOWN"), cursorPosition);
//
// determine if cursor is at the bottom of the screen
//
Expand All @@ -457,9 +457,9 @@ class LcdMenu {
* - Toggle the state of an item.
*/
void enter() {
// Log
printCmd(F("ENTER"));
MenuItem* item = currentMenuTable[cursorPosition];
// Log
printCmd(F("ENTER"), item->getType());
//
// determine the type of menu entry, then execute it
//
Expand Down Expand Up @@ -716,12 +716,12 @@ class LcdMenu {
MenuItem* item = currentMenuTable[cursorPosition];
//
if (item->getType() != MENU_ITEM_INPUT) return;
// Log
printCmd(F("BACKSPACE"));
//
uint8_t p = blinkerPosition - (strlen(item->getText()) + 2) - 1;
remove(item->getValue(), p, 1);

// Log
printCmd(F("BACKSPACE"), item->getValue());
//
blinkerPosition--;
update();
}
Expand Down Expand Up @@ -798,12 +798,12 @@ class LcdMenu {
MenuItem* item = currentMenuTable[cursorPosition];
//
if (item->getType() != MENU_ITEM_INPUT) return;
// Log
printCmd(F("CLEAR"));
//
// set the value
//
item->setValue((char*)"");
// Log
printCmd(F("CLEAR"), item->getValue());
//
// update blinker position
//
Expand Down
7 changes: 7 additions & 0 deletions src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ void printCmd(const __FlashStringHelper* command, const char value) {
Serial.println(value);
}

void printCmd(const __FlashStringHelper* command, const uint8_t value) {
Serial.print(F("#CMD# "));
Serial.print(command);
Serial.print(F("="));
Serial.println(value, DEC);
}

void printCmd(const __FlashStringHelper* command, const char* value) {
Serial.print(F("#CMD# "));
Serial.print(command);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ void printCmd(const __FlashStringHelper* command);

void printCmd(const __FlashStringHelper* command, const char value);

void printCmd(const __FlashStringHelper* command, const uint8_t value);

void printCmd(const __FlashStringHelper* command, const char* value);

#endif

0 comments on commit c115305

Please sign in to comment.