In this micropython tuto ==> MicroPython: WS2812B Addressable RGB LEDs with ESP32 and ESP8266:
https://randomnerdtutorials.com/micropy ... 2-esp8266/
At the middle of tuto in the part ==> WS2812B RGB LEDs with MicroPython: Project example
They build a simple circuit with 4 pushbutton to make different lighting effects.
They create an interrupt handling function that will run every time an interrupt happens – in this case, the button_handler() function.
Code: Select all
def button_handler(pin):
global button_pressed
button_pressed = pin
Code: Select all
button1 = Pin(15, Pin.IN)
button1.irq(trigger=Pin.IRQ_RISING, handler=button_handler)
button2 = Pin(14, Pin.IN)
button2.irq(trigger=Pin.IRQ_RISING, handler=button_handler)
button3 = Pin(12, Pin.IN)
button3.irq(trigger=Pin.IRQ_RISING, handler=button_handler)
button4 = Pin(13, Pin.IN)
But when you press the pushbutton to select an effect, it will only start when the effect that is running stops.
I tought that an hardware interrupt code should be interrupt but not and if you have long lighting effects ==> We wait : it's a problem.
My question is : what is the best way to control the push button (to interrupt the running interrupt task)
- ISR interrupt Handler
Asyncio
A mix of two
or others...
Thierry.