made pid or pidController change exclusive, always refresh from FC after
save10.3.x-maintenance
parent
67c8cdcaac
commit
ca718409df
|
@ -12,84 +12,87 @@
|
|||
</select>
|
||||
</div>
|
||||
<div class="clear-both"></div>
|
||||
|
||||
<table class="pid_tuning">
|
||||
<tr>
|
||||
<th class="name" i18n="pidTuningName"></th>
|
||||
<th class="proportional" i18n="pidTuningProportional"></th>
|
||||
<th class="integral" i18n="pidTuningIntegral"></th>
|
||||
<th class="derivative" i18n="pidTuningDerivative"></th>
|
||||
</tr>
|
||||
<tr class="ROLL"><!-- 0 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
|
||||
<td><input type="number" name="i" step="0.001" min="0" max="0.255" /></td>
|
||||
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
|
||||
</tr>
|
||||
<tr class="PITCH"><!-- 1 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
|
||||
<td><input type="number" name="i" step="0.001" min="0" max="0.255" /></td>
|
||||
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
|
||||
</tr>
|
||||
<tr class="YAW"><!-- 2 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
|
||||
<td><input type="number" name="i" step="0.001" min="0" max="0.255" /></td>
|
||||
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
|
||||
</tr>
|
||||
<tr class="ALT"><!-- 3 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
|
||||
<td><input type="number" name="i" step="0.001" min="0" max="0.255" /></td>
|
||||
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
|
||||
</tr>
|
||||
<tr class="Vario"><!-- 9 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
|
||||
<td><input type="number" name="i" step="0.001" min="0" max="0.255" /></td>
|
||||
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
|
||||
</tr>
|
||||
<tr class="Pos"><!-- 4 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.01" min="0" max="2.55" /></td>
|
||||
<td><input type="number" name="i" step="0.01" min="0" max="2.55" /></td>
|
||||
</tr>
|
||||
<tr class="PosR"><!-- 5 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
|
||||
<td><input type="number" name="i" step="0.01" min="0" max="2.55" /></td>
|
||||
<td><input type="number" name="d" step="0.001" min="0" max="0.255" /></td>
|
||||
</tr>
|
||||
<tr class="NavR"><!-- 6 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
|
||||
<td><input type="number" name="i" step="0.01" min="0" max="2.55" /></td>
|
||||
<td><input type="number" name="d" step="0.001" min="0" max="0.255" /></td>
|
||||
</tr>
|
||||
<tr class="LEVEL"><!-- 7 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
|
||||
<td><input type="number" name="i" step="0.001" min="0" max="0.255" /></td>
|
||||
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
|
||||
</tr>
|
||||
<tr class="MAG"><!-- 8 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="rate-tpa">
|
||||
<tr>
|
||||
<th i18n="pidTuningRollPitchRate"></th>
|
||||
<th i18n="pidTuningYawRate"></th>
|
||||
<th i18n="pidTuningTPA"></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="number" name="roll-pitch" step="0.01" min="0" max="2.55" /></td>
|
||||
<td><input type="number" name="yaw" step="0.01" min="0" max="2.55" /></td>
|
||||
<td><input type="number" name="tpa" step="0.01" min="0" max="2.55" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<form name="pid-tuning" id="pid-tuning">
|
||||
<table class="pid_tuning">
|
||||
<tr>
|
||||
<th class="name" i18n="pidTuningName"></th>
|
||||
<th class="proportional" i18n="pidTuningProportional"></th>
|
||||
<th class="integral" i18n="pidTuningIntegral"></th>
|
||||
<th class="derivative" i18n="pidTuningDerivative"></th>
|
||||
</tr>
|
||||
<tr class="ROLL"><!-- 0 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
|
||||
<td><input type="number" name="i" step="0.001" min="0" max="0.255"/></td>
|
||||
<td><input type="number" name="d" step="1" min="0" max="255"/></td>
|
||||
</tr>
|
||||
<tr class="PITCH"><!-- 1 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
|
||||
<td><input type="number" name="i" step="0.001" min="0" max="0.255"/></td>
|
||||
<td><input type="number" name="d" step="1" min="0" max="255"/></td>
|
||||
</tr>
|
||||
<tr class="YAW"><!-- 2 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
|
||||
<td><input type="number" name="i" step="0.001" min="0" max="0.255"/></td>
|
||||
<td><input type="number" name="d" step="1" min="0" max="255"/></td>
|
||||
</tr>
|
||||
<tr class="ALT"><!-- 3 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
|
||||
<td><input type="number" name="i" step="0.001" min="0" max="0.255"/></td>
|
||||
<td><input type="number" name="d" step="1" min="0" max="255"/></td>
|
||||
</tr>
|
||||
<tr class="Vario"><!-- 9 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
|
||||
<td><input type="number" name="i" step="0.001" min="0" max="0.255"/></td>
|
||||
<td><input type="number" name="d" step="1" min="0" max="255"/></td>
|
||||
</tr>
|
||||
<tr class="Pos"><!-- 4 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.01" min="0" max="2.55"/></td>
|
||||
<td><input type="number" name="i" step="0.01" min="0" max="2.55"/></td>
|
||||
</tr>
|
||||
<tr class="PosR"><!-- 5 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
|
||||
<td><input type="number" name="i" step="0.01" min="0" max="2.55"/></td>
|
||||
<td><input type="number" name="d" step="0.001" min="0" max="0.255"/></td>
|
||||
</tr>
|
||||
<tr class="NavR"><!-- 6 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
|
||||
<td><input type="number" name="i" step="0.01" min="0" max="2.55"/></td>
|
||||
<td><input type="number" name="d" step="0.001" min="0" max="0.255"/></td>
|
||||
</tr>
|
||||
<tr class="LEVEL"><!-- 7 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
|
||||
<td><input type="number" name="i" step="0.001" min="0" max="0.255"/></td>
|
||||
<td><input type="number" name="d" step="1" min="0" max="255"/></td>
|
||||
</tr>
|
||||
<tr class="MAG"><!-- 8 -->
|
||||
<td></td>
|
||||
<td><input type="number" name="p" step="0.1" min="0" max="25.5"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="rate-tpa">
|
||||
<tr>
|
||||
<th i18n="pidTuningRollPitchRate"></th>
|
||||
<th i18n="pidTuningYawRate"></th>
|
||||
<th i18n="pidTuningTPA"></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="number" name="roll-pitch" step="0.01" min="0" max="2.55"/></td>
|
||||
<td><input type="number" name="yaw" step="0.01" min="0" max="2.55"/></td>
|
||||
<td><input type="number" name="tpa" step="0.01" min="0" max="2.55"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<div class="clear-both"></div>
|
||||
<div class="profile">
|
||||
<span class="head" i18n="pidTuningProfileHead"></span>
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
TABS.pid_tuning = {};
|
||||
TABS.pid_tuning = {
|
||||
controllerChanged: true
|
||||
};
|
||||
|
||||
TABS.pid_tuning.initialize = function (callback) {
|
||||
var self = this;
|
||||
|
||||
|
||||
if (GUI.active_tab != 'pid_tuning') {
|
||||
GUI.active_tab = 'pid_tuning';
|
||||
googleAnalytics.sendAppView('PID Tuning');
|
||||
|
@ -36,24 +39,8 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
// requesting MSP_STATUS manually because it contains CONFIG.profile
|
||||
MSP.send_message(MSP_codes.MSP_STATUS, false, false, get_pid_controller);
|
||||
|
||||
function process_html() {
|
||||
// translate to user-selected language
|
||||
localize();
|
||||
|
||||
// Fill in the names from PID_names array
|
||||
// this needs to be reworked, but will do for now
|
||||
$('.pid_tuning tr:eq(1) td:first').text(PID_names[0]);
|
||||
$('.pid_tuning tr:eq(2) td:first').text(PID_names[1]);
|
||||
$('.pid_tuning tr:eq(3) td:first').text(PID_names[2]);
|
||||
$('.pid_tuning tr:eq(4) td:first').text(PID_names[3]);
|
||||
$('.pid_tuning tr:eq(5) td:first').text(PID_names[9]);
|
||||
$('.pid_tuning tr:eq(6) td:first').text(PID_names[4]);
|
||||
$('.pid_tuning tr:eq(7) td:first').text(PID_names[5]);
|
||||
$('.pid_tuning tr:eq(8) td:first').text(PID_names[6]);
|
||||
$('.pid_tuning tr:eq(9) td:first').text(PID_names[7]);
|
||||
$('.pid_tuning tr:eq(10) td:first').text(PID_names[8]);
|
||||
|
||||
// Fill in the data from PIDs array
|
||||
function data_stoarage_to_form() {
|
||||
// Fill in the data from PIDs array
|
||||
var i = 0;
|
||||
$('.pid_tuning .ROLL input').each(function () {
|
||||
switch (i) {
|
||||
|
@ -188,26 +175,106 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
$('.rate-tpa input[name="roll-pitch"]').val(RC_tuning.roll_pitch_rate.toFixed(2));
|
||||
$('.rate-tpa input[name="yaw"]').val(RC_tuning.yaw_rate.toFixed(2));
|
||||
$('.rate-tpa input[name="tpa"]').val(RC_tuning.dynamic_THR_PID.toFixed(2));
|
||||
}
|
||||
|
||||
function form_to_pid_and_rc() {
|
||||
// Catch all the changes and stuff the inside PIDs array
|
||||
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;
|
||||
$('table.pid_tuning tr.LEVEL input').each(function () {
|
||||
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
|
||||
RC_tuning.roll_pitch_rate = parseFloat($('.rate-tpa input[name="roll-pitch"]').val());
|
||||
RC_tuning.yaw_rate = parseFloat($('.rate-tpa input[name="yaw"]').val());
|
||||
RC_tuning.dynamic_THR_PID = parseFloat($('.rate-tpa input[name="tpa"]').val());
|
||||
}
|
||||
|
||||
function process_html() {
|
||||
// translate to user-selected language
|
||||
localize();
|
||||
|
||||
// Fill in the names from PID_names array
|
||||
// this needs to be reworked, but will do for now
|
||||
$('.pid_tuning tr:eq(1) td:first').text(PID_names[0]);
|
||||
$('.pid_tuning tr:eq(2) td:first').text(PID_names[1]);
|
||||
$('.pid_tuning tr:eq(3) td:first').text(PID_names[2]);
|
||||
$('.pid_tuning tr:eq(4) td:first').text(PID_names[3]);
|
||||
$('.pid_tuning tr:eq(5) td:first').text(PID_names[9]);
|
||||
$('.pid_tuning tr:eq(6) td:first').text(PID_names[4]);
|
||||
$('.pid_tuning tr:eq(7) td:first').text(PID_names[5]);
|
||||
$('.pid_tuning tr:eq(8) td:first').text(PID_names[6]);
|
||||
$('.pid_tuning tr:eq(9) td:first').text(PID_names[7]);
|
||||
$('.pid_tuning tr:eq(10) td:first').text(PID_names[8]);
|
||||
|
||||
data_stoarage_to_form();
|
||||
|
||||
var pidController_e = $('select[name="controller"]');
|
||||
|
||||
var profile_e = $('select[name="profile"]');
|
||||
var form_e = $('#pid-tuning');
|
||||
|
||||
if (GUI.canChangePidController) {
|
||||
pidController_e.val(PID.controller);
|
||||
} else {
|
||||
GUI.log(chrome.i18n.getMessage('pidTuningUpgradeFirmwareToChangePidController', [CONFIG.apiVersion, CONFIGURATOR.pidControllerChangeMinApiVersion]));
|
||||
|
||||
|
||||
pidController_e.empty();
|
||||
pidController_e.append('<option value="">Unknown</option>');
|
||||
|
||||
|
||||
pidController_e.prop('disabled', true);
|
||||
}
|
||||
|
||||
|
||||
// Fill in currently selected profile
|
||||
$('select[name="profile"]').val(CONFIG.profile);
|
||||
|
||||
profile_e.val(CONFIG.profile);
|
||||
|
||||
// UI Hooks
|
||||
$('select[name="profile"]').change(function () {
|
||||
profile_e.change(function () {
|
||||
var profile = parseInt($(this).val());
|
||||
MSP.send_message(MSP_codes.MSP_SELECT_SETTING, [profile], false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('pidTuningLoadedProfile', [profile + 1]));
|
||||
|
@ -221,74 +288,36 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
$('a.refresh').click(function () {
|
||||
GUI.tab_switch_cleanup(function () {
|
||||
GUI.log(chrome.i18n.getMessage('pidTuningDataRefreshed'));
|
||||
|
||||
TABS.pid_tuning.initialize();
|
||||
});
|
||||
});
|
||||
|
||||
$('a.update').click(function () {
|
||||
// Catch all the changes and stuff the inside PIDs array
|
||||
var i = 0;
|
||||
$('table.pid_tuning tr.ROLL input').each(function () {
|
||||
PIDs[0][i++] = parseFloat($(this).val());
|
||||
});
|
||||
form_e.find('input').each(function (k, item) {
|
||||
$(item).change(function () {
|
||||
pidController_e.prop("disabled", true);
|
||||
TABS.pid_tuning.controllerChanged = false;
|
||||
})
|
||||
});
|
||||
|
||||
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;
|
||||
$('table.pid_tuning tr.LEVEL input').each(function () {
|
||||
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
|
||||
RC_tuning.roll_pitch_rate = parseFloat($('.rate-tpa input[name="roll-pitch"]').val());
|
||||
RC_tuning.yaw_rate = parseFloat($('.rate-tpa input[name="yaw"]').val());
|
||||
RC_tuning.dynamic_THR_PID = parseFloat($('.rate-tpa input[name="tpa"]').val());
|
||||
|
||||
var pidController_e = $('select[name="controller"]');
|
||||
|
||||
function send_pids() {
|
||||
MSP.send_message(MSP_codes.MSP_SET_PID, MSP.crunch(MSP_codes.MSP_SET_PID), false, send_rc_tuning_changes);
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
// update == save.
|
||||
$('a.update').click(function () {
|
||||
|
||||
form_to_pid_and_rc();
|
||||
|
||||
function send_pids() {
|
||||
if (!TABS.pid_tuning.controllerChanged) MSP.send_message(MSP_codes.MSP_SET_PID, MSP.crunch(MSP_codes.MSP_SET_PID), false, send_rc_tuning_changes);
|
||||
}
|
||||
|
||||
function send_rc_tuning_changes() {
|
||||
MSP.send_message(MSP_codes.MSP_SET_RC_TUNING, MSP.crunch(MSP_codes.MSP_SET_RC_TUNING), false, save_to_eeprom);
|
||||
}
|
||||
|
@ -299,9 +328,14 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
});
|
||||
}
|
||||
|
||||
if (GUI.canChangePidController) {
|
||||
PID.controller = pidController_e.val();
|
||||
MSP.send_message(MSP_codes.MSP_SET_PID_CONTROLLER, MSP.crunch(MSP_codes.MSP_SET_PID_CONTROLLER), false, send_pids);
|
||||
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'));
|
||||
});
|
||||
TABS.pid_tuning.initialize();
|
||||
});
|
||||
} else {
|
||||
send_pids();
|
||||
}
|
||||
|
@ -318,4 +352,4 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
|
||||
TABS.pid_tuning.cleanup = function (callback) {
|
||||
if (callback) callback();
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue