LED.Timer (led v0.1.1)
View SourceTimer helper functions for managing LED blinking and repeating patterns.
Provides mechanisms to send timed messages for blinking intervals, including support for infinite repeats and countdowns.
Summary
Functions
Cancels a list of timer references to stop scheduled timer messages.
Schedules the next timer message for LED blinking or repeating patterns.
Functions
Cancels a list of timer references to stop scheduled timer messages.
timer_refs
is a list of references returned byProcess.send_after/3
.- If a
nil
timer_ref is encountered, logs a debug message and skips cancellation.
Schedules the next timer message for LED blinking or repeating patterns.
Accepts a tuple
{state, interval, times}
where:state
is0
(off) or1
(on).interval
is the delay in milliseconds before sending the next message.times
is the number of remaining toggles;-1
means infinite repeats.
If
times
is-1
, schedules the timer infinitely.If
times
is0
, does nothing (no timer scheduled).If
state
is0
, decrementstimes
and schedules the next timer.If
state
is1
, schedules the next timer without decrementingtimes
.
Returns the timer reference or nil
if no timer is scheduled.