mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-20 14:55:21 +03:00
Add support for MSP_LED_STRIP_CONFIG.
This commit is contained in:
parent
9bb764d1f2
commit
683e68b036
3 changed files with 55 additions and 3 deletions
|
@ -39,6 +39,9 @@ var BF_CONFIG = {
|
|||
currentoffset: 0
|
||||
};
|
||||
|
||||
var LED_STRIP = [];
|
||||
|
||||
|
||||
var PID_names = [];
|
||||
var PIDs = new Array(10);
|
||||
for (var i = 0; i < 10; i++) {
|
||||
|
|
45
js/msp.js
45
js/msp.js
|
@ -13,6 +13,8 @@ var MSP_codes = {
|
|||
MSP_SET_CHANNEL_FORWARDING: 33,
|
||||
MSP_MODE_RANGES: 34,
|
||||
MSP_SET_MODE_RANGE: 35,
|
||||
MSP_LED_STRIP_CONFIG: 48,
|
||||
MSP_SET_LED_STRIP_CONFIG: 49,
|
||||
MSP_ADJUSTMENT_RANGES: 52,
|
||||
MSP_SET_ADJUSTMENT_RANGE: 53,
|
||||
MSP_CF_SERIAL_CONFIG: 54,
|
||||
|
@ -612,6 +614,48 @@ var MSP = {
|
|||
}
|
||||
break;
|
||||
|
||||
case MSP_codes.MSP_LED_STRIP_CONFIG:
|
||||
LED_STRIP = [];
|
||||
|
||||
var ledCount = data.byteLength / 6; // v1.4.0 and below incorrectly reported 4 bytes per led.
|
||||
|
||||
var offset = 0;
|
||||
for (var i = 0; offset < data.byteLength && i < ledCount; i++) {
|
||||
|
||||
var directionMask = data.getUint16(offset, 1);
|
||||
offset += 2;
|
||||
|
||||
var directions = [];
|
||||
var directionLetters = ['n', 'e', 's', 'w', 'u', 'd'];
|
||||
for (var directionLetterIndex = 0; directionLetterIndex < directionLetters.length; directionLetterIndex++) {
|
||||
if (bit_check(directionMask, directionLetterIndex)) {
|
||||
directions.push(directionLetters[directionLetterIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
var functionMask = data.getUint16(offset, 1);
|
||||
offset += 2;
|
||||
|
||||
var functions = [];
|
||||
var functionLetters = ['i', 'w', 'f', 'a', 't'];
|
||||
for (var functionLetterIndex = 0; functionLetterIndex < functionLetters.length; functionLetterIndex++) {
|
||||
if (bit_check(functionMask, functionLetterIndex)) {
|
||||
functions.push(functionLetters[functionLetterIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
var led = {
|
||||
directions: directions,
|
||||
functions: functions,
|
||||
x: data.getUint8(offset++, 1),
|
||||
y: data.getUint8(offset++, 1)
|
||||
};
|
||||
|
||||
LED_STRIP.push(led);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MSP_codes.MSP_SET_MODE_RANGE:
|
||||
console.log('Mode range saved');
|
||||
break;
|
||||
|
@ -619,6 +663,7 @@ var MSP = {
|
|||
console.log('Adjustment range saved');
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
console.log('Unknown code detected: ' + code);
|
||||
}
|
||||
|
|
|
@ -16,11 +16,15 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
|
|||
googleAnalytics.sendAppView('LED Strip');
|
||||
}
|
||||
|
||||
function load_led_config() {
|
||||
MSP.send_message(MSP_codes.MSP_LED_STRIP_CONFIG, false, false, load_html);
|
||||
}
|
||||
|
||||
function load_html() {
|
||||
$('#content').load("./tabs/led_strip.html", process_html);
|
||||
}
|
||||
|
||||
load_html();
|
||||
load_led_config();
|
||||
|
||||
|
||||
function process_html() {
|
||||
|
@ -116,7 +120,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
|
|||
stop: function() {
|
||||
$('.ui-selected').each(function() {
|
||||
if (TABS.led_strip.wireMode) {
|
||||
if ($(this).find('.wire').html() == '' && TABS.led_strip.currentWire < 32) {
|
||||
if ($(this).find('.wire').html() == '' && TABS.led_strip.currentWire < LED_STRIP.length) {
|
||||
$(this).find('.wire').html(TABS.led_strip.currentWire);
|
||||
TABS.led_strip.currentWire++;
|
||||
}
|
||||
|
@ -190,7 +194,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
|
|||
|
||||
TABS.led_strip.totalLights = counter;
|
||||
|
||||
var remaining = 32 - TABS.led_strip.totalLights;
|
||||
var remaining = LED_STRIP.length - TABS.led_strip.totalLights;
|
||||
if (remaining <= 0) {
|
||||
remaining = 0;
|
||||
$('.wires-remaining').addClass('error');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue