1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-26 17:55:24 +03:00

Fix: arm status [icon] (#3438)

Fix status
This commit is contained in:
Mark Haslinghuis 2023-05-09 17:33:49 +02:00 committed by GitHub
parent 5c3951626a
commit e789d97baa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 38 deletions

View file

@ -628,7 +628,7 @@ input[type="number"] {
transition: none; transition: none;
background-image: url(../images/icons/cf_icon_link_grey.svg); background-image: url(../images/icons/cf_icon_link_grey.svg);
} }
.armedicon.active {user-select .armedicon.active {
background-image: url(../images/icons/cf_icon_armed_active.svg); background-image: url(../images/icons/cf_icon_armed_active.svg);
} }
.failsafeicon.active { .failsafeicon.active {
@ -1727,8 +1727,6 @@ dialog {
} }
.buildInfoBtn { .buildInfoBtn {
position: relative; position: relative;
margin-bottom: 0px;
margin-top: 3px;
margin: 4px; margin: 4px;
float: right; float: right;
a { a {

View file

@ -1,4 +1,3 @@
import FC from './fc';
import { bit_check } from './bit'; import { bit_check } from './bit';
export function have_sensor(sensors_detected, sensor_code) { export function have_sensor(sensors_detected, sensor_code) {
@ -29,7 +28,7 @@ export function sensor_status(sensors_detected = 0, gps_fix_state = 0) {
} }
// update UI (if necessary) // update UI (if necessary)
if (sensor_status.previous_sensors_detected == sensors_detected && sensor_status.previous_gps_fix_state == gps_fix_state) { if (sensor_status.previous_sensors_detected === sensors_detected && sensor_status.previous_gps_fix_state === gps_fix_state) {
return; return;
} }
@ -47,10 +46,7 @@ export function sensor_status(sensors_detected = 0, gps_fix_state = 0) {
$(".accicon", eSensorStatus).removeClass("active"); $(".accicon", eSensorStatus).removeClass("active");
} }
if ( if (have_sensor(sensors_detected, "gyro")) {
(FC.CONFIG.boardType == 0 || FC.CONFIG.boardType == 2) &&
have_sensor(sensors_detected, "gyro")
) {
$(".gyro", eSensorStatus).addClass("on"); $(".gyro", eSensorStatus).addClass("on");
$(".gyroicon", eSensorStatus).addClass("active"); $(".gyroicon", eSensorStatus).addClass("active");
} else { } else {

View file

@ -671,30 +671,11 @@ 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_ANALOG); await MSP.promise(MSPCodes.MSP_ANALOG);
await MSP.promise(MSPCodes.MSP_BOXNAMES);
await MSP.promise(MSPCodes.MSP_STATUS_EX);
const active = (performance.now() - FC.ANALOG.last_received_timestamp) < 300;
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));
}
}
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 ? 1 : Math.floor(FC.ANALOG.voltage / FC.BATTERY_CONFIG.vbatmaxcellvoltage) + 1;
const min = FC.BATTERY_CONFIG.vbatmincellvoltage * nbCells; const min = FC.BATTERY_CONFIG.vbatmincellvoltage * nbCells;
const max = FC.BATTERY_CONFIG.vbatmaxcellvoltage * nbCells; const max = FC.BATTERY_CONFIG.vbatmaxcellvoltage * nbCells;
const warn = FC.BATTERY_CONFIG.vbatwarningcellvoltage * nbCells; const warn = FC.BATTERY_CONFIG.vbatwarningcellvoltage * nbCells;
const NO_BATTERY_VOLTAGE_MAXIMUM = 1.8; // Maybe is better to add a call to MSP_BATTERY_STATE but is not available for all versions const NO_BATTERY_VOLTAGE_MAXIMUM = 1.8; // Maybe is better to add a call to MSP_BATTERY_STATE but is not available for all versions
if (FC.ANALOG.voltage < min && FC.ANALOG.voltage > NO_BATTERY_VOLTAGE_MAXIMUM) { if (FC.ANALOG.voltage < min && FC.ANALOG.voltage > NO_BATTERY_VOLTAGE_MAXIMUM) {
@ -710,13 +691,25 @@ async function update_live_status() {
} }
} }
if (have_sensor(FC.CONFIG.activeSensors, 'gps')) { await MSP.promise(MSPCodes.MSP_BOXNAMES);
await MSP.promise(MSPCodes.MSP_RAW_GPS); await MSP.promise(MSPCodes.MSP_STATUS_EX);
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));
}
} }
sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix); if (have_sensor(FC.CONFIG.activeSensors, 'gps')) {
await MSP.promise(MSPCodes.MSP_RAW_GPS);
$(".linkicon").toggleClass('active', active); sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix);
}
statuswrapper.show(); statuswrapper.show();
} }

View file

@ -252,7 +252,7 @@ motors.initialize = async function (callback) {
const motorsEnableTestModeElement = $('#motorsEnableTestMode'); const motorsEnableTestModeElement = $('#motorsEnableTestMode');
self.analyticsChanges = {}; self.analyticsChanges = {};
motorsEnableTestModeElement.prop('checked', false).trigger('change'); motorsEnableTestModeElement.prop('checked', self.armed);
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_42) || !(FC.MOTOR_CONFIG.use_dshot_telemetry || FC.MOTOR_CONFIG.use_esc_sensor)) { if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_42) || !(FC.MOTOR_CONFIG.use_dshot_telemetry || FC.MOTOR_CONFIG.use_esc_sensor)) {
$(".motor_testing .telemetry").hide(); $(".motor_testing .telemetry").hide();

View file

@ -24,7 +24,7 @@ setup.initialize = function (callback) {
} }
function load_status() { function load_status() {
MSP.send_message(MSPCodes.MSP_STATUS, false, false, load_mixer_config); MSP.send_message(MSPCodes.MSP_STATUS_EX, false, false, load_mixer_config);
} }
function load_mixer_config() { function load_mixer_config() {
@ -362,7 +362,7 @@ setup.initialize = function (callback) {
} }
sensor_e.append(i18n.getMessage('sensorStatusSonarShort'), ': ', sonarElements[[FC.SENSOR_CONFIG.sonar_hardware]]); sensor_e.append(i18n.getMessage('sensorStatusSonarShort'), ': ', sonarElements[[FC.SENSOR_CONFIG.sonar_hardware]]);
} }
}); });
}; };
const showFirmwareInfo = function() { const showFirmwareInfo = function() {
@ -401,7 +401,7 @@ setup.initialize = function (callback) {
showFirmwareInfo(); showFirmwareInfo();
// Show Sonar info box if sensor exist // Show Sonar info box if sensor exist
if (! have_sensor(FC.CONFIG.activeSensors, 'sonar')) { if (!have_sensor(FC.CONFIG.activeSensors, 'sonar')) {
$('.sonarBox').hide(); $('.sonarBox').hide();
} }