Skip to content

Commit

Permalink
Add New Logged Events
Browse files Browse the repository at this point in the history
Add new logged events to viewer
  • Loading branch information
Gary Keeble committed Apr 16, 2016
1 parent 02f3bd0 commit 0eff430
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 15 deletions.
1 change: 1 addition & 0 deletions js/flightlog_fielddefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var
LOGGING_RESUME: 14,

GTUNE_CYCLE_RESULT: 20,
FLIGHT_MODE: 30, // New Event type

LOG_END: 255
}),
Expand Down
22 changes: 15 additions & 7 deletions js/flightlog_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,12 @@ var FlightLogParser = function(logData) {
// At the moment they are entered on a dialog box.

defaultSysConfigExtension = {
rcExpo:70, // RC Expo
rRate:0, // Roll Rate
pRate:0, // Pitch Rate
yRate:45, // Yaw Rate
yawExpo: 20, // Yaw Expo
rcExpo:70, // RC Expo
rRate:0, // Roll Rate
pRate:0, // Pitch Rate
yRate:45, // Yaw Rate
rcYawExpo: 20, // Yaw Expo
superExpoFactor: 30, // Super Expo Factor
loopTime: 500, // Looptime
},

Expand Down Expand Up @@ -233,7 +234,7 @@ var FlightLogParser = function(logData) {

//The actual log data stream we're reading:
stream;

//Public fields:

/* Information about the frame types the log contains, along with details on their fields.
Expand Down Expand Up @@ -358,7 +359,10 @@ var FlightLogParser = function(logData) {
that.sysConfig.yRate = ratesParams[2];
break;
case "rcYawExpo":
that.sysConfig.yExpo = parseInt(fieldValue, 10);
that.sysConfig.rcYawExpo = parseInt(fieldValue, 10);
break;
case "superExpoFactor":
that.sysConfig.superExpoFactor = parseInt(fieldValue, 10);
break;
case "looptime":
that.sysConfig.loopTime = parseInt(fieldValue, 10);
Expand Down Expand Up @@ -902,6 +906,10 @@ var FlightLogParser = function(logData) {
lastEvent.data.time = stream.readUnsignedVB();
lastEvent.time = lastEvent.data.time;
break;
case FlightLogEvent.FLIGHT_MODE: // get the flag status change
lastEvent.data.newFlags = stream.readUnsignedVB();
lastEvent.data.lastFlags = stream.readUnsignedVB();
break;
case FlightLogEvent.AUTOTUNE_CYCLE_START:
lastEvent.data.phase = stream.readByte();

Expand Down
50 changes: 50 additions & 0 deletions js/grapher.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,40 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options)
"#ccebc5",
"#ffed6f"
],

EventStates = [
'ARM',
'ANGLE',
'HORIZON',
'BARO',
'MAG',
'HEADFREE',
'HEADADJ',
'CAMSTAB',
'CAMTRIG',
'GPSHOME',
'GPSHOLD',
'PASSTHRU',
'BEEPER',
'LEDMAX',
'LEDLOW',
'LLIGHTS',
'CALIB',
'GOV',
'OSD',
'TELEMETRY',
'GTUNE',
'SONAR',
'SERVO1',
'SERVO2',
'SERVO3',
'BLACKBOX',
'FAILSAFE',
'AIRMODE',
'SUPEREXPO',
'3DDISABLESWITCH',
'CHECKBOX_ITEM_COUNT'
],

WINDOW_WIDTH_MICROS_DEFAULT = 1000000;

Expand Down Expand Up @@ -557,6 +591,19 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options)
function timeToCanvasX(time) {
return canvas.width / windowWidthMicros * (time - windowStartTime);
}

function eventToFriendly(flags, lastFlags) {
var eventState = '';
var found = false;
for(var i=0; i<=31; i++) {
if((1<<i) & (flags ^ lastFlags)) { // State Changed
eventState += ' | ' + EventStates[i] + ' ' + (((1<<i) & flags)?'ON':'OFF')
found = true;
}
}
if(!found) {eventState += ' | ACRO';} // Catch the state when all flags are off, which is ACRO of course
return eventState;
}

function drawEvent(event, sequenceNum) {
var
Expand Down Expand Up @@ -584,6 +631,9 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options)
case FlightLogEvent.INFLIGHT_ADJUSTMENT:
drawEventLine(x, labelY, event.data.name + " = " + event.data.value, "rgba(0,255,255,0.5)", 2);
break;
case FlightLogEvent.FLIGHT_MODE:
drawEventLine(x, labelY, "Flight Mode Change" + eventToFriendly(event.data.newFlags, event.data.lastFlags), "rgba(0,0,255,0.75)", 3);
break;
default:
drawEventLine(x);
}
Expand Down
32 changes: 24 additions & 8 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,33 @@ function BlackboxLogViewer() {
parameters:
[
{ // Index 0
label: "RC Rate",
value: 100
},
{ // Index 1
label: "RC Expo",
value: 70
},
{ // Index 2
label: "Roll Rate",
value: 75
},
{ // Index 1
{ // Index 3
label: "Pitch Rate",
value: 75
},
{ // Index 2
{ // Index 4
label: "Yaw Rate",
value: 45
},
{ // Index 3
{ // Index 5
label: "Yaw Expo",
value: 20
}
},
{ // Index 6
label: "Super Expo",
value: 30
}
]
},
{ label: "Loop Time",
Expand Down Expand Up @@ -461,10 +473,14 @@ function BlackboxLogViewer() {
}

// transfer the parameters from the log file into the settings data structure
if(flightLog.getSysConfig().loopTime != null) {flightLogSettings[1].parameters[0].value = flightLog.getSysConfig().loopTime; }
if(flightLog.getSysConfig().rRate != null) {flightLogSettings[0].parameters[0].value = flightLog.getSysConfig().rRate; }
if(flightLog.getSysConfig().pRate != null) {flightLogSettings[0].parameters[1].value = flightLog.getSysConfig().pRate; }
if(flightLog.getSysConfig().yRate != null) {flightLogSettings[0].parameters[2].value = flightLog.getSysConfig().yRate; }
if(flightLog.getSysConfig().rcRate != null) {flightLogSettings[0].parameters[0].value = flightLog.getSysConfig().rcRate; }
if(flightLog.getSysConfig().rcExpo != null) {flightLogSettings[0].parameters[1].value = flightLog.getSysConfig().rcExpo; }
if(flightLog.getSysConfig().rRate != null) {flightLogSettings[0].parameters[2].value = flightLog.getSysConfig().rRate; }
if(flightLog.getSysConfig().pRate != null) {flightLogSettings[0].parameters[3].value = flightLog.getSysConfig().pRate; }
if(flightLog.getSysConfig().yRate != null) {flightLogSettings[0].parameters[4].value = flightLog.getSysConfig().yRate; }
if(flightLog.getSysConfig().rcYawExpo != null) {flightLogSettings[0].parameters[5].value = flightLog.getSysConfig().rcYawExpo; }
if(flightLog.getSysConfig().superExpoRate != null) {flightLogSettings[0].parameters[6].value = flightLog.getSysConfig().superExpoRate; }
if(flightLog.getSysConfig().loopTime != null) {flightLogSettings[1].parameters[0].value = flightLog.getSysConfig().loopTime; }

if (graph) {
graph.destroy();
Expand Down

0 comments on commit 0eff430

Please sign in to comment.