Merge remote-tracking branch 'cleanflight/master' into cleanflight-throttle-led
This commit is contained in:
commit
16871c7a91
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "build_config.h"
|
||||
|
||||
#include "common/color.h"
|
||||
#include "common/axis.h"
|
||||
#include "flight/flight.h"
|
||||
|
||||
|
@ -98,7 +99,7 @@ void mixerUseConfigs(servoParam_t *servoConfToUse, flight3DConfig_t *flight3DCon
|
|||
master_t masterConfig; // master config struct with data independent from profiles
|
||||
profile_t *currentProfile; // profile config struct
|
||||
|
||||
static const uint8_t EEPROM_CONF_VERSION = 78;
|
||||
static const uint8_t EEPROM_CONF_VERSION = 79;
|
||||
|
||||
static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
|
||||
{
|
||||
|
@ -376,6 +377,7 @@ static void resetConf(void)
|
|||
masterConfig.customMixer[i].throttle = 0.0f;
|
||||
|
||||
#ifdef LED_STRIP
|
||||
applyDefaultColors(masterConfig.colors, CONFIGURABLE_COLOR_COUNT);
|
||||
applyDefaultLedStripConfig(masterConfig.ledConfigs);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -74,7 +74,10 @@ typedef struct master_t {
|
|||
|
||||
telemetryConfig_t telemetryConfig;
|
||||
|
||||
#ifdef LED_STRIP
|
||||
ledConfig_t ledConfigs[MAX_LED_STRIP_LENGTH];
|
||||
hsvColor_t colors[CONFIGURABLE_COLOR_COUNT];
|
||||
#endif
|
||||
|
||||
profile_t profile[3]; // 3 separate profiles
|
||||
uint8_t current_profile_index; // currently loaded profile
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
// FIXME remove dependency on currentProfile and masterConfig globals and clean up include file list.
|
||||
|
||||
#include "common/color.h"
|
||||
|
||||
#include "flight/flight.h"
|
||||
#include "sensors/sensors.h"
|
||||
#include "sensors/acceleration.h"
|
||||
|
|
|
@ -47,39 +47,156 @@
|
|||
|
||||
#include "io/ledstrip.h"
|
||||
|
||||
static bool configured = false;
|
||||
static bool ledStripInitialised = false;
|
||||
static failsafe_t* failsafe;
|
||||
|
||||
#if MAX_LED_STRIP_LENGTH > WS2811_LED_STRIP_LENGTH
|
||||
#error "Led strip length must match driver"
|
||||
#endif
|
||||
|
||||
static hsvColor_t *colors;
|
||||
|
||||
//#define USE_LED_ANIMATION
|
||||
|
||||
// H S V
|
||||
#define LED_WHITE { 0, 255, 255}
|
||||
#define LED_BLACK { 0, 0, 0}
|
||||
#define LED_WHITE { 0, 255, 255}
|
||||
#define LED_RED { 0, 0, 255}
|
||||
#define LED_ORANGE { 30, 0, 255}
|
||||
#define LED_YELLOW { 60, 0, 255}
|
||||
#define LED_LIME_GREEN { 90, 0, 255}
|
||||
#define LED_GREEN {120, 0, 255}
|
||||
#define LED_MINT_GREEN {150, 0, 255}
|
||||
#define LED_CYAN {180, 0, 255}
|
||||
#define LED_LIGHT_BLUE {210, 0, 255}
|
||||
#define LED_BLUE {240, 0, 255}
|
||||
#define LED_DARK_MAGENTA {300, 0, 128}
|
||||
#define LED_PINK {300, 0, 255}
|
||||
#define LED_DARK_VIOLET {270, 0, 255}
|
||||
#define LED_MAGENTA {300, 0, 255}
|
||||
#define LED_DEEP_PINK {330, 0, 255}
|
||||
|
||||
const hsvColor_t hsv_black = LED_BLACK;
|
||||
const hsvColor_t hsv_white = LED_WHITE;
|
||||
const hsvColor_t hsv_red = LED_RED;
|
||||
const hsvColor_t hsv_orange = LED_ORANGE;
|
||||
const hsvColor_t hsv_green = LED_GREEN;
|
||||
const hsvColor_t hsv_blue = LED_BLUE;
|
||||
const hsvColor_t hsv_lightBlue = LED_LIGHT_BLUE;
|
||||
const hsvColor_t hsv_limeGreen = LED_LIME_GREEN;
|
||||
const hsvColor_t hsv_black = LED_BLACK;
|
||||
const hsvColor_t hsv_white = LED_WHITE;
|
||||
const hsvColor_t hsv_red = LED_RED;
|
||||
const hsvColor_t hsv_orange = LED_ORANGE;
|
||||
const hsvColor_t hsv_yellow = LED_YELLOW;
|
||||
const hsvColor_t hsv_limeGreen = LED_LIME_GREEN;
|
||||
const hsvColor_t hsv_green = LED_GREEN;
|
||||
const hsvColor_t hsv_mintGreen = LED_MINT_GREEN;
|
||||
const hsvColor_t hsv_cyan = LED_CYAN;
|
||||
const hsvColor_t hsv_lightBlue = LED_LIGHT_BLUE;
|
||||
const hsvColor_t hsv_blue = LED_BLUE;
|
||||
const hsvColor_t hsv_darkViolet = LED_DARK_VIOLET;
|
||||
const hsvColor_t hsv_magenta = LED_MAGENTA;
|
||||
const hsvColor_t hsv_deepPink = LED_DEEP_PINK;
|
||||
|
||||
#define LED_DIRECTION_COUNT 6
|
||||
|
||||
const hsvColor_t * const defaultColors[] = {
|
||||
&hsv_black,
|
||||
&hsv_white,
|
||||
&hsv_red,
|
||||
&hsv_orange,
|
||||
&hsv_yellow,
|
||||
&hsv_limeGreen,
|
||||
&hsv_green,
|
||||
&hsv_mintGreen,
|
||||
&hsv_cyan,
|
||||
&hsv_lightBlue,
|
||||
&hsv_blue,
|
||||
&hsv_darkViolet,
|
||||
&hsv_magenta,
|
||||
&hsv_deepPink
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
COLOR_BLACK = 0,
|
||||
COLOR_WHITE,
|
||||
COLOR_RED,
|
||||
COLOR_ORANGE,
|
||||
COLOR_YELLOW,
|
||||
COLOR_LIME_GREEN,
|
||||
COLOR_GREEN,
|
||||
COLOR_MINT_GREEN,
|
||||
COLOR_CYAN,
|
||||
COLOR_LIGHT_BLUE,
|
||||
COLOR_BLUE,
|
||||
COLOR_DARK_VIOLET,
|
||||
COLOR_MAGENTA,
|
||||
COLOR_DEEP_PINK,
|
||||
} colorIds;
|
||||
|
||||
typedef enum {
|
||||
DIRECTION_NORTH = 0,
|
||||
DIRECTION_EAST,
|
||||
DIRECTION_SOUTH,
|
||||
DIRECTION_WEST,
|
||||
DIRECTION_UP,
|
||||
DIRECTION_DOWN
|
||||
} directionId_e;
|
||||
|
||||
typedef struct modeColorIndexes_s {
|
||||
uint8_t north;
|
||||
uint8_t east;
|
||||
uint8_t south;
|
||||
uint8_t west;
|
||||
uint8_t up;
|
||||
uint8_t down;
|
||||
} modeColorIndexes_t;
|
||||
|
||||
|
||||
static const modeColorIndexes_t orientationModeColors = {
|
||||
COLOR_WHITE,
|
||||
COLOR_DARK_VIOLET,
|
||||
COLOR_RED,
|
||||
COLOR_DEEP_PINK,
|
||||
COLOR_BLUE,
|
||||
COLOR_ORANGE
|
||||
};
|
||||
|
||||
static const modeColorIndexes_t headfreeModeColors = {
|
||||
COLOR_LIME_GREEN,
|
||||
COLOR_DARK_VIOLET,
|
||||
COLOR_ORANGE,
|
||||
COLOR_DEEP_PINK,
|
||||
COLOR_BLUE,
|
||||
COLOR_ORANGE
|
||||
};
|
||||
|
||||
static const modeColorIndexes_t horizonModeColors = {
|
||||
COLOR_BLUE,
|
||||
COLOR_DARK_VIOLET,
|
||||
COLOR_YELLOW,
|
||||
COLOR_DEEP_PINK,
|
||||
COLOR_BLUE,
|
||||
COLOR_ORANGE
|
||||
};
|
||||
|
||||
static const modeColorIndexes_t angleModeColors = {
|
||||
COLOR_CYAN,
|
||||
COLOR_DARK_VIOLET,
|
||||
COLOR_YELLOW,
|
||||
COLOR_DEEP_PINK,
|
||||
COLOR_BLUE,
|
||||
COLOR_ORANGE
|
||||
};
|
||||
|
||||
static const modeColorIndexes_t magModeColors = {
|
||||
COLOR_MINT_GREEN,
|
||||
COLOR_DARK_VIOLET,
|
||||
COLOR_ORANGE,
|
||||
COLOR_DEEP_PINK,
|
||||
COLOR_BLUE,
|
||||
COLOR_ORANGE
|
||||
};
|
||||
|
||||
static const modeColorIndexes_t baroModeColors = {
|
||||
COLOR_LIGHT_BLUE,
|
||||
COLOR_DARK_VIOLET,
|
||||
COLOR_RED,
|
||||
COLOR_DEEP_PINK,
|
||||
COLOR_BLUE,
|
||||
COLOR_ORANGE
|
||||
};
|
||||
|
||||
|
||||
uint8_t ledGridWidth;
|
||||
|
@ -323,114 +440,32 @@ uint32_t nextWarningFlashAt = 0;
|
|||
#define LED_STRIP_10HZ ((1000 * 1000) / 10)
|
||||
#define LED_STRIP_5HZ ((1000 * 1000) / 5)
|
||||
|
||||
#define LED_DIRECTION_COUNT 6
|
||||
|
||||
struct modeColors_s {
|
||||
hsvColor_t north;
|
||||
hsvColor_t east;
|
||||
hsvColor_t south;
|
||||
hsvColor_t west;
|
||||
hsvColor_t up;
|
||||
hsvColor_t down;
|
||||
};
|
||||
|
||||
typedef union {
|
||||
hsvColor_t raw[LED_DIRECTION_COUNT];
|
||||
struct modeColors_s colors;
|
||||
} modeColors_t;
|
||||
|
||||
static const modeColors_t orientationModeColors = {
|
||||
.raw = {
|
||||
LED_WHITE,
|
||||
LED_DARK_VIOLET,
|
||||
LED_RED,
|
||||
LED_DEEP_PINK,
|
||||
LED_BLUE,
|
||||
LED_ORANGE
|
||||
}
|
||||
};
|
||||
|
||||
static const modeColors_t headfreeModeColors = {
|
||||
.raw = {
|
||||
LED_LIME_GREEN,
|
||||
LED_DARK_VIOLET,
|
||||
LED_ORANGE,
|
||||
LED_DEEP_PINK,
|
||||
LED_BLUE,
|
||||
LED_ORANGE
|
||||
}
|
||||
};
|
||||
|
||||
static const modeColors_t horizonModeColors = {
|
||||
.raw = {
|
||||
LED_BLUE,
|
||||
LED_DARK_VIOLET,
|
||||
LED_YELLOW,
|
||||
LED_DEEP_PINK,
|
||||
LED_BLUE,
|
||||
LED_ORANGE
|
||||
}
|
||||
};
|
||||
|
||||
static const modeColors_t angleModeColors = {
|
||||
.raw = {
|
||||
LED_CYAN,
|
||||
LED_DARK_VIOLET,
|
||||
LED_YELLOW,
|
||||
LED_DEEP_PINK,
|
||||
LED_BLUE,
|
||||
LED_ORANGE
|
||||
}
|
||||
};
|
||||
|
||||
static const modeColors_t magModeColors = {
|
||||
.raw = {
|
||||
LED_PINK,
|
||||
LED_DARK_VIOLET,
|
||||
LED_ORANGE,
|
||||
LED_DEEP_PINK,
|
||||
LED_BLUE,
|
||||
LED_ORANGE
|
||||
}
|
||||
};
|
||||
|
||||
static const modeColors_t baroModeColors = {
|
||||
.raw = {
|
||||
LED_LIGHT_BLUE,
|
||||
LED_DARK_VIOLET,
|
||||
LED_RED,
|
||||
LED_DEEP_PINK,
|
||||
LED_BLUE,
|
||||
LED_ORANGE
|
||||
}
|
||||
};
|
||||
|
||||
void applyDirectionalModeColor(const uint8_t ledIndex, const ledConfig_t *ledConfig, const modeColors_t *modeColors)
|
||||
void applyDirectionalModeColor(const uint8_t ledIndex, const ledConfig_t *ledConfig, const modeColorIndexes_t *modeColors)
|
||||
{
|
||||
// apply up/down colors regardless of quadrant.
|
||||
if ((ledConfig->flags & LED_DIRECTION_UP)) {
|
||||
setLedHsv(ledIndex, &modeColors->colors.up);
|
||||
setLedHsv(ledIndex, &colors[modeColors->up]);
|
||||
}
|
||||
|
||||
if ((ledConfig->flags & LED_DIRECTION_DOWN)) {
|
||||
setLedHsv(ledIndex, &modeColors->colors.down);
|
||||
setLedHsv(ledIndex, &colors[modeColors->down]);
|
||||
}
|
||||
|
||||
// override with n/e/s/w colors to each n/s e/w half - bail at first match.
|
||||
if ((ledConfig->flags & LED_DIRECTION_WEST) && GET_LED_X(ledConfig) <= highestXValueForWest) {
|
||||
setLedHsv(ledIndex, &modeColors->colors.west);
|
||||
setLedHsv(ledIndex, &colors[modeColors->west]);
|
||||
}
|
||||
|
||||
if ((ledConfig->flags & LED_DIRECTION_EAST) && GET_LED_X(ledConfig) >= lowestXValueForEast) {
|
||||
setLedHsv(ledIndex, &modeColors->colors.east);
|
||||
setLedHsv(ledIndex, &colors[modeColors->east]);
|
||||
}
|
||||
|
||||
if ((ledConfig->flags & LED_DIRECTION_NORTH) && GET_LED_Y(ledConfig) <= highestYValueForNorth) {
|
||||
setLedHsv(ledIndex, &modeColors->colors.north);
|
||||
setLedHsv(ledIndex, &colors[modeColors->north]);
|
||||
}
|
||||
|
||||
if ((ledConfig->flags & LED_DIRECTION_SOUTH) && GET_LED_Y(ledConfig) >= lowestYValueForSouth) {
|
||||
setLedHsv(ledIndex, &modeColors->colors.south);
|
||||
setLedHsv(ledIndex, &colors[modeColors->south]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -661,7 +696,7 @@ static void applyLedAnimationLayer(void)
|
|||
|
||||
void updateLedStrip(void)
|
||||
{
|
||||
if (!(configured && isWS2811LedStripReady())) {
|
||||
if (!(ledStripInitialised && isWS2811LedStripReady())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -738,18 +773,29 @@ void updateLedStrip(void)
|
|||
ws2811UpdateStrip();
|
||||
}
|
||||
|
||||
void applyDefaultColors(hsvColor_t *colors, uint8_t colorCount)
|
||||
{
|
||||
memset(colors, 0, colorCount * sizeof(colors));
|
||||
for (uint8_t colorIndex = 0; colorIndex < colorCount && colorIndex < (sizeof(defaultColors) / sizeof(defaultColors[0])); colorIndex++) {
|
||||
*colors++ = *defaultColors[colorIndex];
|
||||
}
|
||||
}
|
||||
|
||||
void applyDefaultLedStripConfig(ledConfig_t *ledConfigs)
|
||||
{
|
||||
memset(ledConfigs, 0, MAX_LED_STRIP_LENGTH * sizeof(ledConfig_t));
|
||||
memcpy(ledConfigs, &defaultLedStripConfig, sizeof(defaultLedStripConfig));
|
||||
|
||||
reevalulateLedConfig();
|
||||
}
|
||||
|
||||
void ledStripInit(ledConfig_t *ledConfigsToUse, failsafe_t* failsafeToUse)
|
||||
void ledStripInit(ledConfig_t *ledConfigsToUse, hsvColor_t *colorsToUse, failsafe_t* failsafeToUse)
|
||||
{
|
||||
ledConfigs = ledConfigsToUse;
|
||||
colors = colorsToUse;
|
||||
failsafe = failsafeToUse;
|
||||
|
||||
reevalulateLedConfig();
|
||||
configured = true;
|
||||
ledStripInitialised = true;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -54,7 +54,11 @@ typedef struct ledConfig_s {
|
|||
|
||||
extern uint8_t ledCount;
|
||||
|
||||
#define CONFIGURABLE_COLOR_COUNT 16
|
||||
|
||||
|
||||
bool parseLedStripConfig(uint8_t ledIndex, const char *config);
|
||||
void updateLedStrip(void);
|
||||
void applyDefaultColors(hsvColor_t *colors, uint8_t colorCount);
|
||||
void applyDefaultLedStripConfig(ledConfig_t *ledConfig);
|
||||
void generateLedConfig(uint8_t ledIndex, char *ledConfigBuffer, size_t bufferSize);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "build_config.h"
|
||||
|
||||
#include "common/axis.h"
|
||||
#include "common/color.h"
|
||||
#include "common/typeconversion.h"
|
||||
|
||||
#include "drivers/system.h"
|
||||
|
|
|
@ -25,8 +25,9 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#include "common/maths.h"
|
||||
#include "common/axis.h"
|
||||
#include "common/color.h"
|
||||
#include "common/maths.h"
|
||||
|
||||
#include "drivers/system.h"
|
||||
#include "drivers/accgyro.h"
|
||||
|
|
|
@ -91,7 +91,7 @@ void navigationInit(gpsProfile_t *initialGpsProfile, pidProfile_t *pidProfile);
|
|||
bool sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t gyroLpf, uint8_t accHardwareToUse, int16_t magDeclinationFromConfig);
|
||||
void imuInit(void);
|
||||
void displayInit(void);
|
||||
void ledStripInit(ledConfig_t *ledConfigsToUse, failsafe_t* failsafeToUse);
|
||||
void ledStripInit(ledConfig_t *ledConfigsToUse, hsvColor_t *colorsToUse, failsafe_t* failsafeToUse);
|
||||
void loop(void);
|
||||
|
||||
// FIXME bad naming - this appears to be for some new board that hasn't been made available yet.
|
||||
|
@ -245,7 +245,7 @@ void init(void)
|
|||
#ifdef LED_STRIP
|
||||
if (feature(FEATURE_LED_STRIP)) {
|
||||
ws2811LedStripInit();
|
||||
ledStripInit(masterConfig.ledConfigs, failsafe);
|
||||
ledStripInit(masterConfig.ledConfigs, masterConfig.colors, failsafe);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "common/maths.h"
|
||||
#include "common/axis.h"
|
||||
#include "common/color.h"
|
||||
|
||||
#include "drivers/accgyro.h"
|
||||
#include "drivers/light_led.h"
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <limits.h>
|
||||
|
||||
#include "common/color.h"
|
||||
#include "common/axis.h"
|
||||
#include "flight/flight.h"
|
||||
|
||||
|
@ -290,18 +291,27 @@ uint16_t flightModeFlags = 0;
|
|||
int16_t rcCommand[4];
|
||||
|
||||
void ws2811UpdateStrip(void) {}
|
||||
void setLedColor(uint16_t index, const rgbColor24bpp_t *color) {
|
||||
|
||||
void setLedValue(uint16_t index, const uint8_t value) {
|
||||
UNUSED(index);
|
||||
UNUSED(value);
|
||||
}
|
||||
|
||||
void setLedHsv(uint16_t index, const hsvColor_t *color) {
|
||||
UNUSED(index);
|
||||
UNUSED(color);
|
||||
}
|
||||
void setLedBrightness(uint16_t index, const uint8_t scalePercent) {
|
||||
|
||||
void scaleLedValue(uint16_t index, const uint8_t scalePercent) {
|
||||
UNUSED(index);
|
||||
UNUSED(scalePercent);
|
||||
}
|
||||
void setStripColor(const rgbColor24bpp_t *color) {
|
||||
|
||||
void setStripColor(const hsvColor_t *color) {
|
||||
UNUSED(color);
|
||||
}
|
||||
void setStripColors(const rgbColor24bpp_t *colors) {
|
||||
|
||||
void setStripColors(const hsvColor_t *colors) {
|
||||
UNUSED(colors);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue