PX4 Firmware
PX4 Autopilot Software http://px4.io
RGBLED Class Reference
Inheritance diagram for RGBLED:
Collaboration diagram for RGBLED:

Public Member Functions

 RGBLED (int bus, int rgbled)
 
virtual ~RGBLED ()
 
virtual int init ()
 
virtual int probe ()
 
int status ()
 

Private Member Functions

void Run () override
 Main loop function. More...
 
int send_led_enable (bool enable)
 Sent ENABLE flag to LED driver. More...
 
int send_led_rgb ()
 Send RGB PWM settings to LED driver according to current color and brightness. More...
 
int get (bool &on, bool &powersave, uint8_t &r, uint8_t &g, uint8_t &b)
 
void update_params ()
 

Private Attributes

float _brightness {1.0f}
 
float _max_brightness {1.0f}
 
uint8_t _r {0}
 
uint8_t _g {0}
 
uint8_t _b {0}
 
volatile bool _running {false}
 
volatile bool _should_run {true}
 
bool _leds_enabled {true}
 
uORB::Subscription _parameter_update_sub {ORB_ID(parameter_update)}
 
LedController _led_controller
 

Detailed Description

Definition at line 63 of file rgbled.cpp.

Constructor & Destructor Documentation

◆ RGBLED()

RGBLED::RGBLED ( int  bus,
int  rgbled 
)

Definition at line 107 of file rgbled.cpp.

Referenced by rgbled_main().

Here is the caller graph for this function:

◆ ~RGBLED()

RGBLED::~RGBLED ( )
virtual

Definition at line 113 of file rgbled.cpp.

References _running, _should_run, and counter.

Member Function Documentation

◆ get()

int RGBLED::get ( bool &  on,
bool &  powersave,
uint8_t &  r,
uint8_t &  g,
uint8_t &  b 
)
private

Definition at line 316 of file rgbled.cpp.

References OK, SETTING_ENABLE, and SETTING_NOT_POWERSAVE.

◆ init()

int RGBLED::init ( )
virtual

Definition at line 124 of file rgbled.cpp.

References _running, ToneAlarmInterface::init(), OK, send_led_enable(), send_led_rgb(), and update_params().

Here is the call graph for this function:

◆ probe()

int RGBLED::probe ( )
virtual

this may look strange, but is needed. There is a serial EEPROM (Microchip-24aa01) that responds to a bunch of I2C addresses, including the 0x55 used by this LED device. So we need to do enough operations to be sure we are talking to the right device. These 3 operations seem to be enough, as the 3rd one consistently fails if no RGBLED is on the bus.

Definition at line 147 of file rgbled.cpp.

References OK, and send_led_enable().

Here is the call graph for this function:

◆ Run()

void RGBLED::Run ( )
overrideprivate

Main loop function.

Definition at line 200 of file rgbled.cpp.

References _b, _brightness, _g, _led_controller, _parameter_update_sub, _r, _running, _should_run, LedControlDataSingle::brightness, LedControlDataSingle::color, uORB::Subscription::copy(), LedControlData::leds, LedController::maximum_update_interval(), send_led_enable(), send_led_rgb(), LedController::update(), update_params(), and uORB::Subscription::updated().

Here is the call graph for this function:

◆ send_led_enable()

int RGBLED::send_led_enable ( bool  enable)
private

Sent ENABLE flag to LED driver.

Definition at line 279 of file rgbled.cpp.

References _leds_enabled, msg, SETTING_ENABLE, SETTING_NOT_POWERSAVE, and SUB_ADDR_SETTINGS.

Referenced by init(), probe(), and Run().

Here is the caller graph for this function:

◆ send_led_rgb()

int RGBLED::send_led_rgb ( )
private

Send RGB PWM settings to LED driver according to current color and brightness.

Definition at line 304 of file rgbled.cpp.

References _b, _brightness, _g, _max_brightness, _r, f(), msg, SUB_ADDR_PWM0, SUB_ADDR_PWM1, and SUB_ADDR_PWM2.

Referenced by init(), and Run().

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

◆ status()

int RGBLED::status ( )

Definition at line 177 of file rgbled.cpp.

References DEVICE_LOG, and OK.

◆ update_params()

void RGBLED::update_params ( )
private

Definition at line 336 of file rgbled.cpp.

References _max_brightness, param_find(), and param_get().

Referenced by init(), and Run().

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

Member Data Documentation

◆ _b

uint8_t RGBLED::_b {0}
private

Definition at line 80 of file rgbled.cpp.

Referenced by Run(), and send_led_rgb().

◆ _brightness

float RGBLED::_brightness {1.0f}
private

Definition at line 75 of file rgbled.cpp.

Referenced by Run(), and send_led_rgb().

◆ _g

uint8_t RGBLED::_g {0}
private

Definition at line 79 of file rgbled.cpp.

Referenced by Run(), and send_led_rgb().

◆ _led_controller

LedController RGBLED::_led_controller
private

Definition at line 87 of file rgbled.cpp.

Referenced by Run().

◆ _leds_enabled

bool RGBLED::_leds_enabled {true}
private

Definition at line 83 of file rgbled.cpp.

Referenced by send_led_enable().

◆ _max_brightness

float RGBLED::_max_brightness {1.0f}
private

Definition at line 76 of file rgbled.cpp.

Referenced by send_led_rgb(), and update_params().

◆ _parameter_update_sub

uORB::Subscription RGBLED::_parameter_update_sub {ORB_ID(parameter_update)}
private

Definition at line 85 of file rgbled.cpp.

Referenced by Run().

◆ _r

uint8_t RGBLED::_r {0}
private

Definition at line 78 of file rgbled.cpp.

Referenced by Run(), and send_led_rgb().

◆ _running

volatile bool RGBLED::_running {false}
private

Definition at line 81 of file rgbled.cpp.

Referenced by init(), Run(), and ~RGBLED().

◆ _should_run

volatile bool RGBLED::_should_run {true}
private

Definition at line 82 of file rgbled.cpp.

Referenced by Run(), and ~RGBLED().


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