Added motor/esc protocol settings to configuration tab

10.3.x-maintenance
KiteAnton 2016-06-20 20:26:00 +02:00
parent 69045ab4f8
commit 8fffd6a186
6 changed files with 147 additions and 7 deletions

View File

@ -1626,5 +1626,14 @@
}, },
"mainHelpLink": { "mainHelpLink": {
"message": "Serial Link Status" "message": "Serial Link Status"
},
"configurationEscProtocol": {
"message": "ESC/Motor protocol"
},
"configurationunsyndePwm": {
"message": "Unsynced PWM output"
},
"configurationUnsyncedPWMFreq": {
"message": "Unsynced PWM frequency"
} }
} }

View File

@ -35,6 +35,7 @@ var SENSOR_ALIGNMENT;
var RX_CONFIG; var RX_CONFIG;
var FAILSAFE_CONFIG; var FAILSAFE_CONFIG;
var RXFAIL_CONFIG; var RXFAIL_CONFIG;
var PID_ADVANCED_CONFIG;
var FC = { var FC = {
resetState: function() { resetState: function() {
@ -235,6 +236,14 @@ var FC = {
align_mag: 0 align_mag: 0
}; };
PID_ADVANCED_CONFIG = {
gyro_sync_denom: 0,
pid_process_denom: 0,
use_unsyncedPwm: 0,
fast_pwm_protocol: 0,
motor_pwm_rate: 0
};
RX_CONFIG = { RX_CONFIG = {
serialrx_provider: 0, serialrx_provider: 0,
maxcheck: 0, maxcheck: 0,
@ -256,4 +265,4 @@ var FC = {
RXFAIL_CONFIG = []; RXFAIL_CONFIG = [];
} }
}; };

View File

@ -40,6 +40,9 @@ var MSP_codes = {
MSP_SET_BLACKBOX_CONFIG: 81, MSP_SET_BLACKBOX_CONFIG: 81,
MSP_TRANSPONDER_CONFIG: 82, MSP_TRANSPONDER_CONFIG: 82,
MSP_SET_TRANSPONDER_CONFIG: 83, MSP_SET_TRANSPONDER_CONFIG: 83,
MSP_PID_ADVANCED_CONFIG: 90,
MSP_SET_PID_ADVANCED_CONFIG: 91,
// Multiwii MSP commands // Multiwii MSP commands
MSP_IDENT: 100, MSP_IDENT: 100,
@ -868,7 +871,14 @@ var MSP = {
} }
break; break;
case MSP_codes.MSP_PID_ADVANCED_CONFIG:
var offset = 0;
PID_ADVANCED_CONFIG.gyro_sync_denom = data.getUint8(offset++, 1);
PID_ADVANCED_CONFIG.pid_process_denom = data.getUint8(offset++, 1);
PID_ADVANCED_CONFIG.use_unsyncedPwm = data.getUint8(offset++, 1);
PID_ADVANCED_CONFIG.fast_pwm_protocol = data.getUint8(offset++, 1);
PID_ADVANCED_CONFIG.motor_pwm_rate = data.getUint16(offset++, 1);
break;
case MSP_codes.MSP_LED_STRIP_CONFIG: case MSP_codes.MSP_LED_STRIP_CONFIG:
LED_STRIP = []; LED_STRIP = [];
@ -1364,7 +1374,14 @@ MSP.crunch = function (code) {
buffer.push(SENSOR_ALIGNMENT.align_acc); buffer.push(SENSOR_ALIGNMENT.align_acc);
buffer.push(SENSOR_ALIGNMENT.align_mag); buffer.push(SENSOR_ALIGNMENT.align_mag);
break break
case MSP_codes.MSP_SET_PID_ADVANCED_CONFIG:
buffer.push(PID_ADVANCED_CONFIG.gyro_sync_denom);
buffer.push(PID_ADVANCED_CONFIG.pid_process_denom);
buffer.push(PID_ADVANCED_CONFIG.use_unsyncedPwm);
buffer.push(PID_ADVANCED_CONFIG.fast_pwm_protocol);
buffer.push(lowByte(PID_ADVANCED_CONFIG.motor_pwm_rate));
buffer.push(highByte(PID_ADVANCED_CONFIG.motor_pwm_rate));
break;
default: default:
return false; return false;
} }

View File

@ -94,6 +94,20 @@
font-weight: normal; font-weight: normal;
} }
.tab-configuration .numberwide input {
width: 55px;
padding-left: 3px;
height: 20px;
line-height: 20px;
text-align: left;
border: 1px solid silver;
border-radius: 3px;
margin-right: 11px;
font-size: 12px;
font-weight: normal;
}
.tab-configuration .number .disabled { .tab-configuration .number .disabled {
width: 43px; width: 43px;
padding: 0px 5px; padding: 0px 5px;
@ -490,4 +504,4 @@
.tab-configuration .current .gui_box { .tab-configuration .current .gui_box {
float: left; float: left;
} }
} }

View File

@ -32,13 +32,40 @@
<div class="spacer_box_title" i18n="configurationEscFeatures"></div> <div class="spacer_box_title" i18n="configurationEscFeatures"></div>
</div> </div>
<div class="spacer_box"> <div class="spacer_box">
<div class="select">
<label>
<select class="escprotocol">
<!-- list generated here -->
</select>
<span i18n="configurationEscProtocol"></span>
</label>
</div>
<div class="checkbox">
<div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;">
<input type="checkbox" name="unsyncedPWMSwitch" class="toggle" />
</div>
<label for="unsyncedpwmswitch"> <span class="freelabel"
i18n="configurationunsyndePwm"></span>
</label>
</div>
<div class="numberwide unsyncedpwmfreq" style="display: show; margin-top: 5px;">
<label>
<div class="numberspacer">
<input type="number" name="unsyncedpwmfreq" min="200" max="32000" />
</div>
<span i18n="configurationUnsyncedPWMFreq"></span>
</label>
</div>
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tbody class="features esc"> <tbody class="features esc">
<!-- table generated here --> <!-- table generated here -->
</tbody> </tbody>
</table> </table>
<!-- --> <!-- -->
<div class="disarm"> <div class="disarm">
<div class="checkbox"> <div class="checkbox">
<div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;"> <div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;">
<input type="checkbox" name="disarmkillswitch" class="toggle" /> <input type="checkbox" name="disarmkillswitch" class="toggle" />

View File

@ -53,13 +53,22 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
function load_3d() { function load_3d() {
var next_callback = load_sensor_alignment; var next_callback = esc_protocol;
if (semver.gte(CONFIG.apiVersion, "1.14.0")) { if (semver.gte(CONFIG.apiVersion, "1.14.0")) {
MSP.send_message(MSP_codes.MSP_3D, false, false, next_callback); MSP.send_message(MSP_codes.MSP_3D, false, false, next_callback);
} else { } else {
next_callback(); next_callback();
} }
} }
function esc_protocol() {
var next_callback = load_sensor_alignment;
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
MSP.send_message(MSP_codes.MSP_PID_ADVANCED_CONFIG, false, false, next_callback);
} else {
next_callback();
}
}
function load_sensor_alignment() { function load_sensor_alignment() {
var next_callback = load_html; var next_callback = load_html;
@ -69,6 +78,9 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
next_callback(); next_callback();
} }
} }
//Update Analog/Battery Data //Update Analog/Battery Data
function load_analog() { function load_analog() {
MSP.send_message(MSP_codes.MSP_ANALOG, false, false, function () { MSP.send_message(MSP_codes.MSP_ANALOG, false, false, function () {
@ -238,9 +250,12 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
'CW 270° flip' 'CW 270° flip'
]; ];
var orientation_gyro_e = $('select.gyroalign'); var orientation_gyro_e = $('select.gyroalign');
var orientation_acc_e = $('select.accalign'); var orientation_acc_e = $('select.accalign');
var orientation_mag_e = $('select.magalign'); var orientation_mag_e = $('select.magalign');
if (semver.lt(CONFIG.apiVersion, "1.15.0")) { if (semver.lt(CONFIG.apiVersion, "1.15.0")) {
$('.tab-configuration .sensoralignment').hide(); $('.tab-configuration .sensoralignment').hide();
@ -255,6 +270,32 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
orientation_mag_e.val(SENSOR_ALIGNMENT.align_mag); orientation_mag_e.val(SENSOR_ALIGNMENT.align_mag);
} }
// ESC protocols
var escprotocols = [
'PWM',
'ONESHOT125',
'ONESHOT42',
'MULTISHOT'
];
var esc_protocol_e = $('select.escprotocol');
for (var i = 0; i < escprotocols.length; i++) {
esc_protocol_e.append('<option value="' + (i+1) + '">'+ escprotocols[i] + '</option>');
}
esc_protocol_e.val(PID_ADVANCED_CONFIG.fast_pwm_protocol+1);
$('input[name="unsyncedPWMSwitch"]').prop('checked', PID_ADVANCED_CONFIG.use_unsyncedPwm);
$('input[name="unsyncedpwmfreq"]').val(PID_ADVANCED_CONFIG.motor_pwm_rate);
if (PID_ADVANCED_CONFIG.use_unsyncedPwm) {
$('div.unsyncedpwmfreq').show();
}
else {
$('div.unsyncedpwmfreq').hide();
}
// generate GPS // generate GPS
var gpsProtocols = [ var gpsProtocols = [
@ -433,6 +474,16 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
}); });
$("input[type='checkbox']").change(function() {
var element = $(this),
name = element.attr('name'),
isChecked = element.is(':checked');
if (name == 'unsyncedPWMSwitch') {
if (isChecked) { $('div.unsyncedpwmfreq').show(); }
else { $('div.unsyncedpwmfreq').hide(); }
}
});
// UI hooks // UI hooks
$('input[type="radio"].feature', features_e).change(function () { $('input[type="radio"].feature', features_e).change(function () {
var element = $(this), var element = $(this),
@ -497,6 +548,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
SENSOR_ALIGNMENT.align_gyro = parseInt(orientation_gyro_e.val()); SENSOR_ALIGNMENT.align_gyro = parseInt(orientation_gyro_e.val());
SENSOR_ALIGNMENT.align_acc = parseInt(orientation_acc_e.val()); SENSOR_ALIGNMENT.align_acc = parseInt(orientation_acc_e.val());
SENSOR_ALIGNMENT.align_mag = parseInt(orientation_mag_e.val()); SENSOR_ALIGNMENT.align_mag = parseInt(orientation_mag_e.val());
PID_ADVANCED_CONFIG.fast_pwm_protocol = parseInt(esc_protocol_e.val()-1);
PID_ADVANCED_CONFIG.use_unsyncedPwm = ~~$('input[name="unsyncedPWMSwitch"]').is(':checked');
PID_ADVANCED_CONFIG.motor_pwm_rate = parseInt($('input[name="unsyncedpwmfreq"]').val());
function save_serial_config() { function save_serial_config() {
if (semver.lt(CONFIG.apiVersion, "1.6.0")) { if (semver.lt(CONFIG.apiVersion, "1.6.0")) {
@ -520,13 +576,21 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
function save_sensor_alignment() { function save_sensor_alignment() {
var next_callback = save_acc_trim; var next_callback = save_esc_protocol;
if(semver.gte(CONFIG.apiVersion, "1.15.0")) { if(semver.gte(CONFIG.apiVersion, "1.15.0")) {
MSP.send_message(MSP_codes.MSP_SET_SENSOR_ALIGNMENT, MSP.crunch(MSP_codes.MSP_SET_SENSOR_ALIGNMENT), false, next_callback); MSP.send_message(MSP_codes.MSP_SET_SENSOR_ALIGNMENT, MSP.crunch(MSP_codes.MSP_SET_SENSOR_ALIGNMENT), false, next_callback);
} else { } else {
next_callback(); next_callback();
} }
} }
function save_esc_protocol() {
var next_callback = save_acc_trim;
if(semver.gte(CONFIG.apiVersion, "1.16.0")) {
MSP.send_message(MSP_codes.MSP_SET_PID_ADVANCED_CONFIG, MSP.crunch(MSP_codes.MSP_SET_PID_ADVANCED_CONFIG), false, next_callback);
} else {
next_callback();
}
}
function save_acc_trim() { function save_acc_trim() {
MSP.send_message(MSP_codes.MSP_SET_ACC_TRIM, MSP.crunch(MSP_codes.MSP_SET_ACC_TRIM), false MSP.send_message(MSP_codes.MSP_SET_ACC_TRIM, MSP.crunch(MSP_codes.MSP_SET_ACC_TRIM), false