Interruption and Timer
Posted: Mon Oct 17, 2022 10:38 am
Hi,
I have a problem with my interruption. So I have a function called by a timer like this : and I have declared button interruption like this :
My problem is that my main function called by the Timer take time and button interruption don't take the advantage on my main funtion so interruption are invisible.
Do you have any suggestion about what I have ?
Thank you
I have a problem with my interruption. So I have a function called by a timer like this :
Code: Select all
tim = Timer(1)
tim.init(period=300, callback=main)
Code: Select all
pin_button_down.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING,
handler=handle_button)
pin_button_enter.irq(trigger=Pin.IRQ_RISING |
Pin.IRQ_FALLING, handler=handle_button)
pin_button_up.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING,
handler=handle_button)
pin_button_escape.irq(trigger=Pin.IRQ_RISING |
Pin.IRQ_FALLING, handler=handle_button)
def handle_button(Pin):
"""Function called when a button is pressed"""
global button_interruption_treated, button_unpressed, coeff_speed_button_incrementation
if button_unpressed or Pin.value() == 0:
myprint("pressed")
treat_button_interruption()
button_interruption_treated = True
button_unpressed = False
else:
print("unpressed")
coeff_speed_button_incrementation = 0
button_unpressed = True
Do you have any suggestion about what I have ?
Thank you