Skip to content

Commit 603ea4e

Browse files
authored
Merge pull request #379 from mikeller/reorder_dshot_protocols
Reordered DShot protocols in ascending order.
2 parents b311650 + ca6debd commit 603ea4e

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

js/msp/MSPHelper.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,29 @@ function MspHelper () {
2525
};
2626
}
2727

28+
MspHelper.prototype.reorderPwmProtocols = function (protocol) {
29+
var result = protocol;
30+
if (semver.lt(CONFIG.apiVersion, "1.26.0")) {
31+
switch (protocol) {
32+
case 5:
33+
result = 7;
34+
35+
break;
36+
case 7:
37+
result = 5;
38+
39+
break;
40+
default:
41+
break;
42+
}
43+
}
44+
45+
return result;
46+
}
47+
2848
MspHelper.prototype.process_data = function(dataHandler) {
2949
var self = this;
50+
3051
var data = dataHandler.dataView; // DataView (allowing us to view arrayBuffer as struct/union)
3152
var code = dataHandler.code;
3253
if (!dataHandler.unsupported) switch (code) {
@@ -615,7 +636,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
615636
PID_ADVANCED_CONFIG.gyro_sync_denom = data.readU8();
616637
PID_ADVANCED_CONFIG.pid_process_denom = data.readU8();
617638
PID_ADVANCED_CONFIG.use_unsyncedPwm = data.readU8();
618-
PID_ADVANCED_CONFIG.fast_pwm_protocol = data.readU8();
639+
PID_ADVANCED_CONFIG.fast_pwm_protocol = self.reorderPwmProtocols(data.readU8());
619640
PID_ADVANCED_CONFIG.motor_pwm_rate = data.readU16();
620641
if (semver.gte(CONFIG.apiVersion, "1.24.0")) {
621642
PID_ADVANCED_CONFIG.digitalIdlePercent = data.readU16() / 100;
@@ -1134,12 +1155,12 @@ MspHelper.prototype.crunch = function(code) {
11341155
buffer.push8(SENSOR_ALIGNMENT.align_gyro)
11351156
.push8(SENSOR_ALIGNMENT.align_acc)
11361157
.push8(SENSOR_ALIGNMENT.align_mag);
1137-
break
1158+
break;
11381159
case MSPCodes.MSP_SET_ADVANCED_CONFIG:
11391160
buffer.push8(PID_ADVANCED_CONFIG.gyro_sync_denom)
11401161
.push8(PID_ADVANCED_CONFIG.pid_process_denom)
11411162
.push8(PID_ADVANCED_CONFIG.use_unsyncedPwm)
1142-
.push8(PID_ADVANCED_CONFIG.fast_pwm_protocol)
1163+
.push8(self.reorderPwmProtocols(PID_ADVANCED_CONFIG.fast_pwm_protocol))
11431164
.push16(PID_ADVANCED_CONFIG.motor_pwm_rate);
11441165
if (semver.gte(CONFIG.apiVersion, "1.24.0")) {
11451166
buffer.push16(PID_ADVANCED_CONFIG.digitalIdlePercent * 100);

tabs/configuration.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,18 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
206206
}
207207

208208
if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) {
209-
escprotocols.push('DSHOT600');
210-
escprotocols.push('DSHOT300');
211209
escprotocols.push('DSHOT150');
210+
escprotocols.push('DSHOT300');
211+
escprotocols.push('DSHOT600');
212212
}
213213

214214
var esc_protocol_e = $('select.escprotocol');
215215

216216
for (var i = 0; i < escprotocols.length; i++) {
217-
esc_protocol_e.append('<option value="' + (i+1) + '">'+ escprotocols[i] + '</option>');
217+
esc_protocol_e.append('<option value="' + (i + 1) + '">'+ escprotocols[i] + '</option>');
218218
}
219-
esc_protocol_e.val(PID_ADVANCED_CONFIG.fast_pwm_protocol+1);
219+
220+
esc_protocol_e.val(PID_ADVANCED_CONFIG.fast_pwm_protocol + 1);
220221

221222
esc_protocol_e.change(function () {
222223
if ($(this).val() - 1 >= self.DSHOT_PROTOCOL_MIN_VALUE) {

0 commit comments

Comments
 (0)