Skip to content

Commit

Permalink
Add debug modes to blackbox tab
Browse files Browse the repository at this point in the history
  • Loading branch information
IvoFPV committed Aug 8, 2019
1 parent 3eb39d7 commit 39e7845
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 2 deletions.
3 changes: 3 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4819,6 +4819,9 @@
"onboardLoggingRateOfLogging": {
"message": "Blackbox logging rate"
},
"onboardLoggingDebugMode": {
"message": "Blackbox debug mode"
},
"onboardLoggingSerialLogger": {
"message": "Outboard serial logging device"
},
Expand Down
1 change: 1 addition & 0 deletions src/css/tabs-dark/onboard_logging-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
}

.tab-onboard_logging .blackboxRate select,
.tab-onboard_logging .blackboxDebugMode select,
.tab-onboard_logging .blackboxDevice select {
border: 1px solid #9c9c9c;
background-color: #3a3a3a;
Expand Down
2 changes: 2 additions & 0 deletions src/css/tabs/onboard_logging.css
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@
clear: left;
}
.tab-onboard_logging .blackboxRate select,
.tab-onboard_logging .blackboxDebugMode select,
.tab-onboard_logging .blackboxDevice select {
float: left;
width: 180px;
Expand All @@ -300,6 +301,7 @@
border: 1px solid silver;
}
.tab-onboard_logging .blackboxRate span,
.tab-onboard_logging .blackboxDebugMode span,
.tab-onboard_logging .blackboxDevice span {
line-height: 20px;
}
Expand Down
1 change: 1 addition & 0 deletions src/js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ var FC = {
blackboxRateNum: 1,
blackboxRateDenom: 1,
blackboxPDenom: 0,
blackboxDebugMode: 0,
};

TRANSPONDER = {
Expand Down
8 changes: 8 additions & 0 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,10 @@ 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, "1.42.0")) {
BLACKBOX.blackboxDebugMode = data.readU8();
}
}
break;
case MSPCodes.MSP_SET_BLACKBOX_CONFIG:
Expand Down Expand Up @@ -1832,6 +1836,10 @@ MspHelper.prototype.crunch = function(code) {
.push8(BLACKBOX.blackboxRateDenom);
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
buffer.push16(BLACKBOX.blackboxPDenom);

if (semver.gte(CONFIG.apiVersion, "1.42.0")) {
buffer.push8(BLACKBOX.blackboxDebugMode);
}
}
break;

Expand Down
86 changes: 84 additions & 2 deletions src/js/tabs/onboard_logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ TABS.onboard_logging.initialize = function (callback) {

var deviceSelect = $(".blackboxDevice select");
var loggingRatesSelect = $(".blackboxRate select");
var debugModeSelect = $(".blackboxDebugMode select");

if (BLACKBOX.supported) {
$(".tab-onboard_logging a.save-settings").click(function() {
Expand All @@ -110,15 +111,17 @@ TABS.onboard_logging.initialize = function (callback) {
BLACKBOX.blackboxRateNum = parseInt(rate[0], 10);
BLACKBOX.blackboxRateDenom = parseInt(rate[1], 10);
}

BLACKBOX.blackboxDevice = parseInt(deviceSelect.val(), 10);

if (semver.gte(CONFIG.apiVersion, "1.42.0")) {
BLACKBOX.blackboxDebugMode = parseInt(debugModeSelect.val());
}
MSP.send_message(MSPCodes.MSP_SET_BLACKBOX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BLACKBOX_CONFIG), false, save_to_eeprom);
});
}

populateLoggingRates(loggingRatesSelect);
populateDevices(deviceSelect);
populateDebugModes(debugModeSelect);

deviceSelect.change(function() {
if ($(this).val() === "0") {
Expand Down Expand Up @@ -250,6 +253,85 @@ TABS.onboard_logging.initialize = function (callback) {
loggingRatesSelect.val(BLACKBOX.blackboxRateNum + '/' + BLACKBOX.blackboxRateDenom);
}
}

function populateDebugModes(debugModeSelect) {
var debugModes = [];

if (semver.gte(CONFIG.apiVersion, "1.42.0")) {
$('.blackboxDebugMode').show();

debugModes = [
{text: "NONE"},
{text: "CYCLETIME"},
{text: "BATTERY"},
{text: "GYRO_FILTERED"},
{text: "ACCELEROMETER"},
{text: "PIDLOOP"},
{text: "GYRO_SCALED"},
{text: "RC_INTERPOLATION"},
{text: "ANGLERATE"},
{text: "ESC_SENSOR"},
{text: "SCHEDULER"},
{text: "STACK"},
{text: "ESC_SENSOR_RPM"},
{text: "ESC_SENSOR_TMP"},
{text: "ALTITUDE"},
{text: "FFT"},
{text: "FFT_TIME"},
{text: "FFT_FREQ"},
{text: "RX_FRSKY_SPI"},
{text: "RX_SFHSS_SPI"},
{text: "GYRO_RAW"},
{text: "DUAL_GYRO"},
{text: "DUAL_GYRO_RAW"},
{text: "DUAL_GYRO_COMBINE"},
{text: "DUAL_GYRO_DIFF"},
{text: "MAX7456_SIGNAL"},
{text: "MAX7456_SPICLOCK"},
{text: "SBUS"},
{text: "FPORT"},
{text: "RANGEFINDER"},
{text: "RANGEFINDER_QUALITY"},
{text: "LIDAR_TF"},
{text: "ADC_INTERNAL"},
{text: "RUNAWAY_TAKEOFF"},
{text: "SDIO"},
{text: "CURRENT_SENSOR"},
{text: "USB"},
{text: "SMARTAUDIO"},
{text: "RTH"},
{text: "ITERM_RELAX"},
{text: "ACRO_TRAINER"},
{text: "RC_SMOOTHING"},
{text: "RX_SIGNAL_LOSS"},
{text: "RC_SMOOTHING_RATE"},
{text: "ANTI_GRAVITY"},
{text: "DYN_LPF"},
{text: "RX_SPEKTRUM_SPI"},
{text: "DSHOT_RPM_TELEMETRY"},
{text: "RPM_FILTER"},
{text: "D_MIN"},
{text: "AC_CORRECTION"},
{text: "AC_ERROR"},
{text: "DUAL_GYRO_SCALED"},
{text: "DSHOT_RPM_ERRORS"},
{text: "CRSF_LINK_STATISTICS_UPLINK"},
{text: "CRSF_LINK_STATISTICS_PWR"},
{text: "CRSF_LINK_STATISTICS_DOWN"},
{text: "BARO"},
{text: "GPS_RESCUE_THROTTLE_PID"},
{text: "DYN_IDLE"},
];

$.each(debugModes, function(index, item) {
debugModeSelect.append(new Option(item.text, index));
});

debugModeSelect.val(BLACKBOX.blackboxDebugMode);
} else {
$('.blackboxDebugMode').hide();
}
}

function formatFilesizeKilobytes(kilobytes) {
if (kilobytes < 1024) {
Expand Down
5 changes: 5 additions & 0 deletions src/tabs/onboard_logging.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
</select>
<span i18n="onboardLoggingRateOfLogging"></span>
</div>
<div class="line blackboxDebugMode">
<select name="blackboxDebugMode">
</select>
<span i18n="onboardLoggingDebugMode"></span>
</div>
<div class="line">
<a href="#" class="save-settings regular-button" i18n="blackboxButtonSave"></a>
</div>
Expand Down

0 comments on commit 39e7845

Please sign in to comment.