diff --git a/src/css/main.less b/src/css/main.less index d7a6442ff9b..dd06f89f705 100644 --- a/src/css/main.less +++ b/src/css/main.less @@ -628,7 +628,7 @@ input[type="number"] { transition: none; 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); } .failsafeicon.active { diff --git a/src/js/sensor_helpers.js b/src/js/sensor_helpers.js index d204aab2d47..0d9990472cd 100644 --- a/src/js/sensor_helpers.js +++ b/src/js/sensor_helpers.js @@ -29,7 +29,7 @@ export function sensor_status(sensors_detected = 0, gps_fix_state = 0) { } // 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; } @@ -47,10 +47,7 @@ export function sensor_status(sensors_detected = 0, gps_fix_state = 0) { $(".accicon", eSensorStatus).removeClass("active"); } - if ( - (FC.CONFIG.boardType == 0 || FC.CONFIG.boardType == 2) && - have_sensor(sensors_detected, "gyro") - ) { + if (have_sensor(sensors_detected, "gyro")) { $(".gyro", eSensorStatus).addClass("on"); $(".gyroicon", eSensorStatus).addClass("active"); } else { diff --git a/src/js/serial_backend.js b/src/js/serial_backend.js index 38a42156328..2dcbc52cc2e 100644 --- a/src/js/serial_backend.js +++ b/src/js/serial_backend.js @@ -671,30 +671,11 @@ async function update_live_status() { if (GUI.active_tab !== 'cli' && GUI.active_tab !== 'presets') { 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 max = FC.BATTERY_CONFIG.vbatmaxcellvoltage * 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 if (FC.ANALOG.voltage < min && FC.ANALOG.voltage > NO_BATTERY_VOLTAGE_MAXIMUM) { @@ -710,14 +691,26 @@ async function update_live_status() { } } + 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); + + 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)); + } + } + if (have_sensor(FC.CONFIG.activeSensors, 'gps')) { await MSP.promise(MSPCodes.MSP_RAW_GPS); + sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix); } - sensor_status(FC.CONFIG.activeSensors, FC.GPS_DATA.fix); - - $(".linkicon").toggleClass('active', active); - statuswrapper.show(); } } diff --git a/src/js/tabs/motors.js b/src/js/tabs/motors.js index 532453f93ac..c56e0a57fd0 100644 --- a/src/js/tabs/motors.js +++ b/src/js/tabs/motors.js @@ -252,7 +252,7 @@ motors.initialize = async function (callback) { const motorsEnableTestModeElement = $('#motorsEnableTestMode'); 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)) { $(".motor_testing .telemetry").hide(); diff --git a/src/js/tabs/setup.js b/src/js/tabs/setup.js index fd9b409b535..e03c8105e32 100644 --- a/src/js/tabs/setup.js +++ b/src/js/tabs/setup.js @@ -24,7 +24,7 @@ setup.initialize = function (callback) { } 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() { @@ -362,7 +362,7 @@ setup.initialize = function (callback) { } sensor_e.append(i18n.getMessage('sensorStatusSonarShort'), ': ', sonarElements[[FC.SENSOR_CONFIG.sonar_hardware]]); } -}); + }); }; const showFirmwareInfo = function() { @@ -396,15 +396,6 @@ setup.initialize = function (callback) { } }; - prepareDisarmFlags(); - showSensorInfo(); - showFirmwareInfo(); - - // Show Sonar info box if sensor exist - if (! have_sensor(FC.CONFIG.activeSensors, 'sonar')) { - $('.sonarBox').hide(); - } - function get_slow_data() { // Status info is acquired in the background using update_live_status() in serial_backend.js @@ -453,6 +444,15 @@ setup.initialize = function (callback) { } } + prepareDisarmFlags(); + showSensorInfo(); + showFirmwareInfo(); + + // Show Sonar info box if sensor exist + if (!have_sensor(FC.CONFIG.activeSensors, 'sonar')) { + $('.sonarBox').hide(); + } + GUI.interval_add('setup_data_pull_fast', get_fast_data, 33, true); // 30 fps GUI.interval_add('setup_data_pull_slow', get_slow_data, 250, true); // 4 fps