nrfcxx
0.1.0
C++-17 Framework for Nordic nRF5 Devices
|
Class that supports background LED toggles in a repeating pattern. More...
#include <nrfcxx/led.hpp>
Public Member Functions | |
Pattern (led_type &led) | |
Construct referencing a specific LED. | |
unsigned int | pattern () const |
Return the currently configured pattern. | |
void | set_notify_complete (notifier_type notify) |
Provide an event setter used to tell the application when the pattern has completed. | |
int | reps () const |
Return the configured number of repetitions. More... | |
unsigned int | interval_utt () const |
Return the interval between bits of the pattern. | |
int | configure (unsigned int pattern, unsigned int interval_utt, int reps=-1) |
Configure the pattern. More... | |
bool | active () const |
Indicates whether the pattern is currently running. | |
bool | loops () const |
Indicates whether the pattern is configured to loop until cancel() is invoked. | |
unsigned int | deadline () const |
Return the deadline of the underlying alarm. More... | |
int | set_deadline (unsigned int deadline) |
Set the deadline of the underlying alarm. More... | |
int | start (int delay_utt=-1) |
Enable led and start the pattern. More... | |
void | cancel () |
Cancel an active pattern. More... | |
Data Fields | |
led_type & | led |
Provide access to the LED controlled by the pattern. | |
Static Public Attributes | |
static constexpr unsigned int | MIN_INTERVAL_utt = 8U |
Class that supports background LED toggles in a repeating pattern.
This combines an LED instance with an alarm, allowing configuration of a pattern display. The display is decoded from a 32-bit sequence, where set bits indicate the LED should be illuminated and cleared bits indicate the LED should be off. The duration for display of each bit is configurable, as is the number of times the pattern should be repeated.
void nrfcxx::led::Pattern::cancel | ( | ) |
Cancel an active pattern.
led is disabled when this is invoked.
int nrfcxx::led::Pattern::configure | ( | unsigned int | pattern, |
unsigned int | interval_utt, | ||
int | reps = -1 |
||
) |
Configure the pattern.
pattern | a bit pattern showing the LED sequence (bit set = LED on, pattern starts with MSB). |
interval_utt | the duration for displaying each bit in the pattern. This must be at least #MIN_INTERVAL_utt. |
reps | the number of times the pattern should be displayed. A negative value means to repeat the pattern until cancel() is invoked. The value must not exceed 255. |
|
inline |
Return the deadline of the underlying alarm.
If the pattern has completed normally the deadline is the time at which the pattern completed.
|
inline |
Return the configured number of repetitions.
int nrfcxx::led::Pattern::set_deadline | ( | unsigned int | deadline | ) |
Set the deadline of the underlying alarm.
int nrfcxx::led::Pattern::start | ( | int | delay_utt = -1 | ) |
Enable led and start the pattern.
The LED remains enabled until cancel() or the pattern ends naturally, at which point it is disabled.
delay | how long to wait until the pattern starts. If negative (default) the current alarm deadline is used without change. Non-negative values delegate to clock::alarm::schedule_offset(), overriding the currently configured deadline. |