AP_Notify: Use a bitfield to load LED drivers
This commit is contained in:
parent
73cfd40e7f
commit
961e16dca9
@ -20,7 +20,7 @@
|
||||
#include "Buzzer.h"
|
||||
#include "Display.h"
|
||||
#include "ExternalLED.h"
|
||||
#include "NavioLED_I2C.h"
|
||||
#include "PCA9685LED_I2C.h"
|
||||
#include "OreoLED_PX4.h"
|
||||
#include "RCOutputRGBLed.h"
|
||||
#include "ToneAlarm_Linux.h"
|
||||
@ -44,6 +44,60 @@ AP_Notify *AP_Notify::_instance;
|
||||
#define TOSHIBA_LED_I2C_BUS_INTERNAL 0
|
||||
#define TOSHIBA_LED_I2C_BUS_EXTERNAL 1
|
||||
|
||||
#ifndef BUILD_DEFAULT_LED_TYPE
|
||||
// PX4 boards
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_PX4_V3 // Has enough memory for Oreo LEDs
|
||||
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | Notify_LED_ToshibaLED_I2C_Internal | Notify_LED_ToshibaLED_I2C_External | Notify_LED_OreoLED)
|
||||
#else // All other px4 boards use standard devices
|
||||
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | Notify_LED_ToshibaLED_I2C_Internal | Notify_LED_ToshibaLED_I2C_External)
|
||||
#endif
|
||||
|
||||
// ChibiOS and VRBrain boards
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS || \
|
||||
CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
|
||||
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | Notify_LED_ToshibaLED_I2C_Internal | Notify_LED_ToshibaLED_I2C_External)
|
||||
|
||||
// Linux boards
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO
|
||||
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | Notify_LED_ToshibaLED_I2C_Internal | Notify_LED_ToshibaLED_I2C_External |\
|
||||
Notify_LED_PCA9685LED_I2C_External)
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2
|
||||
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | Notify_LED_ToshibaLED_I2C_Internal | Notify_LED_ToshibaLED_I2C_External)
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
|
||||
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | Notify_LED_ToshibaLED_I2C_Internal | Notify_LED_ToshibaLED_I2C_External |\
|
||||
Notify_LED_UAVCAN)
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_POCKET || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
|
||||
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board)
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RST_ZYNQ
|
||||
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_ToshibaLED_I2C_External)
|
||||
|
||||
#else // other linux
|
||||
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | Notify_LED_ToshibaLED_I2C_Internal | Notify_LED_ToshibaLED_I2C_External)
|
||||
#endif
|
||||
|
||||
// F4Light
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_F4LIGHT
|
||||
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | Notify_LED_ToshibaLED_I2C_External)
|
||||
|
||||
// All other builds
|
||||
#else
|
||||
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | Notify_LED_ToshibaLED_I2C_Internal | Notify_LED_ToshibaLED_I2C_External)
|
||||
|
||||
#endif // board selection
|
||||
|
||||
#endif // BUILD_DEFAULT_LED_TYPE
|
||||
|
||||
// table of user settable parameters
|
||||
const AP_Param::GroupInfo AP_Notify::var_info[] = {
|
||||
|
||||
@ -94,13 +148,20 @@ const AP_Param::GroupInfo AP_Notify::var_info[] = {
|
||||
AP_GROUPINFO("BUZZ_PIN", 5, AP_Notify, _buzzer_pin, 0),
|
||||
#endif
|
||||
|
||||
// @Param: LED_TYPES
|
||||
// @DisplayName: LED Driver Types
|
||||
// @Description: Controls what types of LEDs will be enabled
|
||||
// @Bitmask: 0:Build in LED, 1:Internal ToshibaLED, 2:External ToshibaLED, 3:External PCA9685, 4:Oreo LED, 5:UAVCAN
|
||||
// @User: Advanced
|
||||
AP_GROUPINFO("LED_TYPES", 6, AP_Notify, _led_type, BUILD_DEFAULT_LED_TYPE),
|
||||
|
||||
AP_GROUPEND
|
||||
};
|
||||
|
||||
// Default constructor
|
||||
AP_Notify::AP_Notify()
|
||||
{
|
||||
AP_Param::setup_object_defaults(this, var_info);
|
||||
AP_Param::setup_object_defaults(this, var_info);
|
||||
if (_instance != nullptr) {
|
||||
AP_HAL::panic("AP_Notify must be singleton");
|
||||
}
|
||||
@ -135,136 +196,105 @@ void AP_Notify::add_backends(void)
|
||||
return;
|
||||
}
|
||||
|
||||
// Notify devices for PX4 boards
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_PX4_V3 // Has enough memory for Oreo LEDs
|
||||
ADD_BACKEND(new AP_BoardLED());
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
||||
ADD_BACKEND(new ToneAlarm_PX4());
|
||||
ADD_BACKEND(new Display());
|
||||
for (uint32_t i = 1; i < 32; i = i << 1) {
|
||||
switch(_led_type & i) {
|
||||
case Notify_LED_None:
|
||||
case Notify_LED_MAX:
|
||||
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
|
||||
ADD_BACKEND(new Led_Sysfs("rgb_led0", "rgb_led2", "rgb_led1"));
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
|
||||
ADD_BACKEND(new RCOutputRGBLedInverted(12, 13, 14));
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH
|
||||
ADD_BACKEND(new RCOutputRGBLed(HAL_RCOUT_RGBLED_RED, HAL_RCOUT_RGBLED_GREEN, HAL_RCOUT_RGBLED_BLUE));
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
|
||||
ADD_BACKEND(new DiscoLED());
|
||||
#endif
|
||||
#endif // CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||
|
||||
// Oreo LED enable/disable by NTF_OREO_THEME parameter
|
||||
if (_oreo_theme) {
|
||||
ADD_BACKEND(new OreoLED_PX4(_oreo_theme));
|
||||
#if defined(HAL_HAVE_PIXRACER_LED)
|
||||
ADD_BACKEND(new PixRacerLED());
|
||||
#elif (defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN) && defined(HAL_GPIO_C_LED_PIN))
|
||||
#if CONFIG_HAL_BOARD != HAL_BOARD_VRBRAIN || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_VRBRAIN_V45
|
||||
ADD_BACKEND(new AP_BoardLED());
|
||||
#else
|
||||
ADD_BACKEND(new VRBoard_LED());
|
||||
#endif // CONFIG_HAL_BOARD != HAL_BOARD_VRBRAIN || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_VRBRAIN_V45
|
||||
#elif (defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN))
|
||||
ADD_BACKEND(new AP_BoardLED2());
|
||||
#endif
|
||||
break;
|
||||
case Notify_LED_ToshibaLED_I2C_Internal:
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
||||
break;
|
||||
case Notify_LED_ToshibaLED_I2C_External:
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
break;
|
||||
case Notify_LED_PCA9685LED_I2C_External:
|
||||
ADD_BACKEND(new PCA9685LED_I2C());
|
||||
break;
|
||||
case Notify_LED_OreoLED:
|
||||
// OreoLED's are PX4-v3 build only
|
||||
#if (CONFIG_HAL_BOARD == HAL_BOARD_PX4) && (CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_PX4_V3)
|
||||
if (_oreo_theme) {
|
||||
ADD_BACKEND(new OreoLED_PX4(_oreo_theme));
|
||||
}
|
||||
#endif // (CONFIG_HAL_BOARD == HAL_BOARD_PX4) && (CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_PX4_V3)
|
||||
break;
|
||||
case Notify_LED_UAVCAN:
|
||||
#if HAL_WITH_UAVCAN
|
||||
ADD_BACKEND(new UAVCAN_RGB_LED(0));
|
||||
#endif // HAL_WITH_UAVCAN
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_PX4_V4 // Has its own LED board
|
||||
ADD_BACKEND(new PixRacerLED());
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
||||
ADD_BACKEND(new ToneAlarm_PX4());
|
||||
|
||||
// Always try and add a display backend
|
||||
ADD_BACKEND(new Display());
|
||||
|
||||
#else // All other px4 boards use standard devices.
|
||||
ADD_BACKEND(new AP_BoardLED());
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
||||
// Add noise making devices
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || \
|
||||
CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
|
||||
ADD_BACKEND(new ToneAlarm_PX4());
|
||||
ADD_BACKEND(new Display());
|
||||
#endif
|
||||
|
||||
// Notify devices for ChibiOS boards
|
||||
// ChibiOS noise makers
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
|
||||
# ifdef HAL_HAVE_PIXRACER_LED
|
||||
ADD_BACKEND(new PixRacerLED());
|
||||
# elif (defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN) && defined(HAL_GPIO_C_LED_PIN))
|
||||
ADD_BACKEND(new AP_BoardLED());
|
||||
#else
|
||||
ADD_BACKEND(new AP_BoardLED2());
|
||||
# endif
|
||||
#ifdef HAL_BUZZER_PIN
|
||||
ADD_BACKEND(new Buzzer());
|
||||
#endif
|
||||
#ifdef HAL_PWM_ALARM
|
||||
ADD_BACKEND(new ToneAlarm_ChibiOS());
|
||||
#endif
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
||||
ADD_BACKEND(new Display());
|
||||
|
||||
// Notify devices for VRBRAIN boards
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_VRBRAIN_V45 // Uses px4 LED board
|
||||
ADD_BACKEND(new AP_BoardLED());
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
||||
ADD_BACKEND(new ToneAlarm_PX4());
|
||||
ADD_BACKEND(new ExternalLED());
|
||||
#else
|
||||
ADD_BACKEND(new VRBoard_LED());
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
||||
ADD_BACKEND(new ToneAlarm_PX4());
|
||||
ADD_BACKEND(new ExternalLED());
|
||||
#endif
|
||||
|
||||
// Notify devices for linux boards
|
||||
// Linux noise makers
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO
|
||||
ADD_BACKEND(new AP_BoardLED());
|
||||
ADD_BACKEND(new NavioLED_I2C());
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2 || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RST_ZYNQ || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE
|
||||
// No noise makers, keep this though to ensure that the final else is safe
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2
|
||||
ADD_BACKEND(new Led_Sysfs("rgb_led0", "rgb_led2", "rgb_led1"));
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
|
||||
ADD_BACKEND(new RCOutputRGBLedInverted(12, 13, 14));
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
||||
ADD_BACKEND(new UAVCAN_RGB_LED(0));
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI
|
||||
ADD_BACKEND(new AP_BoardLED());
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_POCKET
|
||||
ADD_BACKEND(new Buzzer());
|
||||
ADD_BACKEND(new Display());
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE
|
||||
ADD_BACKEND(new AP_BoardLED());
|
||||
ADD_BACKEND(new Display());
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_POCKET
|
||||
ADD_BACKEND(new AP_BoardLED());
|
||||
ADD_BACKEND(new Buzzer());
|
||||
ADD_BACKEND(new Display());
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
|
||||
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI
|
||||
ADD_BACKEND(new AP_BoardLED());
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH
|
||||
ADD_BACKEND(new AP_BoardLED());
|
||||
ADD_BACKEND(new RCOutputRGBLed(HAL_RCOUT_RGBLED_RED, HAL_RCOUT_RGBLED_GREEN, HAL_RCOUT_RGBLED_BLUE));
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
|
||||
ADD_BACKEND(new DiscoLED());
|
||||
ADD_BACKEND(new ToneAlarm_Linux());
|
||||
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RST_ZYNQ
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
|
||||
#else // other linux
|
||||
ADD_BACKEND(new AP_BoardLED());
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
||||
ADD_BACKEND(new ToneAlarm_Linux());
|
||||
#endif
|
||||
|
||||
// F4Light noise makers
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_F4LIGHT
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
ADD_BACKEND(new Display());
|
||||
ADD_BACKEND(new Buzzer());
|
||||
ADD_BACKEND(new AP_BoardLED2()); // needs AP_BoardLED2 in master
|
||||
#else
|
||||
ADD_BACKEND(new AP_BoardLED());
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
||||
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
||||
ADD_BACKEND(new Display());
|
||||
#endif
|
||||
#endif // Noise makers
|
||||
|
||||
}
|
||||
|
||||
// initialisation
|
||||
|
@ -58,6 +58,17 @@ public:
|
||||
OreoLED_Automobile = 2, // Automobile themed lighting (white front, red back)
|
||||
};
|
||||
|
||||
enum Notify_LED_Type {
|
||||
Notify_LED_None = 0, // not enabled
|
||||
Notify_LED_Board = (1 << 0), // Built in board LED's
|
||||
Notify_LED_ToshibaLED_I2C_Internal = (1 << 1), // Internal ToshibaLED_I2C
|
||||
Notify_LED_ToshibaLED_I2C_External = (1 << 2), // External ToshibaLED_I2C
|
||||
Notify_LED_PCA9685LED_I2C_External = (1 << 3), // External PCA9685_I2C
|
||||
Notify_LED_OreoLED = (1 << 4), // Oreo
|
||||
Notify_LED_UAVCAN = (1 << 5), // UAVCAN RGB LED
|
||||
Notify_LED_MAX
|
||||
};
|
||||
|
||||
/// notify_flags_type - bitmask of notification flags
|
||||
struct notify_flags_and_values_type {
|
||||
uint32_t initialising : 1; // 1 if initialising and copter should not be moved
|
||||
@ -159,6 +170,7 @@ private:
|
||||
AP_Int8 _display_type;
|
||||
AP_Int8 _oreo_theme;
|
||||
AP_Int8 _buzzer_pin;
|
||||
AP_Int32 _led_type;
|
||||
|
||||
char _send_text[NOTIFY_TEXT_BUFFER_SIZE];
|
||||
uint32_t _send_text_updated_millis; // last time text changed
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
NavioLED I2C driver
|
||||
PCA9685LED I2C driver
|
||||
*/
|
||||
/*
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@ -15,7 +15,7 @@
|
||||
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 "NavioLED_I2C.h"
|
||||
#include "PCA9685LED_I2C.h"
|
||||
|
||||
#include <AP_HAL/AP_HAL.h>
|
||||
|
||||
@ -29,12 +29,12 @@
|
||||
|
||||
extern const AP_HAL::HAL& hal;
|
||||
|
||||
NavioLED_I2C::NavioLED_I2C() :
|
||||
PCA9685LED_I2C::PCA9685LED_I2C() :
|
||||
RGBLed(NAVIO_LED_OFF, NAVIO_LED_BRIGHT, NAVIO_LED_MEDIUM, NAVIO_LED_DIM)
|
||||
{
|
||||
}
|
||||
|
||||
bool NavioLED_I2C::hw_init()
|
||||
bool PCA9685LED_I2C::hw_init()
|
||||
{
|
||||
_dev = hal.i2c_mgr->get_device(1, PCA9685_ADDRESS);
|
||||
|
||||
@ -42,13 +42,13 @@ bool NavioLED_I2C::hw_init()
|
||||
return false;
|
||||
}
|
||||
|
||||
_dev->register_periodic_callback(20000, FUNCTOR_BIND_MEMBER(&NavioLED_I2C::_timer, void));
|
||||
_dev->register_periodic_callback(20000, FUNCTOR_BIND_MEMBER(&PCA9685LED_I2C::_timer, void));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// set_rgb - set color as a combination of red, green and blue values
|
||||
bool NavioLED_I2C::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue)
|
||||
bool PCA9685LED_I2C::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
rgb.r = red;
|
||||
rgb.g = green;
|
||||
@ -57,7 +57,7 @@ bool NavioLED_I2C::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue)
|
||||
return true;
|
||||
}
|
||||
|
||||
void NavioLED_I2C::_timer(void)
|
||||
void PCA9685LED_I2C::_timer(void)
|
||||
{
|
||||
if (!_need_update) {
|
||||
return;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
NavioLED I2C driver
|
||||
PCA9685LED I2C driver
|
||||
|
||||
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
|
||||
@ -19,10 +19,10 @@
|
||||
#include <AP_HAL/I2CDevice.h>
|
||||
#include "RGBLed.h"
|
||||
|
||||
class NavioLED_I2C : public RGBLed
|
||||
class PCA9685LED_I2C : public RGBLed
|
||||
{
|
||||
public:
|
||||
NavioLED_I2C(void);
|
||||
PCA9685LED_I2C(void);
|
||||
protected:
|
||||
bool hw_init(void) override;
|
||||
bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b) override;
|
Loading…
Reference in New Issue
Block a user