forked from betaflight/blackbox-log-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflightlog_fields_presenter.js
696 lines (642 loc) · 27.3 KB
/
flightlog_fields_presenter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
"use strict";
function FlightLogFieldPresenter() {
}
(function() {
var FRIENDLY_FIELD_NAMES = {
'axisP[all]': 'PID P',
'axisP[0]': 'PID P [roll]',
'axisP[1]': 'PID P [pitch]',
'axisP[2]': 'PID P [yaw]',
'axisI[all]': 'PID I',
'axisI[0]': 'PID I [roll]',
'axisI[1]': 'PID I [pitch]',
'axisI[2]': 'PID I [yaw]',
'axisD[all]': 'PID D',
'axisD[0]': 'PID D [roll]',
'axisD[1]': 'PID D [pitch]',
'axisD[2]': 'PID D [yaw]',
'axisF[all]': 'PID Feedforward',
'axisF[0]': 'PID Feedforward [roll]',
'axisF[1]': 'PID Feedforward [pitch]',
'axisF[2]': 'PID Feedforward [yaw]',
//Virtual field
'axisSum[all]': 'PID Sum',
'axisSum[0]' : 'PID Sum [roll]',
'axisSum[1]' : 'PID Sum [pitch]',
'axisSum[2]' : 'PID Sum [yaw]',
//Virtual field
'axisError[all]': 'PID Error',
'axisError[0]' : 'PID Error [roll]',
'axisError[1]' : 'PID Error [pitch]',
'axisError[2]' : 'PID Error [yaw]',
//Virtual field
'rcCommands[all]': 'Setpoints',
'rcCommands[0]' : 'Setpoint [roll]',
'rcCommands[1]' : 'Setpoint [pitch]',
'rcCommands[2]' : 'Setpoint [yaw]',
'rcCommands[3]' : 'Setpoint [throttle]',
'rcCommand[all]': 'RC Commands',
'rcCommand[0]': 'RC Command [roll]',
'rcCommand[1]': 'RC Command [pitch]',
'rcCommand[2]': 'RC Command [yaw]',
'rcCommand[3]': 'RC Command [throttle]',
'gyroADC[all]': 'Gyros',
'gyroADC[0]': 'Gyro [roll]',
'gyroADC[1]': 'Gyro [pitch]',
'gyroADC[2]': 'Gyro [yaw]',
//End-users prefer 1-based indexing
'motor[all]': 'Motors',
'motor[0]': 'Motor [1]',
'motor[1]': 'Motor [2]',
'motor[2]': 'Motor [3]',
'motor[3]': 'Motor [4]',
'motor[4]': 'Motor [5]',
'motor[5]': 'Motor [6]',
'motor[6]': 'Motor [7]',
'motor[7]': 'Motor [8]',
'servo[all]': 'Servos',
'servo[5]': 'Servo Tail',
'vbatLatest': 'Battery volt.',
'amperageLatest': 'Amperage',
'BaroAlt': 'Barometer',
'heading[all]': 'Heading',
'heading[0]': 'Heading [roll]',
'heading[1]': 'Heading [pitch]',
'heading[2]': 'Heading [yaw]',
'accSmooth[all]': 'Accel.',
'accSmooth[0]': 'Accel. [X]',
'accSmooth[1]': 'Accel. [Y]',
'accSmooth[2]': 'Accel. [Z]',
'magADC[all]': 'Compass',
'magADC[0]': 'Compass [X]',
'magADC[1]': 'Compass [Y]',
'magADC[2]': 'Compass [Z]',
'flightModeFlags': 'Flight Mode Flags',
'stateFlags': 'State Flags',
'failsafePhase': 'Failsafe Phase',
'rxSignalReceived': 'RX Signal Received',
'rxFlightChannelsValid': 'RX Flight Ch. Valid',
'rssi': 'RSSI',
};
var DEBUG_FRIENDLY_FIELD_NAMES = {
'NONE' : {
'debug[all]':'Debug [all]',
'debug[0]':'Debug [0]',
'debug[1]':'Debug [1]',
'debug[2]':'Debug [2]',
'debug[3]':'Debug [3]',
},
'CYCLETIME' : {
'debug[all]':'Debug Cycle Time',
'debug[0]':'Cycle Time',
'debug[1]':'CPU Load',
'debug[2]':'Motor Update',
'debug[3]':'Motor Deviation',
},
'BATTERY' : {
'debug[all]':'Debug Battery',
'debug[0]':'Battery Volt. ADC',
'debug[1]':'Battery Volt.',
'debug[2]':'Not Used',
'debug[3]':'Not Used',
},
'GYRO' : {
'debug[all]':'Debug Gyro',
'debug[0]':'Gyro Raw [X]',
'debug[1]':'Gyro Raw [Y]',
'debug[2]':'Gyro Raw [Z]',
'debug[3]':'Not Used',
},
'GYRO_FILTERED' : {
'debug[all]':'Debug Gyro Filtered',
'debug[0]':'Gyro Filtered [X]',
'debug[1]':'Gyro Filtered [Y]',
'debug[2]':'Gyro Filtered [Z]',
'debug[3]':'Not Used',
},
'ACCELEROMETER' : {
'debug[all]':'Debug Accel.',
'debug[0]':'Accel. Raw [X]',
'debug[1]':'Accel. Raw [Y]',
'debug[2]':'Accel. Raw [Z]',
'debug[3]':'Not Used',
},
'MIXER' : {
'debug[all]':'Debug Mixer',
'debug[0]':'Roll-Pitch-Yaw Mix [0]',
'debug[1]':'Roll-Pitch-Yaw Mix [1]',
'debug[2]':'Roll-Pitch-Yaw Mix [2]',
'debug[3]':'Roll-Pitch-Yaw Mix [3]',
},
'PIDLOOP' : {
'debug[all]':'Debug PID',
'debug[0]':'Wait Time',
'debug[1]':'Sub Update Time',
'debug[2]':'PID Update Time',
'debug[3]':'Motor Update Time',
},
'NOTCH' : {
'debug[all]':'Debug Notch',
'debug[0]':'Gyro Pre-Notch [roll]',
'debug[1]':'Gyro Pre-Notch [pitch]',
'debug[2]':'Gyro Pre-Notch [yaw]',
'debug[3]':'Not Used',
},
'GYRO_SCALED' : {
'debug[all]':'Debug Gyro Scaled',
'debug[0]':'Gyro Scaled [roll]',
'debug[1]':'Gyro Scaled [pitch]',
'debug[2]':'Gyro Scaled [yaw]',
'debug[3]':'Not Used',
},
'RC_INTERPOLATION' : {
'debug[all]':'Debug RC Interpolation',
'debug[0]':'Raw RC Command [roll]',
'debug[1]':'Current RX Refresh Rate',
'debug[2]':'Interpolation Step Count',
'debug[3]':'RC Setpoint [roll]',
},
'RC_SMOOTHING' : {
'debug[all]':'Debug RC Smoothing',
'debug[0]':'Raw RC Command',
'debug[1]':'Raw RC Derivative',
'debug[2]':'Smoothed RC Derivative',
'debug[3]':'RX Refresh Rate',
},
'RC_SMOOTHING_RATE' : {
'debug[all]':'Debug RC Smoothing Rate',
'debug[0]':'Current RX Refresh Rate',
'debug[1]':'Training Step Count',
'debug[2]':'Average RX Refresh Rate',
'debug[3]':'Sampling State',
},
'DTERM_FILTER' : {
'debug[all]':'Debug Filter',
'debug[0]':'DTerm Filter [roll]',
'debug[1]':'DTerm Filter [pitch]',
'debug[2]':'Not Used',
'debug[3]':'Not Used',
},
'ANGLERATE' : {
'debug[all]':'Debug Angle Rate',
'debug[0]':'Angle Rate[roll]',
'debug[1]':'Angle Rate[pitch]',
'debug[2]':'Angle Rate[yaw]',
'debug[3]':'Not Used',
},
'ESC_SENSOR' : {
'debug[all]':'ESC Sensor',
'debug[0]':'Motor Index',
'debug[1]':'Timeouts',
'debug[2]':'CNC errors',
'debug[3]':'Data age',
},
'SCHEDULER' : {
'debug[all]':'Scheduler',
'debug[0]':'Not Used',
'debug[1]':'Not Used',
'debug[2]':'Schedule Time',
'debug[3]':'Function Exec Time',
},
'STACK' : {
'debug[all]':'Stack',
'debug[0]':'Stack High Mem',
'debug[1]':'Stack Low Mem',
'debug[2]':'Stack Current',
'debug[3]':'Stack p',
},
'FFT' : {
'debug[all]':'Debug FFT',
'debug[0]':'Gyro Scaled [dbg-axis]',
'debug[1]':'Gyro Pre-Dyn [dbg-axis]',
'debug[2]':'Gyro Downsampled [roll]',
'debug[3]':'FFT Center Index [roll]',
},
'FFT_TIME' : {
'debug[all]':'Debug FFT TIME',
'debug[0]':'Active calc step',
'debug[1]':'Step duration',
'debug[2]':'Additional steps',
'debug[3]':'Not used',
},
'FFT_FREQ' : {
'debug[all]':'Debug FFT FREQ',
'debug[0]':'Center Freq [roll]',
'debug[1]':'Center Freq [pitch]',
'debug[2]':'Gyro Pre-Dyn [dbg-axis]',
'debug[3]':'Gyro Scaled [dbg-axis]',
},
'GYRO_RAW' : {
'debug[all]':'Debug Gyro Raw',
'debug[0]':'Gyro Raw [X]',
'debug[1]':'Gyro Raw [Y]',
'debug[2]':'Gyro Raw [Z]',
'debug[3]':'Not Used',
},
'DUAL_GYRO' : {
'debug[all]':'Debug Dual Gyro',
'debug[0]':'Gyro 1 Filtered [roll]',
'debug[1]':'Gyro 1 Filtered [pitch]',
'debug[2]':'Gyro 2 Filtered [roll]',
'debug[3]':'Gyro 2 Filtered [pitch]',
},
'DUAL_GYRO_RAW': {
'debug[all]':'Debug Dual Gyro Raw',
'debug[0]':'Gyro 1 Raw [roll]',
'debug[1]':'Gyro 1 Raw [pitch]',
'debug[2]':'Gyro 2 Raw [roll]',
'debug[3]':'Gyro 2 Raw [pitch]',
},
'DUAL_GYRO_COMBINED': {
'debug[all]':'Debug Dual Combined',
'debug[0]':'Not Used',
'debug[1]':'Gyro Filtered [roll]',
'debug[2]':'Gyro Filtered [pitch]',
'debug[3]':'Not Used',
},
'DUAL_GYRO_DIFF': {
'debug[all]':'Debug Dual Gyro Diff',
'debug[0]':'Gyro Diff [roll]',
'debug[1]':'Gyro Diff [pitch]',
'debug[2]':'Gyro Diff [yaw]',
'debug[3]':'Not Used',
},
'ESC_SENSOR_RPM' : {
'debug[all]':'ESC RPM',
'debug[0]':'ESC RPM [1]',
'debug[1]':'ESC RPM [2]',
'debug[2]':'ESC RPM [3]',
'debug[3]':'ESC RPM [4]',
},
'DSHOT_RPM_TELEMETRY' : {
'debug[all]':'DSHOT RPM',
'debug[0]':'DSHOT RPM [1]',
'debug[1]':'DSHOT RPM [2]',
'debug[2]':'DSHOT RPM [3]',
'debug[3]':'DSHOT RPM [4]',
},
'RPM_FILTER' : {
'debug[all]':'RPM Filter',
'debug[0]':'RPM Filter [1]',
'debug[1]':'RPM Filter [2]',
'debug[2]':'RPM Filter [3]',
'debug[3]':'RPM Filter [4]',
},
'D_MIN' : {
'debug[all]':'D_MIN',
'debug[0]':'Gyro Factor [roll]',
'debug[1]':'Setpoint Factor [roll]',
'debug[2]':'Actual D [roll]',
'debug[3]':'Actual D [pitch]',
},
'ITERM_RELAX' : {
'debug[all]':'I-term Relax',
'debug[0]':'Setpoint HPF [roll]',
'debug[1]':'I Relax Factor [roll]',
'debug[2]':'Relaxed I Error [roll]',
'debug[3]':'Axis Error [roll]',
},
'DYN_LPF' : {
'debug[all]':'Debug Dyn LPF',
'debug[0]':'Gyro Scaled [dbg-axis]',
'debug[1]':'Notch Center [roll]',
'debug[2]':'Lowpass Cutoff',
'debug[3]':'Gyro Pre-Dyn [dbg-axis]',
},
'AC_CORRECTION' : {
'debug[all]':'AC Correction',
'debug[0]':'AC Correction [roll]',
'debug[1]':'AC Correction [pitch]',
'debug[2]':'AC Correction [yaw]',
'debug[3]':'Not Used',
},
'AC_ERROR' : {
'debug[all]':'AC Error',
'debug[0]':'AC Error [roll]',
'debug[1]':'AC Error [pitch]',
'debug[2]':'AC Error [yaw]',
'debug[3]':'Not Used',
},
};
function presentFlags(flags, flagNames) {
var
printedFlag = false,
i,
result = "";
i = 0;
while (flags > 0) {
if ((flags & 1) != 0) {
if (printedFlag) {
result += "|";
} else {
printedFlag = true;
}
result += flagNames[i];
}
flags >>= 1;
i++;
}
if (printedFlag) {
return result;
} else {
return "0"; //No flags set
}
}
// Only list events that have changed, flag with eirer go ON or OFF.
FlightLogFieldPresenter.presentChangeEvent = function presentChangeEvent(flags, lastFlags, flagNames) {
var eventState = '';
var found = false;
for(var i = 0; i < flagNames.length; i++) {
if((1<<i) & (flags ^ lastFlags)) { // State Changed
eventState += '|' + flagNames[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 presentEnum(value, enumNames) {
if (enumNames[value] === undefined)
return value;
return enumNames[value];
}
/**
* Attempt to decode the given raw logged value into something more human readable, or return an empty string if
* no better representation is available.
*
* @param fieldName Name of the field
* @param value Value of the field
*/
FlightLogFieldPresenter.decodeFieldToFriendly = function(flightLog, fieldName, value, currentFlightMode) {
if (value === undefined)
return "";
switch (fieldName) {
case 'time':
return formatTime(value / 1000, true);
case 'gyroADC[0]':
case 'gyroADC[1]':
case 'gyroADC[2]':
return Math.round(flightLog.gyroRawToDegreesPerSecond(value)) + " deg/s";
case 'gyroADCs[0]':
case 'gyroADCs[1]':
case 'gyroADCs[2]':
return value.toFixed(0) + " deg/s";
case 'axisError[0]':
case 'axisError[1]':
case 'axisError[2]':
return Math.round(value) + " deg/s";
case 'rcCommand[0]':
case 'rcCommand[1]':
case 'rcCommand[2]':
return (value + 1500).toFixed(0) + " us";
case 'rcCommand[3]':
return value.toFixed(0) + " us";
case 'motor[0]':
case 'motor[1]':
case 'motor[2]':
case 'motor[3]':
case 'motor[4]':
case 'motor[5]':
case 'motor[6]':
case 'motor[7]':
return Math.round(flightLog.rcMotorRawToPct(value)) + " %";
case 'rcCommands[0]':
case 'rcCommands[1]':
case 'rcCommands[2]':
return value.toFixed(0) + " deg/s";
case 'rcCommands[3]':
return value.toFixed(1) + "%";
case 'axisSum[0]':
case 'axisSum[1]':
case 'axisSum[2]':
case 'axisP[0]':
case 'axisP[1]':
case 'axisP[2]':
case 'axisI[0]':
case 'axisI[1]':
case 'axisI[2]':
case 'axisD[0]':
case 'axisD[1]':
case 'axisD[2]':
case 'axisF[0]':
case 'axisF[1]':
case 'axisF[2]':
return flightLog.getPIDPercentage(value).toFixed(1) + "%";
case 'accSmooth[0]':
case 'accSmooth[1]':
case 'accSmooth[2]':
return flightLog.accRawToGs(value).toFixed(2) + "g";
case 'vbatLatest':
if(flightLog.getSysConfig().firmwareType == FIRMWARE_TYPE_BETAFLIGHT && semver.gte(flightLog.getSysConfig().firmwareVersion, '4.0.0')) {
return (value / 100).toFixed(2) + "V" + ", " + (value / 100 / flightLog.getNumCellsEstimate()).toFixed(2) + "V/cell";
} else if((flightLog.getSysConfig().firmwareType == FIRMWARE_TYPE_BETAFLIGHT && semver.gte(flightLog.getSysConfig().firmwareVersion, '3.1.0')) ||
(flightLog.getSysConfig().firmwareType == FIRMWARE_TYPE_CLEANFLIGHT && semver.gte(flightLog.getSysConfig().firmwareVersion, '2.0.0'))) {
return (value / 10).toFixed(2) + "V" + ", " + (value / 10 / flightLog.getNumCellsEstimate()).toFixed(2) + "V/cell";
} else {
return (flightLog.vbatADCToMillivolts(value) / 1000).toFixed(2) + "V" + ", " + (flightLog.vbatADCToMillivolts(value) / 1000 / flightLog.getNumCellsEstimate()).toFixed(2) + "V/cell";
}
case 'amperageLatest':
if((flightLog.getSysConfig().firmwareType == FIRMWARE_TYPE_BETAFLIGHT && semver.gte(flightLog.getSysConfig().firmwareVersion, '3.1.7')) ||
(flightLog.getSysConfig().firmwareType == FIRMWARE_TYPE_CLEANFLIGHT && semver.gte(flightLog.getSysConfig().firmwareVersion, '2.0.0'))) {
return (value / 100).toFixed(2) + "A" + ", " + (value / 100 / flightLog.getNumMotors()).toFixed(2) + "A/motor";
} else if(flightLog.getSysConfig().firmwareType == FIRMWARE_TYPE_BETAFLIGHT && semver.gte(flightLog.getSysConfig().firmwareVersion, '3.1.0')) {
return (value / 100).toFixed(2) + "A" + ", " + (value / 100 / flightLog.getNumMotors()).toFixed(2) + "A/motor";
} else {
return (flightLog.amperageADCToMillivolts(value) / 1000).toFixed(2) + "A" + ", " + (flightLog.amperageADCToMillivolts(value) / 1000 / flightLog.getNumMotors()).toFixed(2) + "A/motor";
}
case 'heading[0]':
case 'heading[1]':
case 'heading[2]':
return (value / Math.PI * 180).toFixed(1) + "°";
case 'BaroAlt':
return (value / 100).toFixed(1) + "m";
case 'flightModeFlags':
return presentFlags(value, FLIGHT_LOG_FLIGHT_MODE_NAME);
case 'stateFlags':
return presentFlags(value, FLIGHT_LOG_FLIGHT_STATE_NAME);
case 'failsafePhase':
return presentEnum(value, FLIGHT_LOG_FAILSAFE_PHASE_NAME);
case 'features':
return presentEnum(value, FLIGHT_LOG_FEATURES);
case 'rssi':
return (value / 1024 * 100).toFixed(2) + "%";
case 'debug[0]':
case 'debug[1]':
case 'debug[2]':
case 'debug[3]':
return FlightLogFieldPresenter.decodeDebugFieldToFriendly(flightLog, fieldName, value, currentFlightMode);
default:
return "";
}
};
FlightLogFieldPresenter.decodeDebugFieldToFriendly = function(flightLog, fieldName, value, currentFlightMode) {
if(flightLog) {
var debugModeName = DEBUG_MODE[flightLog.getSysConfig().debug_mode]; // convert to recognisable name
switch (debugModeName) {
case 'NONE':
case 'AIRMODE':
case 'VELOCITY':
return "";
case 'CYCLETIME':
switch (fieldName) {
case 'debug[1]':
return value.toFixed(0) + "%";
default:
return value.toFixed(0) + "\u03BCS";
}
case 'PIDLOOP':
return value.toFixed(0) + "\u03BCS";
case 'BATTERY':
switch (fieldName) {
case 'debug[0]':
return value.toFixed(0);
default:
return (value/10).toFixed(1) + "V"
}
case 'GYRO':
case 'GYRO_FILTERED':
case 'GYRO_SCALED':
case 'NOTCH':
case 'DUAL_GYRO':
case 'DUAL_GYRO_COMBINED':
case 'DUAL_GYRO_DIFF':
case 'DUAL_GYRO_RAW':
return Math.round(flightLog.gyroRawToDegreesPerSecond(value)) + "deg/s";
case 'ACCELEROMETER':
return flightLog.accRawToGs(value).toFixed(2) + "g";
case 'MIXER':
return Math.round(flightLog.rcCommandRawToThrottle(value)) + " %";
case 'RC_INTERPOLATION':
switch (fieldName) {
case 'debug[1]': // current RX refresh rate
return value.toFixed(0) + 'ms';
case 'debug[3]': // setpoint [roll]
return value.toFixed(0) + 'deg/s';
}
break;
case 'RC_SMOOTHING':
switch (fieldName) {
case 'debug[0]':
return (value + 1500).toFixed(0) + " us";
case 'debug[3]': // rx frame rate [us]
return (value / 1000).toFixed(1) + 'ms';
}
break;
case 'RC_SMOOTHING_RATE':
switch (fieldName) {
case 'debug[0]': // current frame rate [us]
case 'debug[2]': // average frame rate [us]
return (value / 1000).toFixed(2) + 'ms';
}
break;
case 'DFILTER':
return "";
case 'ANGLERATE':
return value.toFixed(0) + "deg/s";
case 'ESC_SENSOR':
switch (fieldName) {
case 'debug[3]':
return value.toFixed(0) + "\u03BCS";
default:
return value.toFixed(0) + "";
}
case 'ESC_SENSOR_RPM':
return value.toFixed(0) + "rpm";
case 'ESC_SENSOR_TMP':
return value.toFixed(0) + "°C";
case 'SCHEDULER':
return value.toFixed(0) + "\u03BCS";
case 'STACK':
return value.toFixed(0);
case 'FFT':
switch (fieldName) {
case 'debug[0]': // gyro scaled [for selected axis]
case 'debug[1]': // pre-dyn notch gyro [for selected axis]
case 'debug[2]': // pre-dyn notch gyro FFT downsampled [roll]
return Math.round(flightLog.gyroRawToDegreesPerSecond(value)) + "deg/s";
case 'debug[3]': // FFT bin mean index
return (value / 100).toFixed(2);
}
break;
case 'FFT_TIME':
switch (fieldName) {
case 'debug[0]':
return presentEnum(value, FFT_CALC_STEPS);
case 'debug[1]':
case 'debug[2]':
return value.toFixed(0) + "\u03BCs";
}
break;
case 'FFT_FREQ':
switch (fieldName) {
case 'debug[2]': // pre-dyn notch gyro [for selected axis]
case 'debug[3]': // raw gyro [for selected axis]
return Math.round(flightLog.gyroRawToDegreesPerSecond(value)) + "deg/s";
default:
return value.toFixed(0) + "Hz";
}
case 'DSHOT_RPM_TELEMETRY':
return value.toFixed(0) + "erpm";
case 'RPM_FILTER':
return value.toFixed(0) + "Hz";
case 'D_MIN':
switch (fieldName) {
case 'debug[0]': // roll gyro factor
case 'debug[1]': // roll setpoint Factor
return value.toFixed(0) + '%';
case 'debug[2]': // roll actual D
case 'debug[3]': // pitch actual D
return (value / 10).toFixed(1);
}
break;
case 'ITERM_RELAX':
switch (fieldName) {
case 'debug[0]': // roll setpoint high-pass filtered
return value.toFixed(0) + 'deg/s';
case 'debug[1]': // roll I-term relax factor
return value.toFixed(0) + '%';
case 'debug[3]': // roll absolute control axis error
return (value / 10).toFixed(1) + 'deg';
}
break;
case 'DYN_LPF':
switch (fieldName) {
case 'debug[0]': // gyro scaled [for selected axis]
case 'debug[3]': // pre-dyn notch gyro [for selected axis]
return Math.round(flightLog.gyroRawToDegreesPerSecond(value)) + "deg/s";
default:
return value.toFixed(0) + "Hz";
}
break;
case 'AC_ERROR':
return (value / 10).toFixed(1) + 'deg';
case 'AC_CORRECTION':
return (value / 10).toFixed(1) + 'deg/s';
}
return value.toFixed(0);
}
return "";
};
FlightLogFieldPresenter.fieldNameToFriendly = function(fieldName, debugMode) {
if (debugMode) {
if(fieldName.includes('debug')) {
var debugModeName = DEBUG_MODE[debugMode];
var debugFields;
if (debugModeName) {
debugFields = DEBUG_FRIENDLY_FIELD_NAMES[debugModeName];
}
if (!debugFields) {
if (fieldName === 'debug[all]') {
return 'Debug (' + (debugModeName || debugMode) + ')';
}
debugFields = DEBUG_FRIENDLY_FIELD_NAMES[DEBUG_MODE[0]];
}
return debugFields[fieldName];
}
}
if (FRIENDLY_FIELD_NAMES[fieldName]) {
return FRIENDLY_FIELD_NAMES[fieldName];
}
return fieldName;
};
})();