diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 892a8af2..4bcb6746 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -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" }, diff --git a/tabs/pid_tuning.css b/tabs/pid_tuning.css index 3b5a147d..0eb5af4a 100644 --- a/tabs/pid_tuning.css +++ b/tabs/pid_tuning.css @@ -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; -} \ No newline at end of file +} diff --git a/tabs/pid_tuning.html b/tabs/pid_tuning.html index 3d695d83..07da7a63 100755 --- a/tabs/pid_tuning.html +++ b/tabs/pid_tuning.html @@ -25,7 +25,7 @@
-
+
@@ -33,11 +33,14 @@ + + +
- @@ -47,6 +50,11 @@ + + + + + @@ -54,6 +62,7 @@ + @@ -61,6 +70,18 @@ + + + +
+
+
+
+ + + + + +
@@ -153,41 +174,60 @@
-
+
- +
- - - - - - - - - - - - - - + + + + + + + +
+
+
+ +
+
+
- + +
+
+ + + + + + + + + + +
+
+
+ +
+
+
+
+
+ - + - +
diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index 111cac3e..d5d206d4 100755 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -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(); } -}; \ No newline at end of file +}; diff --git a/tabs/receiver.css b/tabs/receiver.css index df26f132..ed4c83b1 100644 --- a/tabs/receiver.css +++ b/tabs/receiver.css @@ -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; -} \ No newline at end of file +} diff --git a/tabs/receiver.html b/tabs/receiver.html index c5843b9c..05b756ac 100644 --- a/tabs/receiver.html +++ b/tabs/receiver.html @@ -71,35 +71,6 @@
-
-
-
-
- -
-
-
- - - - - - - - - -
- - - - - - - -
-
-
-
diff --git a/tabs/receiver.js b/tabs/receiver.js index ea10ec6c..846a0c76 100644 --- a/tabs/receiver.js +++ b/tabs/receiver.js @@ -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());