Skip to content

Commit f7d4f74

Browse files
authored
Merge pull request #45 from KiteAnton/sensor_config
Added sensor enable/disable to system settings in configuration tab
2 parents 040e090 + 3bd7754 commit f7d4f74

File tree

3 files changed

+73
-6
lines changed

3 files changed

+73
-6
lines changed

_locales/en/messages.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@
666666
"message": "Cycles/Sec (Hz)"
667667
},
668668
"configurationLoopTimeHelp": {
669-
"message": "<strong>Note:</strong> Make sure your FC is capable to operate on these speeds! Check CPU and cycletime stability. Changing this may require PID re-tuning. TIP: Disable Accelerometer and other sensors to gain more performance. (CLI commands: set acc_hardware = NONE, set baro_hardware = NONE, set mag_hardware = NONE)"
669+
"message": "<strong>Note:</strong> Make sure your FC is capable to operate on these speeds! Check CPU and cycletime stability. Changing this may require PID re-tuning. TIP: Disable Accelerometer and other sensors to gain more performance."
670670
},
671671
"configurationGPS": {
672672
"message": "GPS"
@@ -1647,5 +1647,15 @@
16471647
},
16481648
"configurationPidProcessDenom": {
16491649
"message": "PID loop frequency"
1650-
}
1650+
},
1651+
"configurationAccHardware": {
1652+
"message": "Accelerometer"
1653+
},
1654+
"configurationBaroHardware": {
1655+
"message": "Barometer"
1656+
},
1657+
"configurationMagHardware": {
1658+
"message": "Magnetometer"
1659+
}
1660+
16511661
}

tabs/configuration.html

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,15 +363,40 @@
363363
<span i18n="configurationGyroSyncDenom"></span>
364364
</label>
365365
</div>
366-
<div class="selectPidProcessDenom">
366+
<div class="select selectPidProcessDenom">
367367
<label>
368368
<select class="pidProcessDenom">
369369
<!-- list generated here -->
370370
</select>
371371
<span i18n="configurationPidProcessDenom"></span>
372372
</label>
373373
</div>
374-
374+
<div class="hardwareSelection">
375+
<div class="select">
376+
<div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;">
377+
<input type="checkbox" name="accHardwareSwitch" class="toggle" />
378+
</div>
379+
<label for="accHardwareSwitch"> <span class="freelabel"
380+
i18n="configurationAccHardware"></span>
381+
</label>
382+
</div>
383+
<div class="select">
384+
<div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;">
385+
<input type="checkbox" name="baroHardwareSwitch" class="toggle" />
386+
</div>
387+
<label for="baroHardwareSwitch"> <span class="freelabel"
388+
i18n="configurationBaroHardware"></span>
389+
</label>
390+
</div>
391+
<div class="select">
392+
<div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;">
393+
<input type="checkbox" name="magHardwareSwitch" class="toggle" />
394+
</div>
395+
<label for="magHardwareSwitch"> <span class="freelabel"
396+
i18n="configurationMagHardware"></span>
397+
</label>
398+
</div>
399+
</div>
375400
</div>
376401
</div>
377402
</div>

tabs/configuration.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,23 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
6262
}
6363

6464
function esc_protocol() {
65-
var next_callback = load_sensor_alignment;
65+
var next_callback = sensor_config;
6666
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
6767
MSP.send_message(MSP_codes.MSP_PID_ADVANCED_CONFIG, false, false, next_callback);
6868
} else {
6969
next_callback();
7070
}
7171
}
7272

73+
function sensor_config() {
74+
var next_callback = load_sensor_alignment;
75+
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
76+
MSP.send_message(MSP_codes.MSP_SENSOR_CONFIG, false, false, next_callback);
77+
} else {
78+
next_callback();
79+
}
80+
}
81+
7382
function load_sensor_alignment() {
7483
var next_callback = load_html;
7584
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
@@ -344,11 +353,22 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
344353

345354
});
346355

356+
$('input[name="accHardwareSwitch"]').prop('checked', (SENSOR_CONFIG.acc_hardware!=1)?1:0);
357+
$('input[name="baroHardwareSwitch"]').prop('checked', (SENSOR_CONFIG.baro_hardware!=1)?1:0);
358+
$('input[name="magHardwareSwitch"]').prop('checked', (SENSOR_CONFIG.mag_hardware!=1)?1:0);
359+
360+
361+
// Only show these sections for supported FW
347362
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.lt(CONFIG.flightControllerVersion, "2.8.1")) {
348363
$('.selectProtocol').hide();
349364
$('.checkboxPwm').hide();
350365
$('.selectPidProcessDenom').hide();
351366
}
367+
368+
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.lt(CONFIG.flightControllerVersion, "2.8.2")) {
369+
$('.hardwareSelection').hide();
370+
}
371+
352372

353373
// generate GPS
354374
var gpsProtocols = [
@@ -645,14 +665,26 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
645665
}
646666

647667
function save_looptime_config() {
648-
var next_callback = save_to_eeprom;
668+
var next_callback = save_sensor_config;
649669
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.lt(CONFIG.flightControllerVersion, "2.8.1")) {
650670
FC_CONFIG.loopTime = PID_ADVANCED_CONFIG.gyro_sync_denom * 125;
651671
MSP.send_message(MSP_codes.MSP_SET_LOOP_TIME, MSP.crunch(MSP_codes.MSP_SET_LOOP_TIME), false, next_callback);
652672
} else {
653673
next_callback();
654674
}
655675
}
676+
function save_sensor_config() {
677+
var next_callback = save_to_eeprom;
678+
679+
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.gte(CONFIG.flightControllerVersion, "2.8.2")) {
680+
SENSOR_CONFIG.acc_hardware = $('input[name="accHardwareSwitch"]').is(':checked')?0:1;
681+
SENSOR_CONFIG.baro_hardware = $('input[name="baroHardwareSwitch"]').is(':checked')?0:1;
682+
SENSOR_CONFIG.mag_hardware = $('input[name="magHardwareSwitch"]').is(':checked')?0:1
683+
MSP.send_message(MSP_codes.MSP_SET_SENSOR_CONFIG, MSP.crunch(MSP_codes.MSP_SET_SENSOR_CONFIG), false, next_callback);
684+
} else {
685+
next_callback();
686+
}
687+
}
656688

657689
function save_to_eeprom() {
658690
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, reboot);

0 commit comments

Comments
 (0)