diff --git a/locales/en/messages.json b/locales/en/messages.json index a68ac53b..6885bc36 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1358,6 +1358,18 @@ "configurationCalculatedCyclesSec": { "message": "Cycles/Sec [Hz]" }, + "configurationSpeedGyroNoGyro": { + "message": "No gyro", + "description": "When no gyro is configured this appears in place of the speed of the gyro in kHz" + }, + "configurationSpeedPidNoGyro": { + "message": "Gyro / {{value}}", + "description": "When no gyro is configured this appears in place of the speed of the PID in kHz. Try to keep it short." + }, + "configurationKHzUnitLabel": { + "message": "{{value}} kHz", + "description": "Value for some options that show the speed of gyro, pid, etc. in kHz" + }, "configurationLoopTimeHelp": { "message": "Note: Make sure your FC is able to operate at these speeds! Check CPU and cycletime stability. Changing this may require PID re-tuning. TIP: Disable Accelerometer and other sensors to gain more performance." }, diff --git a/src/css/tabs/configuration.css b/src/css/tabs/configuration.css index 9b2b85a8..6a6a899c 100644 --- a/src/css/tabs/configuration.css +++ b/src/css/tabs/configuration.css @@ -432,10 +432,18 @@ width: 100%; } -.tab-configuration .gyroSyncDenom, .tab-configuration .pidProcessDenom { +.tab-configuration .gyroSyncDenom, .tab-configuration .pidProcessDenom, .tab-configuration .gyroFrequency { width:90px; } +.tab-configuration .gyroFrequency { + border: none; + background-color: var(--alternativeBackground); + padding-left: 6px; + margin-right: 10px; + font-weight: bold; +} + .tab-configuration ._3dSettings { margin-top: 10px; float: left; diff --git a/src/js/fc.js b/src/js/fc.js index 4c854a09..2544ad8c 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -104,6 +104,7 @@ var FC = { signature: [], mcuTypeId: 255, configurationState: 0, + sampleRateHz: 0, }; BF_CONFIG = { diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 6d501a90..de5c0382 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -800,6 +800,11 @@ MspHelper.prototype.process_data = function(dataHandler) { if (semver.gte(CONFIG.apiVersion, "1.42.0")) { CONFIG.configurationState = data.readU8(); + + if (semver.gte(CONFIG.apiVersion, "1.43.0")) { + CONFIG.sampleRateHz = data.readU16(); + } + } } else { CONFIG.mcuTypeId = 255; diff --git a/src/js/tabs/configuration.js b/src/js/tabs/configuration.js index cbacd1ff..2f5356c9 100644 --- a/src/js/tabs/configuration.js +++ b/src/js/tabs/configuration.js @@ -557,97 +557,106 @@ TABS.configuration.initialize = function (callback, scrollPosition) { }).change(); // Gyro and PID update - var gyroUse32kHz_e = $('input[id="gyroUse32kHz"]'); - var gyro_select_e = $('select.gyroSyncDenom'); - var pid_select_e = $('select.pidProcessDenom'); + const gyroUse32kHzElement = $('input[id="gyroUse32kHz"]'); + const gyroTextElement = $('input.gyroFrequency'); + const gyroSelectElement = $('select.gyroSyncDenom'); + const pidSelectElement = $('select.pidProcessDenom'); - function addDenomOption(element, denom, baseFreq) { - element.append(''); + function addDenomOption(element, denom, baseFreq) { + let denomDescription; + if (baseFreq === 0) { + denomDescription = i18n.getMessage('configurationSpeedPidNoGyro', {'value' : denom}); + } else { + denomDescription = i18n.getMessage('configurationKHzUnitLabel', { 'value' : (baseFreq / denom).toFixed(2)}); + } + element.append(``); } - var updateGyroDenom = function (gyroBaseFreq) { - var originalGyroDenom = gyro_select_e.val(); + const updateGyroDenom = function (gyroBaseFreq) { - gyro_select_e.empty(); + gyroTextElement.hide(); - var denom = 1; - while (denom <= 8) { - addDenomOption(gyro_select_e, denom, gyroBaseFreq); - denom ++; + const originalGyroDenom = gyroSelectElement.val(); + + gyroSelectElement.empty(); + + const MAX_DENOM = semver.gte(CONFIG.apiVersion, "1.25.0") ? 32 : 8; + for (let denom = 1; denom <= MAX_DENOM; denom++) { + addDenomOption(gyroSelectElement, denom, gyroBaseFreq); } - if (semver.gte(CONFIG.apiVersion, "1.25.0")) { - while (denom <= 32) { - addDenomOption(gyro_select_e, denom, gyroBaseFreq); + gyroSelectElement.val(originalGyroDenom); - denom ++; - } - } + gyroSelectElement.change(); + }; - gyro_select_e.val(originalGyroDenom); + const updateGyroDenomReadOnly = function (gyroFrequency) { + gyroSelectElement.hide(); - gyro_select_e.change(); - }; + let gyroContent; + if (gyroFrequency === 0) { + gyroContent = i18n.getMessage('configurationSpeedGyroNoGyro'); + } else { + gyroContent = i18n.getMessage('configurationKHzUnitLabel', { 'value' : (gyroFrequency / 1000).toFixed(2)}); + } + gyroTextElement.val(gyroContent); + }; - if (semver.gte(CONFIG.apiVersion, "1.25.0") && semver.lt(CONFIG.apiVersion, "1.41.0")) { - gyroUse32kHz_e.prop('checked', PID_ADVANCED_CONFIG.gyroUse32kHz !== 0); + if (semver.gte(CONFIG.apiVersion, "1.25.0") && semver.lt(CONFIG.apiVersion, "1.41.0")) { + gyroUse32kHzElement.prop('checked', PID_ADVANCED_CONFIG.gyroUse32kHz !== 0); - gyroUse32kHz_e.change(function () { - var gyroBaseFreq; - if ($(this).is(':checked')) { - gyroBaseFreq = 32; - } else { - gyroBaseFreq = 8; - } + gyroUse32kHzElement.change(function () { + const gyroBaseFreq = ($(this).is(':checked'))? 32 : 8; - updateGyroDenom(gyroBaseFreq); - }).change(); - } else { - $('div.gyroUse32kHz').hide(); + updateGyroDenom(gyroBaseFreq); + }).change(); + + } else { + + $('div.gyroUse32kHz').hide(); + + if (semver.gte(CONFIG.apiVersion, "1.43.0")) { + updateGyroDenomReadOnly(CONFIG.sampleRateHz); + } else { + updateGyroDenom(8); + } + + gyroSelectElement.val(PID_ADVANCED_CONFIG.gyro_sync_denom); - updateGyroDenom(8); } - if (semver.gte(CONFIG.apiVersion, "1.41.0")) { $('.systemconfigNote').html(i18n.getMessage('configurationLoopTimeNo32KhzHelp')); } else { $('.systemconfigNote').html(i18n.getMessage('configurationLoopTimeHelp')); } - gyro_select_e.val(PID_ADVANCED_CONFIG.gyro_sync_denom); + gyroSelectElement.change(function () { + const originalPidDenom = pidSelectElement.val(); - gyro_select_e.change(function () { - var originalPidDenom = pid_select_e.val(); - - var pidBaseFreq = 8; - if (semver.gte(CONFIG.apiVersion, "1.25.0") && semver.lt(CONFIG.apiVersion, "1.41.0") && gyroUse32kHz_e.is(':checked')) { - pidBaseFreq = 32; - } - - pidBaseFreq = pidBaseFreq / parseInt($(this).val()); - - pid_select_e.empty(); - - var denom = 1; - - while (denom <= 8) { - addDenomOption(pid_select_e, denom, pidBaseFreq); - denom ++; - } - - if (semver.gte(CONFIG.apiVersion, "1.24.0")) { - while (denom <= 16) { - addDenomOption(pid_select_e, denom, pidBaseFreq); - - denom ++; + let pidBaseFreq; + if (semver.gte(CONFIG.apiVersion, "1.43.0")) { + pidBaseFreq = CONFIG.sampleRateHz / 1000; + } else { + pidBaseFreq = 8; + if (semver.gte(CONFIG.apiVersion, "1.25.0") && semver.lt(CONFIG.apiVersion, "1.41.0") && gyroUse32kHzElement.is(':checked')) { + pidBaseFreq = 32; } + pidBaseFreq = pidBaseFreq / parseInt($(this).val()); } - pid_select_e.val(originalPidDenom); + pidSelectElement.empty(); + + const MAX_DENOM = semver.gte(CONFIG.apiVersion, "1.24.0") ? 16 : 8; + + for (let denom = 1; denom <= MAX_DENOM; denom++) { + addDenomOption(pidSelectElement, denom, pidBaseFreq); + } + + pidSelectElement.val(originalPidDenom); }).change(); - pid_select_e.val(PID_ADVANCED_CONFIG.pid_process_denom); + pidSelectElement.val(PID_ADVANCED_CONFIG.pid_process_denom); $('input[id="accHardwareSwitch"]').prop('checked', SENSOR_CONFIG.acc_hardware !== 1); $('input[id="baroHardwareSwitch"]').prop('checked', SENSOR_CONFIG.baro_hardware !== 1); @@ -1194,8 +1203,8 @@ TABS.configuration.initialize = function (callback, scrollPosition) { PID_ADVANCED_CONFIG.fast_pwm_protocol = parseInt(esc_protocol_e.val()-1); PID_ADVANCED_CONFIG.use_unsyncedPwm = $('input[id="unsyncedPWMSwitch"]').is(':checked') ? 1 : 0; PID_ADVANCED_CONFIG.motor_pwm_rate = parseInt($('input[name="unsyncedpwmfreq"]').val()); - PID_ADVANCED_CONFIG.gyro_sync_denom = parseInt(gyro_select_e.val()); - PID_ADVANCED_CONFIG.pid_process_denom = parseInt(pid_select_e.val()); + PID_ADVANCED_CONFIG.gyro_sync_denom = parseInt(gyroSelectElement.val()); + PID_ADVANCED_CONFIG.pid_process_denom = parseInt(pidSelectElement.val()); PID_ADVANCED_CONFIG.digitalIdlePercent = parseFloat($('input[name="digitalIdlePercent"]').val()); if (semver.gte(CONFIG.apiVersion, "1.25.0") && semver.lt(CONFIG.apiVersion, "1.41.0")) { PID_ADVANCED_CONFIG.gyroUse32kHz = $('input[id="gyroUse32kHz"]').is(':checked') ? 1 : 0; diff --git a/src/js/tabs/onboard_logging.js b/src/js/tabs/onboard_logging.js index 59b64fa1..c67245af 100644 --- a/src/js/tabs/onboard_logging.js +++ b/src/js/tabs/onboard_logging.js @@ -192,16 +192,22 @@ TABS.onboard_logging.initialize = function (callback) { function populateLoggingRates(loggingRatesSelect) { // Offer a reasonable choice of logging rates (if people want weird steps they can use CLI) - var loggingRates = []; - var pidRateBase = 8000; + let loggingRates = []; - if (semver.gte(CONFIG.apiVersion, "1.25.0") && semver.lt(CONFIG.apiVersion, "1.41.0") && PID_ADVANCED_CONFIG.gyroUse32kHz !== 0) { - pidRateBase = 32000; + let pidRate; + if (semver.gte(CONFIG.apiVersion, "1.43.0")) { + pidRate = CONFIG.sampleRateHz / PID_ADVANCED_CONFIG.pid_process_denom; + + } else { + + let pidRateBase = 8000; + + if (semver.gte(CONFIG.apiVersion, "1.25.0") && semver.lt(CONFIG.apiVersion, "1.41.0") && PID_ADVANCED_CONFIG.gyroUse32kHz !== 0) { + pidRateBase = 32000; + } + pidRate = pidRateBase / PID_ADVANCED_CONFIG.gyro_sync_denom / PID_ADVANCED_CONFIG.pid_process_denom; } - var pidRate = pidRateBase / PID_ADVANCED_CONFIG.gyro_sync_denom / - PID_ADVANCED_CONFIG.pid_process_denom; - if (semver.gte(CONFIG.apiVersion, "1.36.0")) { loggingRates = [ {text: "Disabled", hz: 0, p_denom: 0}, diff --git a/src/tabs/configuration.html b/src/tabs/configuration.html index 84bf247b..ca33ff7b 100644 --- a/src/tabs/configuration.html +++ b/src/tabs/configuration.html @@ -60,6 +60,7 @@
+