Skip to content

Commit

Permalink
Merge pull request #571 from basdelfos/3.1.x-fixes
Browse files Browse the repository at this point in the history
3.1.x fixes
  • Loading branch information
borisbstyle authored Jul 30, 2017
2 parents 9d240fb + f95b6f1 commit 05426a3
Show file tree
Hide file tree
Showing 10 changed files with 451 additions and 57 deletions.
36 changes: 36 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2480,6 +2480,42 @@
"configurationMagHardware": {
"message": "Magnetometer (if supported)"
},
"configurationBatteryVoltage": {
"message": "Battery Voltage"
},
"configurationBatteryCurrent": {
"message": "Battery Current"
},
"configurationBatteryMeterType": {
"message": "Battery Meter Type"
},
"configurationBatteryMinimum": {
"message": "Minimum Cell Voltage"
},
"configurationBatteryMaximum": {
"message": "Maximum Cell Voltage"
},
"configurationBatteryWarning": {
"message": "Warning Cell Voltage"
},
"configurationBatteryScale": {
"message": "Voltage Scale"
},
"configurationCurrentMeterType": {
"message": "Current Meter Type"
},
"configurationCurrent": {
"message": "Current Sensor"
},
"configurationCurrentScale": {
"message": "Scale the output voltage to milliamps [1/10th mV/A]"
},
"configurationCurrentOffset": {
"message": "Offset in millivolt steps"
},
"configurationBatteryMultiwiiCurrent": {
"message": "Enable support for legacy Multiwii MSP current output"
},
"pidTuningProfile": {
"message": "Profile"
},
Expand Down
6 changes: 3 additions & 3 deletions changelog.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<span>2016.07.29 - 3.1.2 - BetaFlight</span>
<span>2017.07.29 - 3.1.3 - BetaFlight</span>
<ul>
<li>First version suitable for 3.2 features</li>
<li>Fixed incompatibility issues with BF 3.1.x</li>
</ul>
<span>2016.03.09 - 3.1.1 - BetaFlight</span>
<span>2017.07.28 - 3.1.1 - BetaFlight</span>
<ul>
<li>Changed donation page to english</li>
</ul>
Expand Down
9 changes: 9 additions & 0 deletions js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

// define all the global variables that are uses to hold FC state
var CONFIG;
var BF_CONFIG; // Remove when we officialy retire BF 3.1
var FEATURE_CONFIG;
var BEEPER_CONFIG;
var MIXER_CONFIG;
Expand Down Expand Up @@ -79,6 +80,13 @@ var FC = {
boardType: 0,
};

BF_CONFIG = {
currentscale: 0,
currentoffset: 0,
currentmetertype: 0,
batterycapacity: 0,
};

FEATURE_CONFIG = {
features: 0,
};
Expand Down Expand Up @@ -228,6 +236,7 @@ var FC = {
vbatmincellvoltage: 0,
vbatmaxcellvoltage: 0,
vbatwarningcellvoltage: 0,
batterymetertype: 1, // 1=ADC, 2=ESC
};
MOTOR_CONFIG = {
minthrottle: 0,
Expand Down
104 changes: 63 additions & 41 deletions js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
}
break;
case MSPCodes.MSP_CURRENT_METERS:

CURRENT_METERS = [];
var currentMeterLength = 5;
for (var i = 0; i < (data.byteLength / currentMeterLength); i++) {
Expand All @@ -192,46 +193,63 @@ MspHelper.prototype.process_data = function(dataHandler) {
break;

case MSPCodes.MSP_VOLTAGE_METER_CONFIG:
VOLTAGE_METER_CONFIGS = [];
var voltage_meter_count = data.readU8();

for (var i = 0; i < voltage_meter_count; i++) {
var subframe_length = data.readU8();
if (subframe_length != 5) {
for (var j = 0; j < subframe_length; j++) {
data.readU8();
if (semver.lt(CONFIG.apiVersion, "1.36.0")) {
MISC.vbatscale = data.readU8(); // 10-200
MISC.vbatmincellvoltage = data.readU8() / 10; // 10-50
MISC.vbatmaxcellvoltage = data.readU8() / 10; // 10-50
MISC.vbatwarningcellvoltage = data.readU8() / 10; // 10-50
if (semver.gte(CONFIG.apiVersion, "1.23.0")) {
MISC.batterymetertype = data.readU8();
}
} else {
VOLTAGE_METER_CONFIGS = [];
var voltage_meter_count = data.readU8();

for (var i = 0; i < voltage_meter_count; i++) {
var subframe_length = data.readU8();
if (subframe_length != 5) {
for (var j = 0; j < subframe_length; j++) {
data.readU8();
}
} else {
var voltageMeterConfig = {};
voltageMeterConfig.id = data.readU8();
voltageMeterConfig.sensorType = data.readU8();
voltageMeterConfig.vbatscale = data.readU8();
voltageMeterConfig.vbatresdivval = data.readU8();
voltageMeterConfig.vbatresdivmultiplier = data.readU8();

VOLTAGE_METER_CONFIGS.push(voltageMeterConfig);
}
} else {
var voltageMeterConfig = {};
voltageMeterConfig.id = data.readU8();
voltageMeterConfig.sensorType = data.readU8();
voltageMeterConfig.vbatscale = data.readU8();
voltageMeterConfig.vbatresdivval = data.readU8();
voltageMeterConfig.vbatresdivmultiplier = data.readU8();

VOLTAGE_METER_CONFIGS.push(voltageMeterConfig);
}
}
break;
case MSPCodes.MSP_CURRENT_METER_CONFIG:
var offset = 0;
CURRENT_METER_CONFIGS = [];
var current_meter_count = data.readU8();
for (var i = 0; i < current_meter_count; i++) {
var currentMeterConfig = {};
var subframe_length = data.readU8();

if (subframe_length != 6) {
for (var j = 0; j < subframe_length; j++) {
data.readU8();
}
} else {
currentMeterConfig.id = data.readU8();
currentMeterConfig.sensorType = data.readU8();
currentMeterConfig.scale = data.readU16();
currentMeterConfig.offset = data.readU16();
if (semver.lt(CONFIG.apiVersion, "1.36.0")) {
BF_CONFIG.currentscale = data.read16();
BF_CONFIG.currentoffset = data.read16();
BF_CONFIG.currentmetertype = data.readU8();
BF_CONFIG.batterycapacity = data.readU16();
} else {
var offset = 0;
CURRENT_METER_CONFIGS = [];
var current_meter_count = data.readU8();
for (var i = 0; i < current_meter_count; i++) {
var currentMeterConfig = {};
var subframe_length = data.readU8();

if (subframe_length != 6) {
for (var j = 0; j < subframe_length; j++) {
data.readU8();
}
} else {
currentMeterConfig.id = data.readU8();
currentMeterConfig.sensorType = data.readU8();
currentMeterConfig.scale = data.readU16();
currentMeterConfig.offset = data.readU16();

CURRENT_METER_CONFIGS.push(currentMeterConfig);
CURRENT_METER_CONFIGS.push(currentMeterConfig);
}
}
}
break;
Expand Down Expand Up @@ -557,7 +575,9 @@ MspHelper.prototype.process_data = function(dataHandler) {

case MSPCodes.MSP_MIXER_CONFIG:
MIXER_CONFIG.mixer = data.readU8();
MIXER_CONFIG.reverseMotorDir = data.readU8();
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
MIXER_CONFIG.reverseMotorDir = data.readU8();
}
break;

case MSPCodes.MSP_FEATURE_CONFIG:
Expand Down Expand Up @@ -1161,7 +1181,9 @@ MspHelper.prototype.crunch = function(code) {
break;
case MSPCodes.MSP_SET_MIXER_CONFIG:
buffer.push8(MIXER_CONFIG.mixer)
.push8(MIXER_CONFIG.reverseMotorDir);
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
buffer.push8(MIXER_CONFIG.reverseMotorDir);
}
break;
case MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG:
buffer.push16(BOARD_ALIGNMENT_CONFIG.roll)
Expand Down Expand Up @@ -1269,19 +1291,19 @@ MspHelper.prototype.crunch = function(code) {
case MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG:
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));
.push8(Math.round(MISC.vbatmincellvoltage * 10))
.push8(Math.round(MISC.vbatmaxcellvoltage * 10))
.push8(Math.round(MISC.vbatwarningcellvoltage * 10));
if (semver.gte(CONFIG.apiVersion, "1.23.0")) {
buffer.push8(BATTERY_CONFIG.voltageMeterSource);
buffer.push8(MISC.batterymetertype);
}
}
break;
case MSPCodes.MSP_SET_CURRENT_METER_CONFIG:
if (semver.lt(CONFIG.apiVersion, "1.36.0")) {
buffer.push16(BF_CONFIG.currentscale)
.push16(BF_CONFIG.currentoffset)
.push8(BATTERY_CONFIG.currentMeterSource)
.push8(BF_CONFIG.currentmetertype)
.push16(BF_CONFIG.batterycapacity)
}
break;
Expand Down
7 changes: 7 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,18 @@ function updateTabList(features) {
} else {
$('#tabs ul.mode-connected li.tab_transponder').hide();
}

if (features.isEnabled('OSD')) {
$('#tabs ul.mode-connected li.tab_osd').show();
} else {
$('#tabs ul.mode-connected li.tab_osd').hide();
}

if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
$('#tabs ul.mode-connected li.tab_power').show();
} else {
$('#tabs ul.mode-connected li.tab_power').hide();
}
}

function zeroPad(value, width) {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"minimum_chrome_version": "38",
"version": "3.1.2",
"version": "3.1.3",
"author": "Betaflight Squad",
"name": "Betaflight - Configurator",
"short_name": "Betaflight",
Expand Down
10 changes: 9 additions & 1 deletion tabs/configuration.css
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,21 @@
width: 150px;
}

.tab-configuration .currentMeterSource {
.tab-configuration .currentmetertype {
border: 1px solid silver;
margin-right: 5px;
float: left;
width: 150px;
}

.tab-configuration .vbatmonitoring {
margin-top: 5px;
}

.tab-configuration .currentMonitoring {
margin-top: 5px;
}

.tab-configuration .rssi td:nth-child(2) {
width: 30px;
}
Expand Down
Loading

0 comments on commit 05426a3

Please sign in to comment.