AP_Notify: Add an alternate LED scheme

This commit is contained in:
Michael du Breuil 2019-08-29 14:04:17 -07:00 committed by Peter Barker
parent c09d6908ed
commit 8adc6ba3ad
3 changed files with 31 additions and 2 deletions

View File

@ -111,8 +111,8 @@ 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). // @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 // @Values: 0:Standard,1:MAVLink,2:OutbackChallenge,3:TrafficLight
// @User: Advanced // @User: Advanced
AP_GROUPINFO("LED_OVERRIDE", 2, AP_Notify, _rgb_led_override, 0), AP_GROUPINFO("LED_OVERRIDE", 2, AP_Notify, _rgb_led_override, 0),

View File

@ -162,6 +162,30 @@ uint32_t RGBLed::get_colour_sequence(void) const
return sequence_disarmed_bad_gps; return sequence_disarmed_bad_gps;
} }
uint32_t RGBLed::get_colour_sequence_traffic_light(void) const
{
if (AP_Notify::flags.initialising) {
return DEFINE_COLOUR_SEQUENCE(RED,GREEN,BLUE,RED,GREEN,BLUE,RED,GREEN,BLUE,OFF);
}
if (AP_Notify::flags.armed) {
return DEFINE_COLOUR_SEQUENCE_SLOW(RED);
}
if (hal.util->safety_switch_state() != AP_HAL::Util::SAFETY_DISARMED) {
if (!AP_Notify::flags.pre_arm_check) {
return DEFINE_COLOUR_SEQUENCE_ALTERNATE(YELLOW, OFF);
} else {
return DEFINE_COLOUR_SEQUENCE_SLOW(YELLOW);
}
}
if (!AP_Notify::flags.pre_arm_check) {
return DEFINE_COLOUR_SEQUENCE_ALTERNATE(GREEN, OFF);
}
return DEFINE_COLOUR_SEQUENCE_SLOW(GREEN);
}
// update - updates led according to timed_updated. Should be called // update - updates led according to timed_updated. Should be called
// at 50Hz // at 50Hz
void RGBLed::update() void RGBLed::update()
@ -178,6 +202,9 @@ void RGBLed::update()
case obc: case obc:
current_colour_sequence = get_colour_sequence_obc(); current_colour_sequence = get_colour_sequence_obc();
break; break;
case traffic_light:
current_colour_sequence = get_colour_sequence_traffic_light();
break;
} }
const uint8_t brightness = get_brightness(); const uint8_t brightness = get_brightness();

View File

@ -67,6 +67,7 @@ private:
void update_colours(); void update_colours();
uint32_t get_colour_sequence() const; uint32_t get_colour_sequence() const;
uint32_t get_colour_sequence_obc() const; uint32_t get_colour_sequence_obc() const;
uint32_t get_colour_sequence_traffic_light() const;
uint8_t get_brightness(void) const; uint8_t get_brightness(void) const;
@ -108,6 +109,7 @@ private:
standard = 0, standard = 0,
mavlink = 1, mavlink = 1,
obc = 2, obc = 2,
traffic_light = 3,
}; };
rgb_source_t rgb_source() const; rgb_source_t rgb_source() const;