From 16c5f9feb5d6649647e1d460a2c313ab472c9b4b Mon Sep 17 00:00:00 2001 From: Miguel Angel Mulero Martinez Date: Mon, 23 Jul 2018 11:50:47 +0200 Subject: [PATCH] Add Anti Gravity Mode --- locales/en/messages.json | 11 +++++++++++ src/js/fc.js | 1 + src/js/msp/MSPHelper.js | 4 +++- src/js/tabs/pid_tuning.js | 21 +++++++++++++++++++++ src/tabs/pid_tuning.html | 15 +++++++++++++-- 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 354db4f4..d02e6509 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1242,6 +1242,17 @@ "message": "Profile independent PID Controller Settings" }, + "pidTuningAntiGravityMode": { + "message": "Anti Gravity Mode" + }, + "pidTuningAntiGravityModeOptionSmooth": { + "message": "Smooth", + "description": "One of the modes of anti gravity" + }, + "pidTuningAntiGravityModeOptionStep": { + "message": "Step", + "description": "One of the modes of anti gravity" + }, "pidTuningAntiGravityGain": { "message": "Anti Gravity Gain" }, diff --git a/src/js/fc.js b/src/js/fc.js index 084ea1b9..a3cd969c 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -380,6 +380,7 @@ var FC = { feedforwardPitch: 0, feedforwardYaw: 0, feedforwardTransition: 0, + antiGravityMode: 0, }; SENSOR_CONFIG = { diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 5f046469..59b1ccea 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -911,6 +911,7 @@ MspHelper.prototype.process_data = function(dataHandler) { ADVANCED_TUNING.feedforwardRoll = data.readU16(); ADVANCED_TUNING.feedforwardPitch = data.readU16(); ADVANCED_TUNING.feedforwardYaw = data.readU16(); + ADVANCED_TUNING.antiGravityMode = data.readU8(); } } } @@ -1585,7 +1586,8 @@ MspHelper.prototype.crunch = function(code) { .push8(ADVANCED_TUNING.acroTrainerAngleLimit) .push16(ADVANCED_TUNING.feedforwardRoll) .push16(ADVANCED_TUNING.feedforwardPitch) - .push16(ADVANCED_TUNING.feedforwardYaw); + .push16(ADVANCED_TUNING.feedforwardYaw) + .push8(ADVANCED_TUNING.antiGravityMode); } } } diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index 2a033c21..a278ddef 100755 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -391,6 +391,22 @@ TABS.pid_tuning.initialize = function (callback) { feedforwardTransitionNumberElement.val($(this).val()); }); + // AntiGravity Mode + var antiGravityModeSelect = $('.antigravity select[id="antiGravityMode"]'); + antiGravityModeSelect.change(function () { + var antiGravityModeValue = $('.antigravity select[id="antiGravityMode"]').val(); + + // Smooth + if (antiGravityModeValue == 0) { + $('.antigravity table th:nth-child(3)').hide(); + $('.antigravity table td:nth-child(3)').hide(); + } else { + $('.antigravity table th:nth-child(3)').show(); + $('.antigravity table td:nth-child(3)').show(); + } + }); + + antiGravityModeSelect.val(ADVANCED_TUNING.antiGravityMode).change(); } else { $('.itermrotation').hide(); @@ -407,6 +423,9 @@ TABS.pid_tuning.initialize = function (callback) { $('#pid_main .pid_titlebar2 th').attr("colspan", 8); $('#pid-tuning .feedforwardTransition').hide(); + + $('.antigravity table th:first-child').hide(); + $('.antigravity table td:first-child').hide(); } $('input[id="gyroNotch1Enabled"]').change(function() { @@ -657,6 +676,8 @@ TABS.pid_tuning.initialize = function (callback) { ADVANCED_TUNING.feedforwardYaw = parseInt($('.pid_tuning .YAW input[name="f"]').val()); ADVANCED_TUNING.feedforwardTransition = parseInt($('input[name="feedforwardTransition-number"]').val() * 100); + + ADVANCED_TUNING.antiGravityMode = $('select[id="antiGravityMode"]').val(); } } diff --git a/src/tabs/pid_tuning.html b/src/tabs/pid_tuning.html index db58cb63..2c51edb3 100755 --- a/src/tabs/pid_tuning.html +++ b/src/tabs/pid_tuning.html @@ -455,14 +455,25 @@ + - - + + +
+ + + + + +