mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
AP_Notify: allow external leds to be disabled
This commit is contained in:
parent
e978a710cc
commit
aae18f9ead
@ -20,8 +20,10 @@
|
||||
struct AP_Notify::notify_type AP_Notify::flags;
|
||||
|
||||
// initialisation
|
||||
void AP_Notify::init(void)
|
||||
void AP_Notify::init(bool enable_external_leds)
|
||||
{
|
||||
AP_Notify::flags.external_leds = enable_external_leds;
|
||||
|
||||
boardled.init();
|
||||
toshibaled.init();
|
||||
|
||||
|
@ -42,6 +42,9 @@ public:
|
||||
uint16_t failsafe_radio : 1; // 1 if radio failsafe
|
||||
uint16_t failsafe_battery : 1; // 1 if battery failsafe
|
||||
uint16_t failsafe_gps : 1; // 1 if gps failsafe
|
||||
|
||||
// additional flags
|
||||
uint16_t external_leds : 1; // 1 if external LEDs are enabled (normally only used for copter)
|
||||
};
|
||||
|
||||
// the notify flags are static to allow direct class access
|
||||
@ -49,7 +52,7 @@ public:
|
||||
static struct notify_type flags;
|
||||
|
||||
// initialisation
|
||||
void init(void);
|
||||
void init(bool enable_external_leds);
|
||||
|
||||
/// update - allow updates of leds that cannot be updated during a timed interrupt
|
||||
void update(void);
|
||||
|
@ -22,6 +22,11 @@ extern const AP_HAL::HAL& hal;
|
||||
|
||||
void ExternalLED::init(void)
|
||||
{
|
||||
// return immediately if disabled
|
||||
if (!AP_Notify::flags.external_leds) {
|
||||
return;
|
||||
}
|
||||
|
||||
// setup the main LEDs as outputs
|
||||
hal.gpio->pinMode(EXTERNAL_LED_ARMED, GPIO_OUTPUT);
|
||||
hal.gpio->pinMode(EXTERNAL_LED_GPS, GPIO_OUTPUT);
|
||||
@ -40,6 +45,11 @@ void ExternalLED::init(void)
|
||||
*/
|
||||
void ExternalLED::update(void)
|
||||
{
|
||||
// return immediately if disabled
|
||||
if (!AP_Notify::flags.external_leds) {
|
||||
return;
|
||||
}
|
||||
|
||||
// reduce update rate from 50hz to 10hz
|
||||
_counter++;
|
||||
if (_counter < 5) {
|
||||
|
Loading…
Reference in New Issue
Block a user