mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-16 21:05:30 +03:00
Fix led_strip
This commit is contained in:
parent
6008707746
commit
8e8a15cb5c
2 changed files with 17 additions and 15 deletions
|
@ -5,12 +5,7 @@
|
|||
const ledDirectionLetters = ['n', 'e', 's', 'w', 'u', 'd']; // in LSB bit order
|
||||
const ledFunctionLetters = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l']; // in LSB bit order
|
||||
const ledBaseFunctionLetters = ['c', 'f', 'a', 'l', 's', 'g', 'r']; // in LSB bit
|
||||
let ledOverlayLetters;
|
||||
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
ledOverlayLetters = ['t', 'o', 'b', 'n', 'i', 'w']; // in LSB bit
|
||||
} else {
|
||||
ledOverlayLetters = ['t', 'o', 'b', 'v', 'i', 'w']; // in LSB bit
|
||||
}
|
||||
let ledOverlayLetters = ['t', 'o', 'b', 'v', 'i', 'w']; // in LSB bit
|
||||
|
||||
function MspHelper() {
|
||||
const self = this;
|
||||
|
@ -1211,6 +1206,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
|
||||
ledCount = data.byteLength / 4;
|
||||
}
|
||||
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
ledOverlayLetters = ['t', 'o', 'b', 'n', 'i', 'w']; // in LSB bit
|
||||
}
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
|
||||
// According to betaflight/src/main/msp/msp.c
|
||||
// API 1.41 - add indicator for advanced profile support and the current profile selection
|
||||
|
@ -2587,9 +2585,13 @@ MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
|
|||
|
||||
buffer.push(ledIndex);
|
||||
|
||||
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
ledOverlayLetters = ['t', 'o', 'b', 'n', 'i', 'w']; // in LSB bit
|
||||
}
|
||||
|
||||
if (semver.lt(FC.CONFIG.apiVersion, "1.20.0")) {
|
||||
let directionMask = 0;
|
||||
for (const directionLetterIndex of led.directions) {
|
||||
for (let directionLetterIndex = 0; directionLetterIndex < led.directions.length; directionLetterIndex++) {
|
||||
const bitIndex = ledDirectionLetters.indexOf(led.directions[directionLetterIndex]);
|
||||
if (bitIndex >= 0) {
|
||||
directionMask = bit_set(directionMask, bitIndex);
|
||||
|
@ -2598,7 +2600,7 @@ MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
|
|||
buffer.push16(directionMask);
|
||||
|
||||
let functionMask = 0;
|
||||
for (const functionLetterIndex of led.functions) {
|
||||
for (let functionLetterIndex = 0; functionLetterIndex < led.functions.length; functionLetterIndex++) {
|
||||
const bitIndex = ledFunctionLetters.indexOf(led.functions[functionLetterIndex]);
|
||||
if (bitIndex >= 0) {
|
||||
functionMask = bit_set(functionMask, bitIndex);
|
||||
|
@ -2615,7 +2617,7 @@ MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
|
|||
mask |= (led.y << 0);
|
||||
mask |= (led.x << 4);
|
||||
|
||||
for (const functionLetterIndex of led.functions) {
|
||||
for (let functionLetterIndex = 0; functionLetterIndex < led.functions.length; functionLetterIndex++) {
|
||||
const fnIndex = ledBaseFunctionLetters.indexOf(led.functions[functionLetterIndex]);
|
||||
if (fnIndex >= 0) {
|
||||
mask |= (fnIndex << 8);
|
||||
|
@ -2623,7 +2625,7 @@ MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
|
|||
}
|
||||
}
|
||||
|
||||
for (const overlayLetterIndex of led.functions) {
|
||||
for (let overlayLetterIndex = 0; overlayLetterIndex < led.functions.length; overlayLetterIndex++) {
|
||||
const bitIndex = ledOverlayLetters.indexOf(led.functions[overlayLetterIndex]);
|
||||
if (bitIndex >= 0) {
|
||||
mask |= bit_set(mask, bitIndex + 12);
|
||||
|
@ -2632,7 +2634,7 @@ MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
|
|||
|
||||
mask |= (led.color << 18);
|
||||
|
||||
for (const directionLetterIndex of led.directions) {
|
||||
for (let directionLetterIndex = 0; directionLetterIndex < led.directions.length; directionLetterIndex++) {
|
||||
const bitIndex = ledDirectionLetters.indexOf(led.directions[directionLetterIndex]);
|
||||
if (bitIndex >= 0) {
|
||||
mask |= bit_set(mask, bitIndex + 22);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue