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
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 10 additions & 3 deletions src/css/tabs/led_strip.less
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,21 @@
color: var(--defaultText);
}
}
.header {
color: #c4c4c4;
font-size: 13px;
font-weight: 600;
}
.overlays {
display: inline-block;
margin-top: 5px;
}
.modifiers {
display: inline-block;
margin-top: 5px;
.rainbowOverlay {
margin-top: 1px;
}
.auxSelect {
border: 1px solid var(--subtleAccent);
border-radius: 3px;
Expand Down Expand Up @@ -499,9 +509,6 @@
z-index: 100;
border: 1px dotted white;
}
.modifiers .switchery, .overlays .switchery {
margin-top: 2px !important;
}
}
.gridWire {
.wire {
Expand Down
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
13 changes: 3 additions & 10 deletions src/js/tabs/led_strip.js
Original file line number Diff line number Diff line change
Expand Up @@ -777,13 +777,6 @@ led_strip.initialize = function (callback, scrollPosition) {
const activeFunction = $('select.functionSelect').val();
$('select.functionSelect').addClass(activeFunction);

// >= 20
// Show GPS (Func)
// Hide RSSI (O/L), Blink (Func)
// Show Battery, RSSI (Func), Larson (O/L), Blink (O/L), Landing (O/L)
$(".extra_functions20").show();
$(".mode_colors").show();

// set color modifiers (check-boxes) visibility
$('.overlays').toggle(areOverlaysActive(activeFunction));

Expand All @@ -795,13 +788,13 @@ led_strip.initialize = function (callback, scrollPosition) {

$('.vtxOverlay').toggle(isVtxActive(activeFunction));

$('.mode_colors').hide();

// set mode colors visibility

if (activeFunction === "function-f") {
$('.mode_colors').show();
}
else {
$('.mode_colors').hide();
}

// set special colors visibility
$('.special_colors').show();
Expand Down
18 changes: 9 additions & 9 deletions src/tabs/led_strip.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@


<div class="select">
<span class="color_section" i18n="ledStripFunctionTitle"></span>
<span i18n="ledStripFunctionTitle"></span>
<select id="ledStripFunctionSelect" class="functionSelect">
<option value="" i18n="ledStripFunctionNoneOption"></option>
<option value="function-c" i18n="ledStripFunctionColorOption"></option>
<option value="function-f" i18n="ledStripFunctionModesOption"></option>
<option value="function-a" i18n="ledStripFunctionArmOption"></option>
<option value="function-l" class="extra_functions20" i18n="ledStripFunctionBatteryOption"></option>
<option value="function-s" class="extra_functions20" i18n="ledStripFunctionRSSIOption"></option>
<option value="function-g" class="extra_functions20" i18n="ledStripFunctionGPSOption"></option>
<option value="function-l" i18n="ledStripFunctionBatteryOption"></option>
<option value="function-s" i18n="ledStripFunctionRSSIOption"></option>
<option value="function-g" i18n="ledStripFunctionGPSOption"></option>
<option value="function-r" i18n="ledStripFunctionRingOption"></option>
</select>
</div>


<div class="modifiers">
<span class="color_section" i18n="ledStripColorModifierTitle"></span>
<span class="header" i18n="ledStripColorModifierTitle"></span>
<div class="checkbox">
<input type="checkbox" name="ThrottleHue" class="toggle function-t" />
<label>
Expand All @@ -75,24 +75,24 @@
</label>
</div>

<div class="checkbox extra_functions20">
<div class="checkbox">
<input type="checkbox" name="LarsonScanner" class="toggle function-o" />
<label> <span i18n="ledStripLarsonOverlay"></span></label>
</div>

<div class="checkbox extra_functions20">
<div class="checkbox">
<input type="checkbox" name="blink" class="toggle function-b" />
<label> <span i18n="ledStripBlinkAlwaysOverlay"></span></label>
</div>

<div class="checkbox extra_functions20 rainbowOverlay">
<div class="checkbox rainbowOverlay">
<input type="checkbox" name="Rainbow" class="toggle function-y" />
<label> <span i18n="ledStripRainbowOverlay"></span></label>
</div>
</div>

<div class="overlays">
<span class="color_section" i18n="ledStripOverlayTitle"></span>
<span class="header" i18n="ledStripOverlayTitle"></span>
<div class="checkbox warningOverlay">
<input type="checkbox" name="Warnings" class="toggle function-w" />
<label> <span i18n="ledStripWarningsOverlay"></span></label>
Expand Down