Revert "Betaflight led strip resubmit"
This commit is contained in:
parent
a5a0024fbd
commit
63c7ae18ff
|
@ -71,15 +71,4 @@ http://resnet.uoregon.edu/~gurney_j/jmpc/bitwise.html
|
|||
static inline int16_t cmp16(uint16_t a, uint16_t b) { return a-b; }
|
||||
static inline int32_t cmp32(uint32_t a, uint32_t b) { return a-b; }
|
||||
|
||||
// using memcpy_fn will force memcpy function call, instead of inlining it. In most cases function call takes fewer instructions
|
||||
// than inlined version (inlining is cheaper for very small moves < 8 bytes / 2 store instructions)
|
||||
#ifdef UNIT_TEST
|
||||
// Call memcpy when building unittest - this is easier that asm symbol name mangling (symbols start with _underscore on win32)
|
||||
#include <string.h>
|
||||
static inline void memcpy_fn ( void * destination, const void * source, size_t num ) { memcpy(destination, source, num); };
|
||||
#else
|
||||
void * memcpy_fn ( void * destination, const void * source, size_t num ) asm("memcpy");
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -615,10 +615,8 @@ static void resetConf(void)
|
|||
}
|
||||
|
||||
#ifdef LED_STRIP
|
||||
applyDefaultColors(masterConfig.colors);
|
||||
applyDefaultColors(masterConfig.colors, CONFIGURABLE_COLOR_COUNT);
|
||||
applyDefaultLedStripConfig(masterConfig.ledConfigs);
|
||||
applyDefaultModeColors(masterConfig.modeColors);
|
||||
applyDefaultSpecialColors(&(masterConfig.specialColors));
|
||||
masterConfig.ledstrip_visual_beeper = 0;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -119,10 +119,8 @@ typedef struct master_t {
|
|||
telemetryConfig_t telemetryConfig;
|
||||
|
||||
#ifdef LED_STRIP
|
||||
ledConfig_t ledConfigs[LED_MAX_STRIP_LENGTH];
|
||||
hsvColor_t colors[LED_CONFIGURABLE_COLOR_COUNT];
|
||||
modeColorIndexes_t modeColors[LED_MODE_COUNT];
|
||||
specialColorIndexes_t specialColors;
|
||||
ledConfig_t ledConfigs[MAX_LED_STRIP_LENGTH];
|
||||
hsvColor_t colors[CONFIGURABLE_COLOR_COUNT];
|
||||
uint8_t ledstrip_visual_beeper; // suppress LEDLOW mode if beeper is on
|
||||
#endif
|
||||
|
||||
|
|
|
@ -53,3 +53,6 @@ bool isWS2811LedStripReady(void);
|
|||
|
||||
extern uint8_t ledStripDMABuffer[WS2811_DMA_BUFFER_SIZE];
|
||||
extern volatile uint8_t ws2811LedDataTransferInProgress;
|
||||
|
||||
extern const hsvColor_t hsv_white;
|
||||
extern const hsvColor_t hsv_black;
|
||||
|
|
|
@ -105,7 +105,6 @@ void ws2811LedStripHardwareInit(void)
|
|||
|
||||
DMA_ITConfig(DMA1_Channel6, DMA_IT_TC, ENABLE);
|
||||
|
||||
const hsvColor_t hsv_white = { 0, 255, 255};
|
||||
ws2811Initialised = true;
|
||||
setStripColor(&hsv_white);
|
||||
ws2811UpdateStrip();
|
||||
|
|
|
@ -111,7 +111,6 @@ void ws2811LedStripHardwareInit(void)
|
|||
|
||||
DMA_ITConfig(WS2811_DMA_CHANNEL, DMA_IT_TC, ENABLE);
|
||||
|
||||
const hsvColor_t hsv_white = { 0, 255, 255};
|
||||
ws2811Initialised = true;
|
||||
setStripColor(&hsv_white);
|
||||
ws2811UpdateStrip();
|
||||
|
|
|
@ -154,7 +154,6 @@ void ws2811LedStripHardwareInit(void)
|
|||
|
||||
dmaSetHandler(WS2811_DMA_HANDLER_IDENTIFER, WS2811_DMA_IRQHandler, NVIC_PRIO_WS2811_DMA, 0);
|
||||
|
||||
const hsvColor_t hsv_white = { 0, 255, 255};
|
||||
ws2811Initialised = true;
|
||||
setStripColor(&hsv_white);
|
||||
ws2811UpdateStrip();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -17,163 +17,81 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define LED_MAX_STRIP_LENGTH 32
|
||||
#define LED_CONFIGURABLE_COLOR_COUNT 16
|
||||
#define LED_MODE_COUNT 6
|
||||
#define LED_DIRECTION_COUNT 6
|
||||
#define LED_BASEFUNCTION_COUNT 7
|
||||
#define LED_OVERLAY_COUNT 6
|
||||
#define LED_SPECIAL_COLOR_COUNT 11
|
||||
|
||||
#define LED_POS_OFFSET 0
|
||||
#define LED_FUNCTION_OFFSET 8
|
||||
#define LED_OVERLAY_OFFSET 12
|
||||
#define LED_COLOR_OFFSET 18
|
||||
#define LED_DIRECTION_OFFSET 22
|
||||
#define LED_PARAMS_OFFSET 28
|
||||
|
||||
#define LED_POS_BITCNT 8
|
||||
#define LED_FUNCTION_BITCNT 4
|
||||
#define LED_OVERLAY_BITCNT 6
|
||||
#define LED_COLOR_BITCNT 4
|
||||
#define LED_DIRECTION_BITCNT 6
|
||||
#define LED_PARAMS_BITCNT 4
|
||||
|
||||
#define LED_FLAG_OVERLAY_MASK ((1 << LED_OVERLAY_BITCNT) - 1)
|
||||
#define LED_FLAG_DIRECTION_MASK ((1 << LED_DIRECTION_BITCNT) - 1)
|
||||
|
||||
#define LED_MOV_POS(pos) ((pos) << LED_POS_OFFSET)
|
||||
#define LED_MOV_FUNCTION(func) ((func) << LED_FUNCTION_OFFSET)
|
||||
#define LED_MOV_OVERLAY(overlay) ((overlay) << LED_OVERLAY_OFFSET)
|
||||
#define LED_MOV_COLOR(colorId) ((colorId) << LED_COLOR_OFFSET)
|
||||
#define LED_MOV_DIRECTION(direction) ((direction) << LED_DIRECTION_OFFSET)
|
||||
#define LED_MOV_PARAMS(param) ((param) << LED_PARAMS_OFFSET)
|
||||
|
||||
#define LED_BIT_MASK(len) ((1 << (len)) - 1)
|
||||
|
||||
#define LED_POS_MASK LED_MOV_POS(((1 << LED_POS_BITCNT) - 1))
|
||||
#define LED_FUNCTION_MASK LED_MOV_FUNCTION(((1 << LED_FUNCTION_BITCNT) - 1))
|
||||
#define LED_OVERLAY_MASK LED_MOV_OVERLAY(LED_FLAG_OVERLAY_MASK)
|
||||
#define LED_COLOR_MASK LED_MOV_COLOR(((1 << LED_COLOR_BITCNT) - 1))
|
||||
#define LED_DIRECTION_MASK LED_MOV_DIRECTION(LED_FLAG_DIRECTION_MASK)
|
||||
#define LED_PARAMS_MASK LED_MOV_PARAMS(((1 << LED_PARAMS_BITCNT) - 1))
|
||||
|
||||
#define LED_FLAG_OVERLAY(id) (1 << (id))
|
||||
#define LED_FLAG_DIRECTION(id) (1 << (id))
|
||||
#define MAX_LED_STRIP_LENGTH 32
|
||||
#define CONFIGURABLE_COLOR_COUNT 16
|
||||
|
||||
#define LED_X_BIT_OFFSET 4
|
||||
#define LED_Y_BIT_OFFSET 0
|
||||
#define LED_XY_MASK 0x0F
|
||||
#define CALCULATE_LED_XY(x, y) ((((x) & LED_XY_MASK) << LED_X_BIT_OFFSET) | (((y) & LED_XY_MASK) << LED_Y_BIT_OFFSET))
|
||||
|
||||
#define LED_XY_MASK (0x0F)
|
||||
|
||||
#define GET_LED_X(ledConfig) ((ledConfig->xy >> LED_X_BIT_OFFSET) & LED_XY_MASK)
|
||||
#define GET_LED_Y(ledConfig) ((ledConfig->xy >> LED_Y_BIT_OFFSET) & LED_XY_MASK)
|
||||
|
||||
#define CALCULATE_LED_X(x) ((x & LED_XY_MASK) << LED_X_BIT_OFFSET)
|
||||
#define CALCULATE_LED_Y(y) ((y & LED_XY_MASK) << LED_Y_BIT_OFFSET)
|
||||
|
||||
|
||||
#define CALCULATE_LED_XY(x,y) (CALCULATE_LED_X(x) | CALCULATE_LED_Y(y))
|
||||
|
||||
typedef enum {
|
||||
LED_MODE_ORIENTATION = 0,
|
||||
LED_MODE_HEADFREE,
|
||||
LED_MODE_HORIZON,
|
||||
LED_MODE_ANGLE,
|
||||
LED_MODE_MAG,
|
||||
LED_MODE_BARO,
|
||||
LED_SPECIAL
|
||||
} ledModeIndex_e;
|
||||
LED_DISABLED = 0,
|
||||
LED_DIRECTION_NORTH = (1 << 0),
|
||||
LED_DIRECTION_EAST = (1 << 1),
|
||||
LED_DIRECTION_SOUTH = (1 << 2),
|
||||
LED_DIRECTION_WEST = (1 << 3),
|
||||
LED_DIRECTION_UP = (1 << 4),
|
||||
LED_DIRECTION_DOWN = (1 << 5),
|
||||
LED_FUNCTION_INDICATOR = (1 << 6),
|
||||
LED_FUNCTION_WARNING = (1 << 7),
|
||||
LED_FUNCTION_FLIGHT_MODE = (1 << 8),
|
||||
LED_FUNCTION_ARM_STATE = (1 << 9),
|
||||
LED_FUNCTION_THROTTLE = (1 << 10),
|
||||
LED_FUNCTION_THRUST_RING = (1 << 11),
|
||||
LED_FUNCTION_COLOR = (1 << 12),
|
||||
} ledFlag_e;
|
||||
|
||||
typedef enum {
|
||||
LED_SCOLOR_DISARMED = 0,
|
||||
LED_SCOLOR_ARMED,
|
||||
LED_SCOLOR_ANIMATION,
|
||||
LED_SCOLOR_BACKGROUND,
|
||||
LED_SCOLOR_BLINKBACKGROUND,
|
||||
LED_SCOLOR_GPSNOSATS,
|
||||
LED_SCOLOR_GPSNOLOCK,
|
||||
LED_SCOLOR_GPSLOCKED
|
||||
} ledSpecialColorIds_e;
|
||||
|
||||
typedef enum {
|
||||
LED_DIRECTION_NORTH = 0,
|
||||
LED_DIRECTION_EAST,
|
||||
LED_DIRECTION_SOUTH,
|
||||
LED_DIRECTION_WEST,
|
||||
LED_DIRECTION_UP,
|
||||
LED_DIRECTION_DOWN
|
||||
} ledDirectionId_e;
|
||||
|
||||
typedef enum {
|
||||
LED_FUNCTION_COLOR,
|
||||
LED_FUNCTION_FLIGHT_MODE,
|
||||
LED_FUNCTION_ARM_STATE,
|
||||
LED_FUNCTION_BATTERY,
|
||||
LED_FUNCTION_RSSI,
|
||||
LED_FUNCTION_GPS,
|
||||
LED_FUNCTION_THRUST_RING,
|
||||
} ledBaseFunctionId_e;
|
||||
|
||||
typedef enum {
|
||||
LED_OVERLAY_THROTTLE,
|
||||
LED_OVERLAY_LARSON_SCANNER,
|
||||
LED_OVERLAY_BLINK,
|
||||
LED_OVERLAY_LANDING_FLASH,
|
||||
LED_OVERLAY_INDICATOR,
|
||||
LED_OVERLAY_WARNING,
|
||||
} ledOverlayId_e;
|
||||
|
||||
typedef struct modeColorIndexes_s {
|
||||
uint8_t color[LED_DIRECTION_COUNT];
|
||||
} modeColorIndexes_t;
|
||||
|
||||
typedef struct specialColorIndexes_s {
|
||||
uint8_t color[LED_SPECIAL_COLOR_COUNT];
|
||||
} specialColorIndexes_t;
|
||||
|
||||
typedef uint32_t ledConfig_t;
|
||||
|
||||
typedef struct ledCounts_s {
|
||||
uint8_t count;
|
||||
uint8_t ring;
|
||||
uint8_t larson;
|
||||
uint8_t ringSeqLen;
|
||||
} ledCounts_t;
|
||||
#define LED_DIRECTION_BIT_OFFSET 0
|
||||
#define LED_DIRECTION_MASK ( \
|
||||
LED_DIRECTION_NORTH | \
|
||||
LED_DIRECTION_EAST | \
|
||||
LED_DIRECTION_SOUTH | \
|
||||
LED_DIRECTION_WEST | \
|
||||
LED_DIRECTION_UP | \
|
||||
LED_DIRECTION_DOWN \
|
||||
)
|
||||
#define LED_FUNCTION_BIT_OFFSET 6
|
||||
#define LED_FUNCTION_MASK ( \
|
||||
LED_FUNCTION_INDICATOR | \
|
||||
LED_FUNCTION_WARNING | \
|
||||
LED_FUNCTION_FLIGHT_MODE | \
|
||||
LED_FUNCTION_ARM_STATE | \
|
||||
LED_FUNCTION_THROTTLE | \
|
||||
LED_FUNCTION_THRUST_RING | \
|
||||
LED_FUNCTION_COLOR \
|
||||
)
|
||||
|
||||
|
||||
ledConfig_t *ledConfigs;
|
||||
hsvColor_t *colors;
|
||||
modeColorIndexes_t *modeColors;
|
||||
specialColorIndexes_t specialColors;
|
||||
typedef struct ledConfig_s {
|
||||
uint8_t xy; // see LED_X/Y_MASK defines
|
||||
uint8_t color; // see colors (config_master)
|
||||
uint16_t flags; // see ledFlag_e
|
||||
} ledConfig_t;
|
||||
|
||||
#define DEFINE_LED(x, y, col, dir, func, ol, params) (LED_MOV_POS(CALCULATE_LED_XY(x, y)) | LED_MOV_COLOR(col) | LED_MOV_DIRECTION(dir) | LED_MOV_FUNCTION(func) | LED_MOV_OVERLAY(ol) | LED_MOV_PARAMS(params))
|
||||
extern uint8_t ledCount;
|
||||
extern uint8_t ledsInRingCount;
|
||||
|
||||
static inline uint8_t ledGetXY(const ledConfig_t *lcfg) { return ((*lcfg >> LED_POS_OFFSET) & LED_BIT_MASK(LED_POS_BITCNT)); }
|
||||
static inline uint8_t ledGetX(const ledConfig_t *lcfg) { return ((*lcfg >> (LED_POS_OFFSET + LED_X_BIT_OFFSET)) & LED_XY_MASK); }
|
||||
static inline uint8_t ledGetY(const ledConfig_t *lcfg) { return ((*lcfg >> (LED_POS_OFFSET + LED_Y_BIT_OFFSET)) & LED_XY_MASK); }
|
||||
static inline uint8_t ledGetFunction(const ledConfig_t *lcfg) { return ((*lcfg >> LED_FUNCTION_OFFSET) & LED_BIT_MASK(LED_FUNCTION_BITCNT)); }
|
||||
static inline uint8_t ledGetOverlay(const ledConfig_t *lcfg) { return ((*lcfg >> LED_OVERLAY_OFFSET) & LED_BIT_MASK(LED_OVERLAY_BITCNT)); }
|
||||
static inline uint8_t ledGetColor(const ledConfig_t *lcfg) { return ((*lcfg >> LED_COLOR_OFFSET) & LED_BIT_MASK(LED_COLOR_BITCNT)); }
|
||||
static inline uint8_t ledGetDirection(const ledConfig_t *lcfg) { return ((*lcfg >> LED_DIRECTION_OFFSET) & LED_BIT_MASK(LED_DIRECTION_BITCNT)); }
|
||||
static inline uint8_t ledGetParams(const ledConfig_t *lcfg) { return ((*lcfg >> LED_PARAMS_OFFSET) & LED_BIT_MASK(LED_PARAMS_BITCNT)); }
|
||||
|
||||
static inline bool ledGetOverlayBit(const ledConfig_t *lcfg, int id) { return ((ledGetOverlay(lcfg) >> id) & 1); }
|
||||
static inline bool ledGetDirectionBit(const ledConfig_t *lcfg, int id) { return ((ledGetDirection(lcfg) >> id) & 1); }
|
||||
/*
|
||||
PG_DECLARE_ARR(ledConfig_t, LED_MAX_STRIP_LENGTH, ledConfigs);
|
||||
PG_DECLARE_ARR(hsvColor_t, LED_CONFIGURABLE_COLOR_COUNT, colors);
|
||||
PG_DECLARE_ARR(modeColorIndexes_t, LED_MODE_COUNT, modeColors);
|
||||
PG_DECLARE(specialColorIndexes_t, specialColors);
|
||||
*/
|
||||
bool parseColor(int index, const char *colorConfig);
|
||||
|
||||
bool parseLedStripConfig(int ledIndex, const char *config);
|
||||
void generateLedConfig(int ledIndex, char *ledConfigBuffer, size_t bufferSize);
|
||||
void reevaluateLedConfig(void);
|
||||
|
||||
void ledStripInit(ledConfig_t *ledConfigsToUse, hsvColor_t *colorsToUse, modeColorIndexes_t *modeColorsToUse, specialColorIndexes_t *specialColorsToUse);
|
||||
void ledStripEnable(void);
|
||||
bool parseLedStripConfig(uint8_t ledIndex, const char *config);
|
||||
void updateLedStrip(void);
|
||||
|
||||
bool setModeColor(ledModeIndex_e modeIndex, int modeColorIndex, int colorIndex);
|
||||
|
||||
extern uint16_t rssi; // FIXME dependency on mw.c
|
||||
|
||||
void updateLedRing(void);
|
||||
|
||||
void applyDefaultLedStripConfig(ledConfig_t *ledConfig);
|
||||
void applyDefaultColors(hsvColor_t *colors);
|
||||
void applyDefaultModeColors(modeColorIndexes_t *modeColors);
|
||||
void applyDefaultSpecialColors(specialColorIndexes_t *specialColors);
|
||||
void generateLedConfig(uint8_t ledIndex, char *ledConfigBuffer, size_t bufferSize);
|
||||
|
||||
bool parseColor(uint8_t index, const char *colorConfig);
|
||||
void applyDefaultColors(hsvColor_t *colors, uint8_t colorCount);
|
||||
|
||||
void ledStripEnable(void);
|
||||
void reevaluateLedConfig(void);
|
||||
|
|
|
@ -156,7 +156,6 @@ static void cliMap(char *cmdline);
|
|||
#ifdef LED_STRIP
|
||||
static void cliLed(char *cmdline);
|
||||
static void cliColor(char *cmdline);
|
||||
static void cliModeColor(char *cmdline);
|
||||
#endif
|
||||
|
||||
#ifndef USE_QUAD_MIXER_ONLY
|
||||
|
@ -265,7 +264,6 @@ const clicmd_t cmdTable[] = {
|
|||
CLI_COMMAND_DEF("aux", "configure modes", NULL, cliAux),
|
||||
#ifdef LED_STRIP
|
||||
CLI_COMMAND_DEF("color", "configure colors", NULL, cliColor),
|
||||
CLI_COMMAND_DEF("mode_color", "configure mode and special colors", NULL, cliModeColor),
|
||||
#endif
|
||||
CLI_COMMAND_DEF("defaults", "reset to defaults and reboot", NULL, cliDefaults),
|
||||
CLI_COMMAND_DEF("dfu", "DFU mode on reboot", NULL, cliDfu),
|
||||
|
@ -1406,20 +1404,20 @@ static void cliLed(char *cmdline)
|
|||
char ledConfigBuffer[20];
|
||||
|
||||
if (isEmpty(cmdline)) {
|
||||
for (i = 0; i < LED_MAX_STRIP_LENGTH; i++) {
|
||||
for (i = 0; i < MAX_LED_STRIP_LENGTH; i++) {
|
||||
generateLedConfig(i, ledConfigBuffer, sizeof(ledConfigBuffer));
|
||||
cliPrintf("led %u %s\r\n", i, ledConfigBuffer);
|
||||
}
|
||||
} else {
|
||||
ptr = cmdline;
|
||||
i = atoi(ptr);
|
||||
if (i < LED_MAX_STRIP_LENGTH) {
|
||||
if (i < MAX_LED_STRIP_LENGTH) {
|
||||
ptr = strchr(cmdline, ' ');
|
||||
if (!parseLedStripConfig(i, ++ptr)) {
|
||||
cliShowParseError();
|
||||
}
|
||||
} else {
|
||||
cliShowArgumentRangeError("index", 0, LED_MAX_STRIP_LENGTH - 1);
|
||||
cliShowArgumentRangeError("index", 0, MAX_LED_STRIP_LENGTH - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1430,7 +1428,7 @@ static void cliColor(char *cmdline)
|
|||
char *ptr;
|
||||
|
||||
if (isEmpty(cmdline)) {
|
||||
for (i = 0; i < LED_CONFIGURABLE_COLOR_COUNT; i++) {
|
||||
for (i = 0; i < CONFIGURABLE_COLOR_COUNT; i++) {
|
||||
cliPrintf("color %u %d,%u,%u\r\n",
|
||||
i,
|
||||
masterConfig.colors[i].h,
|
||||
|
@ -1441,57 +1439,16 @@ static void cliColor(char *cmdline)
|
|||
} else {
|
||||
ptr = cmdline;
|
||||
i = atoi(ptr);
|
||||
if (i < LED_CONFIGURABLE_COLOR_COUNT) {
|
||||
if (i < CONFIGURABLE_COLOR_COUNT) {
|
||||
ptr = strchr(cmdline, ' ');
|
||||
if (!parseColor(i, ++ptr)) {
|
||||
cliShowParseError();
|
||||
}
|
||||
} else {
|
||||
cliShowArgumentRangeError("index", 0, LED_CONFIGURABLE_COLOR_COUNT - 1);
|
||||
cliShowArgumentRangeError("index", 0, CONFIGURABLE_COLOR_COUNT - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void cliModeColor(char *cmdline)
|
||||
{
|
||||
if (isEmpty(cmdline)) {
|
||||
for (int i = 0; i < LED_MODE_COUNT; i++) {
|
||||
for (int j = 0; j < LED_DIRECTION_COUNT; j++) {
|
||||
int colorIndex = modeColors[i].color[j];
|
||||
cliPrintf("mode_color %u %u %u\r\n", i, j, colorIndex);
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < LED_SPECIAL_COLOR_COUNT; j++) {
|
||||
int colorIndex = specialColors.color[j];
|
||||
cliPrintf("mode_color %u %u %u\r\n", LED_SPECIAL, j, colorIndex);
|
||||
}
|
||||
} else {
|
||||
enum {MODE = 0, FUNCTION, COLOR, ARGS_COUNT};
|
||||
int args[ARGS_COUNT];
|
||||
int argNo = 0;
|
||||
char* ptr = strtok(cmdline, " ");
|
||||
while (ptr && argNo < ARGS_COUNT) {
|
||||
args[argNo++] = atoi(ptr);
|
||||
ptr = strtok(NULL, " ");
|
||||
}
|
||||
|
||||
if (ptr != NULL || argNo != ARGS_COUNT) {
|
||||
cliShowParseError();
|
||||
return;
|
||||
}
|
||||
|
||||
int modeIdx = args[MODE];
|
||||
int funIdx = args[FUNCTION];
|
||||
int color = args[COLOR];
|
||||
if(!setModeColor(modeIdx, funIdx, color)) {
|
||||
cliShowParseError();
|
||||
return;
|
||||
}
|
||||
// values are validated
|
||||
cliPrintf("mode_color %u %u %u\r\n", modeIdx, funIdx, color);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
|
@ -2116,9 +2073,6 @@ static void cliDump(char *cmdline)
|
|||
|
||||
cliPrint("\r\n\r\n# color\r\n");
|
||||
cliColor("");
|
||||
|
||||
cliPrint("\r\n\r\n# mode_color\r\n");
|
||||
cliModeColor("");
|
||||
#endif
|
||||
|
||||
cliPrint("\r\n# aux\r\n");
|
||||
|
|
|
@ -1150,8 +1150,8 @@ static bool processOutCommand(uint8_t cmdMSP)
|
|||
|
||||
#ifdef LED_STRIP
|
||||
case MSP_LED_COLORS:
|
||||
headSerialReply(LED_CONFIGURABLE_COLOR_COUNT * 4);
|
||||
for (i = 0; i < LED_CONFIGURABLE_COLOR_COUNT; i++) {
|
||||
headSerialReply(CONFIGURABLE_COLOR_COUNT * 4);
|
||||
for (i = 0; i < CONFIGURABLE_COLOR_COUNT; i++) {
|
||||
hsvColor_t *color = &masterConfig.colors[i];
|
||||
serialize16(color->h);
|
||||
serialize8(color->s);
|
||||
|
@ -1160,27 +1160,14 @@ static bool processOutCommand(uint8_t cmdMSP)
|
|||
break;
|
||||
|
||||
case MSP_LED_STRIP_CONFIG:
|
||||
headSerialReply(LED_MAX_STRIP_LENGTH * 4);
|
||||
for (i = 0; i < LED_MAX_STRIP_LENGTH; i++) {
|
||||
headSerialReply(MAX_LED_STRIP_LENGTH * 7);
|
||||
for (i = 0; i < MAX_LED_STRIP_LENGTH; i++) {
|
||||
ledConfig_t *ledConfig = &masterConfig.ledConfigs[i];
|
||||
serialize32(*ledConfig);
|
||||
}
|
||||
break;
|
||||
|
||||
case MSP_LED_STRIP_MODECOLOR:
|
||||
headSerialReply(((LED_MODE_COUNT * LED_DIRECTION_COUNT) + LED_SPECIAL_COLOR_COUNT) * 3);
|
||||
for (int i = 0; i < LED_MODE_COUNT; i++) {
|
||||
for (int j = 0; j < LED_DIRECTION_COUNT; j++) {
|
||||
serialize8(i);
|
||||
serialize8(j);
|
||||
serialize8(masterConfig.modeColors[i].color[j]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < LED_SPECIAL_COLOR_COUNT; j++) {
|
||||
serialize8(LED_MODE_COUNT);
|
||||
serialize8(j);
|
||||
serialize8(masterConfig.specialColors.color[j]);
|
||||
serialize16((ledConfig->flags & LED_DIRECTION_MASK) >> LED_DIRECTION_BIT_OFFSET);
|
||||
serialize16((ledConfig->flags & LED_FUNCTION_MASK) >> LED_FUNCTION_BIT_OFFSET);
|
||||
serialize8(GET_LED_X(ledConfig));
|
||||
serialize8(GET_LED_Y(ledConfig));
|
||||
serialize8(ledConfig->color);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
@ -1795,7 +1782,7 @@ static bool processInCommand(void)
|
|||
|
||||
#ifdef LED_STRIP
|
||||
case MSP_SET_LED_COLORS:
|
||||
for (i = 0; i < LED_CONFIGURABLE_COLOR_COUNT; i++) {
|
||||
for (i = 0; i < CONFIGURABLE_COLOR_COUNT; i++) {
|
||||
hsvColor_t *color = &masterConfig.colors[i];
|
||||
color->h = read16();
|
||||
color->s = read8();
|
||||
|
@ -1806,26 +1793,31 @@ static bool processInCommand(void)
|
|||
case MSP_SET_LED_STRIP_CONFIG:
|
||||
{
|
||||
i = read8();
|
||||
if (i >= LED_MAX_STRIP_LENGTH || currentPort->dataSize != (1 + 4)) {
|
||||
if (i >= MAX_LED_STRIP_LENGTH || currentPort->dataSize != (1 + 7)) {
|
||||
headSerialError(0);
|
||||
break;
|
||||
}
|
||||
ledConfig_t *ledConfig = &masterConfig.ledConfigs[i];
|
||||
*ledConfig = read32();
|
||||
uint16_t mask;
|
||||
// currently we're storing directions and functions in a uint16 (flags)
|
||||
// the msp uses 2 x uint16_t to cater for future expansion
|
||||
mask = read16();
|
||||
ledConfig->flags = (mask << LED_DIRECTION_BIT_OFFSET) & LED_DIRECTION_MASK;
|
||||
|
||||
mask = read16();
|
||||
ledConfig->flags |= (mask << LED_FUNCTION_BIT_OFFSET) & LED_FUNCTION_MASK;
|
||||
|
||||
mask = read8();
|
||||
ledConfig->xy = CALCULATE_LED_X(mask);
|
||||
|
||||
mask = read8();
|
||||
ledConfig->xy |= CALCULATE_LED_Y(mask);
|
||||
|
||||
ledConfig->color = read8();
|
||||
|
||||
reevaluateLedConfig();
|
||||
}
|
||||
break;
|
||||
|
||||
case MSP_SET_LED_STRIP_MODECOLOR:
|
||||
{
|
||||
ledModeIndex_e modeIdx = read8();
|
||||
int funIdx = read8();
|
||||
int color = read8();
|
||||
|
||||
if (!setModeColor(modeIdx, funIdx, color))
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case MSP_REBOOT:
|
||||
isRebootScheduled = true;
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
#define MSP_PROTOCOL_VERSION 0
|
||||
|
||||
#define API_VERSION_MAJOR 1 // increment when major changes are made
|
||||
#define API_VERSION_MINOR 20 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR
|
||||
#define API_VERSION_MINOR 17 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR
|
||||
|
||||
#define API_VERSION_LENGTH 2
|
||||
|
||||
|
@ -247,7 +247,6 @@ static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER;
|
|||
#define MSP_3D 124 //out message Settings needed for reversible ESCs
|
||||
#define MSP_RC_DEADBAND 125 //out message deadbands for yaw alt pitch roll
|
||||
#define MSP_SENSOR_ALIGNMENT 126 //out message orientation of acc,gyro,mag
|
||||
#define MSP_LED_STRIP_MODECOLOR 127 //out message Get LED strip mode_color settings
|
||||
|
||||
#define MSP_SET_RAW_RC 200 //in message 8 rc chan
|
||||
#define MSP_SET_RAW_GPS 201 //in message fix, numsat, lat, lon, alt, speed
|
||||
|
@ -268,7 +267,6 @@ static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER;
|
|||
#define MSP_SET_RC_DEADBAND 218 //in message deadbands for yaw alt pitch roll
|
||||
#define MSP_SET_RESET_CURR_PID 219 //in message resetting the current pid profile to defaults
|
||||
#define MSP_SET_SENSOR_ALIGNMENT 220 //in message set the orientation of the acc,gyro,mag
|
||||
#define MSP_SET_LED_STRIP_MODECOLOR 221 //in message Set LED strip mode_color settings
|
||||
|
||||
// #define MSP_BIND 240 //in message no param
|
||||
// #define MSP_ALARMS 242
|
||||
|
|
|
@ -134,7 +134,7 @@ void gpsInit(serialConfig_t *serialConfig, gpsConfig_t *initialGpsConfig);
|
|||
void navigationInit(gpsProfile_t *initialGpsProfile, pidProfile_t *pidProfile);
|
||||
void imuInit(void);
|
||||
void displayInit(rxConfig_t *intialRxConfig);
|
||||
void ledStripInit(ledConfig_t *ledConfigsToUse, hsvColor_t *colorsToUse, modeColorIndexes_t *modeColorsToUse, specialColorIndexes_t *specialColorsToUse);
|
||||
void ledStripInit(ledConfig_t *ledConfigsToUse, hsvColor_t *colorsToUse);
|
||||
void spektrumBind(rxConfig_t *rxConfig);
|
||||
const sonarHardware_t *sonarGetHardwareConfiguration(currentSensor_e currentSensor);
|
||||
void osdInit(void);
|
||||
|
@ -544,7 +544,7 @@ void init(void)
|
|||
#endif
|
||||
|
||||
#ifdef LED_STRIP
|
||||
ledStripInit(masterConfig.ledConfigs, masterConfig.colors, masterConfig.modeColors, &masterConfig.specialColors);
|
||||
ledStripInit(masterConfig.ledConfigs, masterConfig.colors);
|
||||
|
||||
if (feature(FEATURE_LED_STRIP)) {
|
||||
ledStripEnable();
|
||||
|
|
|
@ -224,7 +224,7 @@ fix12_t calculateVbatPidCompensation(void) {
|
|||
|
||||
uint8_t calculateBatteryPercentage(void)
|
||||
{
|
||||
return constrain((((uint32_t)vbat - (batteryConfig->vbatmincellvoltage * batteryCellCount)) * 100) / ((batteryConfig->vbatmaxcellvoltage - batteryConfig->vbatmincellvoltage) * batteryCellCount), 0, 100);
|
||||
return (((uint32_t)vbat - (batteryConfig->vbatmincellvoltage * batteryCellCount)) * 100) / ((batteryConfig->vbatmaxcellvoltage - batteryConfig->vbatmincellvoltage) * batteryCellCount);
|
||||
}
|
||||
|
||||
uint8_t calculateBatteryCapacityRemainingPercentage(void)
|
||||
|
|
Loading…
Reference in New Issue