Skip to content

Commit c77e479

Browse files
Gary KeebleGary Keeble
authored andcommitted
Added Bookmark feature
Similar to the Marker feature, bookmarks can store the current time for fast recall. Store and recall bookmarks using keys 1 through 9 whilst holding down the ALT key).
1 parent 7ee0aa7 commit c77e479

File tree

5 files changed

+88
-9
lines changed

5 files changed

+88
-9
lines changed

index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,13 +509,17 @@ <h5 class="modal-title-date"></h5>
509509
<th colspan="5">D-Term</th>
510510
</tr>
511511
<tr>
512+
<th class="bf-only">Calculation</th>
513+
<th class="bf-only">Dynamic Threshold</th>
512514
<th class="bf-only">Differentiator</th>
513515
<th>Filter (Hz)</th>
514516
<th class="bf-only">Average Count</th>
515517
</tr>
516518
</thead>
517519
<tbody>
518520
<tr>
521+
<td class="bf-only"><select name='deltaMethod' title="deltaMethod"><!-- list generated here --></select></td>
522+
<td class="bf-only"><input type="number" name="dynamic_dterm_threshold" title="dynamic_dterm_threshold" step="0.01" min="0" max="999.00" /></td>
519523
<td class="bf-only"><select name='dterm_differentiator' title="dterm_differentiator"><!-- list generated here --></select></td>
520524
<td><input type="number" name="dterm_lpf_hz" title="dterm_lpf_hz" step="0.01" min="0" max="999.00" /></td>
521525
<td class="bf-only"><input type="number" name="dterm_average_count" title="dterm_average_count" step="1" min="0" max="12" /></td>
@@ -891,6 +895,14 @@ <h4 class="modal-title">Shortcut Keys</h4>
891895
<li><span class=keys"><div class="key">Ctrl</div><div class="key">Z</div></span>
892896
<div class="description">Swap back to your last graph configuration. Repeatedly pressing Ctrl-Z will toggle the last two graph configurations.</div></li>
893897
</ul>
898+
<ul>
899+
<li><span class=keys"><div class="key">Alt</div><div class="key">Shift</div><div class="key">1</div><div class="normal">to</div><div class="key">9</div></span>
900+
<div class="description">Save the current time to Bookmark hotkeys 1 through 9</div></li>
901+
<li><span class=keys"><div class="key">Alt</div><div class="key">1</div><div class="normal">to</div><div class="key">9</div></span>
902+
<div class="description">Recall Bookmark 1 though 9 to jump to specific time quickly.</div></li>
903+
<li><span class=keys"><div class="key">Alt</div><div class="key">0</div></span>
904+
<div class="description">Special Case, clear all bookmarks</div></li>
905+
</ul>
894906
</div>
895907
</div>
896908
<div class="clear-both"></div>

js/flightlog_parser.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,12 @@ var FlightLogParser = function(logData) {
473473
case "dterm_differentiator": // Betaflight Only
474474
that.sysConfig.dterm_differentiator = parseInt(fieldValue, 10);
475475
break;
476+
case "deltaMethod": // Betaflight Only
477+
that.sysConfig.deltaMethod = parseInt(fieldValue, 10);
478+
break;
479+
case "dynamic_dterm_threshold": // Betaflight Only
480+
that.sysConfig.dynamic_dterm_threshold = parseInt(fieldValue, 10);
481+
break;
476482
case "H_sensitivity": // Betaflight Only
477483
that.sysConfig.H_sensitivity = parseInt(fieldValue, 10);
478484
break;

js/grapher.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,22 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options)
655655
label:'Marker:' +formatTime((markerEvent.time-flightLog.getMinTime())/1000, true)
656656
}, sequenceNum++);
657657
}
658+
659+
// Draw Bookmarks Event Line
660+
var bookmarkEvents = blackboxLogViewer.getBookmarks();
661+
if(bookmarkEvents!=null) {
662+
for(var i=0; i<=9; i++) {
663+
if(bookmarkEvents[i]!=null) {
664+
if(bookmarkEvents[i].state) drawEvent(
665+
{
666+
event:FlightLogEvent.CUSTOM,
667+
time:bookmarkEvents[i].time,
668+
label: i
669+
}, sequenceNum++);
670+
}
671+
}
672+
}
673+
658674
}
659675

660676
/**

js/header_dialog.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ function HeaderDialog(dialog, onSave) {
325325
setParameter('dterm_lpf_hz' ,sysConfig.dterm_lpf_hz,2);
326326
setParameter('dterm_cut_hz' ,sysConfig.dterm_cut_hz,2);
327327
renderSelect('dterm_differentiator' ,sysConfig.dterm_differentiator, DTERM_DIFFERENTIATOR);
328+
renderSelect('deltaMethod' ,sysConfig.deltaMethod, PID_DELTA_TYPE);
329+
setParameter('dynamic_dterm_threshold' ,sysConfig.dynamic_dterm_threshold,2);
328330
setParameter('H_sensitivity' ,sysConfig.H_sensitivity,2);
329331
setParameter('deadband' ,sysConfig.deadband,0);
330332
setParameter('yaw_deadband' ,sysConfig.yaw_deadband,0);

js/main.js

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function BlackboxLogViewer() {
4242
// JSON array of graph configurations for New Workspaces feature
4343
lastGraphConfig = null, // Undo feature - go back to last configuration.
4444
workspaceGraphConfigs = {}, // Workspaces
45+
bookmarkTimes = [], // Empty array for bookmarks (times)
4546

4647
// Graph configuration which is currently in use, customised based on the current flight log from graphConfig
4748
activeGraphConfig = new GraphConfig(),
@@ -582,6 +583,25 @@ function BlackboxLogViewer() {
582583
time:markerTime
583584
};
584585
}
586+
587+
this.getBookmarks = function() { // get bookmark events
588+
var bookmarks = [];
589+
try {
590+
if(bookmarkTimes!=null) {
591+
for(var i=0; i<=9; i++) {
592+
if(bookmarkTimes[i]!=null) {
593+
bookmarks[i] = {
594+
state: (bookmarkTimes[i]!=0),
595+
time: bookmarkTimes[i]
596+
};
597+
} else bookmarks[i] = null;
598+
}
599+
}
600+
return bookmarks;
601+
} catch(e) {
602+
return null;
603+
}
604+
}
585605

586606
prefs.get('videoConfig', function(item) {
587607
if (item) {
@@ -974,15 +994,38 @@ function BlackboxLogViewer() {
974994
case "8".charCodeAt(0):
975995
case "9".charCodeAt(0):
976996
try {
977-
if (!e.shiftKey) { // retreive graph configuration from workspace
978-
if (workspaceGraphConfigs.graphConfig[e.which-48] != null) {
979-
newGraphConfig(workspaceGraphConfigs.graphConfig[e.which-48]);
980-
}
981-
} else // store configuration to workspace
982-
{
983-
workspaceGraphConfigs.graphConfig[e.which-48] = graphConfig; // Save current config
984-
prefs.set('workspaceGraphConfigs', workspaceGraphConfigs); // Store to local cache
985-
}
997+
if(!e.altKey) { // Workspaces feature
998+
if (!e.shiftKey) { // retreive graph configuration from workspace
999+
if (workspaceGraphConfigs.graphConfig[e.which-48] != null) {
1000+
newGraphConfig(workspaceGraphConfigs.graphConfig[e.which-48]);
1001+
}
1002+
} else // store configuration to workspace
1003+
{
1004+
workspaceGraphConfigs.graphConfig[e.which-48] = graphConfig; // Save current config
1005+
prefs.set('workspaceGraphConfigs', workspaceGraphConfigs); // Store to local cache
1006+
}
1007+
} else { // Bookmark Feature
1008+
if (!e.shiftKey) { // retrieve time from bookmark
1009+
if (bookmarkTimes[e.which-48] != null) {
1010+
setCurrentBlackboxTime(bookmarkTimes[e.which-48]);
1011+
invalidateGraph();
1012+
}
1013+
1014+
} else {// store time to bookmark
1015+
// Special Case : Shift Alt 0 clears all bookmarks
1016+
if(e.which==48) {
1017+
bookmarkTimes = null;
1018+
} else {
1019+
if(bookmarkTimes==null) bookmarkTimes = new Array();
1020+
if (bookmarkTimes[e.which-48] == null) {
1021+
bookmarkTimes[e.which-48] = currentBlackboxTime; // Save current time to bookmark
1022+
} else {
1023+
bookmarkTimes[e.which-48] = null; // clear the bookmark
1024+
}
1025+
}
1026+
invalidateGraph();
1027+
}
1028+
}
9861029
} catch(e) {
9871030
console.log('Workspace feature not functioning');
9881031
}

0 commit comments

Comments
 (0)