1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-24 16:55:22 +03:00

Merge pull request #31 from martinbudden/inav_nrf24

Added NRF24 setting to configuration tab
This commit is contained in:
Konstantin Sharlaimov 2016-07-25 01:54:57 +03:00 committed by GitHub
commit ec8941bb2d
7 changed files with 108 additions and 5 deletions

View file

@ -531,6 +531,15 @@
"featureTRANSPONDERTip": {
"message": "Configure via the Race Transponder tab after enabling."
},
"featureRX_NRF24": {
"message": "NRF24L01 based receiver"
},
"featureRX_NRF24Tip": {
"message": "Remember to set the NRF24 protocol after enabling."
},
"featureSOFTSPI": {
"message": "Enable CPU based SPI"
},
"configurationFeatureEnabled": {
"message": "Enabled"
@ -691,6 +700,9 @@
"configurationSerialRX": {
"message": "Serial Receiver Provider"
},
"configurationNrf24Protocol": {
"message": "NRF24 protocol"
},
"configurationEepromSaved": {
"message": "EEPROM <span style=\"color: #37a8db\">saved</span>"
},

View file

@ -546,7 +546,9 @@ function configuration_restore(callback) {
mincheck: 1100,
maxcheck: 1900,
rx_min_usec: 885,
rx_max_usec: 2115
rx_max_usec: 2115,
nrf24rx_protocol: 0,
nrf24rx_id: 0
};
}

View file

@ -253,7 +253,9 @@ var FC = {
mincheck: 0,
spektrum_sat_bind: 0,
rx_min_usec: 0,
rx_max_usec: 0
rx_max_usec: 0,
nrf24rx_protocol: 0,
nrf24rx_id: 0
};
FAILSAFE_CONFIG = {

View file

@ -853,6 +853,12 @@ var MSP = {
offset += 2;
RX_CONFIG.rx_max_usec = data.getUint16(offset, 1);
offset += 2;
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
RX_CONFIG.nrf24rx_protocol = data.getUint8(offset, 1);
offset++;
RX_CONFIG.nrf24rx_id = data.getUint32(offset, 1);
offset += 4;
}
break;
case MSP_codes.MSP_FAILSAFE_CONFIG:
@ -1380,6 +1386,13 @@ MSP.crunch = function (code) {
buffer.push(highByte(RX_CONFIG.rx_min_usec));
buffer.push(lowByte(RX_CONFIG.rx_max_usec));
buffer.push(highByte(RX_CONFIG.rx_max_usec));
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
buffer.push(RX_CONFIG.nrf24rx_protocol);
buffer.push(RX_CONFIG.nrf24rx_id & 0xFF);
buffer.push((RX_CONFIG.nrf24rx_id >> 8) & 0xFF);
buffer.push((RX_CONFIG.nrf24rx_id >> 16) & 0xFF);
buffer.push((RX_CONFIG.nrf24rx_id >> 24) & 0xFF);
}
break;
case MSP_codes.MSP_SET_FAILSAFE_CONFIG:

View file

@ -126,6 +126,12 @@
margin-bottom: 5px;
}
.tab-configuration .nrf24Protocol {
width: 100%;
border: 1px solid silver;
margin-bottom: 5px;
}
.tab-configuration .current .checkbox {
margin-top: 0px;
float: left;
@ -274,6 +280,10 @@
min-height: 214px;
}
.tab-configuration .nrf24provider {
min-height: 140px;
}
.tab-configuration .current td:nth-child(2) {
width: 30px;
}

View file

@ -212,6 +212,16 @@
</select>
</div>
</div>
<div class="gui_box grey nrf24provider">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="configurationNrf24Protocol"></div>
</div>
<div class="spacer_box">
<select class="nrf24Protocol" size="8">
<!-- list generated here -->
</select>
</div>
</div>
</div>
<div class="rightWrapper current voltage">
<div class="gui_box grey">

View file

@ -41,7 +41,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_loop_time() {
var next_callback = load_3d;
var next_callback = load_rx_config;
if (semver.gte(CONFIG.apiVersion, "1.8.0")) {
MSP.send_message(MSP_codes.MSP_LOOP_TIME, false, false, next_callback);
} else {
@ -49,6 +49,15 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
function load_rx_config() {
var next_callback = load_3d;
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
MSP.send_message(MSP_codes.MSP_RX_CONFIG, false, false, next_callback);
} else {
next_callback();
}
}
function load_3d() {
var next_callback = load_sensor_alignment;
if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
@ -145,6 +154,13 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
);
}
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
features.push(
{bit: 22, group: 'rxMode', mode: 'group', name: 'RX_NRF24', haveTip: true},
{bit: 23, group: 'other', name: 'SOFTSPI'}
);
}
function isFeatureEnabled(featureName) {
for (var i = 0; i < features.length; i++) {
if (features[i].name == featureName && bit_check(BF_CONFIG.features, features[i].bit)) {
@ -347,6 +363,30 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
// code below is a temporary fix, which we will be able to remove in the future (hopefully)
$('#content').scrollTop((scrollPosition) ? scrollPosition : 0);
var nrf24Protocoltypes = [
'V202 250Kbps',
'V202 1Mbps',
'Syma X',
'Syma X5C',
'Cheerson CX10',
'Cheerson CX10A',
'JJRC H8_3D',
'iNav Reference protocol'
];
var nrf24Protocol_e = $('select.nrf24Protocol');
for (var i = 0; i < nrf24Protocoltypes.length; i++) {
nrf24Protocol_e.append('<option value="' + i + '">' + nrf24Protocoltypes[i] + '</option>');
}
nrf24Protocol_e.change(function () {
RX_CONFIG.nrf24rx_protocol = parseInt($(this).val());
RX_CONFIG.nrf24rx_id = 0;
});
// select current nrf24 protocol
nrf24Protocol_e.val(RX_CONFIG.nrf24rx_protocol);
// fill board alignment
$('input[name="board_align_roll"]').val((BF_CONFIG.board_align_roll / 10.0).toFixed(1));
$('input[name="board_align_pitch"]').val((BF_CONFIG.board_align_pitch / 10.0).toFixed(1));
@ -492,7 +532,12 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
if (isFeatureEnabled('RX_SERIAL')) {
googleAnalytics.sendEvent('Setting', 'SerialRxProvider', serialRXtypes[BF_CONFIG.serialrx_type]);
}
// track feature usage
if (isFeatureEnabled('RX_NRF24')) {
googleAnalytics.sendEvent('Setting', 'nrf24Protocol', nrf24Protocoltypes[RX_CONFIG.nrf24rx_protocol]);
}
for (var i = 0; i < features.length; i++) {
var featureName = features[i].name;
if (isFeatureEnabled(featureName)) {
@ -541,7 +586,16 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function save_looptime_config() {
MSP.send_message(MSP_codes.MSP_SET_LOOP_TIME, MSP.crunch(MSP_codes.MSP_SET_LOOP_TIME), false, save_to_eeprom);
MSP.send_message(MSP_codes.MSP_SET_LOOP_TIME, MSP.crunch(MSP_codes.MSP_SET_LOOP_TIME), false, save_rx_config);
}
function save_rx_config() {
var next_callback = save_to_eeprom;
if(semver.gte(CONFIG.apiVersion, "1.21.0")) {
MSP.send_message(MSP_codes.MSP_SET_RX_CONFIG, MSP.crunch(MSP_codes.MSP_SET_RX_CONFIG), false, next_callback);
} else {
next_callback();
}
}
function save_to_eeprom() {