1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-19 22:35:15 +03:00

Add support for the RX changes in MSP

Implement a combobox selector for the receiver type, showing
just the options for the specific type (e.g. selecting serial
receiver reveals the combobox for the serial protocol).

On INAV > 1.7.3 read and write receiver type to RX_CONFIG rather
than to feature bits. Note that this will break the configurator
in builds with version = 1.7.4 before https://github.com/iNavFlight/inav/pull/1596/files
is applied.
This commit is contained in:
Alberto García Hierro 2017-10-05 21:37:59 +01:00
parent 836f72661c
commit 587d1c5cb4
5 changed files with 126 additions and 25 deletions

View file

@ -458,18 +458,31 @@
"message": "EEPROM <span style=\"color: #37a8db\">saved</span>"
},
"featureRX_PPM": {
"RX_PPM": {
"message": "PPM RX input"
},
"RX_SERIAL": {
"message": "Serial-based receiver (SPEKSAT, SBUS, SUMD)"
},
"RX_PARALLEL_PWM": {
"message": "PWM RX input (one wire per channel)"
},
"RX_MSP": {
"message": "MSP RX input (control via MSP port)"
},
"RX_NRF24": {
"message": "RX SPI based receiver (NRF24L01, RFM22)"
},
"RX_NONE": {
"message": "No receiver"
},
"featureVBAT": {
"message": "Battery voltage monitoring"
},
"featureINFLIGHT_ACC_CAL": {
"message": "In-flight level calibration"
},
"featureRX_SERIAL": {
"message": "Serial-based receiver (SPEKSAT, SBUS, SUMD)"
},
"featureMOTOR_STOP": {
"message": "Don't spin the motors when armed"
},
@ -503,12 +516,6 @@
"feature3D": {
"message": "3D mode (for use with reversible ESCs)"
},
"featureRX_PARALLEL_PWM": {
"message": "PWM RX input (one wire per channel)"
},
"featureRX_MSP": {
"message": "MSP RX input (control via MSP port)"
},
"featureRSSI_ADC": {
"message": "Analog RSSI input"
},
@ -545,12 +552,6 @@
"featureTRANSPONDERTip": {
"message": "Configure via the Race Transponder tab after enabling."
},
"featureRX_NRF24": {
"message": "RX SPI based receiver (NRF24L01, RFM22)"
},
"featureRX_NRF24Tip": {
"message": "Remember to set the RX SPI protocol after enabling."
},
"featureSOFTSPI": {
"message": "CPU based SPI"
},

View file

@ -347,6 +347,7 @@ var FC = {
};
RX_CONFIG = {
receiver_type: 0,
serialrx_provider: 0,
maxcheck: 0,
midrc: 0,
@ -392,9 +393,7 @@ var FC = {
},
getFeatures: function () {
var features = [
{bit: 0, group: 'rxMode', mode: 'group', name: 'RX_PPM'},
{bit: 1, group: 'batteryVoltage', name: 'VBAT'},
{bit: 3, group: 'rxMode', mode: 'group', name: 'RX_SERIAL'},
{bit: 4, group: 'esc', name: 'MOTOR_STOP'},
{bit: 5, group: 'other', name: 'SERVO_TILT', showNameInTip: true},
{bit: 6, group: 'other', name: 'SOFTSERIAL', haveTip: true, showNameInTip: true},
@ -402,8 +401,6 @@ var FC = {
{bit: 10, group: 'other', name: 'TELEMETRY', showNameInTip: true},
{bit: 11, group: 'batteryCurrent', name: 'CURRENT_METER'},
{bit: 12, group: 'other', name: '3D', showNameInTip: true},
{bit: 13, group: 'rxMode', mode: 'group', name: 'RX_PARALLEL_PWM'},
{bit: 14, group: 'rxMode', mode: 'group', name: 'RX_MSP'},
{bit: 15, group: 'other', name: 'RSSI_ADC', haveTip: true, showNameInTip: true},
{bit: 16, group: 'other', name: 'LED_STRIP', showNameInTip: true},
{bit: 17, group: 'other', name: 'DISPLAY', showNameInTip: true},
@ -444,7 +441,6 @@ var FC = {
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
features.push(
{bit: 25, group: 'rxMode', mode: 'group', name: 'RX_NRF24', haveTip: true},
{bit: 26, group: 'other', name: 'SOFTSPI'}
);
}
@ -604,6 +600,68 @@ var FC = {
'Disabled'
];
},
getRxTypes: function() {
// Keep value field in sync with rxReceiverType_e in rx.h
var rxTypes = [
{
name: 'RX_SERIAL',
bit: 3,
value: 3,
},
{
name: 'RX_PPM',
bit: 0,
value: 1,
},
{
name: 'RX_PARALLEL_PWM',
bit: 13,
value: 2,
},
{
name: 'RX_MSP',
bit: 14,
value: 4,
},
];
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
rxTypes.push(
{
name: 'RX_NRF24',
bit: 25,
value: 5,
},
);
}
if (semver.gt(CONFIG.flightControllerVersion, "1.7.3")) {
rxTypes.push(
{
name: 'RX_NONE',
value: 0,
},
);
}
return rxTypes;
},
isRxTypeEnabled: function(rxType) {
if (semver.gt(CONFIG.flightControllerVersion, "1.7.3")) {
return RX_CONFIG.receiver_type == rxType.value;
}
return bit_check(BF_CONFIG.features, rxType.bit);
},
setRxTypeEnabled: function(rxType) {
if (semver.gt(CONFIG.flightControllerVersion, "1.7.3")) {
RX_CONFIG.receiver_type = rxType.value;
} else {
// Clear other rx features before
var rxTypes = this.getRxTypes();
for (var ii = 0; ii < rxTypes.length; ii++) {
BF_CONFIG.features = bit_clear(BF_CONFIG.features, rxTypes[ii].bit);
}
// Set the feature for this rx type
BF_CONFIG.features = bit_set(BF_CONFIG.features, rxType.bit);
}
},
getSerialRxTypes: function () {
var data = [
'SPEKTRUM1024',

View file

@ -594,6 +594,10 @@ var mspHelper = (function (gui) {
RX_CONFIG.nrf24rx_id = data.getUint32(offset, true);
offset += 4;
}
if (semver.gt(CONFIG.flightControllerVersion, "1.7.3")) {
RX_CONFIG.receiver_type = data.getUint8(offset);
offset += 1;
}
break;
case MSPCodes.MSP_FAILSAFE_CONFIG:
@ -1170,6 +1174,10 @@ var mspHelper = (function (gui) {
buffer.push((RX_CONFIG.nrf24rx_id >> 16) & 0xFF);
buffer.push((RX_CONFIG.nrf24rx_id >> 24) & 0xFF);
}
if (semver.gt(CONFIG.flightControllerVersion, "1.7.3")) {
// receiver type in RX_CONFIG rather than in BF_CONFIG.features
buffer.push(RX_CONFIG.receiver_type);
}
break;
case MSPCodes.MSP_SET_FAILSAFE_CONFIG:

View file

@ -119,10 +119,10 @@
<div class="spacer_box_title" data-i18n="configurationReceiver"></div>
</div>
<div class="spacer_box">
<div class="features rxMode"></div>
<!--feature list goes here-->
<select id="rxType" class="full-width">
</select>
</div>
<div class="spacer_box">
<div data-rx-type="RX_SERIAL" class="spacer_box">
<h3 data-i18n="configurationSerialRX"></h3>
<div class="note">
<div class="note_spacer">
@ -133,7 +133,7 @@
<!-- list generated here -->
</select>
</div>
<div class="spacer_box">
<div data-rx-type="RX_NRF24" class="spacer_box">
<h3 data-i18n="configurationNrf24Protocol"></h3>
<select id="nrf24-protocol" class="full-width" size="1">
<!-- list generated here -->

View file

@ -84,6 +84,40 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
// select current mixer configuration
mixer_list_e.val(BF_CONFIG.mixerConfiguration).change();
// receiver configuration
var rxTypesSelect = $('#rxType');
var rxTypes = FC.getRxTypes();
for (var ii = 0; ii < rxTypes.length; ii++) {
var rxType = rxTypes[ii];
var option = $('<option value="' + rxType.name + '" >' + chrome.i18n.getMessage(rxType.name) + '</option>');
option.data('rx-type', rxType);
if (FC.isRxTypeEnabled(rxType)) {
option.prop('selected', true);
}
option.appendTo(rxTypesSelect);
}
var rxTypeOptions = $('[data-rx-type]');
var updateRxOptions = function(animated) {
var duration = animated ? 400 : 0;
rxTypeOptions.each(function (ii, obj) {
var $obj = $(obj);
var rxType = $obj.data('rx-type');
if (rxType && rxType != rxTypesSelect.val()) {
$obj.slideUp(duration);
} else {
$obj.slideDown(duration);
}
});
};
updateRxOptions(false);
rxTypesSelect.change(function () {
updateRxOptions(true);
var rxType = rxTypesSelect.find(':selected').data('rx-type');
FC.setRxTypeEnabled(rxType);
});
// generate features
var features = FC.getFeatures();