mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-24 00:35:26 +03:00
Fix sensors and battery cellcount (#4221)
This commit is contained in:
parent
8826812bb4
commit
467b6cc9f7
5 changed files with 51 additions and 36 deletions
|
@ -704,14 +704,19 @@ export function read_serial(info) {
|
|||
}
|
||||
}
|
||||
|
||||
async function update_live_status() {
|
||||
export async function update_sensor_status() {
|
||||
const statuswrapper = $('#quad-status_wrapper');
|
||||
|
||||
if (GUI.active_tab !== 'cli' && GUI.active_tab !== 'presets') {
|
||||
await MSP.promise(MSPCodes.MSP_ANALOG);
|
||||
await MSP.promise(MSPCodes.MSP_BATTERY_STATE);
|
||||
await MSP.promise(MSPCodes.MSP_ANALOG);
|
||||
await MSP.promise(MSPCodes.MSP_BATTERY_STATE);
|
||||
|
||||
if (FC.ANALOG !== undefined) {
|
||||
let nbCells = Math.floor(FC.ANALOG.voltage / FC.BATTERY_CONFIG.vbatmaxcellvoltage) + 1;
|
||||
|
||||
if (FC.ANALOG.voltage == 0) {
|
||||
nbCells = 1;
|
||||
}
|
||||
|
||||
const nbCells = FC.ANALOG.voltage === 0 || FC.BATTERY_STATE.cellCount === 0 ? 1 : FC.BATTERY_STATE.cellCount;
|
||||
const min = FC.BATTERY_CONFIG.vbatmincellvoltage * nbCells;
|
||||
const max = FC.BATTERY_CONFIG.vbatmaxcellvoltage * nbCells;
|
||||
const warn = FC.BATTERY_CONFIG.vbatwarningcellvoltage * nbCells;
|
||||
|
@ -729,29 +734,36 @@ async function update_live_status() {
|
|||
$(".battery-status").addClass('state-ok').removeClass('state-warning').removeClass('state-empty');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await MSP.promise(MSPCodes.MSP_BOXNAMES);
|
||||
await MSP.promise(MSPCodes.MSP_STATUS_EX);
|
||||
await MSP.promise(MSPCodes.MSP_BOXNAMES);
|
||||
await MSP.promise(MSPCodes.MSP_STATUS_EX);
|
||||
|
||||
const active = (performance.now() - FC.ANALOG.last_received_timestamp) < 300;
|
||||
$(".linkicon").toggleClass('active', active);
|
||||
const active = (performance.now() - FC.ANALOG.last_received_timestamp) < 300;
|
||||
$(".linkicon").toggleClass('active', active);
|
||||
|
||||
for (let i = 0; i < FC.AUX_CONFIG.length; i++) {
|
||||
if (FC.AUX_CONFIG[i] === 'ARM') {
|
||||
$(".armedicon").toggleClass('active', bit_check(FC.CONFIG.mode, i));
|
||||
}
|
||||
if (FC.AUX_CONFIG[i] === 'FAILSAFE') {
|
||||
$(".failsafeicon").toggleClass('active', bit_check(FC.CONFIG.mode, i));
|
||||
}
|
||||
for (let i = 0; i < FC.AUX_CONFIG.length; i++) {
|
||||
if (FC.AUX_CONFIG[i] === 'ARM') {
|
||||
$(".armedicon").toggleClass('active', bit_check(FC.CONFIG.mode, i));
|
||||
}
|
||||
|
||||
if (have_sensor(FC.CONFIG.activeSensors, 'gps')) {
|
||||
await MSP.promise(MSPCodes.MSP_RAW_GPS);
|
||||
if (FC.AUX_CONFIG[i] === 'FAILSAFE') {
|
||||
$(".failsafeicon").toggleClass('active', bit_check(FC.CONFIG.mode, i));
|
||||
}
|
||||
}
|
||||
|
||||
sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix);
|
||||
if (have_sensor(FC.CONFIG.activeSensors, 'gps')) {
|
||||
await MSP.promise(MSPCodes.MSP_RAW_GPS);
|
||||
}
|
||||
|
||||
statuswrapper.show();
|
||||
sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix);
|
||||
|
||||
statuswrapper.show();
|
||||
}
|
||||
|
||||
async function update_live_status() {
|
||||
// cli or presets tab do not use MSP connection
|
||||
if (GUI.active_tab !== 'cli' && GUI.active_tab !== 'presets') {
|
||||
await update_sensor_status();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -792,7 +804,7 @@ export function reinitializeConnection(callback) {
|
|||
gui_log(i18n.getMessage('deviceReady'));
|
||||
}, 2000);
|
||||
|
||||
if (callback) {
|
||||
if (callback && typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue