Skip to content

Commit 1c9343d

Browse files
committed
Manage disable fields
Add disabled fields indicators in header dialog Manage additional fields computed over disabled fields Hide example graphs not available in the current log
1 parent 187225a commit 1c9343d

File tree

5 files changed

+261
-168
lines changed

5 files changed

+261
-168
lines changed

index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,25 @@ <h5 class="modal-title-craft"></h5>
15061506
</table>
15071507
</div>
15081508
</div>
1509+
<div class="gui_box grey disabled_fields">
1510+
<div class="gui_box_titlebar">
1511+
<div class="spacer_box_title">Disabled Fields</div>
1512+
</div>
1513+
<div class="spacer_box">
1514+
<table cellpadding="0" cellspacing="0">
1515+
<thead class="fields_list disabled_fields noline">
1516+
<tr>
1517+
<th class="checkbox"></th>
1518+
<th class="item"></th>
1519+
<th class="description"></th>
1520+
</tr>
1521+
</thead>
1522+
<tbody class="fields_list disabled_fields noline">
1523+
<!-- table generated here -->
1524+
</tbody>
1525+
</table>
1526+
</div>
1527+
</div>
15091528
</div>
15101529
<div class="cf_column half right">
15111530
<div class="spacer_left">

js/flightlog.js

Lines changed: 69 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -209,27 +209,34 @@ function FlightLog(logData) {
209209
};
210210

