AP_Notify: use existing method for setting rgb and rate

This commit is contained in:
Peter Barker 2022-10-20 19:28:01 +11:00 committed by Peter Barker
parent 69b23eea14
commit 56c4794700
2 changed files with 7 additions and 15 deletions

View File

@ -241,21 +241,13 @@ void RGBLed::handle_led_control(const mavlink_message_t &msg)
_led_override.start_ms = AP_HAL::millis(); _led_override.start_ms = AP_HAL::millis();
uint8_t rate_hz = 0;
switch (packet.custom_len) { switch (packet.custom_len) {
case 3:
_led_override.rate_hz = 0;
_led_override.r = packet.custom_bytes[0];
_led_override.g = packet.custom_bytes[1];
_led_override.b = packet.custom_bytes[2];
break;
case 4: case 4:
_led_override.rate_hz = packet.custom_bytes[3]; rate_hz = packet.custom_bytes[3];
_led_override.r = packet.custom_bytes[0]; FALLTHROUGH;
_led_override.g = packet.custom_bytes[1]; case 3:
_led_override.b = packet.custom_bytes[2]; rgb_control(packet.custom_bytes[0], packet.custom_bytes[1], packet.custom_bytes[2], rate_hz);
break;
default:
// not understood
break; break;
} }
} }

View File

@ -26,7 +26,7 @@ public:
RGBLed(uint8_t led_off, uint8_t led_bright, uint8_t led_medium, uint8_t led_dim); RGBLed(uint8_t led_off, uint8_t led_bright, uint8_t led_medium, uint8_t led_dim);
// set_rgb - set color as a combination of red, green and blue levels from 0 ~ 15 // set_rgb - set color as a combination of red, green and blue levels from 0 ~ 15
virtual void set_rgb(uint8_t red, uint8_t green, uint8_t blue); void set_rgb(uint8_t red, uint8_t green, uint8_t blue);
// update - updates led according to timed_updated. Should be // update - updates led according to timed_updated. Should be
// called at 50Hz // called at 50Hz
@ -37,7 +37,7 @@ public:
// RGB control // RGB control
// give RGB and flash rate, used with scripting // give RGB and flash rate, used with scripting
virtual void rgb_control(uint8_t r, uint8_t g, uint8_t b, uint8_t rate_hz) override; void rgb_control(uint8_t r, uint8_t g, uint8_t b, uint8_t rate_hz) override;
protected: protected:
// methods implemented in hardware specific classes // methods implemented in hardware specific classes