mirror of https://github.com/ArduPilot/ardupilot
AP_Notify: add support for controlling ProfiLED via IOMCU safety pins
This commit is contained in:
parent
d348ffbff9
commit
646e09ebaa
|
@ -42,6 +42,7 @@
|
||||||
#include "ProfiLED.h"
|
#include "ProfiLED.h"
|
||||||
#include "ScriptingLED.h"
|
#include "ScriptingLED.h"
|
||||||
#include "DShotLED.h"
|
#include "DShotLED.h"
|
||||||
|
#include "ProfiLED_IOMCU.h"
|
||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
|
@ -115,7 +116,11 @@ AP_Notify *AP_Notify::_singleton;
|
||||||
#endif // defined (DEFAULT_NTF_LED_TYPES)
|
#endif // defined (DEFAULT_NTF_LED_TYPES)
|
||||||
|
|
||||||
#ifndef DEFAULT_NTF_LED_TYPES
|
#ifndef DEFAULT_NTF_LED_TYPES
|
||||||
#define DEFAULT_NTF_LED_TYPES (Notify_LED_Board | I2C_LEDS)
|
#if HAL_WITH_IO_MCU && AP_IOMCU_PROFILED_SUPPORT_ENABLED
|
||||||
|
#define DEFAULT_NTF_LED_TYPES (Notify_LED_Board | Notify_LED_ProfiLED_IOMCU | I2C_LEDS)
|
||||||
|
#else
|
||||||
|
#define DEFAULT_NTF_LED_TYPES (Notify_LED_Board | I2C_LEDS)
|
||||||
|
#endif
|
||||||
#endif // DEFAULT_NTF_LED_TYPES
|
#endif // DEFAULT_NTF_LED_TYPES
|
||||||
|
|
||||||
#ifndef BUZZER_ENABLE_DEFAULT
|
#ifndef BUZZER_ENABLE_DEFAULT
|
||||||
|
@ -203,7 +208,7 @@ const AP_Param::GroupInfo AP_Notify::var_info[] = {
|
||||||
// @Param: LED_TYPES
|
// @Param: LED_TYPES
|
||||||
// @DisplayName: LED Driver Types
|
// @DisplayName: LED Driver Types
|
||||||
// @Description: Controls what types of LEDs will be enabled
|
// @Description: Controls what types of LEDs will be enabled
|
||||||
// @Bitmask: 0:Built-in LED, 1:Internal ToshibaLED, 2:External ToshibaLED, 3:External PCA9685, 4:Oreo LED, 5:DroneCAN, 6:NCP5623 External, 7:NCP5623 Internal, 8:NeoPixel, 9:ProfiLED, 10:Scripting, 11:DShot, 12:ProfiLED_SPI, 13:LP5562 External, 14: LP5562 Internal, 15:IS31FL3195 External, 16: IS31FL3195 Internal, 17: DiscreteRGB, 18: NeoPixelRGB
|
// @Bitmask: 0:Built-in LED, 1:Internal ToshibaLED, 2:External ToshibaLED, 3:External PCA9685, 4:Oreo LED, 5:DroneCAN, 6:NCP5623 External, 7:NCP5623 Internal, 8:NeoPixel, 9:ProfiLED, 10:Scripting, 11:DShot, 12:ProfiLED_SPI, 13:LP5562 External, 14: LP5562 Internal, 15:IS31FL3195 External, 16: IS31FL3195 Internal, 17: DiscreteRGB, 18: NeoPixelRGB, 19:ProfiLED_IOMCU
|
||||||
// @User: Advanced
|
// @User: Advanced
|
||||||
AP_GROUPINFO("LED_TYPES", 6, AP_Notify, _led_type, DEFAULT_NTF_LED_TYPES),
|
AP_GROUPINFO("LED_TYPES", 6, AP_Notify, _led_type, DEFAULT_NTF_LED_TYPES),
|
||||||
|
|
||||||
|
@ -368,6 +373,11 @@ void AP_Notify::add_backends(void)
|
||||||
ADD_BACKEND(NEW_NOTHROW DShotLED());
|
ADD_BACKEND(NEW_NOTHROW DShotLED());
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
#if HAL_WITH_IO_MCU && AP_IOMCU_PROFILED_SUPPORT_ENABLED
|
||||||
|
case Notify_LED_ProfiLED_IOMCU:
|
||||||
|
ADD_BACKEND(NEW_NOTHROW ProfiLED_IOMCU());
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
#if AP_NOTIFY_LP5562_ENABLED
|
#if AP_NOTIFY_LP5562_ENABLED
|
||||||
case Notify_LED_LP5562_I2C_External:
|
case Notify_LED_LP5562_I2C_External:
|
||||||
FOREACH_I2C_EXTERNAL(b) {
|
FOREACH_I2C_EXTERNAL(b) {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <AP_Common/AP_Common.h>
|
#include <AP_Common/AP_Common.h>
|
||||||
#include <AP_Param/AP_Param.h>
|
#include <AP_Param/AP_Param.h>
|
||||||
#include "AP_Notify_config.h"
|
#include "AP_Notify_config.h"
|
||||||
|
#include <AP_IOMCU/AP_IOMCU.h>
|
||||||
|
|
||||||
#include "NotifyDevice.h"
|
#include "NotifyDevice.h"
|
||||||
|
|
||||||
|
@ -97,6 +98,9 @@ public:
|
||||||
#endif
|
#endif
|
||||||
#if AP_NOTIFY_NEOPIXEL_ENABLED
|
#if AP_NOTIFY_NEOPIXEL_ENABLED
|
||||||
Notify_LED_NeoPixelRGB = (1 << 18), // NeoPixel AdaFruit 4544 Worldsemi WS2811
|
Notify_LED_NeoPixelRGB = (1 << 18), // NeoPixel AdaFruit 4544 Worldsemi WS2811
|
||||||
|
#endif
|
||||||
|
#if HAL_WITH_IO_MCU && AP_IOMCU_PROFILED_SUPPORT_ENABLED
|
||||||
|
Notify_LED_ProfiLED_IOMCU = (1 << 19), // ProfiLED IOMCU
|
||||||
#endif
|
#endif
|
||||||
Notify_LED_MAX
|
Notify_LED_MAX
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "RGBLed.h"
|
||||||
|
#include <AP_Common/AP_Common.h>
|
||||||
|
#include <AP_IOMCU/AP_IOMCU.h>
|
||||||
|
|
||||||
|
#if HAL_WITH_IO_MCU && AP_IOMCU_PROFILED_SUPPORT_ENABLED
|
||||||
|
|
||||||
|
class ProfiLED_IOMCU : public RGBLed {
|
||||||
|
public:
|
||||||
|
ProfiLED_IOMCU() : RGBLed(0, 0xFF, 0x7F, 0x33) {}
|
||||||
|
|
||||||
|
bool init(void) override { return true; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b) override {
|
||||||
|
const auto iomcu = AP::iomcu();
|
||||||
|
if (iomcu == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
iomcu->set_profiled(r, g, b);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue