Skip to content

Commit

Permalink
Fix: arm status [icon] (#3438)
Browse files Browse the repository at this point in the history
Fix status
  • Loading branch information
haslinghuis authored May 9, 2023
1 parent 5c39516 commit e789d97
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 37 deletions.
4 changes: 1 addition & 3 deletions src/css/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1727,8 +1727,6 @@ dialog {
}
.buildInfoBtn {
position: relative;
margin-bottom: 0px;
margin-top: 3px;
margin: 4px;
float: right;
a {
Expand Down
8 changes: 2 additions & 6 deletions src/js/sensor_helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import FC from './fc';
import { bit_check } from './bit';

export function have_sensor(sensors_detected, sensor_code) {
Expand Down Expand Up @@ -29,7 +28,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;
}

Expand All @@ -47,10 +46,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 {
Expand Down
41 changes: 17 additions & 24 deletions src/js/serial_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/tabs/motors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/js/tabs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -362,7 +362,7 @@ setup.initialize = function (callback) {
}
sensor_e.append(i18n.getMessage('sensorStatusSonarShort'), ': ', sonarElements[[FC.SENSOR_CONFIG.sonar_hardware]]);
}
});
});
};

const showFirmwareInfo = function() {
Expand Down Expand Up @@ -401,7 +401,7 @@ setup.initialize = function (callback) {
showFirmwareInfo();

// Show Sonar info box if sensor exist
if (! have_sensor(FC.CONFIG.activeSensors, 'sonar')) {
if (!have_sensor(FC.CONFIG.activeSensors, 'sonar')) {
$('.sonarBox').hide();
}

Expand Down

0 comments on commit e789d97

Please sign in to comment.