AP_Notify: gate mavlink access on HAL_GCS_ENABLED

via AP_NOTIFY_MAVLINK_LED_CONTROL_SUPPORT_ENABLED
This commit is contained in:
Peter Barker 2022-10-21 22:48:51 +11:00 committed by Peter Barker
parent eead037513
commit c136257a3a
8 changed files with 18 additions and 0 deletions

View File

@ -412,6 +412,7 @@ void AP_Notify::update(void)
memset(&AP_Notify::events, 0, sizeof(AP_Notify::events));
}
#if AP_NOTIFY_MAVLINK_LED_CONTROL_SUPPORT_ENABLED
// handle a LED_CONTROL message
void AP_Notify::handle_led_control(const mavlink_message_t &msg)
{
@ -421,6 +422,7 @@ void AP_Notify::handle_led_control(const mavlink_message_t &msg)
}
}
}
#endif
// handle RGB from Scripting or AP_Periph
void AP_Notify::handle_rgb(uint8_t r, uint8_t g, uint8_t b, uint8_t rate_hz)

View File

@ -151,8 +151,10 @@ public:
/// update - allow updates of leds that cannot be updated during a timed interrupt
void update(void);
#if AP_NOTIFY_MAVLINK_LED_CONTROL_SUPPORT_ENABLED
// handle a LED_CONTROL message
static void handle_led_control(const mavlink_message_t &msg);
#endif
// handle RGB from Scripting or AP_Periph
static void handle_rgb(uint8_t r, uint8_t g, uint8_t b, uint8_t rate_hz = 0);

View File

@ -8,3 +8,7 @@
#ifndef AP_NOTIFY_MAVLINK_PLAY_TUNE_SUPPORT_ENABLED
#define AP_NOTIFY_MAVLINK_PLAY_TUNE_SUPPORT_ENABLED HAL_GCS_ENABLED
#endif
#ifndef AP_NOTIFY_MAVLINK_LED_CONTROL_SUPPORT_ENABLED
#define AP_NOTIFY_MAVLINK_LED_CONTROL_SUPPORT_ENABLED HAL_GCS_ENABLED
#endif

View File

@ -14,8 +14,10 @@ public:
// called at 50Hz
virtual void update() = 0;
#if AP_NOTIFY_MAVLINK_LED_CONTROL_SUPPORT_ENABLED
// handle a LED_CONTROL message, by default device ignore message
virtual void handle_led_control(const mavlink_message_t &msg) {}
#endif
// play a MML tune
virtual void play_tune(const char *tune) {}

View File

@ -561,6 +561,7 @@ void OreoLED_I2C::send_sync(void)
#if AP_NOTIFY_MAVLINK_LED_CONTROL_SUPPORT_ENABLED
// Handle an LED_CONTROL mavlink message
void OreoLED_I2C::handle_led_control(const mavlink_message_t &msg)
{
@ -645,6 +646,7 @@ void OreoLED_I2C::handle_led_control(const mavlink_message_t &msg)
}
_pattern_override = packet.pattern;
}
#endif
OreoLED_I2C::oreo_state::oreo_state()
{

View File

@ -41,8 +41,10 @@ public:
// called at 50Hz
void update() override;
#if AP_NOTIFY_MAVLINK_LED_CONTROL_SUPPORT_ENABLED
// handle a LED_CONTROL message, by default device ignore message
void handle_led_control(const mavlink_message_t &msg) override;
#endif
private:
enum oreoled_pattern {

View File

@ -225,6 +225,7 @@ void RGBLed::update()
set_rgb(red_des, green_des, blue_des);
}
#if AP_NOTIFY_MAVLINK_LED_CONTROL_SUPPORT_ENABLED
/*
handle LED control, only used when LED_OVERRIDE=1
*/
@ -251,6 +252,7 @@ void RGBLed::handle_led_control(const mavlink_message_t &msg)
break;
}
}
#endif
/*
update LED when in override mode

View File

@ -32,8 +32,10 @@ public:
// called at 50Hz
virtual void update() override;
#if AP_NOTIFY_MAVLINK_LED_CONTROL_SUPPORT_ENABLED
// handle LED control, only used when LED_OVERRIDE=1
virtual void handle_led_control(const mavlink_message_t &msg) override;
#endif
// RGB control
// give RGB and flash rate, used with scripting