mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-20 14:55:15 +03:00
Fix cpuload
This commit is contained in:
parent
75c00a15ed
commit
934f2746ec
1 changed files with 27 additions and 17 deletions
|
@ -491,24 +491,26 @@ function connectCli() {
|
||||||
$('#tabs .tab_cli a').click();
|
$('#tabs .tab_cli a').click();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onConnect() {
|
function onConnect() {
|
||||||
if ($('div#flashbutton a.flash_state').hasClass('active') && $('div#flashbutton a.flash').hasClass('active')) {
|
if ($('div#flashbutton a.flash_state').hasClass('active') && $('div#flashbutton a.flash').hasClass('active')) {
|
||||||
$('div#flashbutton a.flash_state').removeClass('active');
|
$('div#flashbutton a.flash_state').removeClass('active');
|
||||||
$('div#flashbutton a.flash').removeClass('active');
|
$('div#flashbutton a.flash').removeClass('active');
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI.timeout_remove('connecting'); // kill connecting timer
|
GUI.timeout_remove('connecting'); // kill connecting timer
|
||||||
|
|
||||||
$('div#connectbutton div.connect_state').text(i18n.getMessage('disconnect')).addClass('active');
|
$('div#connectbutton div.connect_state').text(i18n.getMessage('disconnect')).addClass('active');
|
||||||
$('div#connectbutton a.connect').addClass('active');
|
$('div#connectbutton a.connect').addClass('active');
|
||||||
|
|
||||||
$('#tabs ul.mode-disconnected').hide();
|
$('#tabs ul.mode-disconnected').hide();
|
||||||
$('#tabs ul.mode-connected-cli').show();
|
$('#tabs ul.mode-connected-cli').show();
|
||||||
|
|
||||||
|
|
||||||
// show only appropriate tabs
|
// show only appropriate tabs
|
||||||
$('#tabs ul.mode-connected li').hide();
|
$('#tabs ul.mode-connected li').hide();
|
||||||
$('#tabs ul.mode-connected li').filter(function (index) {
|
$('#tabs ul.mode-connected li').filter(function (index) {
|
||||||
const classes = $(this).attr("class").split(/\s+/);
|
const classes = $(this).attr("class").split(/\s+/);
|
||||||
let found = false;
|
let found = false;
|
||||||
|
|
||||||
$.each(GUI.allowedTabs, (_index, value) => {
|
$.each(GUI.allowedTabs, (_index, value) => {
|
||||||
const tabName = `tab_${value}`;
|
const tabName = `tab_${value}`;
|
||||||
if ($.inArray(tabName, classes) >= 0) {
|
if ($.inArray(tabName, classes) >= 0) {
|
||||||
|
@ -532,13 +534,14 @@ async function onConnect() {
|
||||||
|
|
||||||
$('#tabs ul.mode-connected').show();
|
$('#tabs ul.mode-connected').show();
|
||||||
|
|
||||||
await MSP.promise(MSPCodes.MSP_FEATURE_CONFIG);
|
MSP.send_message(MSPCodes.MSP_FEATURE_CONFIG, false, false);
|
||||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_33)) {
|
MSP.send_message(MSPCodes.MSP_BATTERY_CONFIG, false, false);
|
||||||
await MSP.promise(MSPCodes.MSP_BATTERY_CONFIG);
|
|
||||||
}
|
getStatus();
|
||||||
await MSP.promise(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_32) ? MSPCodes.MSP_STATUS_EX : MSPCodes.MSP_STATUS);
|
|
||||||
await MSP.promise(MSPCodes.MSP_DATAFLASH_SUMMARY);
|
MSP.send_message(MSPCodes.MSP_DATAFLASH_SUMMARY, false, false);
|
||||||
if (FC.CONFIG.boardType == 0 || FC.CONFIG.boardType == 2) {
|
|
||||||
|
if (FC.CONFIG.boardType === 0 || FC.CONFIG.boardType === 2) {
|
||||||
startLiveDataRefreshTimer();
|
startLiveDataRefreshTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -688,8 +691,15 @@ function startLiveDataRefreshTimer() {
|
||||||
GUI.timeout_add('data_refresh', update_live_status, 100);
|
GUI.timeout_add('data_refresh', update_live_status, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update_live_status() {
|
async function getStatus() {
|
||||||
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_32)) {
|
||||||
|
return MSP.promise(MSPCodes.MSP_STATUS_EX);
|
||||||
|
} else {
|
||||||
|
return MSP.promise(MSPCodes.MSP_STATUS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function update_live_status() {
|
||||||
const statuswrapper = $('#quad-status_wrapper');
|
const statuswrapper = $('#quad-status_wrapper');
|
||||||
|
|
||||||
$(".quad-status-contents").css({
|
$(".quad-status-contents").css({
|
||||||
|
@ -698,7 +708,7 @@ async function update_live_status() {
|
||||||
|
|
||||||
if (GUI.active_tab !== 'cli' && GUI.active_tab !== 'presets') {
|
if (GUI.active_tab !== 'cli' && GUI.active_tab !== 'presets') {
|
||||||
await MSP.promise(MSPCodes.MSP_BOXNAMES);
|
await MSP.promise(MSPCodes.MSP_BOXNAMES);
|
||||||
await MSP.promise(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_32) ? MSPCodes.MSP_STATUS_EX : MSPCodes.MSP_STATUS);
|
await getStatus();
|
||||||
await MSP.promise(MSPCodes.MSP_ANALOG);
|
await MSP.promise(MSPCodes.MSP_ANALOG);
|
||||||
|
|
||||||
const active = ((Date.now() - FC.ANALOG.last_received_timestamp) < 300);
|
const active = ((Date.now() - FC.ANALOG.last_received_timestamp) < 300);
|
||||||
|
@ -828,7 +838,7 @@ function reinitializeConnection(originatorTab, callback) {
|
||||||
if (connectionTimestamp !== previousTimeStamp && CONFIGURATOR.connectionValid) {
|
if (connectionTimestamp !== previousTimeStamp && CONFIGURATOR.connectionValid) {
|
||||||
console.log(`Serial connection available after ${attempts / 10} seconds`);
|
console.log(`Serial connection available after ${attempts / 10} seconds`);
|
||||||
clearInterval(reconnect);
|
clearInterval(reconnect);
|
||||||
await MSP.promise(MSPCodes.MSP_STATUS);
|
await getStatus();
|
||||||
GUI.log(i18n.getMessage('deviceReady'));
|
GUI.log(i18n.getMessage('deviceReady'));
|
||||||
originatorTab.initialize(false, $('#content').scrollTop());
|
originatorTab.initialize(false, $('#content').scrollTop());
|
||||||
callback?.();
|
callback?.();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue