Skip to content

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

@GreenEllipsis

Description

@GreenEllipsis

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions