mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-17 21:35:33 +03:00
Finishing Power & Battery tab
This commit is contained in:
parent
667c4d5af3
commit
3ee2884d62
5 changed files with 219 additions and 125 deletions
|
@ -2007,7 +2007,7 @@
|
|||
"message": "Warning Cell Voltage"
|
||||
},
|
||||
"powerVoltageHead": {
|
||||
"message": "Voltage"
|
||||
"message": "Voltage Meter"
|
||||
},
|
||||
"powerVoltageValue": {
|
||||
"message": "$1 V"
|
||||
|
@ -2016,7 +2016,7 @@
|
|||
"message": "$1 A"
|
||||
},
|
||||
"powerVoltageId10": {
|
||||
"message": "Battery"
|
||||
"message": "Onboard ADC"
|
||||
},
|
||||
"powerVoltageId20": {
|
||||
"message": "5V"
|
||||
|
@ -2097,10 +2097,10 @@
|
|||
},
|
||||
|
||||
"powerAmperageHead": {
|
||||
"message": "Amperage"
|
||||
"message": "Amperage Meter"
|
||||
},
|
||||
"powerAmperageId10": {
|
||||
"message": "Battery"
|
||||
"message": "Onboard ADC"
|
||||
},
|
||||
"powerAmperageId50": {
|
||||
"message": "ESC Combined"
|
||||
|
@ -2149,15 +2149,18 @@
|
|||
},
|
||||
|
||||
"powerAmperageScale": {
|
||||
"message": "Scale the output voltage to milliamps [1/10th mV/A]"
|
||||
"message": "Scale"
|
||||
},
|
||||
"powerAmperageOffset": {
|
||||
"message": "Offset in millivolt steps"
|
||||
"message": "Offset in milliampere steps"
|
||||
},
|
||||
|
||||
"powerBatteryHead": {
|
||||
"message": "Battery"
|
||||
},
|
||||
"powerStateHead": {
|
||||
"message": "Power State"
|
||||
},
|
||||
"powerBatteryConnected": {
|
||||
"message": "Connected"
|
||||
},
|
||||
|
|
|
@ -1245,22 +1245,47 @@ MspHelper.prototype.crunch = function(code) {
|
|||
.push8(BATTERY_CONFIG.voltageMeterSource)
|
||||
.push8(BATTERY_CONFIG.currentMeterSource);
|
||||
break;
|
||||
// FIXME - Needs updating before it can be used.
|
||||
// case MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG:
|
||||
// buffer.push8(MISC.vbatscale)
|
||||
// .push8(Math.round(BATTERY_CONFIG.vbatmincellvoltage * 10))
|
||||
// .push8(Math.round(BATTERY_CONFIG.vbatmaxcellvoltage * 10))
|
||||
// .push8(Math.round(BATTERY_CONFIG.vbatwarningcellvoltage * 10));
|
||||
// if (semver.gte(CONFIG.apiVersion, "1.23.0")) {
|
||||
// buffer.push8(BATTERY_CONFIG.voltageMeterSource);
|
||||
// }
|
||||
// break;
|
||||
// case MSPCodes.MSP_SET_CURRENT_METER_CONFIG:
|
||||
// buffer.push16(BF_CONFIG.currentscale)
|
||||
// .push16(BF_CONFIG.currentoffset)
|
||||
// .push8(BATTERY_CONFIG.currentMeterSource)
|
||||
// .push16(BF_CONFIG.batterycapacity)
|
||||
// break;
|
||||
|
||||
case MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG:
|
||||
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
|
||||
buffer.push8(VOLTAGE_METER_CONFIGS.length)
|
||||
for (var i = 0; i < VOLTAGE_METER_CONFIGS.length; i++) {
|
||||
buffer.push8(4) // subframe length
|
||||
.push8(VOLTAGE_METER_CONFIGS[i].id)
|
||||
.push8(VOLTAGE_METER_CONFIGS[i].vbatscale)
|
||||
.push8(VOLTAGE_METER_CONFIGS[i].vbatresdivval)
|
||||
.push8(VOLTAGE_METER_CONFIGS[i].vbatresdivmultiplier);
|
||||
}
|
||||
}
|
||||
else {
|
||||
buffer
|
||||
.push8(MISC.vbatscale)
|
||||
.push8(Math.round(BATTERY_CONFIG.vbatmincellvoltage * 10))
|
||||
.push8(Math.round(BATTERY_CONFIG.vbatmaxcellvoltage * 10))
|
||||
.push8(Math.round(BATTERY_CONFIG.vbatwarningcellvoltage * 10));
|
||||
if (semver.gte(CONFIG.apiVersion, "1.23.0")) {
|
||||
buffer.push8(BATTERY_CONFIG.voltageMeterSource);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSPCodes.MSP_SET_CURRENT_METER_CONFIG:
|
||||
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
|
||||
buffer.push8(CURRENT_METER_CONFIGS.length)
|
||||
for (var i = 0; i < CURRENT_METER_CONFIGS.length; i++) {
|
||||
buffer.push8(5) // subframe length
|
||||
.push8(CURRENT_METER_CONFIGS[i].id)
|
||||
.push16(CURRENT_METER_CONFIGS[i].scale)
|
||||
.push16(CURRENT_METER_CONFIGS[i].offset);
|
||||
}
|
||||
}
|
||||
else {
|
||||
buffer.push16(BF_CONFIG.currentscale)
|
||||
.push16(BF_CONFIG.currentoffset)
|
||||
.push8(BATTERY_CONFIG.currentMeterSource)
|
||||
.push16(BF_CONFIG.batterycapacity)
|
||||
}
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP_SET_RX_CONFIG:
|
||||
buffer.push8(RX_CONFIG.serialrx_provider)
|
||||
.push16(RX_CONFIG.stick_max)
|
||||
|
|
|
@ -2,11 +2,20 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
.tab-power .leftWrapper {
|
||||
float: left;
|
||||
width:calc(50% - 20px)
|
||||
}
|
||||
|
||||
.tab-power .rightWrapper {
|
||||
float: left;
|
||||
width: calc(50% - 0px);
|
||||
margin: 0 0 10px 20px;
|
||||
}
|
||||
|
||||
.tab-power td.configuration {
|
||||
padding-top: 5px;
|
||||
text-align: left;
|
||||
width: 50%;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.tab-power .battery-state .configuration {
|
||||
|
@ -18,6 +27,10 @@
|
|||
width: 20%;
|
||||
}
|
||||
|
||||
.tab-power .label {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.tab-power .number input {
|
||||
width: 50px;
|
||||
padding-left: 3px;
|
||||
|
@ -32,11 +45,7 @@
|
|||
}
|
||||
|
||||
|
||||
.tab-power .spacer_box {
|
||||
padding-bottom: 10px;
|
||||
float: left;
|
||||
width: calc(100% - 20px);
|
||||
}
|
||||
|
||||
|
||||
.tab-power .number,
|
||||
.tab-power .select
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="tab-power toolbar_fixed_bottom">
|
||||
<div class="content_wrapper initialstyle">
|
||||
<div class="content_wrapper">
|
||||
<!-- should be the first DIV on each tab -->
|
||||
<div class="cf_column spacerbottom">
|
||||
<div class="tab_title" i18n="tabPower">Power</div>
|
||||
|
@ -7,19 +7,46 @@
|
|||
<a id="button-documentation" href="" target="_blank"></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="require-support">
|
||||
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="leftWrapper">
|
||||
<div class="gui_box grey">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title" i18n="powerBatteryHead"></div>
|
||||
</div>
|
||||
<div class="spacer_box battery">
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cf_table">
|
||||
<table border="0" cellpadding="0" cellspacing="0" class="cf_table">
|
||||
<tbody class="battery-config">
|
||||
<td class="configuration" rowspan="4"></td>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rightWrapper">
|
||||
<div class="gui_box grey">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title" i18n="powerStateHead"></div>
|
||||
</div>
|
||||
<div class="spacer_box battery">
|
||||
<table border="0" cellpadding="0" cellspacing="0" class="cf_table">
|
||||
<tbody class="battery-state">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gui_box grey">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="leftWrapper">
|
||||
<div class="gui_box grey boxVoltageConfiguration">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title" i18n="powerVoltageHead"></div>
|
||||
</div>
|
||||
|
@ -30,7 +57,17 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gui_box grey">
|
||||
</div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="leftWrapper">
|
||||
<div class="gui_box grey boxAmperageConfiguration">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title" i18n="powerAmperageHead"></div>
|
||||
</div>
|
||||
|
@ -42,12 +79,18 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<div class="note require-upgrade">
|
||||
<div class="note_spacer">
|
||||
<p i18n="powerFirmwareUpgradeRequired"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content_toolbar">
|
||||
<div class="btn save_btn">
|
||||
<a class="save" href="#" i18n="powerButtonSave"></a>
|
||||
|
@ -76,12 +119,11 @@
|
|||
</tbody>
|
||||
</table>
|
||||
|
||||
<table class="battery-states">
|
||||
<table class="battery-state">
|
||||
<tbody class="battery-state">
|
||||
<tr class="connection-state">
|
||||
<td i18n="powerBatteryConnected"></td>
|
||||
<td class="value">?</td>
|
||||
<td class="configuration" rowspan="4"></td>
|
||||
</tr>
|
||||
<tr class="voltage">
|
||||
<td i18n="powerBatteryVoltage"></td>
|
||||
|
|
|
@ -65,6 +65,9 @@ TABS.power.initialize = function (callback) {
|
|||
var template = $('#tab-power-templates .voltage-meters .voltage-meter');
|
||||
var destination = $('.tab-power .voltage-meters');
|
||||
|
||||
if (BATTERY_CONFIG.voltageMeterSource == 0)
|
||||
$('.boxVoltageConfiguration').hide();
|
||||
|
||||
for (var index = 0; index < VOLTAGE_METERS.length; index++) {
|
||||
var meterElement = template.clone();
|
||||
$(meterElement).attr('id', 'voltage-meter-' + index);
|
||||
|
@ -72,6 +75,12 @@ TABS.power.initialize = function (callback) {
|
|||
var message = chrome.i18n.getMessage('powerVoltageId' + VOLTAGE_METERS[index].id);
|
||||
$(meterElement).find('.label').text(message)
|
||||
destination.append(meterElement);
|
||||
|
||||
meterElement.hide();
|
||||
if ((BATTERY_CONFIG.voltageMeterSource == 1 && VOLTAGE_METERS[index].id == 10) // TODO: replace hardcoded constants
|
||||
|| (BATTERY_CONFIG.voltageMeterSource == 2 && VOLTAGE_METERS[index].id >= 50)) {
|
||||
meterElement.show();
|
||||
}
|
||||
}
|
||||
|
||||
var template = $('#tab-power-templates .voltage-configuration');
|
||||
|
@ -85,9 +94,9 @@ TABS.power.initialize = function (callback) {
|
|||
}
|
||||
destination.append(element);
|
||||
|
||||
$('input[name="vbatscale-' + index + '"]').val(VOLTAGE_METER_CONFIGS[index].vbatscale).attr('disabled','disabled');
|
||||
$('input[name="vbatresdivval-' + index + '"]').val(VOLTAGE_METER_CONFIGS[index].vbatresdivval).attr('disabled','disabled');
|
||||
$('input[name="vbatresdivmultiplier-' + index + '"]').val(VOLTAGE_METER_CONFIGS[index].vbatresdivmultiplier).attr('disabled','disabled');
|
||||
$('input[name="vbatscale-' + index + '"]').val(VOLTAGE_METER_CONFIGS[index].vbatscale);
|
||||
$('input[name="vbatresdivval-' + index + '"]').val(VOLTAGE_METER_CONFIGS[index].vbatresdivval);
|
||||
$('input[name="vbatresdivmultiplier-' + index + '"]').val(VOLTAGE_METER_CONFIGS[index].vbatresdivmultiplier);
|
||||
}
|
||||
|
||||
// amperage meters
|
||||
|
@ -95,6 +104,9 @@ TABS.power.initialize = function (callback) {
|
|||
var template = $('#tab-power-templates .amperage-meters .amperage-meter');
|
||||
var destination = $('.tab-power .amperage-meters');
|
||||
|
||||
if (BATTERY_CONFIG.currentMeterSource == 0)
|
||||
$('.boxAmperageConfiguration').hide();
|
||||
|
||||
for (var index = 0; index < CURRENT_METERS.length; index++) {
|
||||
var meterElement = template.clone();
|
||||
$(meterElement).attr('id', 'amperage-meter-' + index);
|
||||
|
@ -102,6 +114,13 @@ TABS.power.initialize = function (callback) {
|
|||
var message = chrome.i18n.getMessage('powerAmperageId' + CURRENT_METERS[index].id);
|
||||
$(meterElement).find('.label').text(message)
|
||||
destination.append(meterElement);
|
||||
|
||||
meterElement.hide();
|
||||
if ((BATTERY_CONFIG.currentMeterSource == 1 && CURRENT_METERS[index].id == 10) // TODO: replace constants
|
||||
|| (BATTERY_CONFIG.currentMeterSource == 2 && CURRENT_METERS[index].id == 80)
|
||||
|| (BATTERY_CONFIG.currentMeterSource == 3 && CURRENT_METERS[index].id >= 50 && CURRENT_METERS[index].id < 80)) {
|
||||
meterElement.show();
|
||||
}
|
||||
}
|
||||
|
||||
var template = $('#tab-power-templates .amperage-configuration');
|
||||
|
@ -115,14 +134,14 @@ TABS.power.initialize = function (callback) {
|
|||
}
|
||||
destination.append(element);
|
||||
|
||||
$('input[name="amperagescale-' + index + '"]').val(CURRENT_METER_CONFIGS[index].scale).attr('disabled','disabled');
|
||||
$('input[name="amperageoffset-' + index + '"]').val(CURRENT_METER_CONFIGS[index].offset).attr('disabled','disabled');
|
||||
$('input[name="amperagescale-' + index + '"]').val(CURRENT_METER_CONFIGS[index].scale);
|
||||
$('input[name="amperageoffset-' + index + '"]').val(CURRENT_METER_CONFIGS[index].offset);
|
||||
}
|
||||
|
||||
|
||||
// battery
|
||||
|
||||
var template = $('#tab-power-templates .battery-states .battery-state');
|
||||
var template = $('#tab-power-templates .battery-state .battery-state');
|
||||
var destination = $('.tab-power .battery-state');
|
||||
var element = template.clone();
|
||||
$(element).find('.connection-state').attr('id', 'battery-connection-state');
|
||||
|
@ -221,7 +240,6 @@ TABS.power.initialize = function (callback) {
|
|||
|
||||
$('a.save').click(function () {
|
||||
|
||||
/* FIXME update for api 1.33.0
|
||||
for (var index = 0; index < VOLTAGE_METER_CONFIGS.length; index++) {
|
||||
VOLTAGE_METER_CONFIGS[index].vbatscale = parseInt($('input[name="vbatscale-' + index + '"]').val());
|
||||
VOLTAGE_METER_CONFIGS[index].vbatresdivval = parseInt($('input[name="vbatresdivval-' + index + '"]').val());
|
||||
|
@ -232,25 +250,22 @@ TABS.power.initialize = function (callback) {
|
|||
CURRENT_METER_CONFIGS[index].scale = parseInt($('input[name="amperagescale-' + index + '"]').val());
|
||||
CURRENT_METER_CONFIGS[index].offset = parseInt($('input[name="amperageoffset-' + index + '"]').val());
|
||||
}
|
||||
*/
|
||||
|
||||
BATTERY_CONFIG.vbatmincellvoltage = parseFloat($('input[name="mincellvoltage"]').val());
|
||||
BATTERY_CONFIG.vbatmaxcellvoltage = parseFloat($('input[name="maxcellvoltage"]').val());
|
||||
BATTERY_CONFIG.vbatwarningcellvoltage = parseFloat($('input[name="warningcellvoltage"]').val());
|
||||
BATTERY_CONFIG.capacity = parseInt($('input[name="capacity"]').val());
|
||||
|
||||
/* FIXME update for api 1.33.0
|
||||
function save_battery_config() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_BATTERY_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BATTERY_CONFIG), false, save_voltage_config);
|
||||
}
|
||||
|
||||
function save_voltage_config() {
|
||||
MSP.sendVoltageMeterConfigs(save_amperage_config);
|
||||
MSP.send_message(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG), false, save_amperage_config);
|
||||
}
|
||||
|
||||
function save_amperage_config() {
|
||||
MSP.sendAmperageMeterConfigs(save_battery_config);
|
||||
}
|
||||
*/
|
||||
|
||||
function save_battery_config() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_BATTERY_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BATTERY_CONFIG), false, save_to_eeprom);
|
||||
MSP.send_message(MSPCodes.MSP_SET_CURRENT_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_CURRENT_METER_CONFIG), false, save_to_eeprom);
|
||||
}
|
||||
|
||||
function save_to_eeprom() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue