AP_HAL_SITL: return success status from serial_led_send and set_serial_led_rgb_data

This commit is contained in:
Andy Piper 2023-11-17 18:04:48 +00:00 committed by Randy Mackay
parent b5a0db8721
commit 40f687260a
2 changed files with 9 additions and 7 deletions

View File

@ -115,34 +115,36 @@ bool RCOutput::set_serial_led_num_LEDs(const uint16_t chan, uint8_t num_leds, ou
return false;
}
void RCOutput::set_serial_led_rgb_data(const uint16_t chan, int8_t led, uint8_t red, uint8_t green, uint8_t blue)
bool RCOutput::set_serial_led_rgb_data(const uint16_t chan, int8_t led, uint8_t red, uint8_t green, uint8_t blue)
{
if (chan > 15) {
return;
return false;
}
SITL::SIM *sitl = AP::sitl();
if (led == -1) {
for (uint8_t i=0; i < sitl->led.num_leds[chan]; i++) {
set_serial_led_rgb_data(chan, i, red, green, blue);
}
return;
return true;
}
if (led < -1 || led >= sitl->led.num_leds[chan]) {
return;
return false;
}
if (sitl) {
sitl->led.rgb[chan][led].rgb[0] = red;
sitl->led.rgb[chan][led].rgb[1] = green;
sitl->led.rgb[chan][led].rgb[2] = blue;
}
return true;
}
void RCOutput::serial_led_send(const uint16_t chan)
bool RCOutput::serial_led_send(const uint16_t chan)
{
SITL::SIM *sitl = AP::sitl();
if (sitl) {
sitl->led.send_counter++;
}
return true;
}
#endif //CONFIG_HAL_BOARD == HAL_BOARD_SITL

View File

@ -32,8 +32,8 @@ public:
Serial LED emulation
*/
bool set_serial_led_num_LEDs(const uint16_t chan, uint8_t num_leds, output_mode mode = MODE_PWM_NONE, uint32_t clock_mask = 0) override;
void set_serial_led_rgb_data(const uint16_t chan, int8_t led, uint8_t red, uint8_t green, uint8_t blue) override;
void serial_led_send(const uint16_t chan) override;
bool set_serial_led_rgb_data(const uint16_t chan, int8_t led, uint8_t red, uint8_t green, uint8_t blue) override;
bool serial_led_send(const uint16_t chan) override;
private:
SITL_State *_sitlState;