Merge pull request #2097 from fgiudice98/blackbox-sample-rate
commit
f1110534dd
|
@ -342,6 +342,7 @@ var FC = {
|
||||||
blackboxRateNum: 1,
|
blackboxRateNum: 1,
|
||||||
blackboxRateDenom: 1,
|
blackboxRateDenom: 1,
|
||||||
blackboxPDenom: 0,
|
blackboxPDenom: 0,
|
||||||
|
blackboxSampleRate: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
TRANSPONDER = {
|
TRANSPONDER = {
|
||||||
|
|
|
@ -1353,7 +1353,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
||||||
BLACKBOX.blackboxRateDenom = data.readU8();
|
BLACKBOX.blackboxRateDenom = data.readU8();
|
||||||
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
|
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
|
||||||
BLACKBOX.blackboxPDenom = data.readU16();
|
BLACKBOX.blackboxPDenom = data.readU16();
|
||||||
|
}
|
||||||
|
if (semver.gte(CONFIG.apiVersion, API_VERSION_1_44)) {
|
||||||
|
BLACKBOX.blackboxSampleRate = data.readU8();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MSPCodes.MSP_SET_BLACKBOX_CONFIG:
|
case MSPCodes.MSP_SET_BLACKBOX_CONFIG:
|
||||||
|
@ -2135,6 +2137,9 @@ MspHelper.prototype.crunch = function(code) {
|
||||||
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
|
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
|
||||||
buffer.push16(BLACKBOX.blackboxPDenom);
|
buffer.push16(BLACKBOX.blackboxPDenom);
|
||||||
}
|
}
|
||||||
|
if (semver.gte(CONFIG.apiVersion, API_VERSION_1_44)) {
|
||||||
|
buffer.push8(BLACKBOX.blackboxSampleRate);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSPCodes.MSP_COPY_PROFILE:
|
case MSPCodes.MSP_COPY_PROFILE:
|
||||||
|
|
|
@ -104,7 +104,9 @@ TABS.onboard_logging.initialize = function (callback) {
|
||||||
|
|
||||||
if (BLACKBOX.supported) {
|
if (BLACKBOX.supported) {
|
||||||
$(".tab-onboard_logging a.save-settings").click(function() {
|
$(".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);
|
BLACKBOX.blackboxPDenom = parseInt(loggingRatesSelect.val(), 10);
|
||||||
} else {
|
} else {
|
||||||
var rate = loggingRatesSelect.val().split('/');
|
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;
|
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 = [
|
loggingRates = [
|
||||||
{text: "Disabled", hz: 0, p_denom: 0},
|
{text: "Disabled", hz: 0, p_denom: 0},
|
||||||
{text: "500 Hz", hz: 500, p_denom: 16},
|
{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 loggingRate = Math.round(pidRate / loggingRates[i].denom);
|
||||||
var loggingRateUnit = " Hz";
|
var loggingRateUnit = " Hz";
|
||||||
if (loggingRate !== Infinity) {
|
if (loggingRate !== Infinity) {
|
||||||
if (gcd(loggingRate, 1000) === 1000) {
|
if (gcd(loggingRate, 1000) === 1000) {
|
||||||
loggingRate /= 1000;
|
loggingRate /= 1000;
|
||||||
loggingRateUnit = " KHz";
|
loggingRateUnit = " kHz";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loggingRatesSelect.append('<option value="' + loggingRates[i].num + '/' + loggingRates[i].denom + '">'
|
loggingRatesSelect.append('<option value="' + loggingRates[i].num + '/' + loggingRates[i].denom + '">'
|
||||||
|
@ -330,7 +344,7 @@ TABS.onboard_logging.initialize = function (callback) {
|
||||||
{text: "FF_INTERPOLATED"},
|
{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) {
|
if (i < debugModes.length) {
|
||||||
debugModeSelect.append(new Option(debugModes[i].text, i));
|
debugModeSelect.append(new Option(debugModes[i].text, i));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue