AP_Notify: add handle rgb
This commit is contained in:
parent
f9c4c17ff4
commit
a45041ce5d
@ -113,7 +113,7 @@ const AP_Param::GroupInfo AP_Notify::var_info[] = {
|
||||
// @Param: LED_OVERRIDE
|
||||
// @DisplayName: Specifies colour source for the RGBLed
|
||||
// @Description: Specifies the source for the colours and brightness for the LED. OutbackChallenge conforms to the MedicalExpress (https://uavchallenge.org/medical-express/) rules, essentially "Green" is disarmed (safe-to-approach), "Red" is armed (not safe-to-approach). Traffic light is a simplified color set, red when armed, yellow when the safety switch is not surpressing outputs (but disarmed), and green when outputs are surpressed and disarmed, the LED will blink faster if disarmed and failing arming checks.
|
||||
// @Values: 0:Standard,1:MAVLink,2:OutbackChallenge,3:TrafficLight
|
||||
// @Values: 0:Standard,1:MAVLink/Scripting,2:OutbackChallenge,3:TrafficLight
|
||||
// @User: Advanced
|
||||
AP_GROUPINFO("LED_OVERRIDE", 2, AP_Notify, _rgb_led_override, 0),
|
||||
|
||||
@ -352,6 +352,16 @@ void AP_Notify::handle_led_control(const mavlink_message_t &msg)
|
||||
}
|
||||
}
|
||||
|
||||
// handle RGB from Scripting
|
||||
void AP_Notify::handle_rgb(uint8_t r, uint8_t g, uint8_t b, uint8_t rate_hz)
|
||||
{
|
||||
for (uint8_t i = 0; i < _num_devices; i++) {
|
||||
if (_devices[i] != nullptr) {
|
||||
_devices[i]->rgb_control(r, g, b, rate_hz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// handle a PLAY_TUNE message
|
||||
void AP_Notify::handle_play_tune(const mavlink_message_t &msg)
|
||||
{
|
||||
|
@ -138,6 +138,9 @@ public:
|
||||
// handle a LED_CONTROL message
|
||||
static void handle_led_control(const mavlink_message_t &msg);
|
||||
|
||||
// handle RGB from Scripting
|
||||
static void handle_rgb(uint8_t r, uint8_t g, uint8_t b, uint8_t rate_hz = 0);
|
||||
|
||||
// handle a PLAY_TUNE message
|
||||
static void handle_play_tune(const mavlink_message_t &msg);
|
||||
|
||||
|
@ -23,6 +23,10 @@ public:
|
||||
// play a MML tune
|
||||
virtual void play_tune(const char *tune) {}
|
||||
|
||||
// RGB control
|
||||
// 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) {}
|
||||
|
||||
// this pointer is used to read the parameters relative to devices
|
||||
const AP_Notify *pNotify;
|
||||
};
|
||||
|
@ -281,3 +281,15 @@ void RGBLed::update_override(void)
|
||||
_set_rgb(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
RGB control
|
||||
give RGB and flash rate, used with scripting
|
||||
*/
|
||||
void RGBLed::rgb_control(uint8_t r, uint8_t g, uint8_t b, uint8_t rate_hz)
|
||||
{
|
||||
_led_override.rate_hz = rate_hz;
|
||||
_led_override.r = r;
|
||||
_led_override.g = g;
|
||||
_led_override.b = b;
|
||||
}
|
||||
|
@ -38,7 +38,11 @@ public:
|
||||
|
||||
// handle LED control, only used when LED_OVERRIDE=1
|
||||
virtual void handle_led_control(const mavlink_message_t &msg) override;
|
||||
|
||||
|
||||
// RGB control
|
||||
// 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;
|
||||
|
||||
protected:
|
||||
// methods implemented in hardware specific classes
|
||||
virtual bool hw_init(void) = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user