1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 16:55:24 +03:00

Merge pull request #17 from mikeller/rate_move

Moved pitch / roll / yaw rate / expo / curves to PID tab
This commit is contained in:
borisbstyle 2016-06-19 22:01:18 +02:00 committed by GitHub
commit afac7acdd7
7 changed files with 249 additions and 171 deletions

View file

@ -754,17 +754,14 @@
"pidTuningDerivative": {
"message": "Derivative"
},
"pidTuningRollPitchRate": {
"message": "ROLL & PITCH rate"
"pidTuningRcRate": {
"message": "RC Rate"
},
"pidTuningRollRate": {
"message": "ROLL rate"
"pidTuningRate": {
"message": "Rate"
},
"pidTuningPitchRate": {
"message": "PITCH rate"
},
"pidTuningYawRate": {
"message": "YAW rate"
"pidTuningRcExpo": {
"message": "RC Expo"
},
"pidTuningTPA": {
"message": "TPA"
@ -772,6 +769,12 @@
"pidTuningTPABreakPoint": {
"message": "TPA Breakpoint"
},
"rcCurve": {
"message": "RC Curve"
},
"rcYawCurve": {
"message": "RC Yaw Curve"
},
"pidTuningButtonSave": {
"message": "Save"
},
@ -803,9 +806,6 @@
"receiverThrottleExpo": {
"message": "Throttle EXPO"
},
"receiverRcRate": {
"message": "RC Rate"
},
"receiverDeadband": {
"message": "RC Deadband"
},
@ -818,12 +818,6 @@
"receiverYawDeadband": {
"message": "Yaw Deadband"
},
"receiverRcExpo": {
"message": "RC Expo"
},
"receiverRcYawExpo": {
"message": "RC Yaw Expo"
},
"receiverChannelMap": {
"message": "Channel Map"
},

View file

@ -1,4 +1,4 @@
.tab-pid_tuning .rate-tpa th {
.tab-pid_tuning .tpa th {
background-color: #828885;
padding: 4px;
border-left: 0px solid #ccc;
@ -44,23 +44,91 @@
border: 1px solid silver;
}
.tab-pid_tuning .rate-tpa th:nth-child(2) {
.tab-pid_tuning .tpa th:nth-child(2) {
border-top-left-radius: 3px;
}
.tab-pid_tuning .rate-tpa th:first-child {
.tab-pid_tuning .tpa th:first-child {
border-top-left-radius: 3px;
}
.tab-pid_tuning .rate-tpa th:last-child {
.tab-pid_tuning .tpa th:last-child {
border-top-right-radius: 3px;
}
.tab-pid_tuning .rate-tpa {
.tab-pid_tuning .tpa {
/*border: 0px solid #ccc; */
margin-bottom: 10px;
}
.tab-pid_tuning .rc_curve {
float: right;
width: calc(100% - 2px); /* - ( "virtual" margin) */
}
.tab-pid_tuning .rc_curve th {
background-color: #828885;
padding: 4px;
border-left: 0px solid #ccc;
border-bottom: 1px solid #ccc;
font-weight: bold;
color: white;
text-align: left;
}
.tab-pid_tuning .rc_curve th:first-child {
border-top-left-radius: 3px;
}
.tab-pid_tuning .rc_curve th:last-child {
border-top-right-radius: 3px;
}
.tab-pid_tuning .pitch_roll_curve {
margin: 0 0px 0px 0;
width: 100%;
height: 100%;
border: 1px solid silver;
border-radius: 3px;
background-image: url(../images/paper.jpg);
background-size: 200%;
background-position: center;
}
.tab-pid_tuning .rc_yaw_curve {
float: right;
width: calc(100% - 2px); /* - ( "virtual" margin) */
}
.tab-pid_tuning .rc_yaw_curve th {
background-color: #828885;
padding: 4px;
border-left: 0px solid #ccc;
border-bottom: 1px solid #ccc;
font-weight: bold;
color: white;
text-align: left;
}
.tab-pid_tuning .rc_yaw_curve th:first-child {
border-top-left-radius: 3px;
}
.tab-pid_tuning .rc_yaw_curve th:last-child {
border-top-right-radius: 3px;
}
.tab-pid_tuning .yaw_curve {
margin: 0 0px 0px 0;
width: 100%;
height: 100%;
border: 1px solid silver;
border-radius: 3px;
background-image: url(../images/paper.jpg);
background-size: 200%;
background-position: center;
}
.tab-pid_tuning input[type="number"]::-webkit-inner-spin-button {
border: 0;
}
@ -114,7 +182,7 @@
.tab-pid_tuning table td {
padding: 1px;
width: 25%;
width: 14%;
border-right: 1px solid #ccc;
}
@ -191,23 +259,35 @@
line-height: 20px;
}
.tab-pid_tuning .pid_tuning .name {
width: 25%;
.tab-pid_tuning .name {
width: 14%;
}
.tab-pid_tuning .proportional {
width: 25%;
width: 14%;
}
.tab-pid_tuning .integral {
width: 25%;
width: 14%;
}
.tab-pid_tuning .derivative {
width: 25%;
width: 14%;
}
.tab-pid_tuning .rate-tpa {
.tab-pid_tuning .rc_rate {
width: 14%;
}
.tab-pid_tuning .rate {
width: 14%;
}
.tab-pid_tuning .rc_expo {
width: 14%;
}
.tab-pid_tuning .tpa {
float: right;
width: calc(100% - 2px); /* - ( "virtual" margin) */
}
@ -386,4 +466,4 @@
.tab-pid_tuning .topspacer {
margin-top:15px;
}
}

View file

@ -25,7 +25,7 @@
</div>
<form name="pid-tuning" id="pid-tuning">
<div class="clear-both"></div>
<div class="cf_column half">
<div class="cf_column twothird">
<div class="gui_box grey">
<table class="pid_titlebar">
<tr>
@ -33,11 +33,14 @@
<th class="proportional" i18n="pidTuningProportional"></th>
<th class="integral" i18n="pidTuningIntegral"></th>
<th class="derivative" i18n="pidTuningDerivative"></th>
<th class="rc_rate" i18n="pidTuningRcRate"></th>
<th class="rate" i18n="pidTuningRate"></th>
<th class="rc_expo" i18n="pidTuningRcExpo"></th>
</tr>
</table>
<table id="pid_main" class="pid_tuning">
<tr>
<th colspan="4">
<th colspan="8">
<div class="pid_mode" i18n="pidTuningBasic"></div>
</th>
</tr>
@ -47,6 +50,11 @@
<td><input type="number" name="p" step="1" min="0" max="255" /></td>
<td><input type="number" name="i" step="1" min="0" max="255" /></td>
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
<td rowspan="3"><input type="number" name="rc_rate" step="0.01" min="0" max="2.5" /></td>
<td class="roll_rate"><input type="number" name="roll_rate" step="0.01" min="0" max="1.00" /></td>
<td class="roll_pitch_rate" rowspan="2"><input type="number" name="roll_pitch_rate" step="0.01" min="0" max="1.00" /></td>
<td rowspan="2"><input type="number" name="rc_expo" step="0.01" min="0" max="1" /></td>
</tr>
<tr class="PITCH">
<!-- 1 -->
@ -54,6 +62,7 @@
<td><input type="number" name="p" step="1" min="0" max="255" /></td>
<td><input type="number" name="i" step="1" min="0" max="255" /></td>
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
<td class="pitch_rate"><input type="number" name="pitch_rate" step="0.01" min="0" max="1.00" /></td>
</tr>
<tr class="YAW">
<!-- 2 -->
@ -61,6 +70,18 @@
<td><input type="number" name="p" step="1" min="0" max="255" /></td>
<td><input type="number" name="i" step="1" min="0" max="255" /></td>
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
<td><input type="number" name="yaw_rate" step="0.01" min="0" max="2.55" /></td>
<td><input type="number" name="rc_yaw_expo" step="0.01" min="0" max="1" /></td>
</tr>
</table>
</div>
<div class="gui_box grey topspacer">
<table class="pid_titlebar">
<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>
</table>
<table id="pid_baro" class="pid_tuning">
@ -153,41 +174,60 @@
</table>
</div>
</div>
<div class="cf_column half">
<div class="cf_column third_right">
<div class="spacer_left">
<table class="rate-tpa cf">
<table class="rc_curve cf">
<thead>
<tr>
<th class="roll-pitch" i18n="pidTuningRollPitchRate"></th>
<th class="roll" i18n="pidTuningRollRate"></th>
<th class="pitch" i18n="pidTuningPitchRate"></th>
<th i18n="pidTuningYawRate"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="roll-pitch"><input type="number" name="roll-pitch" step="0.01" min="0"
max="1.00" /></td>
<td class="roll"><input type="number"
name="roll" step="0.01" min="0" max="1.00" /></td>
<td class="pitch"><input type="number" name="pitch" step="0.01" min="0" max="1.00" /></td>
<td><input type="number" name="yaw" step="0.01" min="0" max="2.55" /></td>
</tr>
</tbody>
<th i18n="rcCurve"></th>
</tr>
</thead>
</tbody>
<tr>
<td>
<div class="spacer" style="margin-top: 10px; margin-bottom: 10px;">
<div class="pitch_roll_curve">
<canvas style="width: 100%; height: 100%"></canvas>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<table class="rate-tpa cf">
</div>
<div class="spacer_left topspacer">
<table class="rc_yaw_curve cf">
<thead>
<tr>
<th i18n="rcYawCurve"></th>
</tr>
</thead>
</tbody>
<tr>
<td>
<div class="spacer" style="margin-top: 10px; margin-bottom: 10px;">
<div class="yaw_curve">
<canvas style="width: 100%; height: 100%"></canvas>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="spacer_left topspacer">
<table class="tpa cf">
<thead>
<tr>
<th i18n="pidTuningTPA"></th>
<th class="tpa-breakpoint" i18n="pidTuningTPABreakPoint"></th>
</tr>
</thead>
<tbody>
<tbody>
<tr>
<td class="leftzero"><input type="number" name="tpa" step="0.01" min="0"
max="1.00" /></td>
<td class="tpa-breakpoint"><input type="number" name="tpa-breakpoint" step="10"
min="1000" max="2000" /></td>
<td class="tpa-breakpoint"><input type="number" name="tpa-breakpoint" step="10" min="1000" max="2000" /></td>
</tr>
</tbody>
</table>

View file

@ -170,12 +170,21 @@ TABS.pid_tuning.initialize = function (callback) {
});
// 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="roll"]').val(RC_tuning.roll_rate.toFixed(2));
$('.rate-tpa input[name="pitch"]').val(RC_tuning.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));
$('.rate-tpa input[name="tpa-breakpoint"]').val(RC_tuning.dynamic_THR_breakpoint);
$('.pid_tuning input[name="rc_rate"]').val(RC_tuning.RC_RATE.toFixed(2));
$('.pid_tuning input[name="roll_pitch_rate"]').val(RC_tuning.roll_pitch_rate.toFixed(2));
$('.pid_tuning input[name="roll_rate"]').val(RC_tuning.roll_rate.toFixed(2));
$('.pid_tuning input[name="pitch_rate"]').val(RC_tuning.pitch_rate.toFixed(2));
$('.pid_tuning input[name="yaw_rate"]').val(RC_tuning.yaw_rate.toFixed(2));
$('.pid_tuning input[name="rc_expo"]').val(RC_tuning.RC_EXPO.toFixed(2));
$('.pid_tuning input[name="rc_yaw_expo"]').val(RC_tuning.RC_YAW_EXPO.toFixed(2));
$('.tpa input[name="tpa"]').val(RC_tuning.dynamic_THR_PID.toFixed(2));
$('.tpa input[name="tpa-breakpoint"]').val(RC_tuning.dynamic_THR_breakpoint);
if (semver.lt(CONFIG.apiVersion, "1.10.0")) {
$('.pid_tuning input[name="rc_yaw_expo"]').hide();
$('.pid_tuning input[name="rc_expo"]').attr("rowspan", "3");
}
}
function form_to_pid_and_rc() {
@ -231,12 +240,16 @@ TABS.pid_tuning.initialize = function (callback) {
});
// catch RC_tuning changes
RC_tuning.roll_pitch_rate = parseFloat($('.rate-tpa input[name="roll-pitch"]').val());
RC_tuning.roll_rate = parseFloat($('.rate-tpa input[name="roll"]').val());
RC_tuning.pitch_rate = parseFloat($('.rate-tpa input[name="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());
RC_tuning.dynamic_THR_breakpoint = parseInt($('.rate-tpa input[name="tpa-breakpoint"]').val());
RC_tuning.RC_RATE = parseFloat($('.pid_tuning input[name="rc_rate"]').val());
RC_tuning.roll_pitch_rate = parseFloat($('.pid_tuning input[name="roll_pitch_rate"]').val());
RC_tuning.roll_rate = parseFloat($('.pid_tuning input[name="roll_rate"]').val());
RC_tuning.pitch_rate = parseFloat($('.pid_tuning input[name="pitch_rate"]').val());
RC_tuning.yaw_rate = parseFloat($('.pid_tuning input[name="yaw_rate"]').val());
RC_tuning.RC_EXPO = parseFloat($('.pid_tuning input[name="rc_expo"]').val());
RC_tuning.RC_YAW_EXPO = parseFloat($('.pid_tuning input[name="rc_yaw_expo"]').val());
RC_tuning.dynamic_THR_PID = parseFloat($('.tpa input[name="tpa"]').val());
RC_tuning.dynamic_THR_breakpoint = parseInt($('.tpa input[name="tpa-breakpoint"]').val());
}
function hideUnusedPids(sensors_detected) {
$('.tab-pid_tuning table.pid_tuning').hide();
@ -331,14 +344,63 @@ TABS.pid_tuning.initialize = function (callback) {
}
if (semver.lt(CONFIG.apiVersion, "1.7.0")) {
$('.rate-tpa .tpa-breakpoint').hide();
$('.rate-tpa .roll').hide();
$('.rate-tpa .pitch').hide();
$('.tpa .tpa-breakpoint').hide();
$('.pid_tuning .roll_rate').hide();
$('.pid_tuning .pitch_rate').hide();
} else {
$('.rate-tpa .roll-pitch').hide();
$('.pid_tuning .roll_pitch_rate').hide();
}
function setCanvasDimensions(canvas) {
canvas.width = canvas.parentNode.clientWidth;
canvas.height = canvas.parentNode.clientHeight;
}
setCanvasDimensions($('.pitch_roll_curve canvas').get(0));
setCanvasDimensions($('.yaw_curve canvas').get(0));
function drawRateCurve(rateElement, expoElement, canvasElement) {
var rate = parseFloat(rateElement.val()),
expo = parseFloat(expoElement.val()),
context = canvasElement.getContext("2d");
// local validation to deal with input event
if (rate >= parseFloat(rateElement.prop('min')) &&
rate <= parseFloat(rateElement.prop('max')) &&
expo >= parseFloat(expoElement.prop('min')) &&
expo <= parseFloat(expoElement.prop('max'))) {
var rateHeight = canvasElement.height;
var rateWidth = canvasElement.width;
// math magic by englishman
var ratey = rateHeight * rate;
// draw
context.clearRect(0, 0, rateWidth, rateHeight);
context.beginPath();
context.moveTo(0, rateHeight);
context.quadraticCurveTo(rateWidth * 11 / 20, rateHeight - ((ratey / 2) * (1 - expo)), rateWidth, rateHeight - ratey);
context.lineWidth = 2;
context.strokeStyle = '#ffbb00';
context.stroke();
}
}
// UI Hooks
// curves
$('.pid_tuning').on('input change', function () {
setTimeout(function () { // let global validation trigger and adjust the values first
var rateElement = $('.pid_tuning input[name="rc_rate"]'),
expoElement = $('.pid_tuning input[name="rc_expo"]'),
yawExpoElement = $('.pid_tuning input[name="rc_yaw_expo"]'),
rcCurveElement = $('.pitch_roll_curve canvas').get(0),
rcYawCurveElement = $('.yaw_curve canvas').get(0);
drawRateCurve(rateElement, expoElement, rcCurveElement);
drawRateCurve(rateElement, yawExpoElement, rcYawCurveElement);
}, 0);
}).trigger('input');
$('a.refresh').click(function () {
GUI.tab_switch_cleanup(function () {
@ -410,4 +472,4 @@ TABS.pid_tuning.cleanup = function (callback) {
if (callback) {
callback();
}
};
};

View file

@ -156,15 +156,6 @@
margin-bottom: 10px;
}
.tab-receiver .tunings .rate {
margin-bottom: 10px;
}
.tab-receiver .tunings .yaw_rate {
margin-left: 0px;
margin-bottom: 10px;
}
.tab-receiver .tunings table, .tab-receiver .tunings table th, .tab-receiver .tunings table td {
padding: 4px;
text-align: left;
@ -319,17 +310,6 @@
background-position: center;
}
.tab-receiver .pitch_roll_curve {
margin: 0 0px 0px 0;
width: 200px;
height: 117px;
border: 1px solid silver;
border-radius: 3px;
background-image: url(../images/paper.jpg);
background-size: 200%;
background-position: center;
}
.tab-receiver select[name="rx_refresh_rate"] {
float: right;
border: 1px solid silver;
@ -437,4 +417,4 @@
stroke: none;
fill: #828885;
font-size: 10px;
}
}

View file

@ -71,35 +71,6 @@
</div>
</div>
</div>
<div class="gui_box grey" style="float: right;">
<div class="spacer" style="margin-top: 10px; margin-bottom: 10px;">
<div class="cf_column curves" style="width: calc(50% - 10px);">
<div class="pitch_roll_curve">
<canvas width="200" height="117"></canvas>
</div>
</div>
<div class="fc_column half tunings">
<table class="rate">
<tr>
<th i18n="receiverRcRate"></th>
<th i18n="receiverRcExpo"></th>
</tr>
<tr>
<td><input type="number" name="rate" step="0.01" min="0" max="2.5" /></td>
<td><input type="number" name="expo" step="0.01" min="0" max="1" /></td>
</tr>
</table>
<table class="yaw_rate" style="margin-bottom: 0px;">
<tr>
<th i18n="receiverRcYawExpo"></th>
</tr>
<tr>
<td><input type="number" name="yaw_expo" step="0.01" min="0" max="1" /></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="clear-both"></div>
<div class="gui_box grey" style="padding-top: 10px; padding-bottom: 10px; margin-top: 20px;">

View file

@ -51,14 +51,6 @@ TABS.receiver.initialize = function (callback) {
$('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2));
$('.tunings .throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2));
$('.tunings .rate input[name="rate"]').val(RC_tuning.RC_RATE.toFixed(2));
$('.tunings .rate input[name="expo"]').val(RC_tuning.RC_EXPO.toFixed(2));
$('.tunings .yaw_rate input[name="yaw_expo"]').val(RC_tuning.RC_YAW_EXPO.toFixed(2));
if (semver.lt(CONFIG.apiVersion, "1.10.0")) {
$('.tunings .yaw_rate input[name="yaw_expo"]').hide();
}
chrome.storage.local.get('rx_refresh_rate', function (result) {
if (result.rx_refresh_rate) {
$('select[name="rx_refresh_rate"]').val(result.rx_refresh_rate).change();
@ -248,39 +240,6 @@ TABS.receiver.initialize = function (callback) {
}, 0);
}).trigger('input');
$('.tunings .rate input').on('input change', function () {
setTimeout(function () { // let global validation trigger and adjust the values first
var rateE = $('.tunings .rate input[name="rate"]'),
expoE = $('.tunings .rate input[name="expo"]'),
rate = parseFloat(rateE.val()),
expo = parseFloat(expoE.val()),
pitch_roll_curve = $('.pitch_roll_curve canvas').get(0),
context = pitch_roll_curve.getContext("2d");
// local validation to deal with input event
if (rate >= parseFloat(rateE.prop('min')) &&
rate <= parseFloat(rateE.prop('max')) &&
expo >= parseFloat(expoE.prop('min')) &&
expo <= parseFloat(expoE.prop('max'))) {
// continue
} else {
return;
}
// math magic by englishman
var ratey = rateHeight * rate;
// draw
context.clearRect(0, 0, 200, rateHeight);
context.beginPath();
context.moveTo(0, rateHeight);
context.quadraticCurveTo(110, rateHeight - ((ratey / 2) * (1 - expo)), 200, rateHeight - ratey);
context.lineWidth = 2;
context.strokeStyle = '#ffbb00';
context.stroke();
}, 0);
}).trigger('input');
$('a.refresh').click(function () {
MSP.send_message(MSP_codes.MSP_RC_TUNING, false, false, function () {
GUI.log(chrome.i18n.getMessage('receiverDataRefreshed'));
@ -289,12 +248,8 @@ TABS.receiver.initialize = function (callback) {
$('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2));
$('.tunings .throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2));
$('.tunings .rate input[name="rate"]').val(RC_tuning.RC_RATE.toFixed(2));
$('.tunings .rate input[name="expo"]').val(RC_tuning.RC_EXPO.toFixed(2));
// update visual representation
$('.tunings .throttle input').change();
$('.tunings .rate input').change();
});
});
@ -303,10 +258,6 @@ TABS.receiver.initialize = function (callback) {
RC_tuning.throttle_MID = parseFloat($('.tunings .throttle input[name="mid"]').val());
RC_tuning.throttle_EXPO = parseFloat($('.tunings .throttle input[name="expo"]').val());
RC_tuning.RC_RATE = parseFloat($('.tunings .rate input[name="rate"]').val());
RC_tuning.RC_EXPO = parseFloat($('.tunings .rate input[name="expo"]').val());
RC_tuning.RC_YAW_EXPO = parseFloat($('.tunings .yaw_rate input[name="yaw_expo"]').val());
if (semver.gte(CONFIG.apiVersion, "1.15.0")) {
RC_deadband.yaw_deadband = parseInt($('.deadband input[name="yaw_deadband"]').val());
RC_deadband.deadband = parseInt($('.deadband input[name="deadband"]').val());