From df2db988d570927bfde4da09459afcc2da2997b2 Mon Sep 17 00:00:00 2001 From: Asizon <43983086+Asizon@users.noreply.github.com> Date: Sun, 27 Oct 2019 16:33:30 +0100 Subject: [PATCH] HideMotorPoles Suggested changes Doblewhitespace --- src/js/tabs/configuration.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/js/tabs/configuration.js b/src/js/tabs/configuration.js index 1cbf2a80..563ff204 100644 --- a/src/js/tabs/configuration.js +++ b/src/js/tabs/configuration.js @@ -516,6 +516,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) { $('input[name="motorPoles"]').val(MOTOR_CONFIG.motor_poles); } + function hideMotorPoles() { + let motorPolesVisible = $("input[id='dshotBidir']").is(':checked') || $("input[name='ESC_SENSOR']").is(':checked'); + $('div.motorPoles').toggle(motorPolesVisible); + } + $('#escProtocolTooltip').toggle(semver.lt(CONFIG.apiVersion, "1.42.0")); $('#escProtocolTooltipNoDSHOT1200').toggle(semver.gte(CONFIG.apiVersion, "1.42.0")); @@ -542,13 +547,15 @@ TABS.configuration.initialize = function (callback, scrollPosition) { $('div.checkboxDshotBidir').toggle(semver.gte(CONFIG.apiVersion, "1.42.0") && digitalProtocol); $('div.motorPoles').toggle(semver.gte(CONFIG.apiVersion, "1.42.0")); + //trigger change dshotBidir and ESC_SENSOR to show/hide Motor Poles tab + $("input[id='dshotBidir']").change(hideMotorPoles).change(); + $("input[name='ESC_SENSOR']").change(hideMotorPoles); //trigger change unsyncedPWMSwitch to show/hide Motor PWM freq input $("input[id='unsyncedPWMSwitch']").change(); }).change(); - // Gyro and PID update var gyroUse32kHz_e = $('input[id="gyroUse32kHz"]'); var gyro_select_e = $('select.gyroSyncDenom');