AP_Periph: Add alternate ordering of NCP5623 LED colors

This commit is contained in:
Phillip Kocmoud 2020-12-11 21:19:28 -06:00 committed by Andrew Tridgell
parent 7449b3eea4
commit ce87b62dcc
4 changed files with 22 additions and 3 deletions

View File

@ -13,7 +13,7 @@
#include "../AP_Bootloader/app_comms.h" #include "../AP_Bootloader/app_comms.h"
#include "hwing_esc.h" #include "hwing_esc.h"
#if defined(HAL_PERIPH_NEOPIXEL_COUNT) || defined(HAL_PERIPH_ENABLE_NCP5623_LED) #if defined(HAL_PERIPH_NEOPIXEL_COUNT) || defined(HAL_PERIPH_ENABLE_NCP5623_LED) || defined(HAL_PERIPH_ENABLE_NCP5623_BGR_LED)
#define AP_PERIPH_HAVE_LED #define AP_PERIPH_HAVE_LED
#endif #endif

View File

@ -550,6 +550,25 @@ static void set_rgb_led(uint8_t red, uint8_t green, uint8_t blue)
dev->transfer(&v, 1, nullptr, 0); dev->transfer(&v, 1, nullptr, 0);
} }
#endif // HAL_PERIPH_ENABLE_NCP5623_LED #endif // HAL_PERIPH_ENABLE_NCP5623_LED
#ifdef HAL_PERIPH_ENABLE_NCP5623_BGR_LED
{
const uint8_t i2c_address = 0x38;
static AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev;
if (!dev) {
dev = std::move(hal.i2c_mgr->get_device(0, i2c_address));
}
WITH_SEMAPHORE(dev->get_semaphore());
dev->set_retries(0);
uint8_t v = 0x3f; // enable LED
dev->transfer(&v, 1, nullptr, 0);
v = 0x40 | blue >> 3; // blue
dev->transfer(&v, 1, nullptr, 0);
v = 0x60 | green >> 3; // green
dev->transfer(&v, 1, nullptr, 0);
v = 0x80 | red >> 3; // red
dev->transfer(&v, 1, nullptr, 0);
}
#endif // HAL_PERIPH_ENABLE_NCP5623_BGR_LED
} }
/* /*

View File

@ -15,7 +15,7 @@ BARO DPS280 I2C:0:0x77
# GPS+MAG+LED+Baro # GPS+MAG+LED+Baro
define HAL_PERIPH_ENABLE_GPS define HAL_PERIPH_ENABLE_GPS
define HAL_PERIPH_ENABLE_MAG define HAL_PERIPH_ENABLE_MAG
define HAL_PERIPH_ENABLE_NCP5623_LED define HAL_PERIPH_ENABLE_NCP5623_BGR_LED
define HAL_PERIPH_ENABLE_BARO define HAL_PERIPH_ENABLE_BARO
# I2C Airspeed sensor must use a different address than 0x77 # I2C Airspeed sensor must use a different address than 0x77
define HAL_PERIPH_ENABLE_AIRSPEED define HAL_PERIPH_ENABLE_AIRSPEED

View File

@ -18,7 +18,7 @@ BARO DPS280 I2C:0:0x77
# GPS+MAG+LED+Baro # GPS+MAG+LED+Baro
define HAL_PERIPH_ENABLE_GPS define HAL_PERIPH_ENABLE_GPS
define HAL_PERIPH_ENABLE_MAG define HAL_PERIPH_ENABLE_MAG
define HAL_PERIPH_ENABLE_NCP5623_LED define HAL_PERIPH_ENABLE_NCP5623_BGR_LED
define HAL_PERIPH_ENABLE_BARO define HAL_PERIPH_ENABLE_BARO
# Optional I2C Airspeed sensor connected to I2C connector # Optional I2C Airspeed sensor connected to I2C connector