Microcontrôleurs & IoT
BlinkFSM — automate imbriqué non-bloquant
BlinkFSM est une LED clignotante implémentée avec… une FSM interne !
#include <BlinkFSM.h>
BlinkFSM stampBlinker(LED_STAMP, 100);
BlinkFSM runBlinker (LED_RUN, 500);
fsm.onEnter(STAMPING, []() { stampBlinker.start(); })
.onExit (STAMPING, []() { stampBlinker.stop(); })
.onEnter(IDLE, []() { runBlinker.stop(); })
.onExit (IDLE, []() { runBlinker.start(); });
void loop() {
fsm.update();
stampBlinker.update();
runBlinker.update();
}
Pendant l'état STAMPING, la LED clignote à 10 Hz.
Zéro delay(), zéro blocage, le moteur descend en même temps.