Skip to content

Commit f2f2d7b

Browse files
authored
Merge pull request #453 from iNavFlight/agh_fix_msp_rx
Fix support for simulated RX via MSP, increase channels to 12
2 parents fa93da4 + 6e80fd2 commit f2f2d7b

File tree

6 files changed

+56
-19
lines changed

6 files changed

+56
-19
lines changed

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ sources.mapJs = [
116116
];
117117

118118
sources.receiverCss = [
119+
'./src/css/tabs/receiver_msp.css',
119120
'./css/opensans_webfontkit/fonts.css',
120121
'./js/libraries/jquery.nouislider.min.css',
121122
'./js/libraries/jquery.nouislider.pips.min.css',
122-
'./tabs/receiver_msp.css'
123123
];
124124

125125
sources.receiverJs = [

js/fc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,15 @@ var FC = {
762762
return rxTypes;
763763
},
764764
isRxTypeEnabled: function(rxType) {
765+
if (typeof rxType === 'string') {
766+
var types = this.getRxTypes();
767+
for (var ii = 0; ii < types.length; ii++) {
768+
if (types[ii].name == rxType) {
769+
rxType = types[ii];
770+
break;
771+
}
772+
}
773+
}
765774
if (semver.gt(CONFIG.flightControllerVersion, "1.7.3")) {
766775
return RX_CONFIG.receiver_type == rxType.value;
767776
}

src/css/tabs/receiver_msp.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
.slider-label {
8787
position: absolute;
8888
text-align: right;
89-
width: 40px;
90-
left: -65px;
89+
width: 50px;
90+
left: -75px;
9191
}
9292

9393
a {

tabs/receiver.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ TABS.receiver.initialize = function (callback) {
2020
mspHelper.loadMisc,
2121
mspHelper.loadRcData,
2222
mspHelper.loadRcMap,
23-
mspHelper.loadBfConfig,
23+
mspHelper.loadRxConfig,
2424
mspHelper.loadRcDeadband
2525
];
2626

@@ -337,8 +337,8 @@ TABS.receiver.initialize = function (callback) {
337337

338338
$("a.sticks").click(function () {
339339
var
340-
windowWidth = 370,
341-
windowHeight = 510;
340+
windowWidth = 420,
341+
windowHeight = Math.min(window.innerHeight, 720);
342342

343343
chrome.app.window.create("/tabs/receiver_msp.html", {
344344
id: "receiver_msp",
@@ -362,7 +362,7 @@ TABS.receiver.initialize = function (callback) {
362362
});
363363

364364
// Only show the MSP control sticks if the MSP Rx feature is enabled
365-
$(".sticks_btn").toggle(bit_check(BF_CONFIG.features, 14 /* RX_MSP */));
365+
$(".sticks_btn").toggle(FC.isRxTypeEnabled('RX_MSP'));
366366

367367
var plot_update_rate = parseInt($(this).val(), 10);
368368

tabs/receiver_msp.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,26 @@
3838
<span class="slider-label"></span>
3939
</div>
4040
</div>
41+
<div class="control-slider">
42+
<div class="slider">
43+
<span class="slider-label"></span>
44+
</div>
45+
</div>
46+
<div class="control-slider">
47+
<div class="slider">
48+
<span class="slider-label"></span>
49+
</div>
50+
</div>
51+
<div class="control-slider">
52+
<div class="slider">
53+
<span class="slider-label"></span>
54+
</div>
55+
</div>
56+
<div class="control-slider">
57+
<div class="slider">
58+
<span class="slider-label"></span>
59+
</div>
60+
</div>
4161
</div>
4262
<div class="warning">
4363
<p>

tabs/receiver_msp.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ var
1111
pitch: 1,
1212
yaw: 3,
1313
throttle: 2,
14-
aux1: 4,
15-
aux2: 5,
16-
aux3: 6,
17-
aux4: 7
14+
ch5: 4,
15+
ch6: 5,
16+
ch7: 6,
17+
ch8: 7,
18+
ch9: 8,
19+
ch10: 9,
20+
ch11: 10,
21+
ch12: 11,
1822
},
1923

2024
// Set reasonable initial stick positions (Mode 2)
@@ -23,10 +27,14 @@ var
2327
pitch: CHANNEL_MID_VALUE,
2428
roll: CHANNEL_MID_VALUE,
2529
yaw: CHANNEL_MID_VALUE,
26-
aux1: CHANNEL_MIN_VALUE,
27-
aux2: CHANNEL_MIN_VALUE,
28-
aux3: CHANNEL_MIN_VALUE,
29-
aux4: CHANNEL_MIN_VALUE
30+
ch5: CHANNEL_MIN_VALUE,
31+
ch6: CHANNEL_MIN_VALUE,
32+
ch7: CHANNEL_MIN_VALUE,
33+
ch8: CHANNEL_MIN_VALUE,
34+
ch9: CHANNEL_MIN_VALUE,
35+
ch10: CHANNEL_MIN_VALUE,
36+
ch11: CHANNEL_MIN_VALUE,
37+
ch12: CHANNEL_MIN_VALUE,
3038
},
3139

3240
// First the vertical axis, then the horizontal:
@@ -42,7 +50,7 @@ var
4250

4351
function transmitChannels() {
4452
var
45-
channelValues = [0, 0, 0, 0, 0, 0, 0, 0];
53+
channelValues = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
4654

4755
if (!enableTX) {
4856
return;
@@ -114,7 +122,7 @@ function localizeAxisNames() {
114122
$(".gimbal-label-horz", gimbal).text(chrome.i18n.getMessage("controlAxis" + gimbals[gimbalIndex][1]));
115123
}
116124

117-
for (var sliderIndex = 0; sliderIndex < 4; sliderIndex++) {
125+
for (var sliderIndex = 0; sliderIndex < 8; sliderIndex++) {
118126
$(".slider-label", sliderElems.get(sliderIndex)).text(chrome.i18n.getMessage("radioChannelShort") + (sliderIndex + 5));
119127
}
120128
}
@@ -148,7 +156,7 @@ $(document).ready(function() {
148156

149157
$(".slider", sliderElems).each(function(sliderIndex) {
150158
var
151-
initialValue = stickValues["aux" + (sliderIndex + 1)];
159+
initialValue = stickValues["ch" + (sliderIndex + 5)];
152160

153161
$(this)
154162
.noUiSlider({
@@ -160,7 +168,7 @@ $(document).ready(function() {
160168
}).on('slide change set', function(e, value) {
161169
value = Math.round(parseFloat(value));
162170

163-
stickValues["aux" + (sliderIndex + 1)] = value;
171+
stickValues["ch" + (sliderIndex + 5)] = value;
164172

165173
$(".tooltip", this).text(value);
166174
});

0 commit comments

Comments
 (0)