AP_SerialLED: add support for NeoPixelRGB via set_num_neopixel_rgb()

This commit is contained in:
Andy Piper 2023-09-28 21:49:26 +01:00 committed by Andrew Tridgell
parent 9ff3d21c20
commit c91ca2d87a
2 changed files with 13 additions and 1 deletions

View File

@ -36,6 +36,15 @@ bool AP_SerialLED::set_num_neopixel(uint8_t chan, uint8_t num_leds)
return false;
}
// set number of NeoPixels per pin in RGB mode
bool AP_SerialLED::set_num_neopixel_rgb(uint8_t chan, uint8_t num_leds)
{
if (chan >= 1 && chan <= 16 && num_leds <= AP_SERIALLED_MAX_LEDS) {
return hal.rcout->set_serial_led_num_LEDs(chan-1, num_leds, AP_HAL::RCOutput::MODE_NEOPIXELRGB);
}
return false;
}
// set number of ProfiLEDs per pin
bool AP_SerialLED::set_num_profiled(uint8_t chan, uint8_t num_leds)
{

View File

@ -18,6 +18,7 @@
#pragma once
#include <AP_HAL/AP_HAL_Boards.h>
#include <AP_HAL/RCOutput.h>
#include "AP_SerialLED_config.h"
@ -34,13 +35,15 @@ public:
// set number of LEDs per pin
bool set_num_neopixel(uint8_t chan, uint8_t num_leds);
bool set_num_profiled(uint8_t chan, uint8_t num_leds);
// set number of LEDs per pin in RGB mode
bool set_num_neopixel_rgb(uint8_t chan, uint8_t num_leds);
// set RGB value on mask of LEDs. chan is PWM output, 1..16
void set_RGB_mask(uint8_t chan, uint32_t ledmask, uint8_t red, uint8_t green, uint8_t blue);
// set RGB value on LED. LED -1 is all LEDs. LED 0 is first LED. chan is PWM output, 1..16
void set_RGB(uint8_t chan, int8_t led, uint8_t red, uint8_t green, uint8_t blue);
// trigger sending of LED changes to LEDs
void send(uint8_t chan);