Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Notify: allow split-standard LED pattern on serial LEDs #27829

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/AP_Notify/AP_Notify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down
1 change: 1 addition & 0 deletions libraries/AP_Notify/RGBLed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 11 additions & 9 deletions libraries/AP_Notify/RGBLed.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,17 @@ class RGBLed: public NotifyDevice {
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;
Expand Down Expand Up @@ -105,12 +115,4 @@ class RGBLed: public NotifyDevice {
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;

};
23 changes: 20 additions & 3 deletions libraries/AP_Notify/SerialLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

#include "SerialLED.h"
#include "AP_Notify/AP_Notify.h"

#if AP_NOTIFY_SERIALLED_ENABLED

Expand Down Expand Up @@ -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);
}
}
}
}

Expand Down
1 change: 0 additions & 1 deletion libraries/AP_Notify/SerialLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class SerialLED: public RGBLed {
virtual uint16_t init_ports() { return 0; };

protected:

bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b) override;

private:
Expand Down
Loading