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

Base class supporting LEDs of different types. More...

#include <nrfcxx/led.hpp>

Inheritance diagram for nrfcxx::led::led_type:
nrfcxx::led::generic_led< active_low >

Public Member Functions

 led_type (const led_type &)=delete
 
led_typeoperator= (const led_type &)=delete
 
 led_type (const led_type &&)=delete
 
led_typeoperator= (led_type &&)=delete
 
virtual bool exists (void) const
 Indicate whether the referenced LED exists. More...
 
void enable (void)
 Set the GPIO associated with the LED to enable the LED. More...
 
void disable (void)
 Disable the nrf5::GPIO associated with the LED. More...
 
void set (int v)
 Set the LED to a specific state. More...
 
virtual void off (void)
 Turn the LED off.
 
virtual void on (void)
 Turn the LED on.
 
virtual void toggle (void)
 Toggle the LED state. More...
 
virtual bool is_on (void) const
 Read the LED. More...
 

Static Public Member Functions

static size_t count (void)
 Get the number of LEDs supported by the target board.
 
static led_typelookup (unsigned int i)
 Return a reference to an LED identified by ordinal position. More...
 

Static Public Attributes

static led_type no_led
 

Protected Member Functions

virtual void enable_ ()
 
virtual void disable_ ()
 

Detailed Description

Base class supporting LEDs of different types.

Member Function Documentation

◆ disable()

void nrfcxx::led::led_type::disable ( void  )
inline

Disable the nrf5::GPIO associated with the LED.

You might want to do this for power reduction.

◆ enable()

void nrfcxx::led::led_type::enable ( void  )
inline

Set the GPIO associated with the LED to enable the LED.

The LED begins in the off state.

◆ exists()

virtual bool nrfcxx::led::led_type::exists ( void  ) const
inlinevirtual

Indicate whether the referenced LED exists.

This should return false only for the stub LED instance that is returned when an ordinal lookup requests an LED that is not supported by the target board.

The stub LED instance exists so the application doesn't have to have error handling code.

◆ is_on()

virtual bool nrfcxx::led::led_type::is_on ( void  ) const
inlinevirtual

Read the LED.

Returns
true iff the LED is active.

◆ lookup()

static led_type& nrfcxx::led::led_type::lookup ( unsigned int  i)
inlinestatic

Return a reference to an LED identified by ordinal position.

Parameters
ithe ordinal position of the desired LED
Returns
a reference to an LED. If i specified an LED that does not exist on the target a no-effect mock LED is returned.

◆ set()

void nrfcxx::led::led_type::set ( int  v)
inline

Set the LED to a specific state.

Parameters
vIf zero the LED is turned off; if positive the LED is turned on; if negative the LED changes state (off to on or on to off).

◆ toggle()

virtual void nrfcxx::led::led_type::toggle ( void  )
inlinevirtual

Toggle the LED state.

Note
Subclasses need override this only if toggling can be performed more efficiently than by invoking is_on() and selecting between off() and on().

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