Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup + led overlay expansion #3390

Merged
merged 4 commits into from
Apr 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Cleanup + led overlay expansion
  • Loading branch information
ASDosjani committed Mar 28, 2023
commit 9192c3b08ae106e9df104857477972ae760ec945
19 changes: 8 additions & 11 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1170,9 +1170,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
let ledCount = (data.byteLength - 2) / 4;

// The 32 bit config of each LED contains these in LSB:
// +--------------------+--------------------+------------------+------------------+----------------------+-----------+-----------+
// | Parameters - 3 bit | Directions - 6 bit | Color ID - 4 bit | Overlays - 7 bit | Function ID - 4 bit | X - 4 bit | Y - 4 bit |
// +--------------------+--------------------+------------------+------------------+----------------------+-----------+-----------+
// +----------------------------------------------------------------------------------------------------------+
// | Directions - 6 bit | Color ID - 4 bit | Overlays - 10 bit | Function ID - 4 bit | X - 4 bit | Y - 4 bit |
// +----------------------------------------------------------------------------------------------------------+
// According to betaflight/src/main/msp/msp.c
// API 1.41 - add indicator for advanced profile support and the current profile selection
// 0 = basic ledstrip available
Expand All @@ -1196,14 +1196,14 @@ MspHelper.prototype.process_data = function(dataHandler) {
}
}

const overlayMask = (mask >> 12) & 0x7F;
const overlayMask = (mask >> 12) & 0x3FF;
for (let overlayLetterIndex = 0; overlayLetterIndex < ledOverlayLetters.length; overlayLetterIndex++) {
if (bit_check(overlayMask, overlayLetterIndex)) {
functions.push(ledOverlayLetters[overlayLetterIndex]);
}
}

const directionMask = (mask >> 23) & 0x3F;
const directionMask = (mask >> 26) & 0x3F;
const directions = [];
for (let directionLetterIndex = 0; directionLetterIndex < ledDirectionLetters.length; directionLetterIndex++) {
if (bit_check(directionMask, directionLetterIndex)) {
Expand All @@ -1214,9 +1214,8 @@ MspHelper.prototype.process_data = function(dataHandler) {
y: (mask) & 0xF,
x: (mask >> 4) & 0xF,
functions: functions,
color: (mask >> 19) & 0xF,
color: (mask >> 22) & 0xF,
directions: directions,
parameters: (mask >>> 29) & 0x7,
};

FC.LED_STRIP.push(led);
Expand Down Expand Up @@ -2552,17 +2551,15 @@ MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
}
}

mask |= (led.color << 19);
mask |= (led.color << 22);

for (let directionLetterIndex = 0; directionLetterIndex < led.directions.length; directionLetterIndex++) {
const bitIndex = ledDirectionLetters.indexOf(led.directions[directionLetterIndex]);
if (bitIndex >= 0) {
mask |= bit_set(mask, bitIndex + 23);
mask |= bit_set(mask, bitIndex + 26);
}
}

mask |= (0 << 29); // parameters

buffer.push32(mask);
}
else {
Expand Down