Skip to content

Commit

Permalink
checkpoint working meter menus
Browse files Browse the repository at this point in the history
  • Loading branch information
Bad-Assumptions committed Jul 12, 2023
1 parent b9ce4a1 commit f1cde51
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/LiquidMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,16 @@ bool LiquidMenu::change_screen(LiquidScreen *p_liquidScreen) {
if (p_liquidScreen == _p_liquidScreen[s]) {
// if (reinterpret_cast<uintptr_t>(&p_liquidScreen) == reinterpret_cast<uintptr_t>(&(*_p_liquidScreen[s]))) {
_currentScreen = s;

update();
ESP_LOGD("LiquidMenu", "Switched to screen:%d pointer:%p", _currentScreen, p_liquidScreen)
DEBUG(F("Switched to screen ("));
DEBUG(_currentScreen); DEBUGLN(F(")"));
// update(); No reason for two calls to update
return true;
}
}
ESP_LOGD("LiquidMenu", "Invalid request for screen change to %p", p_liquidScreen);
DEBUG(F("Invalid request for screen change to 0x")); DEBUGLN(reinterpret_cast<uintptr_t>(&p_liquidScreen));
return false;
}
Expand Down Expand Up @@ -250,13 +253,15 @@ bool LiquidMenu::is_callable(uint8_t number) const {

bool LiquidMenu::call_function(uint8_t number, bool refresh) const {
bool returnValue = _p_liquidScreen[_currentScreen]->call_function(number);
if (refresh) {
if (refresh)
{
update();
}
return returnValue;
}

void LiquidMenu::update() const {
ESP_LOGV("LiquidMenu", "Updating screen:%d, _p_liquidCrystal:%p", _currentScreen, _p_liquidCrystal);
_p_liquidCrystal->clear();
softUpdate();
}
Expand All @@ -269,6 +274,8 @@ void LiquidMenu::softUpdate() const {
* Will be removed for version 2.0.0 when `LiquidMenu::init()` will
* become mandatory.
*/
ESP_LOGV("LiquidMenu", "Soft updating screen:%d, pointer:%p", _currentScreen, _p_liquidScreen[_currentScreen]);
// _p_liquidCrystal->clear(); Isn't the point of softUpdate() no clear()?
static bool firstRun = true;
if (firstRun) {
firstRun = false;
Expand Down
6 changes: 3 additions & 3 deletions src/LiquidMenu_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ used in the library, also configures the debugging messages.
const uint8_t MAX_VARIABLES = 5; ///< @note Default: 5

/// Configures the number of available functions per line.
const uint8_t MAX_FUNCTIONS = 8; ///< @note Default: 8
const uint8_t MAX_FUNCTIONS = 4; ///< @note Default: 8

/// Configures the number of available lines per screen.
const uint8_t MAX_LINES = 2; ///< @note Default: 12

/// Configures the number of available screens per menu.
const uint8_t MAX_SCREENS = 14; ///< @note Default: 14
const uint8_t MAX_SCREENS = 10; ///< @note Default: 14

/// Configures the number of available menus per menus system.
const uint8_t MAX_MENUS = 8; ///< @note Default: 8
const uint8_t MAX_MENUS = 12; ///< @note Default: 8

/*!
* Enable/disable hiding the focus indicator.
Expand Down
1 change: 1 addition & 0 deletions src/LiquidMenu_const.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Constants file for LiquidMenu library.
/// https://github.com/johnrickman/LiquidCrystal_I2C library (I2C)
#define LiquidCrystal_I2C_LIBRARY (2)
//!@}

3 changes: 3 additions & 0 deletions src/LiquidSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ bool LiquidSystem::add_menu(LiquidMenu &liquidMenu) {
DEBUG(F(""));
return true;
}
ESP_LOGE("LiquidSystem", "failed, edit LiquidMenu_config.h to allow for more menus");
DEBUGLN(F(" failed, edit LiquidMenu_config.h to allow for more menus"));
return false;
}
Expand All @@ -79,6 +80,7 @@ bool LiquidSystem::change_menu(LiquidMenu &p_liquidMenu, bool refresh) {
// if ((uintptr_t)&p_liquidMenu == (uintptr_t) & (*_p_liquidMenu[m])) {
if (reinterpret_cast<uintptr_t>(&p_liquidMenu) == reinterpret_cast<uintptr_t>(&(*_p_liquidMenu[m]))) {
_currentMenu = m;
ESP_LOGD("LiquidSystem", "Menu changed to: %d", _currentMenu);
DEBUG(F("Menu changed to ")); DEBUGLN(_currentMenu);
if (refresh) {
update();
Expand Down Expand Up @@ -189,6 +191,7 @@ bool LiquidSystem::call_function(uint8_t number, bool refresh) const {
}

void LiquidSystem::update() const {
ESP_LOGD("LiquidSystem", "Updating menu:%d, pointer:%p", _currentMenu, _p_liquidMenu[_currentMenu]);
_p_liquidMenu[_currentMenu]->update();
}

Expand Down

0 comments on commit f1cde51

Please sign in to comment.