Skip to content

Commit 51f0fde

Browse files
committed
Update MSPHelper.js
add aurora effect switch Update led_strip.js Update MSPHelper.js
1 parent 82021fd commit 51f0fde

File tree

4 files changed

+49
-20
lines changed

4 files changed

+49
-20
lines changed

locales/en/messages.json

+4
Original file line numberDiff line numberDiff line change
@@ -3974,6 +3974,10 @@
39743974
"message": "Larson scanner",
39753975
"description": "Larson effect switch label on LED Strip tab"
39763976
},
3977+
"ledStripAuroraOverlay": {
3978+
"message": "Aurora Effect",
3979+
"description": "Aurora effect switch label on LED Strip tab"
3980+
},
39773981
"ledStripBlinkAlwaysOverlay": {
39783982
"message": "Blink always"
39793983
},

src/js/msp/MSPHelper.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { reinitializeConnection } from "../serial_backend";
2121
// Used for LED_STRIP
2222
const ledDirectionLetters = ['n', 'e', 's', 'w', 'u', 'd']; // in LSB bit order
2323
const ledBaseFunctionLetters = ['c', 'f', 'a', 'l', 's', 'g', 'r', 'p', 'e', 'u']; // in LSB bit
24-
let ledOverlayLetters = ['t', 'y', 'o', 'b', 'v', 'i', 'w']; // in LSB bit
24+
let ledOverlayLetters = ['t', 'y', 'o', 'x', 'b', 'v', 'i', 'w']; // in LSB bit
2525

2626
function MspHelper() {
2727
const self = this;
@@ -1220,7 +1220,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
12201220
}
12211221
}
12221222

1223-
const overlayMask = (mask >> 12) & 0x3FF;
1223+
const overlayMask = (mask >> 13) & 0x3FF;
12241224
for (let overlayLetterIndex = 0; overlayLetterIndex < ledOverlayLetters.length; overlayLetterIndex++) {
12251225
if (bit_check(overlayMask, overlayLetterIndex)) {
12261226
functions.push(ledOverlayLetters[overlayLetterIndex]);
@@ -1260,7 +1260,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
12601260
}
12611261
}
12621262

