Is there a recommended method for setting and clearing callback functions to respond to button presses on the Display-O-Tron HAT? I’m looking to use this instead of the decorator technique as the button presses will be used for different purposes depending on the application state.
I’ve currently got this working to set the callback:
def handle_left_scenario_1(pin): # do something here based on scenario 1 pass callback_left = nav.on(nav.LEFT, handle_left_scenario_1) callback_left(handle_left_scenario_1)
So, is this an appropriate technique to set the callback and how do I re-define the callback and also clear it?