mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-16 21:05:30 +03:00
Changes according review comments
This commit is contained in:
parent
3ee2884d62
commit
30ff5a6af9
3 changed files with 77 additions and 29 deletions
|
@ -2016,7 +2016,7 @@
|
|||
"message": "$1 A"
|
||||
},
|
||||
"powerVoltageId10": {
|
||||
"message": "Onboard ADC"
|
||||
"message": "Battery"
|
||||
},
|
||||
"powerVoltageId20": {
|
||||
"message": "5V"
|
||||
|
@ -2100,7 +2100,7 @@
|
|||
"message": "Amperage Meter"
|
||||
},
|
||||
"powerAmperageId10": {
|
||||
"message": "Onboard ADC"
|
||||
"message": "Battery"
|
||||
},
|
||||
"powerAmperageId50": {
|
||||
"message": "ESC Combined"
|
||||
|
|
|
@ -1245,21 +1245,9 @@ MspHelper.prototype.crunch = function(code) {
|
|||
.push8(BATTERY_CONFIG.voltageMeterSource)
|
||||
.push8(BATTERY_CONFIG.currentMeterSource);
|
||||
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)
|
||||
if (semver.lt(CONFIG.apiVersion, "1.36.0")) {
|
||||
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));
|
||||
|
@ -1269,23 +1257,13 @@ MspHelper.prototype.crunch = function(code) {
|
|||
}
|
||||
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 {
|
||||
if (semver.lt(CONFIG.apiVersion, "1.36.0")) {
|
||||
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)
|
||||
|
@ -1669,6 +1647,68 @@ MspHelper.prototype.sendAdjustmentRanges = function(onCompleteCallback) {
|
|||
}
|
||||
};
|
||||
|
||||
MspHelper.prototype.sendVoltageConfig = function(onCompleteCallback) {
|
||||
|
||||
var nextFunction = send_next_voltage_config;
|
||||
|
||||
var configIndex = 0;
|
||||
|
||||
if (VOLTAGE_METER_CONFIGS.length == 0) {
|
||||
onCompleteCallback();
|
||||
} else {
|
||||
send_next_voltage_config();
|
||||
}
|
||||
|
||||
function send_next_voltage_config() {
|
||||
var buffer = [];
|
||||
|
||||
buffer.push8(VOLTAGE_METER_CONFIGS[configIndex].id)
|
||||
.push8(VOLTAGE_METER_CONFIGS[configIndex].vbatscale)
|
||||
.push8(VOLTAGE_METER_CONFIGS[configIndex].vbatresdivval)
|
||||
.push8(VOLTAGE_METER_CONFIGS[configIndex].vbatresdivmultiplier);
|
||||
|
||||
// prepare for next iteration
|
||||
configIndex++;
|
||||
if (configIndex == VOLTAGE_METER_CONFIGS.length) {
|
||||
nextFunction = onCompleteCallback;
|
||||
}
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG, buffer, false, nextFunction);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MspHelper.prototype.sendCurrentConfig = function(onCompleteCallback) {
|
||||
|
||||
var nextFunction = send_next_current_config;
|
||||
|
||||
var configIndex = 0;
|
||||
|
||||
if (CURRENT_METER_CONFIGS.length == 0) {
|
||||
onCompleteCallback();
|
||||
} else {
|
||||
send_next_current_config();
|
||||
}
|
||||
|
||||
function send_next_current_config() {
|
||||
var buffer = [];
|
||||
|
||||
buffer.push8(CURRENT_METER_CONFIGS[configIndex].id)
|
||||
.push16(CURRENT_METER_CONFIGS[configIndex].scale)
|
||||
.push16(CURRENT_METER_CONFIGS[configIndex].offset);
|
||||
|
||||
// prepare for next iteration
|
||||
configIndex++;
|
||||
if (configIndex == CURRENT_METER_CONFIGS.length) {
|
||||
nextFunction = onCompleteCallback;
|
||||
}
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_SET_CURRENT_METER_CONFIG, buffer, false, nextFunction);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
MspHelper.prototype.sendLedStripConfig = function(onCompleteCallback) {
|
||||
|
||||
var nextFunction = send_next_led_strip_config;
|
||||
|
|
|
@ -261,12 +261,20 @@ TABS.power.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function save_voltage_config() {
|
||||
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
|
||||
mspHelper.sendVoltageConfig(save_amperage_config);
|
||||
} else {
|
||||
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() {
|
||||
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
|
||||
mspHelper.sendCurrentConfig(save_to_eeprom);
|
||||
} else {
|
||||
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() {
|
||||
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, save_completed);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue