Skip to content

Commit 808767f

Browse files
author
Gary Keeble
committed
Add marker to graph as a custom event
Marker is now shown on the graph as a red event. Adjusted width of chart to allow more toolbar area. Moved the update of the current time text box into the main routine for tidiness.
1 parent e7f5566 commit 808767f

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

css/main.css

Lines changed: 1 addition & 1 deletion
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:1280px;
12+
width:1320px;
1313
}
1414
}
1515

js/flightlog_fielddefs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ var
2323
GTUNE_CYCLE_RESULT: 20,
2424
FLIGHT_MODE: 30, // New Event type
2525

26+
CUSTOM : 250, // Virtual Event Code - Never part of Log File.
2627
LOG_END: 255
2728
}),
28-
29+
2930
FLIGHT_LOG_FLIGHT_MODE_NAME = makeReadOnly([
3031
"ANGLE_MODE",
3132
"HORIZON_MODE",

js/grapher.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,6 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options)
438438
frameLabelTextWidthFrameTime = canvasContext.measureText("00:00.000").width;
439439

440440
canvasContext.fillText(formatTime(timeMsec, true), canvas.width - frameLabelTextWidthFrameTime - 8, canvas.height - 8 - drawingParams.fontSizeFrameLabel - 8);
441-
// update time field on toolbar
442-
// $(".graph-time").val(formatTime(timeMsec, true));
443-
// if(hasMarker) {
444-
// $(".graph-time-marker").val(formatTime(timeMsec-markerTime, true));
445-
// }
446-
447441

448442
}
449443

@@ -641,6 +635,9 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options)
641635
case FlightLogEvent.FLIGHT_MODE:
642636
drawEventLine(x, labelY, "Flight Mode Change" + eventToFriendly(event.data.newFlags, event.data.lastFlags), "rgba(0,0,255,0.75)", 3);
643637
break;
638+
case FlightLogEvent.CUSTOM: // Virtual Events shown in RED
639+
drawEventLine(x, labelY, (event.label)?event.label:'EVENT', "rgba(255,0,0,0.75)", 3);
640+
break;
644641
default:
645642
drawEventLine(x);
646643
}
@@ -677,6 +674,19 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options)
677674
}
678675
}
679676
}
677+
678+
// Add custom markers
679+
680+
// Draw Marker Event Line
681+
var markerEvent = blackboxLogViewer.getMarker();
682+
if(markerEvent!=null) {
683+
if(markerEvent.state) drawEvent(
684+
{
685+
event:FlightLogEvent.CUSTOM,
686+
time:markerEvent.time,
687+
label:'Marker:' +formatTime((markerEvent.time-flightLog.getMinTime())/1000, true)
688+
}, sequenceNum++);
689+
}
680690
}
681691

682692
/**
@@ -838,7 +848,7 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options)
838848

839849
// Draw events
840850
drawEvents(chunks);
841-
851+
842852
// Draw details at the current time
843853
var
844854
centerFrame = flightLog.getSmoothedFrameAtTime(windowCenterTime);

js/main.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function BlackboxLogViewer() {
195195
table.append(rows.join(""));
196196

197197
// update time field on toolbar
198-
$(".graph-time").val(formatTime(currentBlackboxTime/1000, true));
198+
$(".graph-time").val(formatTime((currentBlackboxTime-flightLog.getMinTime())/1000, true));
199199
if(hasMarker) {
200200
$(".graph-time-marker").val(formatTime((currentBlackboxTime-markerTime)/1000, true));
201201
}
@@ -604,11 +604,18 @@ function BlackboxLogViewer() {
604604
updateCanvasSize();
605605
}
606606

607-
function markerSet(state) { // update marker field
607+
function setMarker(state) { // update marker field
608608
hasMarker = state;
609609
(state)?$("html").addClass("has-marker"):$("html").removeClass("has-marker");
610610
}
611-
611+
612+
this.getMarker = function() { // get marker field
613+
return {
614+
state:hasMarker,
615+
time:markerTime
616+
};
617+
}
618+
612619
prefs.get('videoConfig', function(item) {
613620
if (item) {
614621
videoConfig = item;
@@ -906,7 +913,8 @@ function BlackboxLogViewer() {
906913
if (!(shifted)) {
907914
markerTime = currentBlackboxTime;
908915
$(".graph-time-marker").val(formatTime(0));
909-
markerSet(!hasMarker);
916+
setMarker(!hasMarker);
917+
invalidateGraph();
910918
}
911919
e.preventDefault();
912920
break;

0 commit comments

Comments
 (0)