Skip to content

Commit 30880a8

Browse files
authored
Merge pull request #560 from daleckystepan/bb-resolution
Blackbox increase resolution on setpoint, gyro and rounding
2 parents 399d104 + f143fb9 commit 30880a8

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

js/flightlog_fielddefs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ var
213213
"SRXL",
214214
"CUSTOM",
215215
"FPORT",
216+
"SRXL2",
217+
"GHST"
216218
]),
217219

218220
ANTI_GRAVITY_MODE = makeReadOnly([

js/flightlog_fields_presenter.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -776,14 +776,17 @@ function FlightLogFieldPresenter() {
776776
return "";
777777
}
778778

779+
const highResolutionScale = (flightLog && flightLog.getSysConfig().blackbox_high_resolution > 0) ? 10 : 1;
780+
const highResolutionAddPrecision = (flightLog && flightLog.getSysConfig().blackbox_high_resolution > 0) ? 1 : 0;
781+
779782
switch (fieldName) {
780783
case 'time':
781784
return formatTime(value / 1000, true);
782785

783786
case 'gyroADC[0]':
784787
case 'gyroADC[1]':
785788
case 'gyroADC[2]':
786-
return Math.round(flightLog.gyroRawToDegreesPerSecond(value)) + " deg/s";
789+
return flightLog.gyroRawToDegreesPerSecond(value / highResolutionScale).toFixed(highResolutionAddPrecision) + " deg/s";
787790

788791
case 'gyroADCs[0]':
789792
case 'gyroADCs[1]':
@@ -793,14 +796,14 @@ function FlightLogFieldPresenter() {
793796
case 'axisError[0]':
794797
case 'axisError[1]':
795798
case 'axisError[2]':
796-
return Math.round(value) + " deg/s";
799+
return (value / highResolutionScale).toFixed(highResolutionAddPrecision) + " deg/s";
797800

798801
case 'rcCommand[0]':
799802
case 'rcCommand[1]':
800803
case 'rcCommand[2]':
801-
return (value + 1500).toFixed(0) + " us";
804+
return (value / highResolutionScale + 1500).toFixed(highResolutionAddPrecision) + " us";
802805
case 'rcCommand[3]':
803-
return value.toFixed(0) + " us";
806+
return (value / highResolutionScale).toFixed(highResolutionAddPrecision) + " us";
804807

805808
case 'motor[0]':
806809
case 'motor[1]':
@@ -825,7 +828,7 @@ function FlightLogFieldPresenter() {
825828
case 'rcCommands[0]':
826829
case 'rcCommands[1]':
827830
case 'rcCommands[2]':
828-
return value.toFixed(0) + " deg/s";
831+
return (value / highResolutionScale).toFixed(highResolutionAddPrecision) + " deg/s";
829832
case 'rcCommands[3]':
830833
return value.toFixed(1) + "%";
831834

@@ -849,7 +852,7 @@ function FlightLogFieldPresenter() {
849852
case 'accSmooth[0]':
850853
case 'accSmooth[1]':
851854
case 'accSmooth[2]':
852-
return flightLog.accRawToGs(value).toFixed(2) + "g";
855+
return flightLog.accRawToGs(value).toFixed(2 + highResolutionAddPrecision) + "g";
853856

854857
case 'vbatLatest':
855858
if(flightLog.getSysConfig().firmwareType == FIRMWARE_TYPE_BETAFLIGHT && semver.gte(flightLog.getSysConfig().firmwareVersion, '4.0.0')) {
@@ -926,7 +929,7 @@ function FlightLogFieldPresenter() {
926929
case 'debug[0]':
927930
return value.toFixed(0);
928931
default:
929-
return (value/10).toFixed(1) + "V";
932+
return (value / 10).toFixed(1) + "V";
930933
}
931934
case 'ACCELEROMETER':
932935
return flightLog.accRawToGs(value).toFixed(2) + "g";

js/flightlog_parser.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ var FlightLogParser = function(logData) {
204204
anti_gravity_gain:null, // Anti gravity gain
205205
anti_gravity_mode:null, // Anti gravity mode
206206
anti_gravity_threshold:null, // Anti gravity threshold for step mode
207+
blackbox_high_resolution:null, // Blackbox high resolution mode
207208
thrMid:null, // Throttle Mid Position
208209
thrExpo:null, // Throttle Expo
209210
tpa_breakpoint:null, // TPA Breakpoint
@@ -737,6 +738,8 @@ var FlightLogParser = function(logData) {
737738
case "throttle_boost_cutoff":
738739

739740
case "motor_poles":
741+
742+
case "blackbox_high_resolution":
740743
that.sysConfig[fieldName] = parseInt(fieldValue, 10);
741744
break;
742745
case "rc_expo":

js/graph_config.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ GraphConfig.load = function(config) {
257257
}
258258

259259
const gyroScaleMargin = 1.20; // Give a 20% margin for gyro graphs
260+
const highResolutionScale = sysConfig.blackbox_high_resolution > 0 ? 10 : 1;
260261

261262
try {
262263
if (fieldName.match(/^motor\[/)) {
@@ -302,7 +303,7 @@ GraphConfig.load = function(config) {
302303
return {
303304
offset: 0,
304305
power: 0.25, /* Make this 1.0 to scale linearly */
305-
inputRange: maxDegreesSecond(gyroScaleMargin), // Maximum grad/s + 20%
306+
inputRange: maxDegreesSecond(gyroScaleMargin * highResolutionScale), // Maximum grad/s + 20%
306307
outputRange: 1.0
307308
};
308309
} else if (fieldName.match(/^axis.+\[/)) {
@@ -314,16 +315,16 @@ GraphConfig.load = function(config) {
314315
};
315316
} else if (fieldName == "rcCommand[3]") { // Throttle
316317
return {
317-
offset: -1500,
318+
offset: -1500 * highResolutionScale,
318319
power: 1.0,
319-
inputRange: 500,
320+
inputRange: 500 * highResolutionScale,
320321
outputRange: 1.0
321322
};
322323
} else if (fieldName.match(/^rcCommand\[/)) {
323324
return {
324325
offset: 0,
325326
power: 0.25,
326-
inputRange: 500 * gyroScaleMargin, // +20% to let compare in the same scale with the rccommands
327+
inputRange: 500 * highResolutionScale * gyroScaleMargin, // +20% to let compare in the same scale with the rccommands
327328
outputRange: 1.0
328329
};
329330
} else if (fieldName == "heading[2]") {
@@ -771,7 +772,7 @@ GraphConfig.load = function(config) {
771772
EXAMPLE_GRAPHS.push({label: "Gyros",fields: ["gyroADC[all]"]});
772773
}
773774
if (!flightLog.isFieldDisabled().SETPOINT) {
774-
EXAMPLE_GRAPHS.push({label: "RC Rates",fields: ["rcCommands[all]"]});
775+
EXAMPLE_GRAPHS.push({label: "Setpoint",fields: ["rcCommands[all]"]});
775776
}
776777
if (!flightLog.isFieldDisabled().RC_COMMANDS) {
777778
EXAMPLE_GRAPHS.push({label: "RC Command",fields: ["rcCommand[all]"]});

js/sticks.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,14 @@ function FlightLogSticks(flightLog, rcCommandFields, canvas) {
195195
stickIndex,
196196
rcCommand = [], rcCommandLabels = [];
197197

198+
const highResolutionScale = flightLog.getSysConfig().blackbox_high_resolution > 0 ? 10 : 1;
199+
198200
for (stickIndex = 0; stickIndex < 4; stickIndex++) {
199201
//Check that stick data is present to be drawn:
200202
if (rcCommandFields[stickIndex] === undefined)
201203
return;
202204

203-
rcCommand[stickIndex] = frame[rcCommandFields[stickIndex]];
205+
rcCommand[stickIndex] = frame[rcCommandFields[stickIndex]] / highResolutionScale;
204206
if (stickLabel != null) {
205207
rcCommandLabels[stickIndex] = (rcCommand[stickIndex] * ((stickIndex == 2) ? -1 : 1)) + ""; // correct the value for Yaw being inverted
206208
if (userSettings.stickUnits != null) {

0 commit comments

Comments
 (0)