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

Merge pull request #371 from mikeller/fix_voltage_current_config_for_old_versions

Fixed voltage / current meter configuration for firmware versions < 3.1.
This commit is contained in:
Michael Keller 2017-01-04 10:58:49 +13:00 committed by GitHub
commit 883f5464c4
3 changed files with 48 additions and 33 deletions

View file

@ -295,7 +295,7 @@
width: 30px; width: 30px;
} }
.tab-configuration .batterymetertype { .tab-configuration select.batterymetertype {
border: 1px solid silver; border: 1px solid silver;
margin-right: 5px; margin-right: 5px;
float: left; float: left;

View file

@ -339,7 +339,7 @@
<!-- table generated here --> <!-- table generated here -->
</tbody> </tbody>
</table> </table>
<div class="select"> <div class="select batterymetertype">
<label> <label>
<select class="batterymetertype"><!-- list generated here --></select> <select class="batterymetertype"><!-- list generated here --></select>
<span i18n="configurationBatteryMeterType"></span> <span i18n="configurationBatteryMeterType"></span>

View file

@ -444,22 +444,26 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('input[name="mincommand"]').val(MISC.mincommand); $('input[name="mincommand"]').val(MISC.mincommand);
// fill battery // fill battery
var batteryMeterTypes = [ if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
'Onboard ADC', var batteryMeterTypes = [
'ESC Sensor', 'Onboard ADC',
]; 'ESC Sensor'
];
var batteryMeterType_e = $('select.batterymetertype'); var batteryMeterType_e = $('select.batterymetertype');
for (i = 0; i < batteryMeterTypes.length; i++) { for (i = 0; i < batteryMeterTypes.length; i++) {
batteryMeterType_e.append('<option value="' + i + '">' + batteryMeterTypes[i] + '</option>'); batteryMeterType_e.append('<option value="' + i + '">' + batteryMeterTypes[i] + '</option>');
}
batteryMeterType_e.change(function () {
MISC.batterymetertype = parseInt($(this).val());
checkDisableVbatControls();
});
batteryMeterType_e.val(MISC.batterymetertype).change();
} else {
$('div.batterymetertype').hide();
} }
batteryMeterType_e.change(function () {
MISC.batterymetertype = parseInt($(this).val());
checkDisableVbatControls();
});
batteryMeterType_e.val(MISC.batterymetertype).change();
$('input[name="mincellvoltage"]').val(MISC.vbatmincellvoltage); $('input[name="mincellvoltage"]').val(MISC.vbatmincellvoltage);
$('input[name="maxcellvoltage"]').val(MISC.vbatmaxcellvoltage); $('input[name="maxcellvoltage"]').val(MISC.vbatmaxcellvoltage);
$('input[name="warningcellvoltage"]').val(MISC.vbatwarningcellvoltage); $('input[name="warningcellvoltage"]').val(MISC.vbatwarningcellvoltage);
@ -469,10 +473,13 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
var currentMeterTypes = [ var currentMeterTypes = [
'None', 'None',
'Onboard ADC', 'Onboard ADC',
'Virtual', 'Virtual'
'ESC Sensor',
]; ];
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
currentMeterTypes.push('ESC Sensor');
}
var currentMeterType_e = $('select.currentmetertype'); var currentMeterType_e = $('select.currentmetertype');
for (i = 0; i < currentMeterTypes.length; i++) { for (i = 0; i < currentMeterTypes.length; i++) {
currentMeterType_e.append('<option value="' + i + '">' + currentMeterTypes[i] + '</option>'); currentMeterType_e.append('<option value="' + i + '">' + currentMeterTypes[i] + '</option>');
@ -528,25 +535,33 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
function checkDisableVbatControls() { function checkDisableVbatControls() {
if (BF_CONFIG.features.isEnabled('VBAT')) { function disableBatteryControls(disabled) {
$('select.batterymetertype').prop('disabled', false); $('input[name="mincellvoltage"]').prop('disabled', disabled);
if (MISC.batterymetertype == 1) { $('input[name="maxcellvoltage"]').prop('disabled', disabled);
$('input[name="mincellvoltage"]').prop('disabled', true); $('input[name="warningcellvoltage"]').prop('disabled', disabled);
$('input[name="maxcellvoltage"]').prop('disabled', true); $('input[name="voltagescale"]').prop('disabled', disabled);
$('input[name="warningcellvoltage"]').prop('disabled', true); }
$('input[name="voltagescale"]').prop('disabled', true);
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
if (BF_CONFIG.features.isEnabled('VBAT')) {
$('select.batterymetertype').prop('disabled', false);
if (MISC.batterymetertype == 1) {
disableBatteryControls(true);
} else {
disableBatteryControls(false);
}
} else { } else {
$('input[name="mincellvoltage"]').prop('disabled', false); $('select.batterymetertype').prop('disabled', true);
$('input[name="maxcellvoltage"]').prop('disabled', false);
$('input[name="warningcellvoltage"]').prop('disabled', false); disableBatteryControls(true);
$('input[name="voltagescale"]').prop('disabled', false);
} }
} else { } else {
$('select.batterymetertype').prop('disabled', true); if (BF_CONFIG.features.isEnabled('VBAT')) {
$('input[name="mincellvoltage"]').prop('disabled', true); disableBatteryControls(false);
$('input[name="maxcellvoltage"]').prop('disabled', true); } else {
$('input[name="warningcellvoltage"]').prop('disabled', true); disableBatteryControls(true);
$('input[name="voltagescale"]').prop('disabled', true); }
} }
} }