mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_HAL_SITL: return success status from serial_led_send and set_serial_led_rgb_data
This commit is contained in:
parent
a4b543e4ea
commit
7d5b86958b
@ -115,34 +115,36 @@ bool RCOutput::set_serial_led_num_LEDs(const uint16_t chan, uint8_t num_leds, ou
|
|||||||
return false;
|
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) {
|
if (chan > 15) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
SITL::SIM *sitl = AP::sitl();
|
SITL::SIM *sitl = AP::sitl();
|
||||||
if (led == -1) {
|
if (led == -1) {
|
||||||
for (uint8_t i=0; i < sitl->led.num_leds[chan]; i++) {
|
for (uint8_t i=0; i < sitl->led.num_leds[chan]; i++) {
|
||||||
set_serial_led_rgb_data(chan, i, red, green, blue);
|
set_serial_led_rgb_data(chan, i, red, green, blue);
|
||||||
}
|
}
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
if (led < -1 || led >= sitl->led.num_leds[chan]) {
|
if (led < -1 || led >= sitl->led.num_leds[chan]) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (sitl) {
|
if (sitl) {
|
||||||
sitl->led.rgb[chan][led].rgb[0] = red;
|
sitl->led.rgb[chan][led].rgb[0] = red;
|
||||||
sitl->led.rgb[chan][led].rgb[1] = green;
|
sitl->led.rgb[chan][led].rgb[1] = green;
|
||||||
sitl->led.rgb[chan][led].rgb[2] = blue;
|
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();
|
SITL::SIM *sitl = AP::sitl();
|
||||||
if (sitl) {
|
if (sitl) {
|
||||||
sitl->led.send_counter++;
|
sitl->led.send_counter++;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
#endif //CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
||||||
|
@ -32,8 +32,8 @@ public:
|
|||||||
Serial LED emulation
|
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;
|
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;
|
bool 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 serial_led_send(const uint16_t chan) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SITL_State *_sitlState;
|
SITL_State *_sitlState;
|
||||||
|
Loading…
Reference in New Issue
Block a user