45 #include <px4_platform_common/getopt.h> 46 #include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp> 71 int get(
bool &on,
bool &powersave, uint8_t &r, uint8_t &g, uint8_t &b);
87 ScheduledWorkItem(MODULE_NAME,
px4::wq_configurations::lp_default)
122 int ret =
get(on, powersave, r, g, b);
126 PX4_INFO(
"state: %s", on ?
"ON" :
"OFF");
127 PX4_INFO(
"red: %u, green: %u, blue: %u", (
unsigned)r, (
unsigned)g, (
unsigned)b);
130 PX4_WARN(
"failed to read led");
152 switch (led_control_data.
leds[0].
color) {
153 case led_control_s::COLOR_RED:
154 _r = brightness;
_g = 0;
_b = 0;
157 case led_control_s::COLOR_GREEN:
158 _r = 0;
_g = brightness;
_b = 0;
161 case led_control_s::COLOR_BLUE:
162 _r = 0;
_g = 0;
_b = brightness;
165 case led_control_s::COLOR_AMBER:
166 case led_control_s::COLOR_YELLOW:
167 _r = brightness;
_g = brightness;
_b = 0;
170 case led_control_s::COLOR_PURPLE:
171 _r = brightness;
_g = 0;
_b = brightness;
174 case led_control_s::COLOR_CYAN:
175 _r = 0;
_g = brightness;
_b = brightness;
178 case led_control_s::COLOR_WHITE:
179 _r = brightness;
_g = brightness;
_b = brightness;
200 #if defined(BOARD_HAS_LED_PWM) 206 #if defined(BOARD_HAS_UI_LED_PWM) 219 on =
_r > 0 ||
_g > 0 ||
_b > 0;
229 PX4_INFO(
"missing command: try 'start', 'status', 'stop'");
237 const char *myoptarg =
nullptr;
240 while ((ch = px4_getopt(argc, argv,
"a:b:", &myoptind, &myoptarg)) != EOF) {
254 if (myoptind >= argc) {
259 const char *verb = argv[myoptind];
261 if (!strcmp(verb,
"start")) {
262 if (g_rgbled !=
nullptr) {
263 PX4_WARN(
"already started");
267 if (g_rgbled ==
nullptr) {
270 if (g_rgbled ==
nullptr) {
271 PX4_WARN(
"alloc failed");
275 if (
OK != g_rgbled->init()) {
278 PX4_ERR(
"init failed");
287 if (g_rgbled ==
nullptr) {
288 PX4_WARN(
"not started");
293 if (!strcmp(verb,
"status")) {
298 if (!strcmp(verb,
"stop")) {
int maximum_update_interval() const
get maxium time between two consecutive calls to update() in us.
LedControlDataSingle leds[BOARD_MAX_LEDS]
static void rgbled_usage()
void Run() override
Main loop function.
uint8_t brightness
brightness in [0, 255]
uint8_t color
one of led_control_s::COLOR_*
int get(bool &on, bool &powersave, uint8_t &r, uint8_t &g, uint8_t &b)
LedController _led_controller
int led_pwm_servo_init(void)
unsigned led_pwm_servo_get(unsigned channel)
int update(LedControlData &control_data)
Update and retrieve the Led state.
Led controller helper class, used by Led drivers.
void led_pwm_servo_deinit(void)
int led_pwm_servo_set(unsigned channel, uint8_t value)
__EXPORT int rgbled_pwm_main(int argc, char *argv[])
int send_led_rgb()
Send RGB PWM settings to LED driver according to current color and brightness.
class LedController Handles the led_control topic: blinking, priorities and state updates...
volatile bool _should_run