Skip to content

Commit

Permalink
Merge branch 'Legend-Values'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Keeble committed Apr 24, 2016
2 parents eb1fab7 + 89e2cbd commit 3bef086
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 41 deletions.
16 changes: 13 additions & 3 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ html, body {
/* Add an extended wide size to the page container for large monitors */
@media (min-width: 1400px) {
.container.main-pane {
width:1320px;
width:90%;
}
}

Expand Down Expand Up @@ -231,6 +231,11 @@ html.has-log .log-graph-config {
top:0;
left:0;
pointer-events:none; /* Allow the user to drag the graph lines instead of hitting the craft */
display:none;
}

html.has-craft #craftCanvas {
display:block;
}

.log-graph video {
Expand Down Expand Up @@ -259,6 +264,11 @@ html.has-log .log-graph-config {
padding-bottom:0.1em;
margin-bottom:0.3em;
cursor:pointer;
text-align: right;
}

.graph-legend-field > span {
margin-left: 0.7em;
}

html.has-video .graph-row,
Expand Down Expand Up @@ -323,8 +333,8 @@ html.has-marker .graph-time-marker-group > .graph-time-marker {
.log-metadata, .log-field-values {
display:none;
}
html.has-log .log-metadata,
html.has-log .log-field-values {
html.has-log:not(.is-fullscreen) .log-metadata,
html.has-log:not(.is-fullscreen).has-table .log-field-values {
display:block;
}

Expand Down
16 changes: 16 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,22 @@ <h3 class="log-filename"></h3>
</div>

<ul class="video-top-controls list-unstyled">
<li class="log-view-panel">
<h4>View</h4>
<div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default view-craft" title="View/hide craft display">
<span class="glyphicon glyphicon-plane"></span>
</button>
<button type="button" class="btn btn-default view-sticks" title="View/hide stick display">
<span class="glyphicon glyphicon-pawn"></span>
</button>
<button type="button" class="btn btn-default view-table" title="View/hide statistics display">
<span class="glyphicon glyphicon-list-alt"></span>
</button>
</div>
</div>
</li>
<li class="log-playback-panel">
<h4>Playback</h4>
<div>
Expand Down
14 changes: 5 additions & 9 deletions js/flightlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,22 +913,18 @@ FlightLog.prototype.rcCommandRawToDegreesPerSecond = function(value, axis) {
// Axis 0,1 refers to Roll and Pitch
// Axis 2 refers to Yaw.

// ReWrite or LUXFloat only


// if(axis==2 /*YAW*/) {
// return ((this.settings[0].parameters[axis].value + 47) * value ) >> 7;
// } else { /*ROLL or PITCH */
// return ((this.settings[0].parameters[axis].value + 27) * value ) >> 6;
// }

if(axis==2 /*YAW*/) {
return ((this.getSysConfig().yRate + 47) * value ) >> 7;
} else { /*ROLL or PITCH */
return ((((axis==0)?this.getSysConfig().rRate:this.getSysConfig().pRate) + 27) * value ) >> 6;
}
};

FlightLog.prototype.rcCommandRawToThrottle = function(value) {
// Throttle displayed as percentage
return ((value - this.getSysConfig().minthrottle) / (this.getSysConfig().maxthrottle - this.getSysConfig().minthrottle)) * 100.0;
};

FlightLog.prototype.getReferenceVoltageMillivolts = function() {
return this.vbatADCToMillivolts(this.getSysConfig().vbatref);
};
Expand Down
13 changes: 13 additions & 0 deletions js/flightlog_fields_presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ function FlightLogFieldPresenter() {
case 'gyroADC[2]':
return Math.round(flightLog.gyroRawToDegreesPerSecond(value)) + " deg/s";

case 'gyroADCs[0]':
case 'gyroADCs[1]':
case 'gyroADCs[2]':
return value.toFixed(0) + " deg/s";

case 'axisError[0]':
case 'axisError[1]':
case 'axisError[2]':
Expand All @@ -150,6 +155,14 @@ function FlightLogFieldPresenter() {
case 'rcCommand[2]':
return Math.round(flightLog.rcCommandRawToDegreesPerSecond(value,2)) + " deg/s";

case 'rcCommand[3]':
return Math.round(flightLog.rcCommandRawToThrottle(value)) + " %";

case 'rcCommands[0]':
case 'rcCommands[1]':
case 'rcCommands[2]':
return value.toFixed(0) + " deg/s";

case 'accSmooth[0]':
case 'accSmooth[1]':
case 'accSmooth[2]':
Expand Down
18 changes: 15 additions & 3 deletions js/graph_legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ function GraphLegend(targetElem, config, onVisibilityChange, onNewSelectionChang

graphTitle.text(graph.label);

for (j = 0; j < graph.fields.length; j++) {
for (j = 0; j < graph.fields.length; j++) {
var
field = graph.fields[j],
li = $('<li class="graph-legend-field" graph="' + i + '" field="' + j +'"></li>');
li = $('<li class="graph-legend-field" name="' + field.name + '" graph="' + i + '" field="' + j +'"></li>');

li.text(FlightLogFieldPresenter.fieldNameToFriendly(field.name));
li.css('border-bottom', "2px solid " + field.color);

fieldList.append(li);
}

Expand Down Expand Up @@ -65,6 +64,19 @@ function GraphLegend(targetElem, config, onVisibilityChange, onNewSelectionChang
// on first show, hide the analyser button
if(!config.selectedFieldName) $('.hide-analyser-window').hide();
}

this.updateValues = function(flightLog, frame) {
try {
// New function to show values on legend.
$(".graph-legend-field").each(function(index, value) {
var value = FlightLogFieldPresenter.decodeFieldToFriendly(flightLog, $(this).attr('name'), frame[flightLog.getMainFieldIndexByName($(this).attr('name'))]);
$(this).text(FlightLogFieldPresenter.fieldNameToFriendly($(this).attr('name')) + ((value)?' (' + value + ')':' ') );
$(this).append('<span class="glyphicon glyphicon-equalizer"></span>');
});
} catch(e) {
console.log('Cannot update legend with values');
}
};

this.show = function() {
$('.log-graph-config').show();
Expand Down
5 changes: 5 additions & 0 deletions js/grapher.js
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,11 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options)
}
};

// Add option toggling
this.setDrawSticks = function(state) {
options.drawSticks = state;
};

// Use defaults for any options not provided
options = extend(defaultOptions, options || {});

Expand Down
109 changes: 83 additions & 26 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ function BlackboxLogViewer() {
fieldPresenter = FlightLogFieldPresenter,

hasVideo = false, hasLog = false, hasMarker = false, // add measure feature
hasTable = true, hasCraft = true, hasSticks = true,

isFullscreen = false, // New fullscreen feature (to hide table)

video = $(".log-graph video")[0],
canvas = $("#graphCanvas")[0],
craftCanvas = $("#craftCanvas")[0],
Expand Down Expand Up @@ -168,41 +172,48 @@ function BlackboxLogViewer() {
fieldNames = flightLog.getMainFieldNames();

$("tr:not(:first)", table).remove();

if (frame) {
var
rows = [],
rowCount = Math.ceil(fieldNames.length / 2);

for (i = 0; i < rowCount; i++) {

if(hasTable) { // Only redraw the table if it is enabled

var
row =
"<tr>" +
'<td>' + fieldPresenter.fieldNameToFriendly(fieldNames[i]) + '</td>' +
'<td class="raw-value">' + atMost2DecPlaces(frame[i]) + '</td>' +
'<td>' + fieldPresenter.decodeFieldToFriendly(flightLog, fieldNames[i], frame[i]) + "</td>",

secondColumn = i + rowCount;

if (secondColumn < fieldNames.length) {
row +=
'<td>' + fieldPresenter.fieldNameToFriendly(fieldNames[secondColumn]) + '</td>' +
'<td>' + atMost2DecPlaces(frame[secondColumn]) + '</td>' +
'<td>' + fieldPresenter.decodeFieldToFriendly(flightLog, fieldNames[secondColumn], frame[secondColumn]) + '</td>';
rows = [],
rowCount = Math.ceil(fieldNames.length / 2);

for (i = 0; i < rowCount; i++) {
var
row =
"<tr>" +
'<td>' + fieldPresenter.fieldNameToFriendly(fieldNames[i]) + '</td>' +
'<td class="raw-value">' + atMost2DecPlaces(frame[i]) + '</td>' +
'<td>' + fieldPresenter.decodeFieldToFriendly(flightLog, fieldNames[i], frame[i]) + "</td>",

secondColumn = i + rowCount;

if (secondColumn < fieldNames.length) {
row +=
'<td>' + fieldPresenter.fieldNameToFriendly(fieldNames[secondColumn]) + '</td>' +
'<td>' + atMost2DecPlaces(frame[secondColumn]) + '</td>' +
'<td>' + fieldPresenter.decodeFieldToFriendly(flightLog, fieldNames[secondColumn], frame[secondColumn]) + '</td>';
}

row += "</tr>";

rows.push(row);
}

row += "</tr>";

rows.push(row);

table.append(rows.join(""));
}

table.append(rows.join(""));

// update time field on toolbar
$(".graph-time").val(formatTime((currentBlackboxTime-flightLog.getMinTime())/1000, true));
if(hasMarker) {
$(".graph-time-marker").val(formatTime((currentBlackboxTime-markerTime)/1000, true));
}

// Update the Legend Values
if(graphLegend) graphLegend.updateValues(flightLog, frame);
}
}

Expand Down Expand Up @@ -561,6 +572,8 @@ function BlackboxLogViewer() {

hasLog = true;
$("html").addClass("has-log");
(hasCraft)?$("html").addClass("has-craft"):$("html").removeClass("has-craft");
(hasTable)?$("html").addClass("has-table"):$("html").removeClass("has-table");

selectLog(null);
};
Expand Down Expand Up @@ -613,6 +626,11 @@ function BlackboxLogViewer() {
(state)?$("html").addClass("has-marker"):$("html").removeClass("has-marker");
}

function setFullscreen(state) { // update fullscreen status
isFullscreen = state;
(state)?$("html").addClass("is-fullscreen"):$("html").removeClass("is-fullscreen");
}

this.getMarker = function() { // get marker field
return {
state:hasMarker,
Expand Down Expand Up @@ -673,7 +691,27 @@ function BlackboxLogViewer() {
graphLegend.hide();
}
});


prefs.get('hasCraft', function(item) {
if (item) {
hasCraft = item;
(hasCraft)?$("html").addClass("has-craft"):$("html").removeClass("has-craft");
}
});

prefs.get('hasSticks', function(item) {
if (item) {
hasSticks = item;
}
});

prefs.get('hasTable', function(item) {
if (item) {
hasTable = item;
(hasTable)?$("html").addClass("has-table"):$("html").removeClass("has-table");
}
});

$(".file-open").change(function(e) {
var
files = e.target.files,
Expand All @@ -699,6 +737,25 @@ function BlackboxLogViewer() {
}
});

// New View Controls
$(".view-craft").click(function() {
hasCraft = !hasCraft;
(hasCraft)?$("html").addClass("has-craft"):$("html").removeClass("has-craft");
prefs.set('hasCraft', hasCraft);
});

$(".view-sticks").click(function() {
hasSticks = !hasSticks;
graph.setDrawSticks(hasSticks);
prefs.set('hasSticks', hasSticks);
invalidateGraph();
});

$(".view-table").click(function() {
hasTable = !hasTable;
(hasTable)?$("html").addClass("has-table"):$("html").removeClass("has-table");
prefs.set('hasTable', hasTable);
});

var logJumpBack = function() {
if (hasVideo) {
Expand Down

0 comments on commit 3bef086

Please sign in to comment.