2014-08-09 18:01:17 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-03-10 23:19:24 +00:00
|
|
|
TABS.pid_tuning = {
|
2016-06-24 09:04:18 +00:00
|
|
|
controllerChanged: false
|
2015-03-10 23:19:24 +00:00
|
|
|
};
|
|
|
|
|
2014-08-12 14:20:26 +00:00
|
|
|
TABS.pid_tuning.initialize = function (callback) {
|
2014-10-01 10:58:09 +00:00
|
|
|
var self = this;
|
2014-10-01 11:16:22 +00:00
|
|
|
if (GUI.active_tab != 'pid_tuning') {
|
|
|
|
GUI.active_tab = 'pid_tuning';
|
|
|
|
}
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2016-06-24 09:07:12 +00:00
|
|
|
// requesting MSP_STATUS manually because it contains CONFIG.profile
|
|
|
|
MSP.promise(MSP_codes.MSP_STATUS).then(function() {
|
2015-01-29 17:27:50 +00:00
|
|
|
if (GUI.canChangePidController) {
|
2016-06-24 09:07:12 +00:00
|
|
|
return MSP.promise(MSP_codes.MSP_PID_CONTROLLER);
|
2015-01-29 17:27:50 +00:00
|
|
|
}
|
2016-06-24 09:07:12 +00:00
|
|
|
return true;
|
|
|
|
}).then(function() {
|
|
|
|
return MSP.promise(MSP_codes.MSP_PIDNAMES)
|
|
|
|
}).then(function() {
|
|
|
|
return MSP.promise(MSP_codes.MSP_PID);
|
|
|
|
}).then(function() {
|
|
|
|
return MSP.promise(MSP_codes.MSP_RC_TUNING);
|
|
|
|
}).then(function() {
|
2016-06-24 10:50:33 +00:00
|
|
|
return MSP.promise(MSP_codes.MSP_SPECIAL_PARAMETERS);
|
2016-06-24 09:07:12 +00:00
|
|
|
}).then(function() {
|
|
|
|
return MSP.promise(MSP_codes.MSP_ADVANCED_TUNING);
|
|
|
|
}).then(function() {
|
|
|
|
return MSP.promise(MSP_codes.MSP_FILTER_CONFIG);
|
|
|
|
}).then(function() {
|
2014-03-22 23:28:41 +00:00
|
|
|
$('#content').load("./tabs/pid_tuning.html", process_html);
|
2016-06-24 09:07:12 +00:00
|
|
|
});
|
2014-08-14 14:48:16 +00:00
|
|
|
|
2015-03-11 20:24:46 +00:00
|
|
|
function pid_and_rc_to_form() {
|
2015-03-11 20:34:02 +00:00
|
|
|
// Fill in the data from PIDs array
|
2014-03-22 23:28:41 +00:00
|
|
|
var i = 0;
|
2014-08-12 14:20:26 +00:00
|
|
|
$('.pid_tuning .ROLL input').each(function () {
|
2014-03-22 23:28:41 +00:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[0][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[0][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[0][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
i = 0;
|
2014-08-12 14:20:26 +00:00
|
|
|
$('.pid_tuning .PITCH input').each(function () {
|
2014-03-22 23:28:41 +00:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[1][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[1][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[1][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
i = 0;
|
2014-08-12 14:20:26 +00:00
|
|
|
$('.pid_tuning .YAW input').each(function () {
|
2014-03-22 23:28:41 +00:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[2][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[2][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[2][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2013-04-08 23:09:11 +00:00
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
i = 0;
|
2014-08-12 14:20:26 +00:00
|
|
|
$('.pid_tuning .ALT input').each(function () {
|
2014-03-22 23:28:41 +00:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[3][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[3][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[3][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2013-04-08 23:09:11 +00:00
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
i = 0;
|
2014-08-12 14:20:26 +00:00
|
|
|
$('.pid_tuning .Pos input').each(function () {
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[4][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
});
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
i = 0;
|
2014-08-12 14:20:26 +00:00
|
|
|
$('.pid_tuning .PosR input').each(function () {
|
2014-03-22 23:28:41 +00:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[5][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[5][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[5][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2013-04-08 23:09:11 +00:00
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
i = 0;
|
2014-08-12 14:20:26 +00:00
|
|
|
$('.pid_tuning .NavR input').each(function () {
|
2014-03-22 23:28:41 +00:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[6][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[6][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[6][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2013-04-08 23:09:11 +00:00
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
i = 0;
|
2016-06-30 12:38:26 +00:00
|
|
|
$('.pid_tuning .HORIZON input').each(function () {
|
2014-03-22 23:28:41 +00:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[7][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[7][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
2016-06-30 12:38:26 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$('.pid_tuning .ANGLE input').each(function () {
|
|
|
|
switch (i) {
|
2014-03-22 23:28:41 +00:00
|
|
|
case 2:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[7][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2013-04-08 23:09:11 +00:00
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
i = 0;
|
2014-08-12 14:20:26 +00:00
|
|
|
$('.pid_tuning .MAG input').each(function () {
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[8][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
});
|
2013-04-08 23:49:49 +00:00
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
i = 0;
|
2014-08-12 14:20:26 +00:00
|
|
|
$('.pid_tuning .Vario input').each(function () {
|
2014-03-22 23:28:41 +00:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[9][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[9][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-06-17 18:27:10 +00:00
|
|
|
$(this).val(PIDs[9][i++]);
|
2014-03-22 23:28:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
// Fill in data from RC_tuning object
|
2016-06-14 12:20:23 +00:00
|
|
|
$('.pid_tuning input[name="rc_rate"]').val(RC_tuning.RC_RATE.toFixed(2));
|
|
|
|
$('.pid_tuning input[name="roll_pitch_rate"]').val(RC_tuning.roll_pitch_rate.toFixed(2));
|
|
|
|
$('.pid_tuning input[name="roll_rate"]').val(RC_tuning.roll_rate.toFixed(2));
|
|
|
|
$('.pid_tuning input[name="pitch_rate"]').val(RC_tuning.pitch_rate.toFixed(2));
|
|
|
|
$('.pid_tuning input[name="yaw_rate"]').val(RC_tuning.yaw_rate.toFixed(2));
|
|
|
|
$('.pid_tuning input[name="rc_expo"]').val(RC_tuning.RC_EXPO.toFixed(2));
|
|
|
|
$('.pid_tuning input[name="rc_yaw_expo"]').val(RC_tuning.RC_YAW_EXPO.toFixed(2));
|
2016-06-24 10:50:33 +00:00
|
|
|
$('.pid_tuning input[name="rc_rate_yaw"]').val(SPECIAL_PARAMETERS.RC_RATE_YAW.toFixed(2));
|
2016-06-14 12:20:23 +00:00
|
|
|
|
2016-06-28 13:17:33 +00:00
|
|
|
$('.throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2));
|
|
|
|
$('.throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2));
|
|
|
|
|
2016-06-14 12:20:23 +00:00
|
|
|
$('.tpa input[name="tpa"]').val(RC_tuning.dynamic_THR_PID.toFixed(2));
|
|
|
|
$('.tpa input[name="tpa-breakpoint"]').val(RC_tuning.dynamic_THR_breakpoint);
|
|
|
|
|
|
|
|
if (semver.lt(CONFIG.apiVersion, "1.10.0")) {
|
|
|
|
$('.pid_tuning input[name="rc_yaw_expo"]').hide();
|
|
|
|
$('.pid_tuning input[name="rc_expo"]').attr("rowspan", "3");
|
|
|
|
}
|
2016-06-21 00:16:22 +00:00
|
|
|
|
2016-06-30 12:38:26 +00:00
|
|
|
$('.pid_tuning input[name="gyro"]').val(FILTER_CONFIG.gyro_soft_lpf_hz);
|
|
|
|
$('.pid_tuning input[name="dterm"]').val(FILTER_CONFIG.dterm_lpf_hz);
|
|
|
|
$('.pid_tuning input[name="yaw"]').val(FILTER_CONFIG.yaw_lpf_hz);
|
2016-06-24 12:29:46 +00:00
|
|
|
|
2016-06-30 12:38:26 +00:00
|
|
|
if (CONFIG.flightControllerIdentifier !== "BTFL" || semver.lt(CONFIG.flightControllerVersion, "2.8.1")) {
|
2016-06-24 12:29:46 +00:00
|
|
|
$('.pid_filter').hide();
|
|
|
|
$('.pid_tuning input[name="rc_rate_yaw"]').hide();
|
|
|
|
}
|
2015-03-10 23:19:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function form_to_pid_and_rc() {
|
2015-03-11 20:34:02 +00:00
|
|
|
// Catch all the changes and stuff the inside PIDs array
|
2015-03-10 23:19:24 +00:00
|
|
|
var i = 0;
|
|
|
|
$('table.pid_tuning tr.ROLL input').each(function () {
|
|
|
|
PIDs[0][i++] = parseFloat($(this).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
$('table.pid_tuning tr.PITCH input').each(function () {
|
|
|
|
PIDs[1][i++] = parseFloat($(this).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
$('table.pid_tuning tr.YAW input').each(function () {
|
|
|
|
PIDs[2][i++] = parseFloat($(this).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
$('table.pid_tuning tr.ALT input').each(function () {
|
|
|
|
PIDs[3][i++] = parseFloat($(this).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
$('table.pid_tuning tr.Vario input').each(function () {
|
|
|
|
PIDs[9][i++] = parseFloat($(this).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
$('table.pid_tuning tr.Pos input').each(function () {
|
|
|
|
PIDs[4][i++] = parseFloat($(this).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
$('table.pid_tuning tr.PosR input').each(function () {
|
|
|
|
PIDs[5][i++] = parseFloat($(this).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
$('table.pid_tuning tr.NavR input').each(function () {
|
|
|
|
PIDs[6][i++] = parseFloat($(this).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
i = 0;
|
2016-06-30 12:38:26 +00:00
|
|
|
$('table.pid_tuning tr.HORIZON input').each(function () {
|
|
|
|
PIDs[7][i++] = parseFloat($(this).val());
|
|
|
|
});
|
|
|
|
$('table.pid_tuning tr.ANGLE input').each(function () {
|
2015-03-10 23:19:24 +00:00
|
|
|
PIDs[7][i++] = parseFloat($(this).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
$('table.pid_tuning tr.MAG input').each(function () {
|
|
|
|
PIDs[8][i++] = parseFloat($(this).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
// catch RC_tuning changes
|
2016-06-14 12:20:23 +00:00
|
|
|
RC_tuning.RC_RATE = parseFloat($('.pid_tuning input[name="rc_rate"]').val());
|
|
|
|
RC_tuning.roll_pitch_rate = parseFloat($('.pid_tuning input[name="roll_pitch_rate"]').val());
|
|
|
|
RC_tuning.roll_rate = parseFloat($('.pid_tuning input[name="roll_rate"]').val());
|
|
|
|
RC_tuning.pitch_rate = parseFloat($('.pid_tuning input[name="pitch_rate"]').val());
|
|
|
|
RC_tuning.yaw_rate = parseFloat($('.pid_tuning input[name="yaw_rate"]').val());
|
|
|
|
RC_tuning.RC_EXPO = parseFloat($('.pid_tuning input[name="rc_expo"]').val());
|
|
|
|
RC_tuning.RC_YAW_EXPO = parseFloat($('.pid_tuning input[name="rc_yaw_expo"]').val());
|
2016-06-24 10:50:33 +00:00
|
|
|
SPECIAL_PARAMETERS.RC_RATE_YAW = parseFloat($('.pid_tuning input[name="rc_rate_yaw"]').val());
|
2016-06-14 12:20:23 +00:00
|
|
|
|
2016-06-28 13:17:33 +00:00
|
|
|
RC_tuning.throttle_MID = parseFloat($('.throttle input[name="mid"]').val());
|
|
|
|
RC_tuning.throttle_EXPO = parseFloat($('.throttle input[name="expo"]').val())
|
|
|
|
|
2016-06-14 12:20:23 +00:00
|
|
|
RC_tuning.dynamic_THR_PID = parseFloat($('.tpa input[name="tpa"]').val());
|
|
|
|
RC_tuning.dynamic_THR_breakpoint = parseInt($('.tpa input[name="tpa-breakpoint"]').val());
|
2016-06-30 12:38:26 +00:00
|
|
|
FILTER_CONFIG.gyro_soft_lpf_hz = parseInt($('.pid_tuning input[name="gyro"]').val());
|
|
|
|
FILTER_CONFIG.dterm_lpf_hz = parseInt($('.pid_tuning input[name="dterm"]').val());
|
|
|
|
FILTER_CONFIG.yaw_lpf_hz = parseInt($('.pid_tuning input[name="yaw"]').val());
|
2015-03-10 23:19:24 +00:00
|
|
|
}
|
2016-06-30 12:38:26 +00:00
|
|
|
|
2016-06-30 21:05:18 +00:00
|
|
|
function showAllPids() {
|
|
|
|
$('.tab-pid_tuning .pid_tuning').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
function hideUnusedPids() {
|
2016-06-30 12:38:26 +00:00
|
|
|
$('.tab-pid_tuning .pid_tuning').hide();
|
|
|
|
|
|
|
|
$('#pid_main').show();
|
|
|
|
|
|
|
|
if (CONFIG.flightControllerIdentifier === "BTFL" || semver.ge(CONFIG.flightControllerVersion, "2.9.0")) {
|
|
|
|
$('#pid_filter').show();
|
2016-06-30 21:05:18 +00:00
|
|
|
}
|
2016-06-30 12:38:26 +00:00
|
|
|
|
2016-06-30 21:05:18 +00:00
|
|
|
if (have_sensor(CONFIG.activeSensors, 'acc')) {
|
2016-06-30 12:38:26 +00:00
|
|
|
$('#pid_accel').show();
|
2016-07-04 07:37:26 +00:00
|
|
|
$('#pid_level').show();
|
2016-06-30 12:38:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var showTitle = false;
|
2016-06-30 21:05:18 +00:00
|
|
|
if (have_sensor(CONFIG.activeSensors, 'baro') ||
|
|
|
|
have_sensor(CONFIG.activeSensors, 'sonar')) {
|
2016-06-30 12:38:26 +00:00
|
|
|
$('#pid_baro').show();
|
2016-06-30 21:05:18 +00:00
|
|
|
showTitle = true;
|
2016-06-30 12:38:26 +00:00
|
|
|
}
|
2016-06-30 21:05:18 +00:00
|
|
|
if (have_sensor(CONFIG.activeSensors, 'mag')) {
|
2016-06-30 12:38:26 +00:00
|
|
|
$('#pid_mag').show();
|
2016-06-30 21:05:18 +00:00
|
|
|
showTitle = true;
|
2016-06-30 12:38:26 +00:00
|
|
|
}
|
|
|
|
if (bit_check(BF_CONFIG.features, 7)) { //This will need to be reworked to remove BF_CONFIG reference eventually
|
|
|
|
$('#pid_gps').show();
|
2016-06-30 21:05:18 +00:00
|
|
|
showTitle = true;
|
2016-06-30 12:38:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (showTitle) {
|
|
|
|
$('#pid_optional').show();
|
|
|
|
}
|
2015-11-02 09:10:08 +00:00
|
|
|
}
|
2016-06-30 12:38:26 +00:00
|
|
|
|
2016-07-05 11:30:19 +00:00
|
|
|
function drawAxes(curveContext, width, height, scaleHeight) {
|
2016-07-03 15:02:15 +00:00
|
|
|
curveContext.strokeStyle = '#000000';
|
2016-07-05 11:30:19 +00:00
|
|
|
curveContext.lineWidth = 4;
|
2016-07-03 15:02:15 +00:00
|
|
|
|
|
|
|
// Horizontal
|
|
|
|
curveContext.beginPath();
|
|
|
|
curveContext.moveTo(0, height / 2);
|
|
|
|
curveContext.lineTo(width, height / 2);
|
|
|
|
curveContext.stroke();
|
|
|
|
|
|
|
|
// Vertical
|
|
|
|
curveContext.beginPath();
|
|
|
|
curveContext.moveTo(width / 2, 0);
|
|
|
|
curveContext.lineTo(width / 2, height);
|
|
|
|
curveContext.stroke();
|
|
|
|
|
2016-07-05 11:30:19 +00:00
|
|
|
if (scaleHeight <= height / 2) {
|
|
|
|
curveContext.strokeStyle = '#202020';
|
|
|
|
curveContext.lineWidth = 1;
|
2016-07-03 15:02:15 +00:00
|
|
|
|
|
|
|
curveContext.beginPath();
|
2016-07-05 11:30:19 +00:00
|
|
|
curveContext.moveTo(0, height / 2 + scaleHeight);
|
|
|
|
curveContext.lineTo(width, height / 2 + scaleHeight);
|
2016-07-03 15:02:15 +00:00
|
|
|
curveContext.stroke();
|
|
|
|
|
2016-07-05 11:30:19 +00:00
|
|
|
curveContext.beginPath();
|
|
|
|
curveContext.moveTo(0, height / 2 - scaleHeight);
|
|
|
|
curveContext.lineTo(width, height / 2 - scaleHeight);
|
|
|
|
curveContext.stroke();
|
2016-07-03 15:02:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-05 11:30:19 +00:00
|
|
|
function checkInput(element) {
|
|
|
|
var value = parseFloat(element.val());
|
|
|
|
if (value < parseFloat(element.prop('min'))
|
|
|
|
|| value > parseFloat(element.prop('max'))) {
|
|
|
|
value = undefined;
|
2016-07-03 15:02:15 +00:00
|
|
|
}
|
2016-07-05 11:30:19 +00:00
|
|
|
|
|
|
|
return value;
|
2016-07-03 15:02:15 +00:00
|
|
|
}
|
|
|
|
|
2015-03-10 23:19:24 +00:00
|
|
|
function process_html() {
|
|
|
|
// translate to user-selected language
|
|
|
|
localize();
|
|
|
|
|
2016-06-30 21:05:18 +00:00
|
|
|
var showAllButton = $('#showAllPids');
|
2016-06-30 22:51:47 +00:00
|
|
|
var showAllMsg = chrome.i18n.getMessage("pidTuningShowAllPids");
|
|
|
|
var hideUnusedMsg = chrome.i18n.getMessage("pidTuningHideUnusedPids");
|
2016-06-30 21:05:18 +00:00
|
|
|
|
2016-06-30 22:51:47 +00:00
|
|
|
function updatePidDisplay() {
|
|
|
|
if (!TABS.pid_tuning.showAllPids) {
|
|
|
|
hideUnusedPids();
|
|
|
|
|
|
|
|
showAllButton.text(showAllMsg);
|
|
|
|
} else {
|
|
|
|
showAllPids();
|
|
|
|
|
|
|
|
showAllButton.text(hideUnusedMsg);
|
|
|
|
}
|
2016-06-30 21:05:18 +00:00
|
|
|
}
|
2015-11-02 09:10:08 +00:00
|
|
|
|
2016-06-30 22:51:47 +00:00
|
|
|
updatePidDisplay();
|
2016-06-30 21:05:18 +00:00
|
|
|
|
2016-06-30 22:51:47 +00:00
|
|
|
showAllButton.on('click', function(){
|
|
|
|
TABS.pid_tuning.showAllPids = !TABS.pid_tuning.showAllPids;
|
2016-06-30 21:05:18 +00:00
|
|
|
|
2016-06-30 22:51:47 +00:00
|
|
|
updatePidDisplay();
|
2015-11-02 09:10:08 +00:00
|
|
|
});
|
|
|
|
|
2015-12-12 23:42:49 +00:00
|
|
|
$('#resetPIDs').on('click', function(){
|
|
|
|
MSP.send_message(MSP_codes.MSP_SET_RESET_CURR_PID, false, false, false);
|
2016-06-24 09:07:12 +00:00
|
|
|
updateActivatedTab();
|
2015-12-12 23:42:49 +00:00
|
|
|
});
|
|
|
|
|
2015-11-02 09:10:08 +00:00
|
|
|
$('.pid_tuning tr').each(function(){
|
|
|
|
for(i = 0; i < PID_names.length; i++) {
|
|
|
|
if($(this).hasClass(PID_names[i])) {
|
|
|
|
$(this).find('td:first').text(PID_names[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-03-11 20:24:46 +00:00
|
|
|
pid_and_rc_to_form();
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2015-01-29 17:27:50 +00:00
|
|
|
var pidController_e = $('select[name="controller"]');
|
2015-11-14 00:41:23 +00:00
|
|
|
|
|
|
|
var pidControllerList;
|
|
|
|
|
|
|
|
if (semver.lt(CONFIG.apiVersion, "1.14.0")) {
|
|
|
|
pidControllerList = [
|
|
|
|
{ name: "MultiWii (Old)"},
|
|
|
|
{ name: "MultiWii (rewrite)"},
|
|
|
|
{ name: "LuxFloat"},
|
|
|
|
{ name: "MultiWii (2.3 - latest)"},
|
|
|
|
{ name: "MultiWii (2.3 - hybrid)"},
|
|
|
|
{ name: "Harakiri"}
|
|
|
|
]
|
|
|
|
} else {
|
|
|
|
pidControllerList = [
|
2016-06-19 21:50:14 +00:00
|
|
|
{ name: ""},
|
|
|
|
{ name: "Integer"},
|
|
|
|
{ name: "Float"},
|
2015-11-14 00:41:23 +00:00
|
|
|
]
|
|
|
|
}
|
2016-06-29 20:59:47 +00:00
|
|
|
|
2015-11-14 00:41:23 +00:00
|
|
|
for (var i = 0; i < pidControllerList.length; i++) {
|
|
|
|
pidController_e.append('<option value="' + (i) + '">' + pidControllerList[i].name + '</option>');
|
|
|
|
}
|
2016-06-29 20:59:47 +00:00
|
|
|
|
2015-03-10 23:19:24 +00:00
|
|
|
var form_e = $('#pid-tuning');
|
|
|
|
|
2015-01-29 17:27:50 +00:00
|
|
|
if (GUI.canChangePidController) {
|
|
|
|
pidController_e.val(PID.controller);
|
|
|
|
} else {
|
|
|
|
GUI.log(chrome.i18n.getMessage('pidTuningUpgradeFirmwareToChangePidController', [CONFIG.apiVersion, CONFIGURATOR.pidControllerChangeMinApiVersion]));
|
2015-03-10 23:19:24 +00:00
|
|
|
|
2015-01-29 17:27:50 +00:00
|
|
|
pidController_e.empty();
|
|
|
|
pidController_e.append('<option value="">Unknown</option>');
|
2015-03-10 23:19:24 +00:00
|
|
|
|
2015-01-29 17:27:50 +00:00
|
|
|
pidController_e.prop('disabled', true);
|
|
|
|
}
|
2015-11-02 09:10:08 +00:00
|
|
|
|
2015-05-07 21:10:26 +00:00
|
|
|
if (semver.lt(CONFIG.apiVersion, "1.7.0")) {
|
2016-06-14 12:20:23 +00:00
|
|
|
$('.tpa .tpa-breakpoint').hide();
|
|
|
|
|
|
|
|
$('.pid_tuning .roll_rate').hide();
|
|
|
|
$('.pid_tuning .pitch_rate').hide();
|
2015-03-11 21:56:02 +00:00
|
|
|
} else {
|
2016-06-14 12:20:23 +00:00
|
|
|
$('.pid_tuning .roll_pitch_rate').hide();
|
|
|
|
}
|
|
|
|
|
2016-07-03 15:02:15 +00:00
|
|
|
// Getting the DOM elements for curve display
|
|
|
|
var rcRateElement = $('.pid_tuning input[name="rc_rate"]');
|
2016-07-05 11:30:19 +00:00
|
|
|
var rcRateYawElement;
|
2016-07-03 15:02:15 +00:00
|
|
|
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
|
2016-07-05 11:30:19 +00:00
|
|
|
rcRateYawElement = $('.pid_tuning input[name="rc_rate_yaw"]');
|
2016-07-03 15:02:15 +00:00
|
|
|
} else {
|
2016-07-05 11:30:19 +00:00
|
|
|
rcRateYawElement = rcRateElement;
|
2016-07-03 15:02:15 +00:00
|
|
|
}
|
2016-06-14 12:20:23 +00:00
|
|
|
|
2016-07-05 11:30:19 +00:00
|
|
|
var rateRollElement = $('.pid_tuning input[name="roll_rate"]');
|
|
|
|
var ratePitchElement = $('.pid_tuning input[name="pitch_rate"]');
|
|
|
|
var rateYawElement = $('.pid_tuning input[name="yaw_rate"]');
|
2016-06-14 12:20:23 +00:00
|
|
|
|
2016-07-03 15:02:15 +00:00
|
|
|
var rcExpoElement = $('.pid_tuning input[name="rc_expo"]');
|
2016-07-05 11:30:19 +00:00
|
|
|
var rcExpoYawElement = $('.pid_tuning input[name="rc_yaw_expo"]');
|
2016-06-14 12:20:23 +00:00
|
|
|
|
2016-07-03 15:02:15 +00:00
|
|
|
var rcCurveElement = $('.rate_curve canvas').get(0);
|
|
|
|
var curveContext = rcCurveElement.getContext("2d");
|
|
|
|
rcCurveElement.width = 1000;
|
|
|
|
rcCurveElement.height = 1000;
|
|
|
|
|
2016-07-05 11:30:19 +00:00
|
|
|
var maxAngularVelRollElement = $('.rc_curve .maxAngularVelRoll');
|
|
|
|
var maxAngularVelPitchElement = $('.rc_curve .maxAngularVelPitch');
|
|
|
|
var maxAngularVelYawElement = $('.rc_curve .maxAngularVelYaw');
|
|
|
|
|
2016-07-03 15:02:15 +00:00
|
|
|
var superExpoElement = $('.rc_curve input[name="show_superexpo_rates"]');
|
|
|
|
|
2016-07-05 11:30:19 +00:00
|
|
|
var useLegacyCurve = false;
|
2016-07-03 15:02:15 +00:00
|
|
|
if (CONFIG.flightControllerIdentifier !== "BTFL" || semver.lt(CONFIG.flightControllerVersion, "2.8.0")) {
|
2016-07-06 00:11:20 +00:00
|
|
|
$('.rc_curve .new_rates').hide();
|
2016-07-05 11:30:19 +00:00
|
|
|
useLegacyCurve = true;
|
2015-03-11 21:56:02 +00:00
|
|
|
}
|
2015-01-29 17:27:50 +00:00
|
|
|
|
2016-07-05 11:30:19 +00:00
|
|
|
var rateCurve = new RateCurve(useLegacyCurve);
|
|
|
|
|
2014-03-22 23:28:41 +00:00
|
|
|
// UI Hooks
|
2016-06-14 12:20:23 +00:00
|
|
|
// curves
|
2016-07-03 15:02:15 +00:00
|
|
|
function redrawRateCurves() {
|
2016-06-14 12:20:23 +00:00
|
|
|
setTimeout(function () { // let global validation trigger and adjust the values first
|
2016-07-03 15:02:15 +00:00
|
|
|
var curveHeight = rcCurveElement.height;
|
|
|
|
var curveWidth = rcCurveElement.width;
|
|
|
|
|
|
|
|
var useSuperExpo = superExpoElement.is(':checked');
|
|
|
|
|
2016-07-05 11:30:19 +00:00
|
|
|
var rateRoll = checkInput(rateRollElement);
|
|
|
|
var ratePitch = checkInput(ratePitchElement);
|
|
|
|
var rateYaw = checkInput(rateYawElement);
|
|
|
|
var rcRate = checkInput(rcRateElement);
|
|
|
|
var rcRateYaw = checkInput(rcRateYawElement);
|
|
|
|
var rcExpo = checkInput(rcExpoElement);
|
|
|
|
var rcExpoYaw = checkInput(rcExpoYawElement);
|
|
|
|
|
|
|
|
var maxAngularVelRoll = rateCurve.getMaxAngularVel(rateRoll, rcRate, rcExpo, useSuperExpo);
|
|
|
|
maxAngularVelRollElement.text(maxAngularVelRoll);
|
|
|
|
var maxAngularVelPitch = rateCurve.getMaxAngularVel(ratePitch, rcRate, rcExpo, useSuperExpo);
|
|
|
|
maxAngularVelPitchElement.text(maxAngularVelPitch);
|
|
|
|
var maxAngularVelYaw = rateCurve.getMaxAngularVel(rateYaw, rcRateYaw, rcExpoYaw, useSuperExpo);
|
|
|
|
maxAngularVelYawElement.text(maxAngularVelYaw);
|
|
|
|
var maxAngularVel = Math.max(maxAngularVelRoll, maxAngularVelPitch, maxAngularVelYaw);
|
2016-07-03 15:02:15 +00:00
|
|
|
|
2016-07-05 11:30:19 +00:00
|
|
|
curveContext.clearRect(0, 0, curveWidth, curveHeight);
|
2016-07-03 15:02:15 +00:00
|
|
|
|
2016-07-05 11:30:19 +00:00
|
|
|
if (!useLegacyCurve) {
|
|
|
|
drawAxes(curveContext, curveWidth, curveHeight, (curveHeight / 2) / maxAngularVel * 360);
|
2016-06-28 13:17:33 +00:00
|
|
|
}
|
2016-06-25 00:17:24 +00:00
|
|
|
|
2016-07-03 15:02:15 +00:00
|
|
|
curveContext.lineWidth = 4;
|
|
|
|
|
|
|
|
curveContext.save();
|
|
|
|
curveContext.strokeStyle = '#ff0000';
|
2016-07-05 11:30:19 +00:00
|
|
|
rateCurve.draw(rateRoll, rcRate, rcExpo, useSuperExpo, maxAngularVel, curveContext);
|
2016-07-03 15:02:15 +00:00
|
|
|
curveContext.restore();
|
|
|
|
|
|
|
|
curveContext.save();
|
|
|
|
curveContext.translate(0, -4);
|
|
|
|
curveContext.strokeStyle = '#00ff00';
|
2016-07-05 11:30:19 +00:00
|
|
|
rateCurve.draw(ratePitch, rcRate, rcExpo, useSuperExpo, maxAngularVel, curveContext);
|
2016-07-03 15:02:15 +00:00
|
|
|
curveContext.restore();
|
|
|
|
|
|
|
|
curveContext.save();
|
|
|
|
curveContext.strokeStyle = '#0000ff';
|
2016-07-05 11:30:19 +00:00
|
|
|
curveContext.translate(0, 4);
|
|
|
|
rateCurve.draw(rateYaw, rcRateYaw, rcExpoYaw, useSuperExpo, maxAngularVel, curveContext);
|
2016-07-03 15:02:15 +00:00
|
|
|
curveContext.restore();
|
2016-06-28 13:17:33 +00:00
|
|
|
}, 0);
|
2016-07-03 15:02:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$('.pid_tuning').on('input change', redrawRateCurves).trigger('input');
|
|
|
|
$('.super_expo_checkbox').on('input change', redrawRateCurves).trigger('input');
|
2016-06-28 13:17:33 +00:00
|
|
|
|
|
|
|
$('.throttle input').on('input change', function () {
|
2016-07-03 15:02:15 +00:00
|
|
|
setTimeout(function () { // let global validation trigger and adjust the values first
|
2016-06-28 13:17:33 +00:00
|
|
|
var throttleMidE = $('.throttle input[name="mid"]'),
|
|
|
|
throttleExpoE = $('.throttle input[name="expo"]'),
|
|
|
|
mid = parseFloat(throttleMidE.val()),
|
|
|
|
expo = parseFloat(throttleExpoE.val()),
|
|
|
|
throttleCurve = $('.throttle .throttle_curve canvas').get(0),
|
|
|
|
context = throttleCurve.getContext("2d");
|
|
|
|
|
|
|
|
// local validation to deal with input event
|
|
|
|
if (mid >= parseFloat(throttleMidE.prop('min')) &&
|
|
|
|
mid <= parseFloat(throttleMidE.prop('max')) &&
|
|
|
|
expo >= parseFloat(throttleExpoE.prop('min')) &&
|
|
|
|
expo <= parseFloat(throttleExpoE.prop('max'))) {
|
|
|
|
// continue
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var canvasHeight = throttleCurve.height;
|
|
|
|
var canvasWidth = throttleCurve.width;
|
|
|
|
|
|
|
|
// math magic by englishman
|
|
|
|
var midx = canvasWidth * mid,
|
|
|
|
midxl = midx * 0.5,
|
|
|
|
midxr = (((canvasWidth - midx) * 0.5) + midx),
|
|
|
|
midy = canvasHeight - (midx * (canvasHeight / canvasWidth)),
|
|
|
|
midyl = canvasHeight - ((canvasHeight - midy) * 0.5 *(expo + 1)),
|
|
|
|
midyr = (midy / 2) * (expo + 1);
|
|
|
|
|
|
|
|
// draw
|
|
|
|
context.clearRect(0, 0, canvasWidth, canvasHeight);
|
|
|
|
context.beginPath();
|
|
|
|
context.moveTo(0, canvasHeight);
|
|
|
|
context.quadraticCurveTo(midxl, midyl, midx, midy);
|
|
|
|
context.moveTo(midx, midy);
|
|
|
|
context.quadraticCurveTo(midxr, midyr, canvasWidth, 0);
|
|
|
|
context.lineWidth = 2;
|
|
|
|
context.strokeStyle = '#ffbb00';
|
|
|
|
context.stroke();
|
2016-06-14 12:20:23 +00:00
|
|
|
}, 0);
|
|
|
|
}).trigger('input');
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-08-12 14:20:26 +00:00
|
|
|
$('a.refresh').click(function () {
|
|
|
|
GUI.tab_switch_cleanup(function () {
|
2014-05-06 15:34:59 +00:00
|
|
|
GUI.log(chrome.i18n.getMessage('pidTuningDataRefreshed'));
|
2014-08-12 13:51:31 +00:00
|
|
|
TABS.pid_tuning.initialize();
|
2014-03-22 23:28:41 +00:00
|
|
|
});
|
|
|
|
});
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2015-03-10 23:19:24 +00:00
|
|
|
form_e.find('input').each(function (k, item) {
|
|
|
|
$(item).change(function () {
|
|
|
|
pidController_e.prop("disabled", true);
|
|
|
|
TABS.pid_tuning.controllerChanged = false;
|
|
|
|
})
|
|
|
|
});
|
2014-03-22 23:28:41 +00:00
|
|
|
|
2015-03-10 23:19:24 +00:00
|
|
|
pidController_e.change(function () {
|
|
|
|
if (PID.controller != pidController_e.val()) {
|
|
|
|
form_e.find('input').each(function (k, item) {
|
|
|
|
$(item).prop('disabled', true);
|
|
|
|
TABS.pid_tuning.controllerChanged = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2014-03-22 23:28:41 +00:00
|
|
|
|
2016-06-24 09:07:12 +00:00
|
|
|
$('.delta select').val(ADVANCED_TUNING.deltaMethod).change(function() {
|
2016-06-24 12:29:46 +00:00
|
|
|
ADVANCED_TUNING.deltaMethod = $(this).val();
|
2016-06-24 09:07:12 +00:00
|
|
|
});
|
2014-03-22 23:28:41 +00:00
|
|
|
|
2016-06-24 12:29:46 +00:00
|
|
|
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.lt(CONFIG.flightControllerVersion, "2.8.2")) {
|
|
|
|
$('.delta').hide();
|
2016-06-27 12:45:01 +00:00
|
|
|
$('.note').hide();
|
2016-06-24 12:29:46 +00:00
|
|
|
}
|
|
|
|
|
2015-03-10 23:19:24 +00:00
|
|
|
// update == save.
|
|
|
|
$('a.update').click(function () {
|
|
|
|
form_to_pid_and_rc();
|
|
|
|
if (GUI.canChangePidController && TABS.pid_tuning.controllerChanged) {
|
|
|
|
PID.controller = pidController_e.val();
|
|
|
|
MSP.send_message(MSP_codes.MSP_SET_PID_CONTROLLER, MSP.crunch(MSP_codes.MSP_SET_PID_CONTROLLER), false, function () {
|
|
|
|
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, function () {
|
|
|
|
GUI.log(chrome.i18n.getMessage('pidTuningEepromSaved'));
|
|
|
|
});
|
2015-11-23 22:00:05 +00:00
|
|
|
TABS.pid_tuning.initialize();
|
2015-03-10 23:19:24 +00:00
|
|
|
});
|
2015-01-29 17:27:50 +00:00
|
|
|
} else {
|
2016-06-24 09:07:12 +00:00
|
|
|
if (TABS.pid_tuning.controllerChanged) { return; }
|
|
|
|
MSP.promise(MSP_codes.MSP_SET_PID, MSP.crunch(MSP_codes.MSP_SET_PID)).then(function() {
|
|
|
|
if (TABS.pid_tuning.controllerChanged) { Promise.reject('pid controller changed'); }
|
2016-06-24 12:29:46 +00:00
|
|
|
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
|
|
|
|
return MSP.promise(MSP_codes.MSP_SET_SPECIAL_PARAMETERS, MSP.crunch(MSP_codes.MSP_SET_SPECIAL_PARAMETERS));
|
|
|
|
}
|
2016-06-24 09:07:12 +00:00
|
|
|
}).then(function() {
|
|
|
|
if (TABS.pid_tuning.controllerChanged) { Promise.reject('pid controller changed'); }
|
|
|
|
return MSP.promise(MSP_codes.MSP_SET_ADVANCED_TUNING, MSP.crunch(MSP_codes.MSP_SET_ADVANCED_TUNING));
|
|
|
|
}).then(function() {
|
|
|
|
if (TABS.pid_tuning.controllerChanged) { Promise.reject('pid controller changed'); }
|
2016-06-24 12:29:46 +00:00
|
|
|
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
|
|
|
|
return MSP.promise(MSP_codes.MSP_SET_FILTER_CONFIG, MSP.crunch(MSP_codes.MSP_SET_FILTER_CONFIG));
|
|
|
|
}
|
2016-06-24 09:07:12 +00:00
|
|
|
}).then(function() {
|
|
|
|
return MSP.promise(MSP_codes.MSP_SET_RC_TUNING, MSP.crunch(MSP_codes.MSP_SET_RC_TUNING));
|
|
|
|
}).then(function() {
|
|
|
|
return MSP.promise(MSP_codes.MSP_EEPROM_WRITE);
|
|
|
|
}).then(function() {
|
|
|
|
GUI.log(chrome.i18n.getMessage('pidTuningEepromSaved'));
|
|
|
|
});
|
2015-01-29 17:27:50 +00:00
|
|
|
}
|
2013-12-15 01:28:12 +00:00
|
|
|
});
|
2014-03-22 23:28:41 +00:00
|
|
|
|
2016-06-29 20:59:47 +00:00
|
|
|
// Setup model for rates preview
|
|
|
|
self.initRatesPreview();
|
|
|
|
self.renderModel();
|
|
|
|
|
|
|
|
// enable RC data pulling for rates preview
|
|
|
|
GUI.interval_add('receiver_pull', self.getRecieverData, true);
|
|
|
|
|
2014-03-30 09:51:16 +00:00
|
|
|
// status data pulled via separate timer with static speed
|
2014-10-01 10:58:09 +00:00
|
|
|
GUI.interval_add('status_pull', function status_pull() {
|
2014-06-01 12:10:18 +00:00
|
|
|
MSP.send_message(MSP_codes.MSP_STATUS);
|
2014-03-30 09:51:16 +00:00
|
|
|
}, 250, true);
|
2014-07-10 16:14:33 +00:00
|
|
|
|
2015-11-11 21:01:22 +00:00
|
|
|
GUI.content_ready(callback);
|
2014-03-22 23:28:41 +00:00
|
|
|
}
|
2014-07-10 16:14:33 +00:00
|
|
|
};
|
|
|
|
|
2016-06-29 20:59:47 +00:00
|
|
|
TABS.pid_tuning.getRecieverData = function () {
|
|
|
|
MSP.send_message(MSP_codes.MSP_RC, false, false);
|
|
|
|
};
|
|
|
|
|
|
|
|
TABS.pid_tuning.initRatesPreview = function () {
|
|
|
|
this.keepRendering = true;
|
|
|
|
this.model = new Model($('.rates_preview'), $('.rates_preview canvas'));
|
|
|
|
|
|
|
|
var scale = d3.scale.linear().domain([900, 2100]);
|
|
|
|
|
|
|
|
this.rollScale = scale.range([Math.PI * 2, -Math.PI * 2]);
|
|
|
|
this.pitchScale = scale.range([Math.PI * 2, -Math.PI * 2]);
|
|
|
|
this.yawScale = scale.range([Math.PI * 2, -Math.PI * 2]);
|
|
|
|
|
|
|
|
$(window).on('resize', $.proxy(this.model.resize, this.model));
|
|
|
|
};
|
|
|
|
|
|
|
|
TABS.pid_tuning.renderModel = function () {
|
|
|
|
if (this.keepRendering) { requestAnimationFrame(this.renderModel.bind(this)); }
|
|
|
|
|
|
|
|
if (!this.clock) { this.clock = new THREE.Clock(); }
|
|
|
|
|
|
|
|
if (RC.channels[0] && RC.channels[1] && RC.channels[2]) {
|
|
|
|
var delta = this.clock.getDelta(),
|
|
|
|
roll = delta * this.rollScale(RC.channels[0]),
|
|
|
|
pitch = delta * this.pitchScale(RC.channels[1]),
|
|
|
|
yaw = delta * this.yawScale(RC.channels[2]);
|
|
|
|
|
|
|
|
this.model.rotateBy(pitch, yaw, roll);
|
2015-03-11 20:34:02 +00:00
|
|
|
}
|
2016-06-14 12:20:23 +00:00
|
|
|
};
|
2016-06-29 20:59:47 +00:00
|
|
|
|
|
|
|
TABS.pid_tuning.cleanup = function (callback) {
|
|
|
|
$(window).off('resize', $.proxy(this.model.resize, this.model));
|
|
|
|
|
|
|
|
this.keepRendering = false;
|
|
|
|
|
|
|
|
if (callback) callback();
|
|
|
|
};
|