AP_Notify: stop using linux board subtype in Notify LED setup

... instead have the board definitions define things like we do for ChibiOS
This commit is contained in:
Peter Barker 2024-07-11 12:23:52 +10:00 committed by Andrew Tridgell
parent 55308e6d79
commit 501d0d8759
10 changed files with 74 additions and 20 deletions

View File

@ -287,19 +287,17 @@ void AP_Notify::add_backends(void)
break;
case Notify_LED_Board:
// select the most appropriate built in LED driver type
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2
#if AP_NOTIFY_SYSFS_LED_ENABLED
ADD_BACKEND(NEW_NOTHROW Led_Sysfs("rgb_led0", "rgb_led2", "rgb_led1"));
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
#elif AP_NOTIFY_RCOUTPUTRGBLEDINVERTED_LED_ENABLED
ADD_BACKEND(NEW_NOTHROW RCOutputRGBLedInverted(12, 13, 14));
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH
#elif AP_NOTIFY_RCOUTPUTRGBLED_LED_ENABLED
ADD_BACKEND(NEW_NOTHROW RCOutputRGBLed(HAL_RCOUT_RGBLED_RED, HAL_RCOUT_RGBLED_GREEN, HAL_RCOUT_RGBLED_BLUE));
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
#elif AP_NOTIFY_DISCO_LED_ENABLED
ADD_BACKEND(NEW_NOTHROW DiscoLED());
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR
#elif AP_NOTIFY_NAVIGATOR_LED_ENABLED
ADD_BACKEND(NEW_NOTHROW NavigatorLED());
#endif
#endif // CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#if AP_NOTIFY_EXTERNALLED_ENABLED
ADD_BACKEND(NEW_NOTHROW ExternalLED()); // despite the name this is a built in set of onboard LED's

View File

@ -37,6 +37,14 @@
#define AP_NOTIFY_LP5562_ENABLED 1
#endif
#ifndef AP_NOTIFY_DISCO_LED_ENABLED
#define AP_NOTIFY_DISCO_LED_ENABLED 0
#endif
#ifndef AP_NOTIFY_NAVIGATOR_LED_ENABLED
#define AP_NOTIFY_NAVIGATOR_LED_ENABLED 0
#endif
#ifndef AP_NOTIFY_GPIO_LED_3_ENABLED
#define AP_NOTIFY_GPIO_LED_3_ENABLED 0
#endif
@ -51,6 +59,22 @@
#define AP_NOTIFY_GPIO_LED_RGB_ENABLED 0
#endif
#ifndef AP_NOTIFY_RCOUTPUTRGBLEDINVERTED_LED_ENABLED
#define AP_NOTIFY_RCOUTPUTRGBLEDINVERTED_LED_ENABLED 0
#endif
#ifndef AP_NOTIFY_RCOUTPUTRGBLEDOFF_LED_ENABLED
#define AP_NOTIFY_RCOUTPUTRGBLEDOFF_LED_ENABLED 0
#endif
#ifndef AP_NOTIFY_RCOUTPUTRGBLED_LED_ENABLED
#define AP_NOTIFY_RCOUTPUTRGBLED_LED_ENABLED AP_NOTIFY_RCOUTPUTRGBLEDINVERTED_LED_ENABLED || AP_NOTIFY_RCOUTPUTRGBLEDOFF_LED_ENABLED
#endif
#ifndef AP_NOTIFY_SYSFS_LED_ENABLED
#define AP_NOTIFY_SYSFS_LED_ENABLED 0
#endif
#ifndef AP_NOTIFY_IS31FL3195_ENABLED
#define AP_NOTIFY_IS31FL3195_ENABLED 1
#endif

View File

@ -14,9 +14,13 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AP_Notify_config.h"
#if AP_NOTIFY_DISCO_LED_ENABLED
#include <AP_HAL/AP_HAL.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#include "DiscoLED.h"
#include <AP_HAL_Linux/Led_Sysfs.h>
@ -92,4 +96,4 @@ bool DiscoLED::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue)
return true;
}
#endif
#endif // AP_NOTIFY_DISCO_LED_ENABLED

View File

@ -16,9 +16,12 @@
*/
#pragma once
#include "AP_Notify_config.h"
#if AP_NOTIFY_DISCO_LED_ENABLED
#include <AP_HAL/AP_HAL_Boards.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#include <AP_HAL_Linux/Led_Sysfs.h>
#include <AP_HAL_Linux/PWM_Sysfs.h>
@ -53,4 +56,4 @@ private:
enum led_backend backend;
};
#endif
#endif // AP_NOTIFY_DISCO_LED_ENABLED

View File

@ -14,13 +14,12 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <AP_HAL/AP_HAL.h>
#include "AP_Notify_config.h"
#if AP_NOTIFY_SYSFS_LED_ENABLED
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#include "Led_Sysfs.h"
#include <AP_HAL_Linux/Led_Sysfs.h>
Led_Sysfs::Led_Sysfs(const char *red, const char *green, const char *blue,
uint8_t off_brightness, uint8_t low_brightness, uint8_t medium_brightness, uint8_t high_brightness):
RGBLed(off_brightness, high_brightness, medium_brightness, low_brightness),
@ -47,4 +46,4 @@ bool Led_Sysfs::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue)
return true;
}
#endif
#endif // AP_NOTIFY_SYSFS_LED_ENABLED

View File

@ -16,9 +16,10 @@
*/
#pragma once
#include <AP_HAL/AP_HAL_Boards.h>
#include "AP_Notify_config.h"
#if AP_NOTIFY_SYSFS_LED_ENABLED
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#include <AP_HAL_Linux/Led_Sysfs.h>
#include "RGBLed.h"
@ -39,4 +40,4 @@ private:
Linux::Led_Sysfs green_led;
Linux::Led_Sysfs blue_led;
};
#endif
#endif // AP_NOTIFY_SYSFS_LED_ENABLED

View File

@ -19,6 +19,10 @@
// not used. The data is sent to the neopixel in 24 'SPI bytes', where each
// spi byte is formatted to appear as a single bit of data to the neopixel.
#include "AP_Notify_config.h"
#if AP_NOTIFY_NAVIGATOR_LED_ENABLED
#include <AP_HAL/AP_HAL.h>
#include "AP_Notify/AP_Notify.h"
#include "NavigatorLED.h"
@ -79,3 +83,5 @@ void NavigatorLED::_setup_data(uint8_t red, uint8_t green, uint8_t blue)
_data[16 + i] = (blue & (1<<(7-i))) ? LED_T1 : LED_T0;
}
}
#endif // AP_NOTIFY_NAVIGATOR_LED_ENABLED

View File

@ -14,6 +14,10 @@
*/
#pragma once
#include "AP_Notify_config.h"
#if AP_NOTIFY_NAVIGATOR_LED_ENABLED
#include "RGBLed.h"
#include <AP_Common/AP_Common.h>
@ -30,3 +34,5 @@ private:
void _setup_data(uint8_t red, uint8_t green, uint8_t blue);
AP_HAL::OwnPtr<AP_HAL::SPIDevice> _dev;
};
#endif // AP_NOTIFY_NAVIGATOR_LED_ENABLED

View File

@ -15,6 +15,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AP_Notify_config.h"
#if AP_NOTIFY_RCOUTPUTRGBLED_LED_ENABLED
#include "RCOutputRGBLed.h"
#include <AP_Math/AP_Math.h>
@ -58,10 +62,12 @@ uint16_t RCOutputRGBLed::get_duty_cycle_for_color(const uint8_t color, const uin
return usec_period * color / _led_bright;
}
#if AP_NOTIFY_RCOUTPUTRGBLEDINVERTED_LED_ENABLED
uint16_t RCOutputRGBLedInverted::get_duty_cycle_for_color(const uint8_t color, const uint16_t usec_period) const
{
return usec_period * (255 - color) / _led_bright;
}
#endif // AP_NOTIFY_RCOUTPUTRGBLEDINVERTED_LED_ENABLED
bool RCOutputRGBLed::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue)
@ -91,3 +97,4 @@ bool RCOutputRGBLed::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue)
return true;
}
#endif // AP_NOTIFY_RCOUTPUTRGBLED_LED_ENABLED

View File

@ -2,6 +2,7 @@
#include "RGBLed.h"
#if AP_NOTIFY_RCOUTPUTRGBLED_LED_ENABLED
class RCOutputRGBLed: public RGBLed {
public:
RCOutputRGBLed(uint8_t red_channel, uint8_t green_channel,
@ -20,7 +21,9 @@ private:
uint8_t _green_channel;
uint8_t _blue_channel;
};
#endif // AP_NOTIFY_RCOUTPUTRGBLED_LED_ENABLED
#if AP_NOTIFY_RCOUTPUTRGBLEDINVERTED_LED_ENABLED
class RCOutputRGBLedInverted : public RCOutputRGBLed {
public:
RCOutputRGBLedInverted(uint8_t red_channel, uint8_t green_channel, uint8_t blue_channel)
@ -29,7 +32,9 @@ public:
protected:
virtual uint16_t get_duty_cycle_for_color(const uint8_t color, const uint16_t usec_period) const override;
};
#endif // AP_NOTIFY_RCOUTPUTRGBLEDINVERTED_LED_ENABLED
#if AP_NOTIFY_RCOUTPUTRGBLEDOFF_LED_ENABLED
class RCOutputRGBLedOff : public RCOutputRGBLed {
public:
RCOutputRGBLedOff(uint8_t red_channel, uint8_t green_channel,
@ -45,3 +50,4 @@ public:
return RCOutputRGBLed::hw_set_rgb(_led_off, _led_off, _led_off);
}
};
#endif // AP_NOTIFY_RCOUTPUTRGBLEDOFF_LED_ENABLED