1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-20 06:45:11 +03:00

Initial changes to enable new strobe functionality

This commit is contained in:
Marcelo Bezerra 2022-11-09 20:53:53 +01:00
parent 1a33ca1b12
commit 671b2fe49c
4 changed files with 65 additions and 1 deletions

View file

@ -45,6 +45,8 @@ var MSPCodes = {
MSP_SET_LED_COLORS: 47,
MSP_LED_STRIP_CONFIG: 48,
MSP_SET_LED_STRIP_CONFIG: 49,
MSP_LED_STRIP_CONFIG_EX: 248,
MSP_SET_LED_STRIP_CONFIG_EX: 249,
MSP_ADJUSTMENT_RANGES: 52,
MSP_SET_ADJUSTMENT_RANGE: 53,
MSP_CF_SERIAL_CONFIG: 54,

View file

@ -1028,9 +1028,66 @@ var mspHelper = (function (gui) {
}
}
break;
case MSPCodes.MSP_LED_STRIP_CONFIG_EX:
//noinspection JSUndeclaredVariable
LED_STRIP = [];
var ledCount = data.byteLength / 5;
var directionMask,
directions,
directionLetterIndex,
functions,
led;
for (i = 0; offset < data.byteLength && i < ledCount; i++) {
var mask = data.getUint32(offset, 1);
offset += 4;
var extra = data.getUint8(offset, 1);
offset++;
var functionId = (mask >> 8) & 0xFF;
functions = [];
for (var baseFunctionLetterIndex = 0; baseFunctionLetterIndex < MSP.ledBaseFunctionLetters.length; baseFunctionLetterIndex++) {
if (functionId == baseFunctionLetterIndex) {
functions.push(MSP.ledBaseFunctionLetters[baseFunctionLetterIndex]);
break;
}
}
var overlayMask = (mask >> 16) & 0xFF;
for (var overlayLetterIndex = 0; overlayLetterIndex < MSP.ledOverlayLetters.length; overlayLetterIndex++) {
if (bit_check(overlayMask, overlayLetterIndex)) {
functions.push(MSP.ledOverlayLetters[overlayLetterIndex]);
}
}
directionMask = (mask >> 28) & 0xF | ((extra & 0x3) << 4);
directions = [];
for (directionLetterIndex = 0; directionLetterIndex < MSP.ledDirectionLetters.length; directionLetterIndex++) {
if (bit_check(directionMask, directionLetterIndex)) {
directions.push(MSP.ledDirectionLetters[directionLetterIndex]);
}
}
led = {
y: (mask) & 0xF,
x: (mask >> 4) & 0xF,
functions: functions,
color: (mask >> 24) & 0xF,
directions: directions,
parameters: (extra >> 2) & 0x3F
};
LED_STRIP.push(led);
}
break;
case MSPCodes.MSP_SET_LED_STRIP_CONFIG:
console.log('Led strip config saved');
break;
case MSPCodes.MSP_SET_LED_STRIP_CONFIG_EX:
console.log('Led strip extended config saved');
break;
case MSPCodes.MSP_LED_COLORS:
//noinspection JSUndeclaredVariable

View file

@ -92,6 +92,11 @@
<input type="checkbox" name="landingBlink" class="toggle function-n" />
<label> <span>Blink on landing</span></label>
</div>
<span class="color_section">Strobe</span>
<div class="checkbox strobeOverlay">
<input type="checkbox" name="blink" class="toggle function-e" />
<label> <span>Enable strobe light effect</span></label>
</div>
</div>
<div class="overlays">

View file

@ -13,7 +13,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
TABS.led_strip.functions = ['i', 'w', 'f', 'a', 't', 'r', 'c', 'g', 's', 'b', 'l', 'o', 'n'];
TABS.led_strip.baseFuncs = ['c', 'f', 'a', 'l', 's', 'g', 'r', 'h'];
TABS.led_strip.overlays = ['t', 'o', 'b', 'n', 'i', 'w'];
TABS.led_strip.overlays = ['t', 'o', 'b', 'n', 'i', 'w', 'e'];
TABS.led_strip.wireMode = false;