UI polish

pull/3/head
cTn 11 years ago
parent 7981bbea4e
commit 7dbd4bac82

@ -3,7 +3,7 @@
border-collapse: collapse; border-collapse: collapse;
} }
.tab-pid_tuning table, .tab-pid_tuning table th, .tab-pid_tuning table td { .tab-pid_tuning table, .tab-pid_tuning table th, .tab-pid_tuning table td {
padding: 5px; padding: 4px;
border: 1px solid #8b8b8b; border: 1px solid #8b8b8b;
} }
.tab-pid_tuning table tr:nth-child(odd) { .tab-pid_tuning table tr:nth-child(odd) {
@ -24,27 +24,19 @@
margin-top: 20px; margin-top: 20px;
width: 120px; height: 28px;
height: 56px; line-height: 28px;
line-height: 56px;
padding: 0 15px 0 15px;
font-size: 14px;
color: white;
text-align: center; text-align: center;
font-weight: bold;
border: 1px solid silver; border: 1px solid silver;
background-color: #ececec;
background-color: #6f1515;
} }
.tab-pid_tuning .update:hover { .tab-pid_tuning .update:hover {
cursor: default; background-color: #dedcdc;
}
.tab-pid_tuning .update.active {
background-color: #0fab16;
}
.tab-pid_tuning .update.active:hover {
cursor: pointer;
background-color: #13d81d;
} }
.tab-pid_tuning .rate-tpa { .tab-pid_tuning .rate-tpa {
float: left; float: left;

@ -137,96 +137,87 @@ function tab_initialize_pid_tuning() {
$('.rate-tpa input[name="tpa"]').val(RC_tuning.dynamic_THR_PID.toFixed(2)); $('.rate-tpa input[name="tpa"]').val(RC_tuning.dynamic_THR_PID.toFixed(2));
// UI Hooks // UI Hooks
$('.pid_tuning input, .rate-tpa input').change(function() {
// if any of the fields changed, unlock update button
$('a.update').addClass('active');
});
$('a.update').click(function() { $('a.update').click(function() {
if ($(this).hasClass('active')) { // Catch all the changes and stuff the inside PIDs array
// Catch all the changes and stuff the inside PIDs array var needle_main = 0;
var needle_main = 0; var needle_secondary = 0;
var needle_secondary = 0;
$('.pid_tuning input').each(function() {
$('.pid_tuning input').each(function() { PIDs[needle_main][needle_secondary] = parseFloat($(this).val());
PIDs[needle_main][needle_secondary] = parseFloat($(this).val()); needle_secondary++;
needle_secondary++;
// exceptions (required for the "shorter" PID arrays, 2 fields, 1 field, etc)
// exceptions (required for the "shorter" PID arrays, 2 fields, 1 field, etc) if (needle_main == 4) {
if (needle_main == 4) { if (needle_secondary >= 2) {
if (needle_secondary >= 2) { needle_main++;
needle_main++; needle_secondary = 0;
needle_secondary = 0; }
} } else if (needle_main == 8) {
} else if (needle_main == 8) { if (needle_secondary >= 1) {
if (needle_secondary >= 1) { needle_main++;
needle_main++; needle_secondary = 0;
needle_secondary = 0;
}
} else {
if (needle_secondary >= 3) {
needle_main++;
needle_secondary = 0;
}
} }
}); } else {
if (needle_secondary >= 3) {
var PID_buffer_out = new Array(); needle_main++;
var PID_buffer_needle = 0; needle_secondary = 0;
for (var i = 0; i < PIDs.length; i++) {
switch (i) {
case 0:
case 1:
case 2:
case 3:
case 7:
case 8:
case 9:
PID_buffer_out[PID_buffer_needle] = parseInt(PIDs[i][0] * 10);
PID_buffer_out[PID_buffer_needle + 1] = parseInt(PIDs[i][1] * 1000);
PID_buffer_out[PID_buffer_needle + 2] = parseInt(PIDs[i][2]);
break;
case 4:
PID_buffer_out[PID_buffer_needle] = parseInt(PIDs[i][0] * 100);
PID_buffer_out[PID_buffer_needle + 1] = parseInt(PIDs[i][1] * 100);
PID_buffer_out[PID_buffer_needle + 2] = parseInt(PIDs[i][2]);
break;
case 5:
case 6:
PID_buffer_out[PID_buffer_needle] = parseInt(PIDs[i][0] * 10);
PID_buffer_out[PID_buffer_needle + 1] = parseInt(PIDs[i][1] * 100);
PID_buffer_out[PID_buffer_needle + 2] = parseInt(PIDs[i][2] * 1000);
break;
} }
PID_buffer_needle += 3;
} }
});
var PID_buffer_out = new Array();
var PID_buffer_needle = 0;
for (var i = 0; i < PIDs.length; i++) {
switch (i) {
case 0:
case 1:
case 2:
case 3:
case 7:
case 8:
case 9:
PID_buffer_out[PID_buffer_needle] = parseInt(PIDs[i][0] * 10);
PID_buffer_out[PID_buffer_needle + 1] = parseInt(PIDs[i][1] * 1000);
PID_buffer_out[PID_buffer_needle + 2] = parseInt(PIDs[i][2]);
break;
case 4:
PID_buffer_out[PID_buffer_needle] = parseInt(PIDs[i][0] * 100);
PID_buffer_out[PID_buffer_needle + 1] = parseInt(PIDs[i][1] * 100);
PID_buffer_out[PID_buffer_needle + 2] = parseInt(PIDs[i][2]);
break;
case 5:
case 6:
PID_buffer_out[PID_buffer_needle] = parseInt(PIDs[i][0] * 10);
PID_buffer_out[PID_buffer_needle + 1] = parseInt(PIDs[i][1] * 100);
PID_buffer_out[PID_buffer_needle + 2] = parseInt(PIDs[i][2] * 1000);
break;
}
PID_buffer_needle += 3;
}
// Send over the PID changes // Send over the PID changes
send_message(MSP_codes.MSP_SET_PID, PID_buffer_out); 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(); // catch RC_tuning changes
RC_tuning_buffer_out[0] = parseInt(RC_tuning.RC_RATE * 100); RC_tuning.roll_pitch_rate = parseFloat($('.rate-tpa input[name="roll-pitch"]').val());
RC_tuning_buffer_out[1] = parseInt(RC_tuning.RC_EXPO * 100); RC_tuning.yaw_rate = parseFloat($('.rate-tpa input[name="yaw"]').val());
RC_tuning_buffer_out[2] = parseInt(RC_tuning.roll_pitch_rate * 100); RC_tuning.dynamic_THR_PID = parseFloat($('.rate-tpa input[name="tpa"]').val());
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 var RC_tuning_buffer_out = new Array();
send_message(MSP_codes.MSP_SET_RC_TUNING, RC_tuning_buffer_out); 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);
// Save changes to EEPROM // Send over the RC_tuning changes
send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE); send_message(MSP_codes.MSP_SET_RC_TUNING, RC_tuning_buffer_out);
// remove the active status // Save changes to EEPROM
$(this).removeClass('active'); send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE);
}
}); });
// enable data pulling // enable data pulling

Loading…
Cancel
Save