Skip to content

Commit 63af808

Browse files
committed
Several fixes for compatibility with BF 3.1.x
1 parent 192b3f1 commit 63af808

File tree

7 files changed

+446
-41
lines changed

7 files changed

+446
-41
lines changed

_locales/en/messages.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,6 +2480,45 @@
24802480
"configurationMagHardware": {
24812481
"message": "Magnetometer (if supported)"
24822482
},
2483+
// ---------------------------------------------
2484+
// Remove this when we officialy retire BF 3.1.x
2485+
"configurationBatteryVoltage": {
2486+
"message": "Battery Voltage"
2487+
},
2488+
"configurationBatteryCurrent": {
2489+
"message": "Battery Current"
2490+
},
2491+
"configurationBatteryMeterType": {
2492+
"message": "Battery Meter Type"
2493+
},
2494+
"configurationBatteryMinimum": {
2495+
"message": "Minimum Cell Voltage"
2496+
},
2497+
"configurationBatteryMaximum": {
2498+
"message": "Maximum Cell Voltage"
2499+
},
2500+
"configurationBatteryWarning": {
2501+
"message": "Warning Cell Voltage"
2502+
},
2503+
"configurationBatteryScale": {
2504+
"message": "Voltage Scale"
2505+
},
2506+
"configurationCurrentMeterType": {
2507+
"message": "Current Meter Type"
2508+
},
2509+
"configurationCurrent": {
2510+
"message": "Current Sensor"
2511+
},
2512+
"configurationCurrentScale": {
2513+
"message": "Scale the output voltage to milliamps [1/10th mV/A]"
2514+
},
2515+
"configurationCurrentOffset": {
2516+
"message": "Offset in millivolt steps"
2517+
},
2518+
"configurationBatteryMultiwiiCurrent": {
2519+
"message": "Enable support for legacy Multiwii MSP current output"
2520+
},
2521+
// --------------------------------------------- END
24832522
"pidTuningProfile": {
24842523
"message": "Profile"
24852524
},

js/fc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// define all the global variables that are uses to hold FC state
44
var CONFIG;
5+
var BF_CONFIG; // Remove when we officialy retire BF 3.1
56
var FEATURE_CONFIG;
67
var BEEPER_CONFIG;
78
var MIXER_CONFIG;
@@ -79,6 +80,13 @@ var FC = {
7980
boardType: 0,
8081
};
8182

83+
BF_CONFIG = {
84+
currentscale: 0,
85+
currentoffset: 0,
86+
currentmetertype: 0,
87+
batterycapacity: 0,
88+
};
89+
8290
FEATURE_CONFIG = {
8391
features: 0,
8492
};
@@ -228,6 +236,7 @@ var FC = {
228236
vbatmincellvoltage: 0,
229237
vbatmaxcellvoltage: 0,
230238
vbatwarningcellvoltage: 0,
239+
batterymetertype: 1, // 1=ADC, 2=ESC
231240
};
232241
MOTOR_CONFIG = {
233242
minthrottle: 0,

js/msp/MSPHelper.js

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
171171
}
172172
break;
173173
case MSPCodes.MSP_CURRENT_METERS:
174+
174175
CURRENT_METERS = [];
175176
var currentMeterLength = 5;
176177
for (var i = 0; i < (data.byteLength / currentMeterLength); i++) {
@@ -192,46 +193,63 @@ MspHelper.prototype.process_data = function(dataHandler) {
192193
break;
193194

194195
case MSPCodes.MSP_VOLTAGE_METER_CONFIG:
195-
VOLTAGE_METER_CONFIGS = [];
196-
var voltage_meter_count = data.readU8();
197-
198-
for (var i = 0; i < voltage_meter_count; i++) {
199-
var subframe_length = data.readU8();
200-
if (subframe_length != 5) {
201-
for (var j = 0; j < subframe_length; j++) {
202-
data.readU8();
196+
if (semver.lt(CONFIG.apiVersion, "1.36.0")) {
197+
MISC.vbatscale = data.readU8(); // 10-200
198+
MISC.vbatmincellvoltage = data.readU8() / 10; // 10-50
199+
MISC.vbatmaxcellvoltage = data.readU8() / 10; // 10-50
200+
MISC.vbatwarningcellvoltage = data.readU8() / 10; // 10-50
201+
if (semver.gte(CONFIG.apiVersion, "1.23.0")) {
202+
MISC.batterymetertype = data.readU8();
203+
}
204+
} else {
205+
VOLTAGE_METER_CONFIGS = [];
206+
var voltage_meter_count = data.readU8();
207+
208+
for (var i = 0; i < voltage_meter_count; i++) {
209+
var subframe_length = data.readU8();
210+
if (subframe_length != 5) {
211+
for (var j = 0; j < subframe_length; j++) {
212+
data.readU8();
213+
}
214+
} else {
215+
var voltageMeterConfig = {};
216+
voltageMeterConfig.id = data.readU8();
217+
voltageMeterConfig.sensorType = data.readU8();
218+
voltageMeterConfig.vbatscale = data.readU8();
219+
voltageMeterConfig.vbatresdivval = data.readU8();
220+
voltageMeterConfig.vbatresdivmultiplier = data.readU8();
221+
222+
VOLTAGE_METER_CONFIGS.push(voltageMeterConfig);
203223
}
204-
} else {
205-
var voltageMeterConfig = {};
206-
voltageMeterConfig.id = data.readU8();
207-
voltageMeterConfig.sensorType = data.readU8();
208-
voltageMeterConfig.vbatscale = data.readU8();
209-
voltageMeterConfig.vbatresdivval = data.readU8();
210-
voltageMeterConfig.vbatresdivmultiplier = data.readU8();
211-
212-
VOLTAGE_METER_CONFIGS.push(voltageMeterConfig);
213224
}
214225
}
215226
break;
216227
case MSPCodes.MSP_CURRENT_METER_CONFIG:
217-
var offset = 0;
218-
CURRENT_METER_CONFIGS = [];
219-
var current_meter_count = data.readU8();
220-
for (var i = 0; i < current_meter_count; i++) {
221-
var currentMeterConfig = {};
222-
var subframe_length = data.readU8();
223-
224-
if (subframe_length != 6) {
225-
for (var j = 0; j < subframe_length; j++) {
226-
data.readU8();
227-
}
228-
} else {
229-
currentMeterConfig.id = data.readU8();
230-
currentMeterConfig.sensorType = data.readU8();
231-
currentMeterConfig.scale = data.readU16();
232-
currentMeterConfig.offset = data.readU16();
228+
if (semver.lt(CONFIG.apiVersion, "1.36.0")) {
229+
BF_CONFIG.currentscale = data.read16();
230+
BF_CONFIG.currentoffset = data.read16();
231+
BF_CONFIG.currentmetertype = data.readU8();
232+
BF_CONFIG.batterycapacity = data.readU16();
233+
} else {
234+
var offset = 0;
235+
CURRENT_METER_CONFIGS = [];
236+
var current_meter_count = data.readU8();
237+
for (var i = 0; i < current_meter_count; i++) {
238+
var currentMeterConfig = {};
239+
var subframe_length = data.readU8();
240+
241+
if (subframe_length != 6) {
242+
for (var j = 0; j < subframe_length; j++) {
243+
data.readU8();
244+
}
245+
} else {
246+
currentMeterConfig.id = data.readU8();
247+
currentMeterConfig.sensorType = data.readU8();
248+
currentMeterConfig.scale = data.readU16();
249+
currentMeterConfig.offset = data.readU16();
233250

234-
CURRENT_METER_CONFIGS.push(currentMeterConfig);
251+
CURRENT_METER_CONFIGS.push(currentMeterConfig);
252+
}
235253
}
236254
}
237255
break;
@@ -1273,19 +1291,19 @@ MspHelper.prototype.crunch = function(code) {
12731291
case MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG:
12741292
if (semver.lt(CONFIG.apiVersion, "1.36.0")) {
12751293
buffer.push8(MISC.vbatscale)
1276-
.push8(Math.round(BATTERY_CONFIG.vbatmincellvoltage * 10))
1277-
.push8(Math.round(BATTERY_CONFIG.vbatmaxcellvoltage * 10))
1278-
.push8(Math.round(BATTERY_CONFIG.vbatwarningcellvoltage * 10));
1294+
.push8(Math.round(MISC.vbatmincellvoltage * 10))
1295+
.push8(Math.round(MISC.vbatmaxcellvoltage * 10))
1296+
.push8(Math.round(MISC.vbatwarningcellvoltage * 10));
12791297
if (semver.gte(CONFIG.apiVersion, "1.23.0")) {
1280-
buffer.push8(BATTERY_CONFIG.voltageMeterSource);
1298+
buffer.push8(MISC.batterymetertype);
12811299
}
12821300
}
12831301
break;
12841302
case MSPCodes.MSP_SET_CURRENT_METER_CONFIG:
12851303
if (semver.lt(CONFIG.apiVersion, "1.36.0")) {
12861304
buffer.push16(BF_CONFIG.currentscale)
12871305
.push16(BF_CONFIG.currentoffset)
1288-
.push8(BATTERY_CONFIG.currentMeterSource)
1306+
.push8(BF_CONFIG.currentmetertype)
12891307
.push16(BF_CONFIG.batterycapacity)
12901308
}
12911309
break;

main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,18 @@ function updateTabList(features) {
470470
} else {
471471
$('#tabs ul.mode-connected li.tab_transponder').hide();
472472
}
473+
473474
if (features.isEnabled('OSD')) {
474475
$('#tabs ul.mode-connected li.tab_osd').show();
475476
} else {
476477
$('#tabs ul.mode-connected li.tab_osd').hide();
477478
}
479+
480+
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
481+
$('#tabs ul.mode-connected li.tab_power').show();
482+
} else {
483+
$('#tabs ul.mode-connected li.tab_power').hide();
484+
}
478485
}
479486

480487
function zeroPad(value, width) {

tabs/configuration.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,21 @@
291291
width: 150px;
292292
}
293293

294-
.tab-configuration .currentMeterSource {
294+
.tab-configuration .currentmetertype {
295295
border: 1px solid silver;
296296
margin-right: 5px;
297297
float: left;
298298
width: 150px;
299299
}
300300

301+
.tab-configuration .vbatmonitoring {
302+
margin-top: 5px;
303+
}
304+
305+
.tab-configuration .currentMonitoring {
306+
margin-top: 5px;
307+
}
308+
301309
.tab-configuration .rssi td:nth-child(2) {
302310
width: 30px;
303311
}

tabs/configuration.html

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,11 +668,150 @@
668668
</div>
669669
</div>
670670
</div>
671+
<<<<<<< HEAD
671672

672673
</td>
673674
</tr>
674675
</table>
675676

677+
=======
678+
</div>
679+
</div>
680+
<div class="clear-both"></div>
681+
</div>
682+
683+
684+
<!-- -------------------------------------------------------- -->
685+
<!-- Remove this part when we officialy retire BF 3.1.x -->
686+
<div class="rightWrapper current voltage oldBatteryConfig">
687+
<div class="gui_box grey">
688+
<div class="gui_box_titlebar">
689+
<div class="spacer_box_title" i18n="configurationBatteryVoltage"></div>
690+
</div>
691+
<div class="spacer_box">
692+
<table cellpadding="0" cellspacing="0">
693+
<thead>
694+
<tr>
695+
<th i18n="configurationFeatureEnabled"></th>
696+
<th i18n="configurationFeatureDescription"></th>
697+
<th i18n="configurationFeatureName"></th>
698+
</tr>
699+
</thead>
700+
<tbody class="features batteryVoltage">
701+
<!-- table generated here -->
702+
</tbody>
703+
</table>
704+
<div class="select batterymetertype vbatmonitoring">
705+
<label>
706+
<select class="batterymetertype"><!-- list generated here --></select>
707+
<span i18n="configurationBatteryMeterType"></span>
708+
</label>
709+
</div>
710+
<div class="number vbatmonitoring">
711+
<label> <input type="number" name="mincellvoltage" step="0.1" min="1" max="5" /> <span
712+
i18n="configurationBatteryMinimum"></span>
713+
</label>
714+
</div>
715+
<div class="number vbatmonitoring">
716+
<label> <input type="number" name="maxcellvoltage" step="0.1" min="1" max="5" /> <span
717+
i18n="configurationBatteryMaximum"></span>
718+
</label>
719+
</div>
720+
<div class="number vbatmonitoring">
721+
<label> <input type="number" name="warningcellvoltage" step="0.1" min="1" max="5" /> <span
722+
i18n="configurationBatteryWarning"></span>
723+
</label>
724+
</div>
725+
<div class="number vbatmonitoring vbatCalibration">
726+
<label> <input type="number" name="voltagescale" step="1" min="10" max="255" /> <span
727+
i18n="configurationBatteryScale"></span>
728+
</label>
729+
</div>
730+
<div class="number vbatmonitoring">
731+
<label> <input type="text" name="batteryvoltage" readonly class="disabled" /> <span
732+
i18n="configurationBatteryVoltage"></span>
733+
</label>
734+
</div>
735+
</div>
736+
</div>
737+
<div class="gui_box grey">
738+
<div class="gui_box_titlebar">
739+
<div class="spacer_box_title" i18n="configurationCurrent"></div>
740+
</div>
741+
<div class="spacer_box">
742+
<table cellpadding="0" cellspacing="0">
743+
<thead>
744+
<tr>
745+
<th i18n="configurationFeatureEnabled"></th>
746+
<th i18n="configurationFeatureDescription"></th>
747+
<th i18n="configurationFeatureName"></th>
748+
</tr>
749+
</thead>
750+
<tbody class="features batteryCurrent">
751+
<!-- table generated here -->
752+
</tbody>
753+
</table>
754+
<div class="select currentMonitoring">
755+
<label>
756+
<select class="currentmetertype"><!-- list generated here --></select>
757+
<span i18n="configurationCurrentMeterType"></span>
758+
</label>
759+
</div>
760+
<div class="number currentMonitoring currentCalibration">
761+
<label> <input type="number" name="currentscale" step="1" min="-16000" max="16000" /> <span
762+
i18n="configurationCurrentScale"></span>
763+
</label>
764+
</div>
765+
<div class="number currentMonitoring currentCalibration">
766+
<label> <input type="number" name="currentoffset" step="1" min="-1600" max="16000" /> <span
767+
i18n="configurationCurrentOffset"></span>
768+
</label>
769+
</div>
770+
<div class="number currentMonitoring currentOutput">
771+
<label>
772+
<input type="text" name="batterycurrent" readonly class="disabled" /> <span
773+
i18n="configurationBatteryCurrent"></span>
774+
</label>
775+
</div>
776+
<div class="checkbox currentMonitoring currentOutput">
777+
<div class="numberspacer">
778+
<input type="checkbox" name="multiwiicurrentoutput" class="toggle" />
779+
</div>
780+
<label> <span i18n="configurationBatteryMultiwiiCurrent"></span>
781+
</label>
782+
</div>
783+
</div>
784+
</div>
785+
</div>
786+
<!-- -------------------------------------------------------- -->
787+
788+
<div class="leftWrapper beepers" style="width: calc(100% - 20px);">
789+
<div class="gui_box grey" style="margin-top:10px;">
790+
<div class="gui_box_titlebar">
791+
<div class="spacer_box_title" i18n="configurationBeeper"></div>
792+
</div>
793+
<div class="spacer_box">
794+
<table cellpadding="0" cellspacing="0">
795+
<tbody class="beeper-configuration" id="noline">
796+
<tr class="beeper-template" style="display:none">
797+
<td>
798+
<input class="beeper toggle" id="" name="" title="" type="checkbox" />
799+
</td>
800+
<td>
801+
<label for=""></label>
802+
</td>
803+
<td>
804+
<span i18n=""></span>
805+
</td>
806+
</tr>
807+
<!-- table generated here -->
808+
</tbody>
809+
</table>
810+
</div>
811+
</div>
812+
</div>
813+
<div class="clear-both"></div>
814+
>>>>>>> Several fixes for compatibility with BF 3.1.x
676815
<div class="content_toolbar">
677816
<div class="btn save_btn">
678817
<a class="save" href="#" i18n="configurationButtonSave"></a>

0 commit comments

Comments
 (0)