1263-
const overlayMask = (mask >> 12) & 0x3F;
1263+
const overlayMask = (mask >> 13) & 0x3F;
12641264
for (let overlayLetterIndex = 0; overlayLetterIndex < ledOverlayLetters.length; overlayLetterIndex++) {
12651265
if (bit_check(overlayMask, overlayLetterIndex)) {
12661266
functions.push(ledOverlayLetters[overlayLetterIndex]);
@@ -2591,7 +2591,7 @@ MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
25912591
for (let overlayLetterIndex = 0; overlayLetterIndex < led.functions.length; overlayLetterIndex++) {
25922592
const bitIndex = ledOverlayLetters.indexOf(led.functions[overlayLetterIndex]);
25932593
if (bitIndex >= 0) {
2594-
mask |= bit_set(mask, bitIndex + 12);
2594+
mask |= bit_set(mask, bitIndex + 13);
25952595
}
25962596
}
25972597

@@ -2609,7 +2609,7 @@ MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
26092609
for (let overlayLetterIndex = 0; overlayLetterIndex < led.functions.length; overlayLetterIndex++) {
26102610
const bitIndex = ledOverlayLetters.indexOf(led.functions[overlayLetterIndex]);
26112611
if (bitIndex >= 0) {
2612-
mask |= bit_set(mask, bitIndex + 12);
2612+
mask |= bit_set(mask, bitIndex + 13);
26132613
}
26142614
}
26152615

src/js/tabs/led_strip.js

+35-15
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ led_strip.initialize = function (callback, scrollPosition) {
2020

2121
TABS.led_strip.functions = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l', 'o', 'y'];
2222
TABS.led_strip.baseFuncs = ['c', 'f', 'a', 'l', 's', 'g', 'r', 'p', 'e', 'u'];
23-
TABS.led_strip.overlays = ['t', 'y', 'o', 'b', 'v', 'i', 'w'];
23+
TABS.led_strip.overlays = ['t', 'y', 'o', 'x', 'b', 'v', 'i', 'w'];
2424

2525
if (semver.lt(FC.CONFIG.apiVersion,API_VERSION_1_46)) {
2626
TABS.led_strip.overlays = TABS.led_strip.overlays.filter(x => x !== 'y');
@@ -456,6 +456,7 @@ led_strip.initialize = function (callback, scrollPosition) {
456456
case 't':
457457
case 'y':
458458
case 'o':
459+
case 'x':
459460
case 's':
460461
if (areModifiersActive(`function-${f}`))
461462
p.addClass(`function-${letter}`);
@@ -489,28 +490,46 @@ led_strip.initialize = function (callback, scrollPosition) {
489490
return $(that).is(':checked');
490491
}
491492

493+
// Disable all other functions except the one being activated
494+
function disableOtherFunctions(activeFunction) {
495+
const functions = ['.function-o', '.function-b', '.function-x'];
496+
497+
functions.forEach(func => {
498+
if (!activeFunction.is(func)) {
499+
const checkbox = $(`.checkbox ${func}`);
500+
if (checkbox.is(':checked')) {
501+
checkbox.prop('checked', false);
502+
checkbox.trigger('change');
503+
toggleSwitch(checkbox, func.slice(-1)); // Pass the last character as the identifier
504+
}
505+
}
506+
});
507+
}
508+
492509
// UI: check-box toggle
493510
$('.checkbox').on('change', function(e) {
494511
if (e.originalEvent) {
495512
// user-triggered event
496513
const that = $(this).find('input');
497514

498-
//disable Blink always or Larson scanner, both functions are not working properly at the same time
499-
if (that.is('.function-o')) {
500-
const blink = $('.checkbox .function-b');
501-
if (blink.is(':checked')) {
502-
blink.prop('checked', false);
503-
blink.trigger('change');
504-
toggleSwitch(blink, 'b');
515+
// Event handlers for each function
516+
$('.checkbox .function-o').on('change', function () {
517+
if ($(this).is(':checked')) {
518+
disableOtherFunctions($(this));
519+
}
520+
});
521+
522+
$('.checkbox .function-b').on('change', function () {
523+
if ($(this).is(':checked')) {
524+
disableOtherFunctions($(this));
505525
}
506-
} else if (that.is('.function-b')) {
507-
const larson = $('.checkbox .function-o');
508-
if ($('.checkbox .function-o').is(':checked')) {
509-
larson.prop('checked', false);
510-
larson.trigger('change');
511-
toggleSwitch(larson, 'o');
526+
});
527+
528+
$('.checkbox .function-x').on('change', function () {
529+
if ($(this).is(':checked')) {
530+
disableOtherFunctions($(this));
512531
}
513-
}
532+
});
514533

515534
//Change Rainbow slider visibility
516535
if (that.is('.function-y')) {
@@ -827,6 +846,7 @@ led_strip.initialize = function (callback, scrollPosition) {
827846
case "function-r":
828847
case "function-y":
829848
case "function-o":
849+
case "function-x":
830850
case "function-b":
831851
case "function-g":
832852
return true;

src/tabs/led_strip.html

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@
8383
<label> <span i18n="ledStripLarsonOverlay"></span></label>
8484
</div>
8585

86+
<div class="checkbox">
87+
<input type="checkbox" name="Aurora" class="toggle function-x" />
88+
<label> <span i18n="ledStripAuroraOverlay"></span></label>
89+
</div>
90+
8691
<div class="checkbox">
8792
<input type="checkbox" name="blink" class="toggle function-b" />
8893
<label> <span i18n="ledStripBlinkAlwaysOverlay"></span></label>

0 commit comments

Comments
 (0)