Skip to content

Commit 89e2cbd

Browse files
author
Gary Keeble
committed
Add current values to legend
New feature, current value is shown on legend and new toolbar to hide/view overlays.
1 parent eb1fab7 commit 89e2cbd

File tree

7 files changed

+150
-41
lines changed

7 files changed

+150
-41
lines changed

css/main.css

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ html, body {
99
/* Add an extended wide size to the page container for large monitors */
1010
@media (min-width: 1400px) {
1111
.container.main-pane {
12-
width:1320px;
12+
width:90%;
1313
}
1414
}
1515

@@ -231,6 +231,11 @@ html.has-log .log-graph-config {
231231
top:0;
232232
left:0;
233233
pointer-events:none; /* Allow the user to drag the graph lines instead of hitting the craft */
234+
display:none;
235+
}
236+
237+
html.has-craft #craftCanvas {
238+
display:block;
234239
}
235240

236241
.log-graph video {
@@ -259,6 +264,11 @@ html.has-log .log-graph-config {
259264
padding-bottom:0.1em;
260265
margin-bottom:0.3em;
261266
cursor:pointer;
267+
text-align: right;
268+
}
269+
270+
.graph-legend-field > span {
271+
margin-left: 0.7em;
262272
}
263273

264274
html.has-video .graph-row,
@@ -323,8 +333,8 @@ html.has-marker .graph-time-marker-group > .graph-time-marker {
323333
.log-metadata, .log-field-values {
324334
display:none;
325335
}
326-
html.has-log .log-metadata,
327-
html.has-log .log-field-values {
336+
html.has-log:not(.is-fullscreen) .log-metadata,
337+
html.has-log:not(.is-fullscreen).has-table .log-field-values {
328338
display:block;
329339
}
330340

index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,22 @@ <h3 class="log-filename"></h3>
154154
</div>
155155

156156
<ul class="video-top-controls list-unstyled">
157+
<li class="log-view-panel">
158+
<h4>View</h4>
159+
<div>
160+
<div class="btn-group" role="group">
161+
<button type="button" class="btn btn-default view-craft" title="View/hide craft display">
162+
<span class="glyphicon glyphicon-plane"></span>
163+
</button>
164+
<button type="button" class="btn btn-default view-sticks" title="View/hide stick display">
165+
<span class="glyphicon glyphicon-pawn"></span>
166+
</button>
167+
<button type="button" class="btn btn-default view-table" title="View/hide statistics display">
168+
<span class="glyphicon glyphicon-list-alt"></span>
169+
</button>
170+
</div>
171+
</div>
172+
</li>
157173
<li class="log-playback-panel">
158174
<h4>Playback</h4>
159175
<div>

js/flightlog.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -913,22 +913,18 @@ FlightLog.prototype.rcCommandRawToDegreesPerSecond = function(value, axis) {
913913
// Axis 0,1 refers to Roll and Pitch
914914
// Axis 2 refers to Yaw.
915915

916-
// ReWrite or LUXFloat only
917-
918-
919-
// if(axis==2 /*YAW*/) {
920-
// return ((this.settings[0].parameters[axis].value + 47) * value ) >> 7;
921-
// } else { /*ROLL or PITCH */
922-
// return ((this.settings[0].parameters[axis].value + 27) * value ) >> 6;
923-
// }
924-
925916
if(axis==2 /*YAW*/) {
926917
return ((this.getSysConfig().yRate + 47) * value ) >> 7;
927918
} else { /*ROLL or PITCH */
928919
return ((((axis==0)?this.getSysConfig().rRate:this.getSysConfig().pRate) + 27) * value ) >> 6;
929920
}
930921
};
931922

923+
FlightLog.prototype.rcCommandRawToThrottle = function(value) {
924+
// Throttle displayed as percentage
925+
return ((value - this.getSysConfig().minthrottle) / (this.getSysConfig().maxthrottle - this.getSysConfig().minthrottle)) * 100.0;
926+
};
927+
932928
FlightLog.prototype.getReferenceVoltageMillivolts = function() {
933929
return this.vbatADCToMillivolts(this.getSysConfig().vbatref);
934930
};

js/flightlog_fields_presenter.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ function FlightLogFieldPresenter() {
138138
case 'gyroADC[2]':
139139
return Math.round(flightLog.gyroRawToDegreesPerSecond(value)) + " deg/s";
140140

141+
case 'gyroADCs[0]':
142+
case 'gyroADCs[1]':
143+
case 'gyroADCs[2]':
144+
return value.toFixed(0) + " deg/s";
145+
141146
case 'axisError[0]':
142147
case 'axisError[1]':
143148
case 'axisError[2]':
@@ -150,6 +155,14 @@ function FlightLogFieldPresenter() {
150155
case 'rcCommand[2]':
151156
return Math.round(flightLog.rcCommandRawToDegreesPerSecond(value,2)) + " deg/s";
152157

158+
case 'rcCommand[3]':
159+
return Math.round(flightLog.rcCommandRawToThrottle(value)) + " %";
160+
161+
case 'rcCommands[0]':
162+
case 'rcCommands[1]':
163+
case 'rcCommands[2]':
164+
return value.toFixed(0) + " deg/s";
165+
153166
case 'accSmooth[0]':
154167
case 'accSmooth[1]':
155168
case 'accSmooth[2]':

js/graph_legend.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ function GraphLegend(targetElem, config, onVisibilityChange, onNewSelectionChang
2020

2121
graphTitle.text(graph.label);
2222

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

2828
li.text(FlightLogFieldPresenter.fieldNameToFriendly(field.name));
2929
li.css('border-bottom', "2px solid " + field.color);
30-
3130
fieldList.append(li);
3231
}
3332

@@ -65,6 +64,19 @@ function GraphLegend(targetElem, config, onVisibilityChange, onNewSelectionChang
6564
// on first show, hide the analyser button
6665
if(!config.selectedFieldName) $('.hide-analyser-window').hide();
6766
}
67+
68+
this.updateValues = function(flightLog, frame) {
69+
try {
70+
// New function to show values on legend.
71+
$(".graph-legend-field").each(function(index, value) {
72+
var value = FlightLogFieldPresenter.decodeFieldToFriendly(flightLog, $(this).attr('name'), frame[flightLog.getMainFieldIndexByName($(this).attr('name'))]);
73+
$(this).text(FlightLogFieldPresenter.fieldNameToFriendly($(this).attr('name')) + ((value)?' (' + value + ')':' ') );
74+
$(this).append('<span class="glyphicon glyphicon-equalizer"></span>');
75+
});
76+
} catch(e) {
77+
console.log('Cannot update legend with values');
78+
}
79+
};
6880

6981
this.show = function() {
7082
$('.log-graph-config').show();

js/grapher.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,11 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options)
998998
}
999999
};
10001000

1001+
// Add option toggling
1002+
this.setDrawSticks = function(state) {
1003+
options.drawSticks = state;
1004+
};
1005+
10011006
// Use defaults for any options not provided
10021007
options = extend(defaultOptions, options || {});
10031008

js/main.js

Lines changed: 83 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ function BlackboxLogViewer() {
9898
fieldPresenter = FlightLogFieldPresenter,
9999

100100
hasVideo = false, hasLog = false, hasMarker = false, // add measure feature
101+
hasTable = true, hasCraft = true, hasSticks = true,
102+
103+
isFullscreen = false, // New fullscreen feature (to hide table)
104+
101105
video = $(".log-graph video")[0],
102106
canvas = $("#graphCanvas")[0],
103107
craftCanvas = $("#craftCanvas")[0],
@@ -168,41 +172,48 @@ function BlackboxLogViewer() {
168172
fieldNames = flightLog.getMainFieldNames();
169173

170174
$("tr:not(:first)", table).remove();
171-
175+
172176
if (frame) {
173-
var
174-
rows = [],
175-
rowCount = Math.ceil(fieldNames.length / 2);
176-
177-
for (i = 0; i < rowCount; i++) {
177+
178+
if(hasTable) { // Only redraw the table if it is enabled
179+
178180
var
179-
row =
180-
"<tr>" +
181-
'<td>' + fieldPresenter.fieldNameToFriendly(fieldNames[i]) + '</td>' +
182-
'<td class="raw-value">' + atMost2DecPlaces(frame[i]) + '</td>' +
183-
'<td>' + fieldPresenter.decodeFieldToFriendly(flightLog, fieldNames[i], frame[i]) + "</td>",
184-
185-
secondColumn = i + rowCount;
186-
187-
if (secondColumn < fieldNames.length) {
188-
row +=
189-
'<td>' + fieldPresenter.fieldNameToFriendly(fieldNames[secondColumn]) + '</td>' +
190-
'<td>' + atMost2DecPlaces(frame[secondColumn]) + '</td>' +
191-
'<td>' + fieldPresenter.decodeFieldToFriendly(flightLog, fieldNames[secondColumn], frame[secondColumn]) + '</td>';
181+
rows = [],
182+
rowCount = Math.ceil(fieldNames.length / 2);
183+
184+
for (i = 0; i < rowCount; i++) {
185+
var
186+
row =
187+
"<tr>" +
188+
'<td>' + fieldPresenter.fieldNameToFriendly(fieldNames[i]) + '</td>' +
189+
'<td class="raw-value">' + atMost2DecPlaces(frame[i]) + '</td>' +
190+
'<td>' + fieldPresenter.decodeFieldToFriendly(flightLog, fieldNames[i], frame[i]) + "</td>",
191+
192+
secondColumn = i + rowCount;
193+
194+
if (secondColumn < fieldNames.length) {
195+
row +=
196+
'<td>' + fieldPresenter.fieldNameToFriendly(fieldNames[secondColumn]) + '</td>' +
197+
'<td>' + atMost2DecPlaces(frame[secondColumn]) + '</td>' +
198+
'<td>' + fieldPresenter.decodeFieldToFriendly(flightLog, fieldNames[secondColumn], frame[secondColumn]) + '</td>';
199+
}
200+
201+
row += "</tr>";
202+
203+
rows.push(row);
192204
}
193-
194-
row += "</tr>";
195-
196-
rows.push(row);
205+
206+
table.append(rows.join(""));
197207
}
198208

199-
table.append(rows.join(""));
200-
201209
// update time field on toolbar
202210
$(".graph-time").val(formatTime((currentBlackboxTime-flightLog.getMinTime())/1000, true));
203211
if(hasMarker) {
204212
$(".graph-time-marker").val(formatTime((currentBlackboxTime-markerTime)/1000, true));
205213
}
214+
215+
// Update the Legend Values
216+
if(graphLegend) graphLegend.updateValues(flightLog, frame);
206217
}
207218
}
208219

@@ -561,6 +572,8 @@ function BlackboxLogViewer() {
561572

562573
hasLog = true;
563574
$("html").addClass("has-log");
575+
(hasCraft)?$("html").addClass("has-craft"):$("html").removeClass("has-craft");
576+
(hasTable)?$("html").addClass("has-table"):$("html").removeClass("has-table");
564577

565578
selectLog(null);
566579
};
@@ -613,6 +626,11 @@ function BlackboxLogViewer() {
613626
(state)?$("html").addClass("has-marker"):$("html").removeClass("has-marker");
614627
}
615628

629+
function setFullscreen(state) { // update fullscreen status
630+
isFullscreen = state;
631+
(state)?$("html").addClass("is-fullscreen"):$("html").removeClass("is-fullscreen");
632+
}
633+
616634
this.getMarker = function() { // get marker field
617635
return {
618636
state:hasMarker,
@@ -673,7 +691,27 @@ function BlackboxLogViewer() {
673691
graphLegend.hide();
674692
}
675693
});
676-
694+
695+
prefs.get('hasCraft', function(item) {
696+
if (item) {
697+
hasCraft = item;
698+
(hasCraft)?$("html").addClass("has-craft"):$("html").removeClass("has-craft");
699+
}
700+
});
701+
702+
prefs.get('hasSticks', function(item) {
703+
if (item) {
704+
hasSticks = item;
705+
}
706+
});
707+
708+
prefs.get('hasTable', function(item) {
709+
if (item) {
710+
hasTable = item;
711+
(hasTable)?$("html").addClass("has-table"):$("html").removeClass("has-table");
712+
}
713+
});
714+
677715
$(".file-open").change(function(e) {
678716
var
679717
files = e.target.files,
@@ -699,6 +737,25 @@ function BlackboxLogViewer() {
699737
}
700738
});
701739

740+
// New View Controls
741+
$(".view-craft").click(function() {
742+
hasCraft = !hasCraft;
743+
(hasCraft)?$("html").addClass("has-craft"):$("html").removeClass("has-craft");
744+
prefs.set('hasCraft', hasCraft);
745+
});
746+
747+
$(".view-sticks").click(function() {
748+
hasSticks = !hasSticks;
749+
graph.setDrawSticks(hasSticks);
750+
prefs.set('hasSticks', hasSticks);
751+
invalidateGraph();
752+
});
753+
754+
$(".view-table").click(function() {
755+
hasTable = !hasTable;
756+
(hasTable)?$("html").addClass("has-table"):$("html").removeClass("has-table");
757+
prefs.set('hasTable', hasTable);
758+
});
702759

703760
var logJumpBack = function() {
704761
if (hasVideo) {

0 commit comments

Comments
 (0)