Skip to content

Commit

Permalink
Merge branch 'master' into min_max_chart_settings
Browse files Browse the repository at this point in the history
  • Loading branch information
demvlad authored Mar 6, 2024
2 parents f31b740 + 4d98eef commit a6e9c06
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 86 deletions.
56 changes: 29 additions & 27 deletions js/flightlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function FlightLog(logData) {
} else
return false;
};

function buildFieldNames() {
// Make an independent copy
fieldNames = parser.frameDefs.I.name.slice(0);
Expand Down Expand Up @@ -239,7 +239,7 @@ function FlightLog(logData) {
if (!that.isFieldDisabled().SETPOINT) {
fieldNames.push("rcCommands[0]", "rcCommands[1]", "rcCommands[2]", "rcCommands[3]"); // Custom calculated scaled rccommand
}
if (!(that.isFieldDisabled().GYRO || that.isFieldDisabled().PID)) {
if (!that.isFieldDisabled().GYRO && !that.isFieldDisabled().PID) {
fieldNames.push("axisError[0]", "axisError[1]", "axisError[2]"); // Custom calculated error field
}

Expand Down Expand Up @@ -385,8 +385,8 @@ function FlightLog(logData) {
destFrame,
destFrame_currentIndex;

// The G frames need to be processed always. They are "invalid" if not H (Home) has been detected
// before, but if not processed the viewer shows cuts and gaps. This happens if the quad takes off before
// The G frames need to be processed always. They are "invalid" if not H (Home) has been detected
// before, but if not processed the viewer shows cuts and gaps. This happens if the quad takes off before
// fixing enough satellites.
if (frameValid || (frameType == 'G' && frame)) {
switch (frameType) {
Expand Down Expand Up @@ -419,7 +419,7 @@ function FlightLog(logData) {
destFrame[slowFrameIndex + destFrame_currentIndex] = lastSlow[slowFrameIndex] === undefined ? null : lastSlow[slowFrameIndex];
}
destFrame_currentIndex += slowFrameLength;

// Also merge last seen gps-frame data
for (let gpsFrameIndex = 0; gpsFrameIndex < lastGPSLength; gpsFrameIndex++) {
destFrame[gpsFrameIndex + destFrame_currentIndex] = lastGPS[gpsFrameIndex] === undefined ? null : lastGPS[gpsFrameIndex];
Expand Down Expand Up @@ -617,7 +617,7 @@ function FlightLog(logData) {
destFrame = destChunk.frames[i],
fieldIndex = destFrame.length - ADDITIONAL_COMPUTED_FIELD_COUNT;

if (gyroADC) { //don't calculate attitude if no gyro data
if (!that.isFieldDisabled().GYRO) { //don't calculate attitude if no gyro data
attitude = chunkIMU.updateEstimatedAttitude(
[srcFrame[gyroADC[0]], srcFrame[gyroADC[1]], srcFrame[gyroADC[2]]],
[srcFrame[accSmooth[0]], srcFrame[accSmooth[1]], srcFrame[accSmooth[2]]],
Expand All @@ -632,7 +632,7 @@ function FlightLog(logData) {
}

// Add the Feedforward PID sum (P+I+D+F)
if (axisPID) {
if (!that.isFieldDisabled().GYRO && !that.isFieldDisabled().PID) {
for (var axis = 0; axis < 3; axis++) {
let pidSum =
(axisPID[axis][0] !== undefined ? srcFrame[axisPID[axis][0]] : 0) +
Expand All @@ -647,7 +647,7 @@ function FlightLog(logData) {
}

// Assign value
destFrame[fieldIndex++] = pidSum;
destFrame[fieldIndex++] = pidSum;
}
}

Expand All @@ -657,29 +657,31 @@ function FlightLog(logData) {
// Calculate the Scaled rcCommand (setpoint) (in deg/s, % for throttle)
var fieldIndexRcCommands = fieldIndex;

// Since version 4.0 is not more a virtual field. Copy the real field to the virtual one to maintain the name, workspaces, etc.
if (sysConfig.firmwareType == FIRMWARE_TYPE_BETAFLIGHT && semver.gte(sysConfig.firmwareVersion, '4.0.0')) {
// Roll, pitch and yaw
for (var axis = 0; axis <= AXIS.YAW; axis++) {
destFrame[fieldIndex++] = srcFrame[setpoint[axis]];
}
// Throttle
destFrame[fieldIndex++] = srcFrame[setpoint[AXIS.YAW + 1]]/10;
if (!that.isFieldDisabled().SETPOINT) {

// Versions earlier to 4.0 we must calculate the expected setpoint
} else {
// Roll, pitch and yaw
for (var axis = 0; axis <= AXIS.YAW; axis++) {
// Since version 4.0 is not more a virtual field. Copy the real field to the virtual one to maintain the name, workspaces, etc.
if (sysConfig.firmwareType == FIRMWARE_TYPE_BETAFLIGHT && semver.gte(sysConfig.firmwareVersion, '4.0.0')) {
// Roll, pitch and yaw
for (let axis = 0; axis <= AXIS.YAW; axis++) {
destFrame[fieldIndex++] = srcFrame[setpoint[axis]];
}
// Throttle
destFrame[fieldIndex++] = srcFrame[setpoint[AXIS.YAW + 1]]/10;

// Versions earlier to 4.0 we must calculate the expected setpoint
} else {
// Roll, pitch and yaw
for (let axis = 0; axis <= AXIS.YAW; axis++) {
destFrame[fieldIndex++] = rcCommand[axis] !== undefined ? that.rcCommandRawToDegreesPerSecond(srcFrame[rcCommand[axis]], axis, currentFlightMode) : 0;
}
// Throttle
destFrame[fieldIndex++] =
(rcCommand[axis] !== undefined ? that.rcCommandRawToDegreesPerSecond(srcFrame[rcCommand[axis]], axis, currentFlightMode) : 0);
}
// Throttle
destFrame[fieldIndex++] =
(rcCommand[AXIS.YAW + 1] !== undefined ? that.rcCommandRawToThrottle(srcFrame[rcCommand[AXIS.YAW + 1]]) : 0);
(rcCommand[AXIS.YAW + 1] !== undefined ? that.rcCommandRawToThrottle(srcFrame[rcCommand[AXIS.YAW + 1]]) : 0);
}
}

// Calculate the PID Error
if (axisPID && gyroADC) {
if (!that.isFieldDisabled().GYRO && !that.isFieldDisabled().PID) {
for (var axis = 0; axis < 3; axis++) {
let gyroADCdegrees = (gyroADC[axis] !== undefined ? that.gyroRawToDegreesPerSecond(srcFrame[gyroADC[axis]]) : 0);
destFrame[fieldIndex++] = destFrame[fieldIndexRcCommands + axis] - gyroADCdegrees;
Expand Down Expand Up @@ -1131,7 +1133,7 @@ FlightLog.prototype.rcCommandRawToDegreesPerSecond = function(value, axis, curre
}

var rcRate = sysConfig["rc_rates"][axis] / 100.0;
if (rcRate > 2.0) {
if (rcRate > 2.0) {
rcRate += RC_RATE_INCREMENTAL * (rcRate - 2.0);
}

Expand Down
4 changes: 3 additions & 1 deletion js/flightlog_fields_presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ function FlightLogFieldPresenter() {
'debug[4]':'Minimum Gyro period in 100th of a us',
'debug[5]':'Maximum Gyro period in 100th of a us',
'debug[6]':'Span of Gyro period in 100th of a us',
'debug[7]':'Not Used',
'debug[7]':'Gyro cycle deviation in 100th of a us',
},
'TIMING_ACCURACY' : {
'debug[all]':'Timing Accuracy',
Expand Down Expand Up @@ -1897,6 +1897,8 @@ function FlightLogFieldPresenter() {
return value.toFixed(0);
case 'DSHOT_TELEMETRY_COUNTS':
return value.toFixed(0);
case 'EZLANDING':
return `${(value / 100.0).toFixed(2)} %`;
}
return value.toFixed(0);
}
Expand Down
7 changes: 7 additions & 0 deletions js/graph_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,13 @@ TODO - The stats data have small issues of min-max data !!!!
default:
return getCurveForMinMaxFields(fieldName);
}
case 'EZLANDING':
return {
offset: -5000,
power: 1.0,
inputRange: 5000,
outputRange: 1.0,
};
}
}
// if not found above then
Expand Down
55 changes: 27 additions & 28 deletions js/graph_config_dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ function GraphConfigurationDialog(dialog, onSave) {
prevCfg = null,
cfgMustBeRestored = false;


function chooseColor(currentSelection) {
const selectColor = $('<select class="color-picker"></select>');
for(let i=0; i<GraphConfig.PALETTE.length; i++) {
Expand Down Expand Up @@ -70,7 +69,7 @@ function GraphConfigurationDialog(dialog, onSave) {
}

function renderFieldOption(fieldName, selectedName) {
var
var
option = $("<option></option>")
.text(FlightLogFieldPresenter.fieldNameToFriendly(fieldName, activeFlightLog.getSysConfig().debug_mode))
.attr("value", fieldName);
Expand Down Expand Up @@ -108,12 +107,12 @@ function GraphConfigurationDialog(dialog, onSave) {
}
}

/**
/*
* Render the element for the "pick a field" dropdown box. Provide "field" from the config in order to set up the
* initial selection.
*/
function renderField(flightLog, field, color) {
var
var
elem = $(
'<tr class="config-graph-field">'
+ '<td><select class="form-control"><option value="">(choose a field)</option></select></td>'
Expand Down Expand Up @@ -146,7 +145,7 @@ function GraphConfigurationDialog(dialog, onSave) {

//Populate the Color Picker
$('select.color-picker', elem).replaceWith(chooseColor(color));


// Add event when selection changed to retrieve the current smoothing settings.
$('select.form-control', elem).change( function() {
Expand Down Expand Up @@ -764,7 +763,7 @@ function GraphConfigurationDialog(dialog, onSave) {
}

function renderGraph(flightLog, index, graph) {
var
var
graphElem = $(
'<li class="config-graph" id="'+index+'">'
+ '<dl>'
Expand Down Expand Up @@ -844,11 +843,11 @@ function GraphConfigurationDialog(dialog, onSave) {
});

//Populate the Height seletor
$('select.graph-height', graphElem).replaceWith(chooseHeight(graph.height?(graph.height):1));
$('select.graph-height', graphElem).replaceWith(chooseHeight(graph.height?(graph.height):1));

// Add Field List
for (var i = 0; i < graph.fields.length; i++) {
var
var
field = graph.fields[i],
fieldElem = renderField(flightLog, field, field.color?(field.color):(GraphConfig.PALETTE[i].color));

Expand All @@ -858,9 +857,9 @@ function GraphConfigurationDialog(dialog, onSave) {
fieldList.on('click', 'button', function(e) {
var
parentGraph = $(this).parents('.config-graph');

$(this).parents('.config-graph-field').remove();

// Remove the graph upon removal of the last field
if ($(".config-graph-field", parentGraph).length === 0) {
parentGraph.remove();
Expand All @@ -874,7 +873,7 @@ function GraphConfigurationDialog(dialog, onSave) {

return graphElem;
}

function renderGraphs(flightLog, graphs) {
var
graphList = $(".config-graphs-list", dialog);
Expand All @@ -889,7 +888,7 @@ function GraphConfigurationDialog(dialog, onSave) {
function populateExampleGraphs(flightLog, menu) {
var
i;

menu.empty();

exampleGraphs = GraphConfig.getExampleGraphConfigs(flightLog);
Expand All @@ -899,26 +898,26 @@ function GraphConfigurationDialog(dialog, onSave) {
fields: [{name:""}],
dividerAfter: true
});

for (i = 0; i < exampleGraphs.length; i++) {
var
var
graph = exampleGraphs[i],
li = $('<li><a href="#"></a></li>');

$('a', li)
.text(graph.label)
.data('graphIndex', i);

menu.append(li);

if (graph.dividerAfter) {
menu.append('<li class="divider"></li>');
}
}
}

function convertUIToGraphConfig() {
var
var
graphs = [],
graph,
field;
Expand Down Expand Up @@ -983,7 +982,7 @@ function GraphConfigurationDialog(dialog, onSave) {

for (i = 0; i < fieldNames.length; i++) {
// For fields with multiple bracketed x[0], x[1] versions, add an "[all]" option
var
var
fieldName = fieldNames[i],
matches = fieldName.match(/^(.+)\[[0-9]+\]$/);

Expand All @@ -993,7 +992,7 @@ function GraphConfigurationDialog(dialog, onSave) {
if (matches) {
if (matches[1] != lastRoot) {
lastRoot = matches[1];

offeredFieldNames.push(lastRoot + "[all]");
fieldsSeen[lastRoot + "[all]"] = true;
}
Expand All @@ -1011,13 +1010,13 @@ function GraphConfigurationDialog(dialog, onSave) {
* keep that tail servo in the config when we're viewing a quadcopter).
*/
for (i = 0; i < config.length; i++) {
var
var
graph = config[i];

for (j = 0; j < graph.fields.length; j++) {
var
var
field = graph.fields[j];

if (!fieldsSeen[field.name]) {
offeredFieldNames.push(field.name);
}
Expand All @@ -1043,7 +1042,7 @@ function GraphConfigurationDialog(dialog, onSave) {
if (cfgMustBeRestored)
onSave(prevCfg);
});

$(".graph-configuration-dialog-save").click(function() {
cfgMustBeRestored = false;
onSave(convertUIToGraphConfig());
Expand Down Expand Up @@ -1075,16 +1074,16 @@ function GraphConfigurationDialog(dialog, onSave) {

exampleGraphsButton.dropdown();
exampleGraphsMenu.on("click", "a", function(e) {
var
var
graph = exampleGraphs[$(this).data("graphIndex")],
graphElem = renderGraph(activeFlightLog, $(".config-graph", dialog).length, graph);

$(configGraphsList, dialog).append(graphElem);
updateRemoveAllButton();

// Dismiss the dropdown button
exampleGraphsButton.dropdown("toggle");

e.preventDefault();
});

Expand Down
Loading

0 comments on commit a6e9c06

Please sign in to comment.