AP_Notify: allow split-standard LED pattern on serial LEDs

This commit is contained in:
Andy Piper 2024-08-12 20:56:35 +01:00
parent ce03fd3ed9
commit 0f497d72ca
5 changed files with 33 additions and 14 deletions

View File

@ -183,7 +183,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/Scripting/AP_Periph,2:OutbackChallenge,3:TrafficLight
// @Values: 0:Standard,1:MAVLink/Scripting/AP_Periph,2:OutbackChallenge,3:TrafficLight,4:Split Standard
// @User: Advanced
AP_GROUPINFO("LED_OVERRIDE", 2, AP_Notify, _rgb_led_override, NOTIFY_LED_OVERRIDE_DEFAULT),

View File

@ -213,6 +213,7 @@ void RGBLed::update()
update_override();
return; // note this is a return not a break!
case Source::standard:
case Source::split_standard:
current_colour_sequence = get_colour_sequence();
break;
case Source::obc:

View File

@ -62,7 +62,17 @@ protected:
uint8_t rate_hz;
uint32_t start_ms;
} _led_override;
enum class Source {
standard = 0,
mavlink = 1,
obc = 2,
traffic_light = 3,
split_standard = 4,
};
Source rgb_source() const;
private:
void update_colours();
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);
uint8_t last_step;
enum class Source {
standard = 0,
mavlink = 1,
obc = 2,
traffic_light = 3,
};
Source rgb_source() const;
};

View File

@ -14,6 +14,7 @@
*/
#include "SerialLED.h"
#include "AP_Notify/AP_Notify.h"
#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;
}
for (uint16_t chan=0; chan<16; chan++) {
if ((1U<<chan) & enable_mask) {
led->set_RGB(chan+1, -1, red, green, blue);
if (rgb_source() != Source::split_standard) {
for (uint16_t chan=0; chan<16; chan++) {
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);
}
}
}
}

View File

@ -37,7 +37,6 @@ public:
virtual uint16_t init_ports() { return 0; };
protected:
bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b) override;
private: