1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-21 15:25:36 +03:00

pid tuning improvements

This commit is contained in:
cTn 2013-04-09 01:49:49 +02:00
parent 62a212b0e8
commit d61df6fc82
4 changed files with 76 additions and 4 deletions

View file

@ -240,3 +240,29 @@ table.pid_tuning {
text-decoration: none; text-decoration: none;
background-color: #13b723; background-color: #13b723;
} }
.tab-pid_tuning .update {
display: block;
float: right;
width: 120px;
height: 60px;
line-height: 60px;
font-size: 14px;
color: white;
text-align: center;
border: 1px solid silver;
background-color: #6f1515;
}
.tab-pid_tuning .update:hover {
cursor: default;
}
.tab-pid_tuning .update.active {
background-color: #0fab16;
}
.tab-pid_tuning .update.active:hover {
cursor: pointer;
background-color: #13d81d;
}

View file

@ -2,14 +2,14 @@
<div class="section"> <div class="section">
<a class="calibrateAccel" href="#">Calibrate Accelerometer</a> <a class="calibrateAccel" href="#">Calibrate Accelerometer</a>
<p> <p>
Place frame on a level surface, proceed with calibration, ensure it is not moving during this period. Place frame on a <strong style="color: green;">level</strong> surface, proceed with calibration, ensure it is <strong style="color: red;">not</strong> moving during this period.
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a class="calibrateMag" href="#">Calibrate Magnetometer</a> <a class="calibrateMag" href="#">Calibrate Magnetometer</a>
<p> <p>
Click the button, move multirotor atleast 360 degrees on all axis of rotation. <br /> Click the button, move multirotor atleast <strong>360</strong> degrees on all axis of rotation. <br />
You have 30 seconds to perform this task. You have <strong style="color: red;">30 seconds</strong> to perform this task.
</p> </p>
</div> </div>
</div> </div>

View file

@ -59,4 +59,5 @@
<td><input type="text" name="p" value="" /></td> <td><input type="text" name="p" value="" /></td>
</tr> </tr>
</table> </table>
<a class="update" href="#">Update</a>
</div> </div>

View file

@ -1,4 +1,5 @@
function tab_initialize_pid_tuning() { function tab_initialize_pid_tuning() {
// Fill in the data from PIDs array
var needle = 0; var needle = 0;
var i = 0; var i = 0;
@ -55,4 +56,48 @@ function tab_initialize_pid_tuning() {
}); });
needle++; needle++;
// UI Hooks
$('.pid_tuning input').change(function() {
// if any of the fields changed, unlock update button
$('a.update').addClass('active');
});
$('a.update').click(function() {
if ($(this).hasClass('active')) {
// Catch all the changes and stuff the inside PIDs array
var needle_main = 0;
var needle_secondary = 0;
$('.pid_tuning input').each(function() {
PIDs[needle_main][needle_secondary] = parseFloat($(this).val());
needle_secondary++;
// exceptions (required for the "shorter" PID arrays, 2 fields, 1 field, etc)
if (needle_main == 4) {
if (needle_secondary >= 2) {
needle_main++;
needle_secondary = 0;
}
} else if (needle_main == 8) {
if (needle_secondary >= 1) {
needle_main++;
needle_secondary = 0;
}
} else {
if (needle_secondary >= 3) {
needle_main++;
needle_secondary = 0;
}
}
});
// Send over the changes
// remove the active status
$(this).removeClass('active');
}
});
} }