diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index 0559fd9669..b103f13168 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -42,6 +42,7 @@ #include "ProfiLED.h" #include "ScriptingLED.h" #include "DShotLED.h" +#include "ProfiLED_IOMCU.h" extern const AP_HAL::HAL& hal; @@ -115,7 +116,11 @@ AP_Notify *AP_Notify::_singleton; #endif // defined (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 #ifndef BUZZER_ENABLE_DEFAULT @@ -203,7 +208,7 @@ const AP_Param::GroupInfo AP_Notify::var_info[] = { // @Param: LED_TYPES // @DisplayName: LED Driver Types // @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 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()); break; #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 case Notify_LED_LP5562_I2C_External: FOREACH_I2C_EXTERNAL(b) { diff --git a/libraries/AP_Notify/AP_Notify.h b/libraries/AP_Notify/AP_Notify.h index 5467dfc0df..3f3cf9507e 100644 --- a/libraries/AP_Notify/AP_Notify.h +++ b/libraries/AP_Notify/AP_Notify.h @@ -17,6 +17,7 @@ #include #include #include "AP_Notify_config.h" +#include #include "NotifyDevice.h" @@ -97,6 +98,9 @@ public: #endif #if AP_NOTIFY_NEOPIXEL_ENABLED 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 Notify_LED_MAX }; diff --git a/libraries/AP_Notify/ProfiLED_IOMCU.h b/libraries/AP_Notify/ProfiLED_IOMCU.h new file mode 100644 index 0000000000..ae4a9e0124 --- /dev/null +++ b/libraries/AP_Notify/ProfiLED_IOMCU.h @@ -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 . + */ +#pragma once + +#include "RGBLed.h" +#include +#include + +#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 \ No newline at end of file