mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 04:15:28 +03:00
full PID tuning support
RC related tunings like expos, etc will be available inside Receiver tab
This commit is contained in:
parent
5119fb2050
commit
d450a3f518
5 changed files with 77 additions and 42 deletions
|
@ -203,18 +203,18 @@ a:hover {
|
|||
|
||||
border: 1px dotted silver;
|
||||
}
|
||||
table.pid_tuning {
|
||||
.tab-pid_tuning table {
|
||||
width: 100%;
|
||||
border-collapse:collapse;
|
||||
}
|
||||
table.pid_tuning, table.pid_tuning th, table.pid_tuning td {
|
||||
.tab-pid_tuning table, .tab-pid_tuning table th, .tab-pid_tuning table td {
|
||||
padding: 5px;
|
||||
border: 1px solid #8b8b8b;
|
||||
}
|
||||
table.pid_tuning tr:nth-child(odd) {
|
||||
.tab-pid_tuning table tr:nth-child(odd) {
|
||||
background-color: #ececec;
|
||||
}
|
||||
table.pid_tuning input {
|
||||
.tab-pid_tuning table input {
|
||||
width: 130px;
|
||||
height: 18px;
|
||||
line-height: 18px;
|
||||
|
@ -223,27 +223,12 @@ table.pid_tuning {
|
|||
border: 1px solid silver;
|
||||
text-align: right;
|
||||
}
|
||||
table.pid_tuning a.update {
|
||||
display: block;
|
||||
|
||||
width: 60px;
|
||||
height: 18px;
|
||||
line-height: 18px;
|
||||
|
||||
color: white;
|
||||
text-align: center;
|
||||
|
||||
border: 1px solid silver;
|
||||
background-color: #078814;
|
||||
}
|
||||
table.pid_tuning a.update:hover {
|
||||
text-decoration: none;
|
||||
background-color: #13b723;
|
||||
}
|
||||
.tab-pid_tuning .update {
|
||||
display: block;
|
||||
float: right;
|
||||
|
||||
margin-top: 20px;
|
||||
|
||||
width: 120px;
|
||||
height: 60px;
|
||||
line-height: 60px;
|
||||
|
@ -266,6 +251,11 @@ table.pid_tuning {
|
|||
cursor: pointer;
|
||||
background-color: #13d81d;
|
||||
}
|
||||
.tab-pid_tuning .rate-tpa {
|
||||
float: left;
|
||||
width: 400px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.tab-receiver {
|
||||
}
|
||||
.tab-receiver .bars ul {
|
||||
|
|
|
@ -26,6 +26,9 @@ $(document).ready(function() {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
// temporary
|
||||
//$('#content').load("./tabs/pid_tuning.html", tab_initialize_pid_tuning);
|
||||
});
|
||||
|
||||
function disable_timers() {
|
||||
|
|
|
@ -65,6 +65,16 @@ var RC = {
|
|||
AUX4: 0
|
||||
};
|
||||
|
||||
var RC_tuning = {
|
||||
RC_RATE: 0,
|
||||
RC_EXPO: 0,
|
||||
roll_pitch_rate: 0,
|
||||
yaw_rate: 0,
|
||||
dynamic_THR_PID: 0,
|
||||
throttle_MID: 0,
|
||||
throttle_EXPO: 0,
|
||||
};
|
||||
|
||||
var SENSOR_DATA = {
|
||||
gyroscope: [0, 0, 0],
|
||||
accelerometer: [0, 0, 0],
|
||||
|
@ -154,6 +164,7 @@ function onOpen(openInfo) {
|
|||
send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT);
|
||||
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
|
||||
send_message(MSP_codes.MSP_PID, MSP_codes.MSP_PID);
|
||||
send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING);
|
||||
|
||||
}, connection_delay * 1000);
|
||||
}
|
||||
|
@ -260,9 +271,9 @@ function onCharRead(readInfo) {
|
|||
}
|
||||
}
|
||||
|
||||
function send_message(code, data, bytes_n) {
|
||||
function send_message(code, data) {
|
||||
if (typeof data === 'object') {
|
||||
var size = 6 + bytes_n;
|
||||
var size = 6 + data.length; // 6 bytes for protocol overhead
|
||||
var checksum = 0;
|
||||
|
||||
var bufferOut = new ArrayBuffer(size);
|
||||
|
@ -275,10 +286,11 @@ function send_message(code, data, bytes_n) {
|
|||
bufView[4] = code; // code
|
||||
|
||||
checksum = bufView[3] ^ bufView[4];
|
||||
for (var i = 5; i < data.length; i++) {
|
||||
bufView[i] = data[i - 5];
|
||||
|
||||
checksum ^= bufView[i];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
bufView[i + 5] = data[i];
|
||||
|
||||
checksum ^= bufView[i + 5];
|
||||
}
|
||||
|
||||
bufView[5 + data.length] = checksum;
|
||||
|
@ -289,7 +301,7 @@ function send_message(code, data, bytes_n) {
|
|||
bufView[0] = 36; // $
|
||||
bufView[1] = 77; // M
|
||||
bufView[2] = 60; // <
|
||||
bufView[3] = bytes_n; // data length
|
||||
bufView[3] = 0; // data length
|
||||
bufView[4] = code; // code
|
||||
bufView[5] = data; // data
|
||||
bufView[6] = bufView[3] ^ bufView[4] ^ bufView[5]; // checksum
|
||||
|
@ -366,7 +378,13 @@ function process_message(code, data) {
|
|||
console.log(data);
|
||||
break;
|
||||
case MSP_codes.MSP_RC_TUNING:
|
||||
console.log(data);
|
||||
RC_tuning.RC_RATE = parseFloat((view.getUint8(0) / 100).toFixed(2));
|
||||
RC_tuning.RC_EXPO = parseFloat((view.getUint8(1) / 100).toFixed(2));
|
||||
RC_tuning.roll_pitch_rate = parseFloat((view.getUint8(2) / 100).toFixed(2));
|
||||
RC_tuning.yaw_rate = parseFloat((view.getUint8(3) / 100).toFixed(2));
|
||||
RC_tuning.dynamic_THR_PID = parseFloat((view.getUint8(4) / 100).toFixed(2));
|
||||
RC_tuning.throttle_MID = parseFloat((view.getUint8(5) / 100).toFixed(2));
|
||||
RC_tuning.throttle_EXPO = parseFloat((view.getUint8(6) / 100).toFixed(2));
|
||||
break;
|
||||
case MSP_codes.MSP_PID:
|
||||
// PID data arrived, we need to scale it and save to appropriate bank / array
|
||||
|
@ -428,7 +446,7 @@ function process_message(code, data) {
|
|||
console.log(data);
|
||||
break;
|
||||
case MSP_codes.MSP_SET_RC_TUNING:
|
||||
console.log(data);
|
||||
console.log('RC Tuning saved');
|
||||
break;
|
||||
case MSP_codes.MSP_ACC_CALIBRATION:
|
||||
console.log('Accel calibration executed');
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
<td><input type="text" name="i" value="" /></td>
|
||||
<td><input type="text" name="d" value="" /></td>
|
||||
</tr>
|
||||
|
||||
<tr class="PITCH">
|
||||
<td>PITCH</td>
|
||||
<td><input type="text" name="p" value="" /></td>
|
||||
|
@ -59,5 +58,17 @@
|
|||
<td><input type="text" name="p" value="" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="rate-tpa">
|
||||
<tr>
|
||||
<th>ROLL rate & PITCH rate</th>
|
||||
<th>YAW rate</th>
|
||||
<th>TPA</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="text" name="roll-pitch" value="" /></td>
|
||||
<td><input type="text" name="yaw" value="" /></td>
|
||||
<td><input type="text" name="tpa" value="" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a class="update" href="#">Update</a>
|
||||
</div>
|
|
@ -56,9 +56,13 @@ function tab_initialize_pid_tuning() {
|
|||
});
|
||||
needle++;
|
||||
|
||||
// UI Hooks
|
||||
// Fill in data from RC_tuning object
|
||||
$('.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));
|
||||
|
||||
$('.pid_tuning input').change(function() {
|
||||
// UI Hooks
|
||||
$('.pid_tuning input, .rate-tpa input').change(function() {
|
||||
// if any of the fields changed, unlock update button
|
||||
$('a.update').addClass('active');
|
||||
});
|
||||
|
@ -120,18 +124,27 @@ function tab_initialize_pid_tuning() {
|
|||
break;
|
||||
}
|
||||
PID_buffer_needle += 3;
|
||||
|
||||
/*
|
||||
for (var ii = 0; ii < PIDs[i].length; ii++) {
|
||||
PID_buffer_out[PID_buffer_needle] = PIDs[i][ii];
|
||||
PID_buffer_needle++;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//console.log(PID_buffer_out);
|
||||
// Send over the changes
|
||||
send_message(MSP_codes.MSP_SET_PID, PID_buffer_out, PID_buffer_out.length);
|
||||
// Send over the PID changes
|
||||
send_message(MSP_codes.MSP_SET_PID, PID_buffer_out);
|
||||
|
||||
// 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 RC_tuning_buffer_out = new Array();
|
||||
RC_tuning_buffer_out[0] = parseInt(RC_tuning.RC_RATE * 100);
|
||||
RC_tuning_buffer_out[1] = parseInt(RC_tuning.RC_EXPO * 100);
|
||||
RC_tuning_buffer_out[2] = parseInt(RC_tuning.roll_pitch_rate * 100);
|
||||
RC_tuning_buffer_out[3] = parseInt(RC_tuning.yaw_rate * 100);
|
||||
RC_tuning_buffer_out[4] = parseInt(RC_tuning.dynamic_THR_PID * 100);
|
||||
RC_tuning_buffer_out[5] = parseInt(RC_tuning.throttle_MID * 100);
|
||||
RC_tuning_buffer_out[6] = parseInt(RC_tuning.throttle_EXPO * 100);
|
||||
|
||||
// Send over the RC_tuning changes
|
||||
send_message(MSP_codes.MSP_SET_RC_TUNING, RC_tuning_buffer_out);
|
||||
|
||||
// remove the active status
|
||||
$(this).removeClass('active');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue