mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-20 23:05:19 +03:00
Fix calculate of remaing LEDs and selection of next wire number.
This commit is contained in:
parent
7d86fa9958
commit
3892c02833
1 changed files with 29 additions and 18 deletions
|
@ -1,8 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
TABS.led_strip = {
|
TABS.led_strip = {
|
||||||
totalLights: 0,
|
|
||||||
currentWire: 0,
|
|
||||||
wireMode: false,
|
wireMode: false,
|
||||||
flightModes: ['w', 'f', 'i', 'a', 't'],
|
flightModes: ['w', 'f', 'i', 'a', 't'],
|
||||||
ledOrientations: ['n', 'e', 's', 'w', 'u', 'd'],
|
ledOrientations: ['n', 'e', 's', 'w', 'u', 'd'],
|
||||||
|
@ -27,6 +25,18 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
|
||||||
load_led_config();
|
load_led_config();
|
||||||
|
|
||||||
|
|
||||||
|
function buildUsedWireNumbers() {
|
||||||
|
var usedWireNumbers = [];
|
||||||
|
$('.mainGrid .gPoint .wire').each(function () {
|
||||||
|
var wireNumber = parseInt($(this).html());
|
||||||
|
if (wireNumber >= 0) {
|
||||||
|
usedWireNumbers.push(wireNumber);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
usedWireNumbers.sort(function(a,b){return a - b});
|
||||||
|
return usedWireNumbers;
|
||||||
|
}
|
||||||
|
|
||||||
function process_html() {
|
function process_html() {
|
||||||
|
|
||||||
localize();
|
localize();
|
||||||
|
@ -102,27 +112,34 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
|
||||||
var thisWire = $(this).find('.wire');
|
var thisWire = $(this).find('.wire');
|
||||||
if (thisWire.html() != '') {
|
if (thisWire.html() != '') {
|
||||||
thisWire.html('');
|
thisWire.html('');
|
||||||
TABS.led_strip.currentWire--;
|
|
||||||
}
|
}
|
||||||
updateBulkCmd();
|
updateBulkCmd();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.funcWireClear').click(function() {
|
$('.funcWireClear').click(function() {
|
||||||
TABS.led_strip.currentWire = 0;
|
|
||||||
$('.gPoint .wire').html('');
|
$('.gPoint .wire').html('');
|
||||||
updateBulkCmd();
|
updateBulkCmd();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$('.mainGrid').selectable({
|
$('.mainGrid').selectable({
|
||||||
filter: ' > div',
|
filter: ' > div',
|
||||||
stop: function() {
|
stop: function() {
|
||||||
$('.ui-selected').each(function() {
|
$('.ui-selected').each(function() {
|
||||||
|
|
||||||
|
|
||||||
|
var usedWireNumbers = buildUsedWireNumbers();
|
||||||
|
|
||||||
|
var nextWireNumber = 0;
|
||||||
|
for (var nextWireNumber = 0; nextWireNumber < usedWireNumbers.length; nextWireNumber++) {
|
||||||
|
if (usedWireNumbers[nextWireNumber] != nextWireNumber) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (TABS.led_strip.wireMode) {
|
if (TABS.led_strip.wireMode) {
|
||||||
if ($(this).find('.wire').html() == '' && TABS.led_strip.currentWire < LED_STRIP.length) {
|
if ($(this).find('.wire').html() == '' && nextWireNumber < LED_STRIP.length) {
|
||||||
$(this).find('.wire').html(TABS.led_strip.currentWire);
|
$(this).find('.wire').html(nextWireNumber);
|
||||||
TABS.led_strip.currentWire++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,15 +255,9 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
|
||||||
|
|
||||||
$('.tempOutput').append(lines.join("\n"));
|
$('.tempOutput').append(lines.join("\n"));
|
||||||
|
|
||||||
TABS.led_strip.totalLights = counter;
|
var usedWireNumbers = buildUsedWireNumbers();
|
||||||
|
|
||||||
var remaining = LED_STRIP.length - TABS.led_strip.totalLights;
|
var remaining = LED_STRIP.length - usedWireNumbers.length;
|
||||||
if (remaining <= 0) {
|
|
||||||
remaining = 0;
|
|
||||||
$('.wires-remaining').addClass('error');
|
|
||||||
} else {
|
|
||||||
$('.wires-remaining').removeClass('error');
|
|
||||||
}
|
|
||||||
$('.wires-remaining div').html(remaining);
|
$('.wires-remaining div').html(remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue