Skip to content
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

call_function() calls update() for previous menu if change_menu() is in the callback function #104

Open
1 task done
GreenEllipsis opened this issue Jun 27, 2023 · 0 comments
Labels
type: bug Something isn't working.

Comments

@GreenEllipsis
Copy link

Is there an existing issue for this?

  • I have searched the existing issues.

Library version

Yes, from Arduino library manager.

Bug description

In version 1.6.0, menus are not refreshing appropriately when change_menu() is called from a callback function and call_function() has refresh = true. The correct screen is being displayed then overwritten by a screen from the original menu (usually).

Steps to reproduce

Running the H_system_menu example, press the next_screen key to get to io_screen. Press the switch_focus key to focus on Outputs. Press the increase key.

Expected behavior

outputs_menu, pin6_screen appears.

Actual behavior

  • the screen flashes and then the io_menu is re-displayed.
  • Pressing increase again does result in the pin6_screen appearing.
  • Pressing next_screen results in displaying oSecondary_screen, as expected.
  • Moving focus to /BACK then pressing increase results in the io_menu() flashing, the the oSecondary_screen is re-displayed.
  • Pressing increase again does result in io_screen being displayed.

Probable cause

LiquidSystem's call_function calls the current menu's call_function(). If the callback function contains change_menu(), change_menu appropriately calls the new menu's update(), displaying the correct screen. When the callback function exits, control returns to the original menu's call_function(), which calls update() for the original screen, overwriting the correct display.

workaround

Use call_function() with refresh=false, preventing the original menu's call_function() from calling update(). The side-effect is that other callback functions associated with the same function number will have to manually call update().

potential solution

change_menu() should not call update, or should optionally call update.
LiquidSystems's call_function() could always pass refresh=false to the menu's call_function(), then call update() itself based on the refresh value it actually received. I have tested this against the above steps and it works. I have not tested any other conditions.

Compiler output

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

2 participants