Instead of using a state machine, the LED module operates as follows:
-
When a message is received on the
led_chanchannel:- Any existing blink pattern is canceled.
- The new LED state (colors and timing) is saved.
- The LED is turned on with the specified color.
-
If a blinking pattern is specified (repetitions != 0):
- A timer is started with
duration_on_msec. - When the timer expires, the LED toggles between on and off states.
- The timer alternates between
duration_on_msecandduration_off_msec. - This continues until the specified number of repetitions is reached.
- If repetitions is -1, the blinking continues indefinitely or until a new message is received.
- A timer is started with
The module handles error cases gracefully and reports issues through logging.