1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-23 16:25:22 +03:00

Fixed naming of the 'Altitude' graph in the sensors tab.

This commit is contained in:
mikeller 2019-09-25 22:11:56 +12:00
parent 2395c7a216
commit 0778587fcb
4 changed files with 36 additions and 25 deletions

View file

@ -155,11 +155,11 @@ TABS.sensors.initialize = function (callback) {
}
}
function plot_baro(enable) {
function plot_altitude(enable) {
if (enable) {
$('.wrapper.baro').show();
$('.wrapper.altitude').show();
} else {
$('.wrapper.baro').hide();
$('.wrapper.altitude').hide();
}
}
@ -194,7 +194,7 @@ TABS.sensors.initialize = function (callback) {
if (!have_sensor(CONFIG.activeSensors, 'mag')) {
checkboxes.eq(2).prop('disabled', true);
}
if (!have_sensor(CONFIG.activeSensors, 'baro')) {
if (!(have_sensor(CONFIG.activeSensors, 'baro') || (semver.gte(CONFIG.apiVersion, "1.40.0") && have_sensor(CONFIG.activeSensors, 'gps')))) {
checkboxes.eq(3).prop('disabled', true);
}
if (!have_sensor(CONFIG.activeSensors, 'sonar')) {
@ -222,7 +222,7 @@ TABS.sensors.initialize = function (callback) {
plot_mag(enable);
break;
case 3:
plot_baro(enable);
plot_altitude(enable);
break;
case 4:
plot_sonar(enable);
@ -242,6 +242,10 @@ TABS.sensors.initialize = function (callback) {
ConfigStorage.set({'graphs_enabled': checkboxes});
});
let altitudeHint_e = $('.tab-sensors #sensorsAltitudeHint');
if (semver.lt(CONFIG.apiVersion, "1.40.0")) {
altitudeHint_e.hide();
}
// Always start with default/empty sensor data array, clean slate all
initSensorData();
@ -250,13 +254,13 @@ TABS.sensors.initialize = function (callback) {
var samples_gyro_i = 0,
samples_accel_i = 0,
samples_mag_i = 0,
samples_baro_i = 0,
samples_altitude_i = 0,
samples_sonar_i = 0,
samples_debug_i = 0,
gyro_data = initDataArray(3),
accel_data = initDataArray(3),
mag_data = initDataArray(3),
baro_data = initDataArray(1),
altitude_data = initDataArray(1),
sonar_data = initDataArray(1),
debug_data = [
initDataArray(1),
@ -268,7 +272,7 @@ TABS.sensors.initialize = function (callback) {
var gyroHelpers = initGraphHelpers('#gyro', samples_gyro_i, [-2000, 2000]);
var accelHelpers = initGraphHelpers('#accel', samples_accel_i, [-2, 2]);
var magHelpers = initGraphHelpers('#mag', samples_mag_i, [-1, 1]);
var baroHelpers = initGraphHelpers('#baro', samples_baro_i);
var altitudeHelpers = initGraphHelpers('#altitude', samples_altitude_i);
var sonarHelpers = initGraphHelpers('#sonar', samples_sonar_i);
var debugHelpers = [
initGraphHelpers('#debug1', samples_debug_i),
@ -300,7 +304,7 @@ TABS.sensors.initialize = function (callback) {
'gyro': parseInt($('.tab-sensors select[name="gyro_refresh_rate"]').val(), 10),
'accel': parseInt($('.tab-sensors select[name="accel_refresh_rate"]').val(), 10),
'mag': parseInt($('.tab-sensors select[name="mag_refresh_rate"]').val(), 10),
'baro': parseInt($('.tab-sensors select[name="baro_refresh_rate"]').val(), 10),
'altitude': parseInt($('.tab-sensors select[name="altitude_refresh_rate"]').val(), 10),
'sonar': parseInt($('.tab-sensors select[name="sonar_refresh_rate"]').val(), 10),
'debug': parseInt($('.tab-sensors select[name="debug_refresh_rate"]').val(), 10)
};
@ -311,7 +315,7 @@ TABS.sensors.initialize = function (callback) {
'mag': parseFloat($('.tab-sensors select[name="mag_scale"]').val())
};
// handling of "data pulling" is a little bit funky here, as MSP_RAW_IMU contains values for gyro/accel/mag but not baro
// handling of "data pulling" is a little bit funky here, as MSP_RAW_IMU contains values for gyro/accel/mag but not altitude
// this means that setting a slower refresh rate on any of the attributes would have no effect
// what we will do instead is = determinate the fastest refresh rate for those 3 attributes, use that as a "polling rate"
// and use the "slower" refresh rates only for re-drawing the graphs (to save resources/computing power)
@ -344,7 +348,7 @@ TABS.sensors.initialize = function (callback) {
if (checkboxes[3]) {
GUI.interval_add('altitude_pull', function altitude_data_pull() {
MSP.send_message(MSPCodes.MSP_ALTITUDE, false, false, update_altitude_graph);
}, rates.baro, true);
}, rates.altitude, true);
}
if (checkboxes[4]) {
@ -392,10 +396,10 @@ TABS.sensors.initialize = function (callback) {
}
function update_altitude_graph() {
updateGraphHelperSize(baroHelpers);
updateGraphHelperSize(altitudeHelpers);
samples_baro_i = addSampleToData(baro_data, samples_baro_i, [SENSOR_DATA.altitude]);
drawGraph(baroHelpers, baro_data, samples_baro_i);
samples_altitude_i = addSampleToData(altitude_data, samples_altitude_i, [SENSOR_DATA.altitude]);
drawGraph(altitudeHelpers, altitude_data, samples_altitude_i);
raw_data_text_ements.x[3].text(SENSOR_DATA.altitude.toFixed(2));
}
@ -431,7 +435,7 @@ TABS.sensors.initialize = function (callback) {
$('.tab-sensors select[name="mag_refresh_rate"]').val(result.sensor_settings.rates.mag);
$('.tab-sensors select[name="mag_scale"]').val(result.sensor_settings.scales.mag);
$('.tab-sensors select[name="baro_refresh_rate"]').val(result.sensor_settings.rates.baro);
$('.tab-sensors select[name="altitude_refresh_rate"]').val(result.sensor_settings.rates.altitude);
$('.tab-sensors select[name="sonar_refresh_rate"]').val(result.sensor_settings.rates.sonar);
$('.tab-sensors select[name="debug_refresh_rate"]').val(result.sensor_settings.rates.debug);