PX4 Firmware
PX4 Autopilot Software http://px4.io
LedController Class Reference

class LedController Handles the led_control topic: blinking, priorities and state updates. More...

#include <led.h>

Collaboration diagram for LedController:

Classes

struct  NextState
 
struct  PerLedData
 
struct  PerPriorityData
 

Public Member Functions

 LedController ()=default
 
 ~LedController ()=default
 
int maximum_update_interval () const
 get maxium time between two consecutive calls to update() in us. More...
 
int update (LedControlData &control_data)
 Update and retrieve the Led state. More...
 

Static Public Attributes

static constexpr int BREATHE_INTERVAL = 25 * 1000
 single step when in breathe mode More...
 
static constexpr int BREATHE_STEPS = 64
 number of steps in breathe mode for a full on-off cycle More...
 
static constexpr int BLINK_FAST_DURATION = 100 * 1000
 duration of half a blinking cycle (on-to-off and off-to-on) in us More...
 
static constexpr int BLINK_NORMAL_DURATION = 500 * 1000
 duration of half a blinking cycle (on-to-off and off-to-on) in us More...
 
static constexpr int BLINK_SLOW_DURATION = 2000 * 1000
 duration of half a blinking cycle (on-to-off and off-to-on) in us More...
 

Private Member Functions

void get_control_data (LedControlData &control_data)
 set control_data based on current Led states More...
 

Private Attributes

PerLedData _states [BOARD_MAX_LEDS]
 keep current LED states More...
 
uORB::Subscription _led_control_sub {ORB_ID(led_control)}
 uorb subscription More...
 
hrt_abstime _last_update_call {0}
 
bool _force_update {true}
 force an orb_copy in the beginning More...
 
bool _breathe_enabled {false}
 true if at least one of the led's is currently in breathe mode More...
 

Detailed Description

class LedController Handles the led_control topic: blinking, priorities and state updates.

Definition at line 63 of file led.h.

Constructor & Destructor Documentation

◆ LedController()

LedController::LedController ( )
default

◆ ~LedController()

LedController::~LedController ( )
default

Member Function Documentation

◆ get_control_data()

void LedController::get_control_data ( LedControlData control_data)
inlineprivate

set control_data based on current Led states

Definition at line 197 of file led.cpp.

References _breathe_enabled, _states, LedController::PerPriorityData::blink_times_left, BOARD_MAX_LEDS, BREATHE_INTERVAL, BREATHE_STEPS, LedControlDataSingle::brightness, LedControlDataSingle::color, LedController::PerPriorityData::color, counter, LedController::PerLedData::current_blinking_time, LedControlData::leds, LedController::PerPriorityData::mode, and LedController::PerLedData::priority.

Referenced by update().

Here is the caller graph for this function:

◆ maximum_update_interval()

int LedController::maximum_update_interval ( ) const
inline

get maxium time between two consecutive calls to update() in us.

Definition at line 72 of file led.h.

Referenced by RGBLED_PWM::Run(), RGBLED::Run(), and RGBLED_NPC5623C::Run().

Here is the caller graph for this function:

◆ update()

int LedController::update ( LedControlData control_data)

Update and retrieve the Led state.

It will do the orb_copy() and needs to be called at least every maximum_update_interval(). In addition a caller might poll on the led_control_sub

Parameters
control_dataoutput structure (will always be set)
Returns
1 if control_data set (state changed), 0 if control_data not changed (state did not change), <0 error otherwise

Definition at line 41 of file led.cpp.

References _force_update, _last_update_call, _led_control_sub, _states, LedController::PerLedData::apply_next_state(), BLINK_FAST_DURATION, BLINK_NORMAL_DURATION, BLINK_SLOW_DURATION, LedController::PerPriorityData::blink_times_left, BOARD_MAX_LEDS, BREATHE_INTERVAL, BREATHE_STEPS, uORB::Subscription::copy(), LedController::PerLedData::current_blinking_time, get_control_data(), hrt_absolute_time(), hrt_abstime, led_control, led_control_s::led_mask, LedController::PerPriorityData::mode, LedController::PerLedData::next_state, led_control_s::priority, LedController::NextState::priority, LedController::PerLedData::priority, LedController::NextState::reset(), LedController::NextState::set(), LedController::PerLedData::set(), and uORB::Subscription::updated().

Referenced by RGBLED_PWM::Run(), RGBLED::Run(), and RGBLED_NPC5623C::Run().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _breathe_enabled

bool LedController::_breathe_enabled {false}
private

true if at least one of the led's is currently in breathe mode

Definition at line 180 of file led.h.

Referenced by get_control_data().

◆ _force_update

bool LedController::_force_update {true}
private

force an orb_copy in the beginning

Definition at line 179 of file led.h.

Referenced by update().

◆ _last_update_call

hrt_abstime LedController::_last_update_call {0}
private

Definition at line 178 of file led.h.

Referenced by update().

◆ _led_control_sub

uORB::Subscription LedController::_led_control_sub {ORB_ID(led_control)}
private

uorb subscription

Definition at line 177 of file led.h.

Referenced by update().

◆ _states

PerLedData LedController::_states[BOARD_MAX_LEDS]
private

keep current LED states

Definition at line 175 of file led.h.

Referenced by get_control_data(), and update().

◆ BLINK_FAST_DURATION

constexpr int LedController::BLINK_FAST_DURATION = 100 * 1000
static

duration of half a blinking cycle (on-to-off and off-to-on) in us

Definition at line 88 of file led.h.

Referenced by update().

◆ BLINK_NORMAL_DURATION

constexpr int LedController::BLINK_NORMAL_DURATION = 500 * 1000
static

duration of half a blinking cycle (on-to-off and off-to-on) in us

Definition at line 90 of file led.h.

Referenced by update().

◆ BLINK_SLOW_DURATION

constexpr int LedController::BLINK_SLOW_DURATION = 2000 * 1000
static

duration of half a blinking cycle (on-to-off and off-to-on) in us

Definition at line 92 of file led.h.

Referenced by update().

◆ BREATHE_INTERVAL

constexpr int LedController::BREATHE_INTERVAL = 25 * 1000
static

single step when in breathe mode

Definition at line 85 of file led.h.

Referenced by get_control_data(), and update().

◆ BREATHE_STEPS

constexpr int LedController::BREATHE_STEPS = 64
static

number of steps in breathe mode for a full on-off cycle

Definition at line 86 of file led.h.

Referenced by get_control_data(), and update().


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