Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RPM Debug with common scaling #277

Merged
merged 1 commit into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions js/flightlog_fields_presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,20 @@ function FlightLogFieldPresenter() {
'debug[2]':'Gyro Raw [Z]',
'debug[3]':'Not Used',
},
'ESC_SENSOR_RPM' : {
'debug[all]':'ESC RPM',
'debug[0]':'ESC RPM [1]',
'debug[1]':'ESC RPM [2]',
'debug[2]':'ESC RPM [3]',
'debug[3]':'ESC RPM [4]',
},
'DSHOT_RPM_TELEMETRY' : {
'debug[all]':'DSHOT RPM',
'debug[0]':'DSHOT RPM [1]',
'debug[1]':'DSHOT RPM [2]',
'debug[2]':'DSHOT RPM [3]',
'debug[3]':'DSHOT RPM [4]',
},
};

function presentFlags(flags, flagNames) {
Expand Down
65 changes: 44 additions & 21 deletions js/graph_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,45 @@ GraphConfig.load = function(config) {
flightLog.rcCommandRawToDegreesPerSecond(500,1) * scale,
flightLog.rcCommandRawToDegreesPerSecond(500,2) * scale);
}

var getCurveForMinMaxFields = function(fieldNames) {
// helper to make a curve scale based on the combined min/max of one or more fields

var
stats = flightLog.getStats(),
min = Number.MAX_VALUE,
max = Number.MIN_VALUE;

if(typeof(fieldNames) == 'string')
fieldNames = [fieldNames];

for(var i in fieldNames) {
var
fieldIndex = flightLog.getMainFieldIndexByName(fieldNames[i]),
fieldStat = fieldIndex !== undefined ? stats.field[fieldIndex] : false;

if (fieldStat) {
min = Math.min(min, fieldStat.min);
max = Math.max(max, fieldStat.max);
}
}

if (min != Number.MAX_VALUE && max != Number.MIN_VALUE) {
return {
offset: -(max + min) / 2,
power: 1.0,
inputRange: Math.max((max - min) / 2, 1.0),
outputRange: 1.0
};
} else {
return {
offset: 0,
power: 1.0,
inputRange: 500,
outputRange: 1.0
};
}
}

const gyroScaleMargin = 1.20; // Give a 20% margin for gyro graphs

Expand Down Expand Up @@ -447,31 +486,15 @@ GraphConfig.load = function(config) {
power: 1.0,
inputRange: 100,
outputRange: 1.0
};
};
case 'ESC_SENSOR_RPM':
case 'DSHOT_RPM_TELEMETRY':
return getCurveForMinMaxFields(['debug[0]', 'debug[1]', 'debug[2]', 'debug[3]']);
}
}
// if not found above then
// Scale and center the field based on the whole-log observed ranges for that field
var
stats = flightLog.getStats(),
fieldIndex = flightLog.getMainFieldIndexByName(fieldName),
fieldStat = fieldIndex !== undefined ? stats.field[fieldIndex] : false;

if (fieldStat) {
return {
offset: -(fieldStat.max + fieldStat.min) / 2,
power: 1.0,
inputRange: Math.max((fieldStat.max - fieldStat.min) / 2, 1.0),
outputRange: 1.0
};
} else {
return {
offset: 0,
power: 1.0,
inputRange: 500,
outputRange: 1.0
};
}
return getCurveForMinMaxFields(fieldName);
} catch(e) {
return {
offset: 0,
Expand Down