diff --git a/src/js/fc.js b/src/js/fc.js index d0cc3151..b65117f2 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -342,6 +342,7 @@ var FC = { blackboxRateNum: 1, blackboxRateDenom: 1, blackboxPDenom: 0, + blackboxSampleRate: 0, }; TRANSPONDER = { diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 3872c6b4..b3e82b77 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -1353,7 +1353,9 @@ MspHelper.prototype.process_data = function(dataHandler) { BLACKBOX.blackboxRateDenom = data.readU8(); if (semver.gte(CONFIG.apiVersion, "1.36.0")) { BLACKBOX.blackboxPDenom = data.readU16(); - + } + if (semver.gte(CONFIG.apiVersion, API_VERSION_1_44)) { + BLACKBOX.blackboxSampleRate = data.readU8(); } break; case MSPCodes.MSP_SET_BLACKBOX_CONFIG: @@ -2135,6 +2137,9 @@ MspHelper.prototype.crunch = function(code) { if (semver.gte(CONFIG.apiVersion, "1.36.0")) { buffer.push16(BLACKBOX.blackboxPDenom); } + if (semver.gte(CONFIG.apiVersion, API_VERSION_1_44)) { + buffer.push8(BLACKBOX.blackboxSampleRate); + } break; case MSPCodes.MSP_COPY_PROFILE: diff --git a/src/js/tabs/onboard_logging.js b/src/js/tabs/onboard_logging.js index 534aff6a..61ebaea4 100644 --- a/src/js/tabs/onboard_logging.js +++ b/src/js/tabs/onboard_logging.js @@ -104,7 +104,9 @@ TABS.onboard_logging.initialize = function (callback) { if (BLACKBOX.supported) { $(".tab-onboard_logging a.save-settings").click(function() { - if (semver.gte(CONFIG.apiVersion, "1.36.0")) { + if (semver.gte(CONFIG.apiVersion, API_VERSION_1_44)) { + BLACKBOX.blackboxSampleRate = parseInt(loggingRatesSelect.val(), 10); + } else if (semver.gte(CONFIG.apiVersion, "1.36.0")) { BLACKBOX.blackboxPDenom = parseInt(loggingRatesSelect.val(), 10); } else { var rate = loggingRatesSelect.val().split('/'); @@ -208,7 +210,19 @@ TABS.onboard_logging.initialize = function (callback) { pidRate = pidRateBase / PID_ADVANCED_CONFIG.gyro_sync_denom / PID_ADVANCED_CONFIG.pid_process_denom; } - if (semver.gte(CONFIG.apiVersion, "1.36.0")) { + if (semver.gte(CONFIG.apiVersion, API_VERSION_1_44)) { + const sampleRateNum=5; + for (let i = 0; i < sampleRateNum; i++) { + let loggingFrequency = Math.round(pidRate / (2**i)); + let loggingFrequencyUnit = "Hz"; + if (gcd(loggingFrequency, 1000) === 1000) { + loggingFrequency /= 1000; + loggingFrequencyUnit = "kHz"; + } + loggingRatesSelect.append(``); + } + loggingRatesSelect.val(BLACKBOX.blackboxSampleRate); + } else if (semver.gte(CONFIG.apiVersion, "1.36.0")) { loggingRates = [ {text: "Disabled", hz: 0, p_denom: 0}, {text: "500 Hz", hz: 500, p_denom: 16}, @@ -244,13 +258,13 @@ TABS.onboard_logging.initialize = function (callback) { ]; - for (var i = 0; i < loggingRates.length; i++) { + for (let i = 0; i < loggingRates.length; i++) { var loggingRate = Math.round(pidRate / loggingRates[i].denom); var loggingRateUnit = " Hz"; if (loggingRate !== Infinity) { if (gcd(loggingRate, 1000) === 1000) { loggingRate /= 1000; - loggingRateUnit = " KHz"; + loggingRateUnit = " kHz"; } } loggingRatesSelect.append('