Merge pull request #2097 from fgiudice98/blackbox-sample-rate

10.8-maintenance
Michael Keller 2020-07-05 14:49:17 +12:00 committed by GitHub
commit f1110534dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 6 deletions

View File

@ -342,6 +342,7 @@ var FC = {
blackboxRateNum: 1,
blackboxRateDenom: 1,
blackboxPDenom: 0,
blackboxSampleRate: 0,
};
TRANSPONDER = {

View File

@ -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:

View File

@ -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(`<option value="${i}">1/${2**i} (${loggingFrequency}${loggingFrequencyUnit})</option>`);
}
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('<option value="' + loggingRates[i].num + '/' + loggingRates[i].denom + '">'
@ -330,7 +344,7 @@ TABS.onboard_logging.initialize = function (callback) {
{text: "FF_INTERPOLATED"},
];
for (var i = 0; i < PID_ADVANCED_CONFIG.debugModeCount; i++) {
for (let i = 0; i < PID_ADVANCED_CONFIG.debugModeCount; i++) {
if (i < debugModes.length) {
debugModeSelect.append(new Option(debugModes[i].text, i));
} else {