initial work on servos
parent
711a052f04
commit
5f6aeb72f8
@ -1,3 +1,79 @@
|
||||
<style type="text/css">
|
||||
.tab-servos table {
|
||||
margin-top: 10px;
|
||||
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.tab-servos table th {
|
||||
line-height: 20px;
|
||||
text-align: center;
|
||||
|
||||
border: 1px solid #8b8b8b;
|
||||
}
|
||||
.tab-servos table td {
|
||||
line-height: 18px;
|
||||
|
||||
border: 1px solid #8b8b8b;
|
||||
}
|
||||
.tab-servos table .main {
|
||||
font-weight: bold;
|
||||
|
||||
text-align: center;
|
||||
|
||||
background-color: #ececec;
|
||||
}
|
||||
.tab-servos table input[type="number"] {
|
||||
width: 65px;
|
||||
height: 20px;
|
||||
|
||||
padding-right: 5px;
|
||||
|
||||
line-height: 20px;
|
||||
|
||||
text-align: right;
|
||||
}
|
||||
.tab-servos table input[type="checkbox"]:first-child {
|
||||
margin-left: 24px;
|
||||
}
|
||||
.tab-servos table input[type="checkbox"] {
|
||||
margin-top: 4px;
|
||||
margin-right: 21px;
|
||||
}
|
||||
.tab-servos .update {
|
||||
display: block;
|
||||
float: right;
|
||||
|
||||
margin-top: 10px;
|
||||
|
||||
width: 120px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
|
||||
font-size: 14px;
|
||||
color: white;
|
||||
text-align: center;
|
||||
|
||||
border: 1px solid silver;
|
||||
|
||||
background-color: #0fab16;
|
||||
}
|
||||
.tab-servos .update:hover {
|
||||
cursor: pointer;
|
||||
background-color: #13d81d;
|
||||
}
|
||||
</style>
|
||||
<div class="tab-servos">
|
||||
servos
|
||||
Model: <strong class="model"></strong>
|
||||
<table class="fields">
|
||||
<tr class="main">
|
||||
<th style="width: 150px">Name</th>
|
||||
<th style="width: 70px">MID</th>
|
||||
<th style="width: 70px">MIN</th>
|
||||
<th style="width: 70px">MAX</th>
|
||||
<th style="width: 320px">Throt | Roll | Pitch | Yaw | AUX1 | AUX2 | AUX3 | AUX4</th>
|
||||
<th>Reverse Direction</th>
|
||||
</tr>
|
||||
</table>
|
||||
<a class="update" href="#" title="">Save</a>
|
||||
</div>
|
@ -1,6 +1,115 @@
|
||||
function tab_initialize_servos() {
|
||||
ga_tracker.sendAppView('Servos');
|
||||
|
||||
// request current Servo Config
|
||||
// request current Servos Config
|
||||
send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT);
|
||||
send_message(MSP_codes.MSP_SERVO_CONF, MSP_codes.MSP_SERVO_CONF);
|
||||
|
||||
var model = $('div.tab-servos strong.model');
|
||||
var servos = [];
|
||||
|
||||
setTimeout(function() {
|
||||
switch (CONFIG.multiType) {
|
||||
case 1: // TRI
|
||||
model.html('TRI');
|
||||
|
||||
process_servos('Rear', SERVO_CONFIG[5], 5);
|
||||
|
||||
servos = [5];
|
||||
break;
|
||||
case 4: // BI
|
||||
model.html('BI');
|
||||
|
||||
process_servos('Left', SERVO_CONFIG[4], 4);
|
||||
process_servos('Right', SERVO_CONFIG[5], 5);
|
||||
|
||||
servos = [4, 5];
|
||||
break;
|
||||
case 5: // Gimbal
|
||||
model.html('Gimbal');
|
||||
|
||||
process_servos('Pitch Servo', SERVO_CONFIG[0], 0);
|
||||
process_servos('Roll Servo', SERVO_CONFIG[1], 1);
|
||||
|
||||
servos = [0, 1];
|
||||
break;
|
||||
case 8: // Flying Wing
|
||||
model.html('Flying Wing');
|
||||
|
||||
process_servos('Left', SERVO_CONFIG[3], 3);
|
||||
process_servos('Right', SERVO_CONFIG[4], 4);
|
||||
|
||||
servos = [3, 4];
|
||||
break;
|
||||
case 14: // Airplane
|
||||
model.html('Airplane');
|
||||
|
||||
process_servos('Wing 1', SERVO_CONFIG[3], 3);
|
||||
process_servos('Wing 2', SERVO_CONFIG[4], 4);
|
||||
process_servos('Rudd', SERVO_CONFIG[5], 5);
|
||||
process_servos('Elev', SERVO_CONFIG[6], 6);
|
||||
process_servos('Thro', SERVO_CONFIG[7], 7);
|
||||
|
||||
servos = [2, 3, 4, 5, 6, 7];
|
||||
break;
|
||||
case 20: // Dualcopter
|
||||
model.html('Dualcopter');
|
||||
|
||||
process_servos('Pitch', SERVO_CONFIG[4], 4);
|
||||
process_servos('Roll', SERVO_CONFIG[5], 5);
|
||||
process_servos('M 1', SERVO_CONFIG[6], 6);
|
||||
process_servos('M 0', SERVO_CONFIG[7], 7);
|
||||
|
||||
servos = [4, 5, 6, 7];
|
||||
break;
|
||||
case 21: // Singlecopter
|
||||
model.html('Singlecopter');
|
||||
|
||||
process_servos('Right', SERVO_CONFIG[3], 3);
|
||||
process_servos('Left', SERVO_CONFIG[4], 4);
|
||||
process_servos('Front', SERVO_CONFIG[5], 5);
|
||||
process_servos('Rear', SERVO_CONFIG[6], 6);
|
||||
process_servos('Motor', SERVO_CONFIG[7], 7);
|
||||
|
||||
servos = [3, 4, 5, 6, 7];
|
||||
break;
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
|
||||
function process_servos(name, obj, pos) {
|
||||
$('div.tab-servos table.fields').append('\
|
||||
<tr> \
|
||||
<td style="text-align: center;">' + name + '</td>\
|
||||
<td class="middle"><input type="number" min="1000" max="2000" value="' + obj.middle +'" /></td>\
|
||||
<td class="min"><input type="number" min="1000" max="2000" value="' + obj.min +'" /></td>\
|
||||
<td class="max"><input type="number" min="1000" max="2000" value="' + obj.max +'" /></td>\
|
||||
<td class="channel">\
|
||||
<input type="checkbox"/>\
|
||||
<input type="checkbox"/>\
|
||||
<input type="checkbox"/>\
|
||||
<input type="checkbox"/>\
|
||||
<input type="checkbox"/>\
|
||||
<input type="checkbox"/>\
|
||||
<input type="checkbox"/>\
|
||||
<input type="checkbox"/>\
|
||||
</td>\
|
||||
<td class="direction"></td>\
|
||||
</tr> \
|
||||
'
|
||||
);
|
||||
|
||||
if (obj.middle <= 7) {
|
||||
$('div.tab-servos table.fields tr:last td.channel').find('input').eq(obj.middle).prop('checked', true);
|
||||
}
|
||||
|
||||
// UI hooks
|
||||
$('div.tab-servos table.fields tr:last td.channel').find('input').click(function() {
|
||||
if($(this).is(':checked')) {
|
||||
$(this).parent().parent().parent().find('td.middle input').prop('disabled', true);
|
||||
$('div.tab-servos table.fields tr:last td.channel').find('input').not($(this)).prop('checked', false);
|
||||
} else {
|
||||
$(this).parent().parent().parent().find('td.middle input').prop('disabled', false);
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue