Browse Source

AP_Notify: UAVCAN_RGB_LED: don't init if no UAVCAN backends

This allows us to consider enabling UAVCAN_RGB_LED as a more general
default, as it won't consume one of our limited backend slots if UAVCAN
is not enabled.
c415-sdk
Michael du Breuil 4 years ago committed by Andrew Tridgell
parent
commit
bde695d11f
  1. 8
      libraries/AP_Notify/UAVCAN_RGB_LED.cpp

8
libraries/AP_Notify/UAVCAN_RGB_LED.cpp

@ -45,8 +45,16 @@ UAVCAN_RGB_LED::UAVCAN_RGB_LED(uint8_t led_index, uint8_t led_off, @@ -45,8 +45,16 @@ UAVCAN_RGB_LED::UAVCAN_RGB_LED(uint8_t led_index, uint8_t led_off,
bool UAVCAN_RGB_LED::init()
{
const uint8_t can_num_drivers = AP::can().get_num_drivers();
for (uint8_t i = 0; i < can_num_drivers; i++) {
AP_UAVCAN *uavcan = AP_UAVCAN::get_uavcan(i);
if (uavcan != nullptr) {
return true;
}
}
// no UAVCAN drivers
return false;
}
bool UAVCAN_RGB_LED::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue)

Loading…
Cancel
Save