nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Public Member Functions | Data Fields | Static Public Attributes
nrfcxx::led::Pattern Class Reference

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_typeled
 Provide access to the LED controlled by the pattern.
 

Static Public Attributes

static constexpr unsigned int MIN_INTERVAL_utt = 8U
 

Detailed Description

Class that supports background LED toggles in a repeating pattern.

Warning
This infrastructure cannot be used with an implementation of gpio::generic_pin that is not safe to execute from inside the uptime FLIH.

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.

Member Function Documentation

◆ cancel()

void nrfcxx::led::Pattern::cancel ( )

Cancel an active pattern.

led is disabled when this is invoked.

Note
Cancelling the pattern does not cause the completion event to be generated.

◆ configure()

int nrfcxx::led::Pattern::configure ( unsigned int  pattern,
unsigned int  interval_utt,
int  reps = -1 
)

Configure the pattern.

Parameters
patterna bit pattern showing the LED sequence (bit set = LED on, pattern starts with MSB).
interval_uttthe duration for displaying each bit in the pattern. This must be at least #MIN_INTERVAL_utt.
repsthe 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.
Returns
zero on successful configuration, or a negative error code.

◆ deadline()

unsigned int nrfcxx::led::Pattern::deadline ( ) const
inline

Return the deadline of the underlying alarm.

If the pattern has completed normally the deadline is the time at which the pattern completed.

◆ reps()

int nrfcxx::led::Pattern::reps ( ) const
inline

Return the configured number of repetitions.

Note
This is not the same as the number of repetitions remaining in an active pattern.
Returns
negative if configured to loop until canceled, otherwise the number of repetitions to perform on each start(). Zero indicates an unconfigured pattern.

◆ set_deadline()

int nrfcxx::led::Pattern::set_deadline ( unsigned int  deadline)

Set the deadline of the underlying alarm.

Returns
zero on success, or a negative error code on error (e.g. if invoked while the pattern is running).

◆ start()

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.

Parameters
delayhow 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.
Returns
zero on successful start, or a negative error code.

The documentation for this class was generated from the following file: