Skip to content

Commit

Permalink
AP_SerialLED: support set_num_neopixel_rgb()
Browse files Browse the repository at this point in the history
  • Loading branch information
andyp1per committed Sep 29, 2023
1 parent a6e0429 commit b8ec902
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 11 additions & 3 deletions libraries/AP_SerialLED/AP_SerialLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ extern const AP_HAL::HAL& hal;
AP_SerialLED AP_SerialLED::singleton;

// set number of NeoPixels per pin
bool AP_SerialLED::set_num_neopixel(uint8_t chan, uint8_t num_leds, bool rgb)
bool AP_SerialLED::set_num_neopixel(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,
rgb ? AP_HAL::RCOutput::MODE_NEOPIXELRGB : AP_HAL::RCOutput::MODE_NEOPIXEL);
return hal.rcout->set_serial_led_num_LEDs(chan-1, num_leds, AP_HAL::RCOutput::MODE_NEOPIXEL);
}
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;
}
Expand Down
4 changes: 3 additions & 1 deletion libraries/AP_SerialLED/AP_SerialLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
class AP_SerialLED {
public:
// set number of LEDs per pin
bool set_num_neopixel(uint8_t chan, uint8_t num_leds, bool rgb = false);
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);
Expand Down

0 comments on commit b8ec902

Please sign in to comment.