Select blackbox debug fields (#3363)
parent
6abcce226f
commit
7fbb0597a3
|
@ -6376,6 +6376,9 @@
|
|||
"onboardLoggingRateOfLogging": {
|
||||
"message": "Blackbox logging rate"
|
||||
},
|
||||
"onboardLoggingDebugFields": {
|
||||
"message": "Blackbox debug fields"
|
||||
},
|
||||
"onboardLoggingDebugMode": {
|
||||
"message": "Blackbox debug mode"
|
||||
},
|
||||
|
|
|
@ -177,6 +177,28 @@
|
|||
line-height: 20px;
|
||||
}
|
||||
}
|
||||
.blackboxDebugFields {
|
||||
margin-top: 5px;
|
||||
select {
|
||||
float: left;
|
||||
width: 180px;
|
||||
height: 20px;
|
||||
margin: 0 10px 5px 0;
|
||||
border: 1px solid var(--subtleAccent);
|
||||
border-radius: 3px;
|
||||
}
|
||||
span {
|
||||
&:last-child {
|
||||
margin-left: 7px;
|
||||
}
|
||||
line-height: 20px;
|
||||
}
|
||||
}
|
||||
.ms-choice {
|
||||
background-color: var(--boxBackground) !important;
|
||||
color: var(--defaultText) !important;
|
||||
height: 20px;
|
||||
}
|
||||
.blackboxDebugMode {
|
||||
select {
|
||||
float: left;
|
||||
|
|
|
@ -399,6 +399,7 @@ const FC = {
|
|||
blackboxRateDenom: 1,
|
||||
blackboxPDenom: 0,
|
||||
blackboxSampleRate: 0,
|
||||
blackboxDisabledMask: 0,
|
||||
};
|
||||
|
||||
this.TRANSPONDER = {
|
||||
|
|
|
@ -1294,6 +1294,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
|
||||
FC.BLACKBOX.blackboxSampleRate = data.readU8();
|
||||
}
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
||||
FC.BLACKBOX.blackboxDisabledMask = data.readU32();
|
||||
}
|
||||
break;
|
||||
case MSPCodes.MSP_SET_BLACKBOX_CONFIG:
|
||||
console.log("Blackbox config saved");
|
||||
|
@ -2069,6 +2072,10 @@ MspHelper.prototype.crunch = function(code, modifierCode = undefined) {
|
|||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
|
||||
buffer.push8(FC.BLACKBOX.blackboxSampleRate);
|
||||
}
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
||||
buffer.push32(FC.BLACKBOX.blackboxDisabledMask);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP_COPY_PROFILE:
|
||||
|
|
|
@ -115,25 +115,41 @@ onboard_logging.initialize = function (callback) {
|
|||
const deviceSelect = $(".blackboxDevice select");
|
||||
const loggingRatesSelect = $(".blackboxRate select");
|
||||
const debugModeSelect = $(".blackboxDebugMode select");
|
||||
const debugFieldsSelect = $(".blackboxDebugFields select");
|
||||
|
||||
if (FC.BLACKBOX.supported) {
|
||||
$(".tab-onboard_logging a.save-settings").click(function() {
|
||||
$(".tab-onboard_logging a.save-settings").on('click', async function() {
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
||||
let fieldsMask = 0;
|
||||
|
||||
$(".blackboxDebugFields select option:not(:selected)").each(function() {
|
||||
fieldsMask |= (1 << $(this).val());
|
||||
});
|
||||
|
||||
FC.BLACKBOX.blackboxDisabledMask = fieldsMask;
|
||||
}
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
|
||||
FC.BLACKBOX.blackboxSampleRate = parseInt(loggingRatesSelect.val(), 10);
|
||||
FC.BLACKBOX.blackboxPDenom = parseInt(loggingRatesSelect.val(), 10);
|
||||
}
|
||||
FC.BLACKBOX.blackboxDevice = parseInt(deviceSelect.val(), 10);
|
||||
|
||||
await MSP.promise(MSPCodes.MSP_SET_BLACKBOX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BLACKBOX_CONFIG));
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
|
||||
FC.PID_ADVANCED_CONFIG.debugMode = parseInt(debugModeSelect.val());
|
||||
MSP.send_message(MSPCodes.MSP_SET_ADVANCED_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ADVANCED_CONFIG), false, save_to_eeprom);
|
||||
|
||||
await MSP.promise(MSPCodes.MSP_SET_ADVANCED_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ADVANCED_CONFIG));
|
||||
}
|
||||
MSP.send_message(MSPCodes.MSP_SET_BLACKBOX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BLACKBOX_CONFIG), false, save_to_eeprom);
|
||||
|
||||
save_to_eeprom();
|
||||
});
|
||||
}
|
||||
|
||||
populateLoggingRates(loggingRatesSelect);
|
||||
populateDevices(deviceSelect);
|
||||
populateDebugModes(debugModeSelect);
|
||||
populateDebugFields(debugFieldsSelect);
|
||||
|
||||
deviceSelect.change(function() {
|
||||
if ($(this).val() === "0") {
|
||||
|
@ -354,6 +370,39 @@ onboard_logging.initialize = function (callback) {
|
|||
}
|
||||
}
|
||||
|
||||
function populateDebugFields(debugFieldsSelect) {
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
||||
$('.blackboxDebugFields').show();
|
||||
|
||||
const debugFields = [
|
||||
{ text: "PID Data" },
|
||||
{ text: "RC Commands Data" },
|
||||
{ text: "Setpoint Data" },
|
||||
{ text: "Battery Data" },
|
||||
{ text: "Magnetometer Data" },
|
||||
{ text: "Altitude Data" },
|
||||
{ text: "RSSI Data" },
|
||||
{ text: "Gyro Data" },
|
||||
{ text: "Accelerometer Data" },
|
||||
{ text: "Debug Log Data" },
|
||||
{ text: "Motor Data" },
|
||||
{ text: "GPS Data" },
|
||||
];
|
||||
|
||||
let fieldsMask = FC.BLACKBOX.blackboxDisabledMask;
|
||||
|
||||
for (let i = 0; i < debugFields.length; i++) {
|
||||
const enabled = (fieldsMask & (1 << i)) === 0;
|
||||
debugFieldsSelect.append(new Option(debugFields[i].text, i, false, enabled));
|
||||
}
|
||||
|
||||
debugFieldsSelect.sortSelect().multipleSelect();
|
||||
|
||||
} else {
|
||||
$('.blackboxDebugFields').hide();
|
||||
}
|
||||
}
|
||||
|
||||
function formatFilesizeKilobytes(kilobytes) {
|
||||
if (kilobytes < 1024) {
|
||||
return `${Math.round(kilobytes)}kB`;
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
</select>
|
||||
<span class="blackboxDebugModeText" i18n="onboardLoggingDebugMode"></span>
|
||||
</div>
|
||||
<div class="line blackboxDebugFields">
|
||||
<select name="blackboxDebugFields" multiple="multiple"></select>
|
||||
<span i18n="onboardLoggingDebugFields"></span>
|
||||
</div>
|
||||
<div class="line">
|
||||
<a href="#" class="save-settings regular-button" i18n="blackboxButtonSave"></a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue