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

Changes according review comments

This commit is contained in:
Bas Delfos 2017-07-18 22:18:29 +02:00
parent 3ee2884d62
commit 30ff5a6af9
3 changed files with 77 additions and 29 deletions

View file

@ -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;