I'm pretty new to the Python and Raspberry business and am currently working on my first major application. I like gpiozero and the ability to work with events throughout.
I would like to make my code "event-driven" and "actually" (maybe) only have a beauty question. I would like to query different states in combination. Examples:
BTN1 + BTN2 => Event 1
BTN1 + !BTN2 => Event 2
BTN3 + BTN1 => Event 3 etc.
Is there a nice way to combine the signals here?
I have seen that you could do something like this: led.source = all_values(btn1, btn2)
However, this is not enough for me; I have to call up my own functions in any case.
My only current idea would be something like this:
button1 = Button(1)
button2 = Button(2)
def check_btns():
if button1.is_pressed && button2.is_pressed:
btn1_btn2_pressed()
def btn1_btn2_pressed():
print("Both pressed")
button1.when_pressed = check_btns
button2.when_pressed = check_btns
Does anyone know a more elegant solution for querying the events in combination?
Greetings