211211
function buildFieldNames() {
212-
var
213-
i;
212+
const disabledFields=that.getSysConfig().fields_disabled_mask;
214213

215214
// Make an independent copy
216215
fieldNames = parser.frameDefs.I.name.slice(0);
217216

218217
// Add names of slow fields which we'll merge into the main stream
219218
if (parser.frameDefs.S) {
220-
for (i = 0; i < parser.frameDefs.S.name.length; i++) {
219+
for (let i = 0; i < parser.frameDefs.S.name.length; i++) {
221220
fieldNames.push(parser.frameDefs.S.name[i]);
222221
}
223222
}
224223

225224
// Add names for our ADDITIONAL_COMPUTED_FIELDS
226-
fieldNames.push("heading[0]", "heading[1]", "heading[2]");
227-
fieldNames.push("axisSum[0]", "axisSum[1]", "axisSum[2]");
228-
fieldNames.push("rcCommands[0]", "rcCommands[1]", "rcCommands[2]", "rcCommands[3]"); // Custom calculated scaled rccommand
229-
fieldNames.push("axisError[0]", "axisError[1]", "axisError[2]"); // Custom calculated error field
225+
if (!(disabledFields & 1<<7)) { //if GYRO disabled
226+
fieldNames.push("heading[0]", "heading[1]", "heading[2]");
227+
}
228+
if (!(disabledFields & 1<<0)) {//if PID disabled
229+
fieldNames.push("axisSum[0]", "axisSum[1]", "axisSum[2]");
230+
}
231+
if (!(disabledFields & 1<<2)) {//if setpoint disabled
232+
fieldNames.push("rcCommands[0]", "rcCommands[1]", "rcCommands[2]", "rcCommands[3]"); // Custom calculated scaled rccommand
233+
}
234+
if (!((disabledFields & 1<<7) || (disabledFields & 1<<0))) {//if GYRO or PID disabled
235+
fieldNames.push("axisError[0]", "axisError[1]", "axisError[2]"); // Custom calculated error field
236+
}
230237

231238
fieldNameToIndex = {};
232-
for (i = 0; i < fieldNames.length; i++) {
239+
for (let i = 0; i < fieldNames.length; i++) {
233240
fieldNameToIndex[fieldNames[i]] = i;
234241
}
235242
}
@@ -537,6 +544,26 @@ function FlightLog(logData) {
537544
magADC = false;
538545
}
539546

547+
if (!gyroADC[0]) {
548+
gyroADC = false;
549+
}
550+
551+
if (!accSmooth[0]) {
552+
accSmooth = false;
553+
}
554+
555+
if (!rcCommand[0]) {
556+
rcCommand = false;
557+
}
558+
559+
if (!setpoint[0]) {
560+
setpoint = false;
561+
}
562+
563+
if (!axisPID[0]) {
564+
axisPID = false;
565+
}
566+
540567
sysConfig = that.getSysConfig();
541568

542569
sourceChunkIndex = 0;
@@ -564,34 +591,38 @@ function FlightLog(logData) {
564591
destFrame = destChunk.frames[i],
565592
fieldIndex = destFrame.length - ADDITIONAL_COMPUTED_FIELD_COUNT;
566593

567-
attitude = chunkIMU.updateEstimatedAttitude(
568-
[srcFrame[gyroADC[0]], srcFrame[gyroADC[1]], srcFrame[gyroADC[2]]],
569-
[srcFrame[accSmooth[0]], srcFrame[accSmooth[1]], srcFrame[accSmooth[2]]],
570-
srcFrame[FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME],
571-
sysConfig.acc_1G,
572-
sysConfig.gyroScale,
573-
magADC ? [srcFrame[magADC[0]], srcFrame[magADC[1]], srcFrame[magADC[2]]] : false);
574-
575-
destFrame[fieldIndex++] = attitude.roll;
576-
destFrame[fieldIndex++] = attitude.pitch;
577-
destFrame[fieldIndex++] = attitude.heading;
594+
if (gyroADC) { //don't calculate attitude if no gyro data
595+
attitude = chunkIMU.updateEstimatedAttitude(
596+
[srcFrame[gyroADC[0]], srcFrame[gyroADC[1]], srcFrame[gyroADC[2]]],
597+
[srcFrame[accSmooth[0]], srcFrame[accSmooth[1]], srcFrame[accSmooth[2]]],
598+
srcFrame[FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME],
599+
sysConfig.acc_1G,
600+
sysConfig.gyroScale,
601+
magADC);
602+
603+
destFrame[fieldIndex++] = attitude.roll;
604+
destFrame[fieldIndex++] = attitude.pitch;
605+
destFrame[fieldIndex++] = attitude.heading;
606+
}
578607

579608
// Add the Feedforward PID sum (P+I+D+F)
580-
for (var axis = 0; axis < 3; axis++) {
581-
let pidSum =
582-
(axisPID[axis][0] !== undefined ? srcFrame[axisPID[axis][0]] : 0) +
583-
(axisPID[axis][1] !== undefined ? srcFrame[axisPID[axis][1]] : 0) +
584-
(axisPID[axis][2] !== undefined ? srcFrame[axisPID[axis][2]] : 0) +
585-
(axisPID[axis][3] !== undefined ? srcFrame[axisPID[axis][3]] : 0);
586-
587-
// Limit the PID sum by the limits defined in the header
588-
let pidLimit = axis < AXIS.YAW ? sysConfig.pidSumLimit : sysConfig.pidSumLimitYaw;
589-
if (pidLimit != null && pidLimit > 0) {
590-
pidSum = constrain(pidSum, -pidLimit, pidLimit);
591-
}
609+
if (axisPID) {
610+
for (var axis = 0; axis < 3; axis++) {
611+
let pidSum =
612+
(axisPID[axis][0] !== undefined ? srcFrame[axisPID[axis][0]] : 0) +
613+
(axisPID[axis][1] !== undefined ? srcFrame[axisPID[axis][1]] : 0) +
614+
(axisPID[axis][2] !== undefined ? srcFrame[axisPID[axis][2]] : 0) +
615+
(axisPID[axis][3] !== undefined ? srcFrame[axisPID[axis][3]] : 0);
616+
617+
// Limit the PID sum by the limits defined in the header
618+
let pidLimit = axis < AXIS.YAW ? sysConfig.pidSumLimit : sysConfig.pidSumLimitYaw;
619+
if (pidLimit != null && pidLimit > 0) {
620+
pidSum = constrain(pidSum, -pidLimit, pidLimit);
621+
}
592622

593-
// Assign value
594-
destFrame[fieldIndex++] = pidSum;
623+
// Assign value
624+
destFrame[fieldIndex++] = pidSum;
625+
}
595626
}
596627

597628
// Check the current flightmode (we need to know this so that we can correctly calculate the rates)
@@ -622,9 +653,11 @@ function FlightLog(logData) {
622653
}
623654

624655
// Calculate the PID Error
625-
for (var axis = 0; axis < 3; axis++) {
626-
let gyroADCdegrees = (gyroADC[axis] !== undefined ? that.gyroRawToDegreesPerSecond(srcFrame[gyroADC[axis]]) : 0);
627-
destFrame[fieldIndex++] = gyroADCdegrees - destFrame[fieldIndexRcCommands + axis];
656+
if (axisPID && gyroADC) {
657+
for (var axis = 0; axis < 3; axis++) {
658+
let gyroADCdegrees = (gyroADC[axis] !== undefined ? that.gyroRawToDegreesPerSecond(srcFrame[gyroADC[axis]]) : 0);
659+
destFrame[fieldIndex++] = gyroADCdegrees - destFrame[fieldIndexRcCommands + axis];
660+
}
628661
}
629662

630663
}

js/flightlog_parser.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ var FlightLogParser = function(logData) {
305305
dyn_notch_min_hz: null, // Dyn Notch min limit in Hz for the filter
306306
dyn_notch_max_hz: null, // Dyn Notch max limit in Hz for the filter
307307
rates_type: null,
308+
fields_disabled_mask: null,
308309
unknownHeaders : [] // Unknown Extra Headers
309310
},
310311

@@ -617,6 +618,7 @@ var FlightLogParser = function(logData) {
617618
case "dyn_notch_min_hz":
618619
case "dyn_notch_max_hz":
619620
case "rates_type":
621+
case "fields_disabled_mask":
620622
that.sysConfig[fieldName] = parseInt(fieldValue, 10);
621623
break;
622624
case "rc_expo":

js/graph_config.js

Lines changed: 32 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -172,54 +172,6 @@ GraphConfig.load = function(config) {
172172
};
173173

174174
(function() {
175-
var
176-
EXAMPLE_GRAPHS = [
177-
{
178-
label: "Motors",
179-
fields: ["motor[all]", "servo[5]"]
180-
},
181-
{
182-
label: "Gyros",
183-
fields: ["gyroADC[all]"]
184-
},
185-
{ /* Add custom graph configurations to the main menu ! */
186-
label: "RC Rates",
187-
fields: ["rcCommands[all]"]
188-
},
189-
{
190-
label: "RC Command",
191-
fields: ["rcCommand[all]"]
192-
},
193-
{
194-
label: "PIDs",
195-
fields: ["axisSum[all]"]
196-
},
197-
{
198-
label: "PID Error",
199-
fields: ["axisError[all]"]
200-
},
201-
{
202-
label: "Gyro + PID roll",
203-
fields: ["axisP[0]", "axisI[0]", "axisD[0]", "axisF[0]", "gyroADC[0]"]
204-
},
205-
{
206-
label: "Gyro + PID pitch",
207-
fields: ["axisP[1]", "axisI[1]", "axisD[1]", "axisF[1]", "gyroADC[1]"]
208-
},
209-
{
210-
label: "Gyro + PID yaw",
211-
fields: ["axisP[2]", "axisI[2]", "axisD[2]", "axisF[2]", "gyroADC[2]"]
212-
},
213-
{
214-
label: "Accelerometers",
215-
fields: ["accSmooth[all]"]
216-
},
217-
{
218-
label: "Debug",
219-
fields: ["debug[all]"]
220-
}
221-
];
222-
223175
GraphConfig.getDefaultSmoothingForField = function(flightLog, fieldName) {
224176
try{
225177
if (fieldName.match(/^motor\[/)) {
@@ -598,7 +550,38 @@ GraphConfig.load = function(config) {
598550
var
599551
result = [],
600552
i, j;
601-
553+
554+
const disabledFields=flightLog.getSysConfig().fields_disabled_mask;
555+
let EXAMPLE_GRAPHS = [];
556+
557+
if (!(disabledFields & 1<<10)) {
558+
EXAMPLE_GRAPHS.push({label: "Motors",fields: ["motor[all]", "servo[5]"]});
559+
}
560+
if (!(disabledFields & 1<<7)) {
561+
EXAMPLE_GRAPHS.push({label: "Gyros",fields: ["gyroADC[all]"]});
562+
}
563+
if (!(disabledFields & 1<<2)) {
564+
EXAMPLE_GRAPHS.push({label: "RC Rates",fields: ["rcCommands[all]"]});
565+
}
566+
if (!(disabledFields & 1<<1)) {
567+
EXAMPLE_GRAPHS.push({label: "RC Command",fields: ["rcCommand[all]"]});
568+
}
569+
if (!(disabledFields & 1<<0)) {
570+
EXAMPLE_GRAPHS.push({label: "PIDs",fields: ["axisSum[all]"]});
571+
}
572+
if (!((disabledFields & 1<<7) || (disabledFields & 1<<0))) {
573+
EXAMPLE_GRAPHS.push({label: "PID Error",fields: ["axisError[all]"]},
574+
{label: "Gyro + PID roll",fields: ["axisP[0]", "axisI[0]", "axisD[0]", "axisF[0]", "gyroADC[0]"]},
575+
{label: "Gyro + PID pitch",fields: ["axisP[1]", "axisI[1]", "axisD[1]", "axisF[1]", "gyroADC[1]"]},
576+
{label: "Gyro + PID yaw",fields: ["axisP[2]", "axisI[2]", "axisD[2]", "axisF[2]", "gyroADC[2]"]});
577+
}
578+
if (!(disabledFields & 1<<8)) {
579+
EXAMPLE_GRAPHS.push({label: "Accelerometers",fields: ["accSmooth[all]"]});
580+
}
581+
if (!(disabledFields & 1<<9)) {
582+
EXAMPLE_GRAPHS.push({label: "Debug",fields: ["debug[all]"]});
583+
}
584+
602585
for (i = 0; i < EXAMPLE_GRAPHS.length; i++) {
603586
var
604587
srcGraph = EXAMPLE_GRAPHS[i],

0 commit comments

Comments
 (0)