mirror of https://github.com/ArduPilot/ardupilot
AP_Notify: allow split-standard LED pattern on serial LEDs
This commit is contained in:
parent
ce03fd3ed9
commit
0f497d72ca
|
@ -183,7 +183,7 @@ const AP_Param::GroupInfo AP_Notify::var_info[] = {
|
||||||
// @Param: LED_OVERRIDE
|
// @Param: LED_OVERRIDE
|
||||||
// @DisplayName: Specifies colour source for the RGBLed
|
// @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.
|
// @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/Scripting/AP_Periph,2:OutbackChallenge,3:TrafficLight
|
// @Values: 0:Standard,1:MAVLink/Scripting/AP_Periph,2:OutbackChallenge,3:TrafficLight,4:Split Standard
|
||||||
// @User: Advanced
|
// @User: Advanced
|
||||||
AP_GROUPINFO("LED_OVERRIDE", 2, AP_Notify, _rgb_led_override, NOTIFY_LED_OVERRIDE_DEFAULT),
|
AP_GROUPINFO("LED_OVERRIDE", 2, AP_Notify, _rgb_led_override, NOTIFY_LED_OVERRIDE_DEFAULT),
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,7 @@ void RGBLed::update()
|
||||||
update_override();
|
update_override();
|
||||||
return; // note this is a return not a break!
|
return; // note this is a return not a break!
|
||||||
case Source::standard:
|
case Source::standard:
|
||||||
|
case Source::split_standard:
|
||||||
current_colour_sequence = get_colour_sequence();
|
current_colour_sequence = get_colour_sequence();
|
||||||
break;
|
break;
|
||||||
case Source::obc:
|
case Source::obc:
|
||||||
|
|
|
@ -63,6 +63,16 @@ protected:
|
||||||
uint32_t start_ms;
|
uint32_t start_ms;
|
||||||
} _led_override;
|
} _led_override;
|
||||||
|
|
||||||
|
enum class Source {
|
||||||
|
standard = 0,
|
||||||
|
mavlink = 1,
|
||||||
|
obc = 2,
|
||||||
|
traffic_light = 3,
|
||||||
|
split_standard = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
Source rgb_source() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void update_colours();
|
void update_colours();
|
||||||
uint32_t get_colour_sequence() const;
|
uint32_t get_colour_sequence() const;
|
||||||
|
@ -105,12 +115,4 @@ private:
|
||||||
const uint32_t sequence_disarmed_bad_gps_or_no_location = DEFINE_COLOUR_SEQUENCE_SLOW(BLUE);
|
const uint32_t sequence_disarmed_bad_gps_or_no_location = DEFINE_COLOUR_SEQUENCE_SLOW(BLUE);
|
||||||
|
|
||||||
uint8_t last_step;
|
uint8_t last_step;
|
||||||
enum class Source {
|
|
||||||
standard = 0,
|
|
||||||
mavlink = 1,
|
|
||||||
obc = 2,
|
|
||||||
traffic_light = 3,
|
|
||||||
};
|
|
||||||
Source rgb_source() const;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SerialLED.h"
|
#include "SerialLED.h"
|
||||||
|
#include "AP_Notify/AP_Notify.h"
|
||||||
|
|
||||||
#if AP_NOTIFY_SERIALLED_ENABLED
|
#if AP_NOTIFY_SERIALLED_ENABLED
|
||||||
|
|
||||||
|
@ -42,9 +43,25 @@ bool SerialLED::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint16_t chan=0; chan<16; chan++) {
|
if (rgb_source() != Source::split_standard) {
|
||||||
if ((1U<<chan) & enable_mask) {
|
for (uint16_t chan=0; chan<16; chan++) {
|
||||||
led->set_RGB(chan+1, -1, red, green, blue);
|
if ((1U<<chan) & enable_mask) {
|
||||||
|
led->set_RGB(chan+1, -1, red, green, blue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// switch red and green for half the LEDs in split standard
|
||||||
|
// so that copters can display different armed colours on different sides
|
||||||
|
for (uint16_t chan=0; chan<16; chan++) {
|
||||||
|
const uint8_t led_len = pNotify->get_led_len();
|
||||||
|
if ((1U<<chan) & enable_mask) {
|
||||||
|
for (uint8_t i = 0; i < led_len/2; i++) {
|
||||||
|
led->set_RGB(chan+1, i, red, green, blue);
|
||||||
|
}
|
||||||
|
for (uint8_t i = led_len/2; i < led_len; i++) {
|
||||||
|
led->set_RGB(chan+1, i, green, red, blue);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ public:
|
||||||
virtual uint16_t init_ports() { return 0; };
|
virtual uint16_t init_ports() { return 0; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b) override;
|
bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue