99 * Additional computed fields are derived from the original data set and added as new fields in the resulting data.
1010 * Window based smoothing of fields is offered.
1111 */
12- function FlightLog ( logData ) {
12+ function FlightLog ( logData , newSettings ) {
1313 var
14- ADDITIONAL_COMPUTED_FIELD_COUNT = 6 , /** attitude + PID_SUM **/
14+ ADDITIONAL_COMPUTED_FIELD_COUNT = 15 , /** attitude + PID_SUM + PID_ERROR + RCCOMMAND_SCALED + GYROADC_SCALED **/
1515
1616 that = this ,
1717 logIndex = false ,
@@ -38,25 +38,7 @@ function FlightLog(logData) {
3838 //Public fields:
3939 this . parser = parser ;
4040
41- this . settings = [ // FlightLog Settings
42- { label : "Rates" ,
43- parameters :
44- [
45- { // Index 0
46- label : "Roll Rate" ,
47- value : 75
48- } ,
49- { // Index 1
50- label : "Pitch Rate" ,
51- value : 75
52- } ,
53- { // Index 2
54- label : "Yaw Rate" ,
55- value : 45
56- }
57- ]
58- } ,
59- ] ;
41+ this . settings = newSettings ;
6042
6143 this . getMainFieldCount = function ( ) {
6244 return fieldNames . length ;
@@ -221,6 +203,8 @@ function FlightLog(logData) {
221203 fieldNames . push ( "heading[0]" , "heading[1]" , "heading[2]" ) ;
222204 fieldNames . push ( "axisSum[0]" , "axisSum[1]" , "axisSum[2]" ) ;
223205 fieldNames . push ( "axisError[0]" , "axisError[1]" , "axisError[2]" ) ; // Custom calculated error field
206+ fieldNames . push ( "rcCommands[0]" , "rcCommands[1]" , "rcCommands[2]" ) ; // Custom calculated error field
207+ fieldNames . push ( "gyroADCs[0]" , "gyroADCs[1]" , "gyroADCs[2]" ) ; // Custom calculated error field
224208
225209 fieldNameToIndex = { } ;
226210 for ( i = 0 ; i < fieldNames . length ; i ++ ) {
@@ -563,8 +547,18 @@ function FlightLog(logData) {
563547 destFrame [ fieldIndex ++ ] =
564548 ( gyroADC [ axis ] !== undefined ? that . gyroRawToDegreesPerSecond ( srcFrame [ gyroADC [ axis ] ] ) : 0 ) -
565549 ( rcCommand [ axis ] !== undefined ? that . rcCommandRawToDegreesPerSecond ( srcFrame [ rcCommand [ axis ] ] , axis ) : 0 ) ;
566- console . log ( )
567- }
550+ }
551+ // Calculate the Scaled rcCommand (in deg/s)
552+ for ( var axis = 0 ; axis < 3 ; axis ++ ) {
553+ destFrame [ fieldIndex ++ ] =
554+ ( rcCommand [ axis ] !== undefined ? that . rcCommandRawToDegreesPerSecond ( srcFrame [ rcCommand [ axis ] ] , axis ) : 0 ) ;
555+ }
556+
557+ // Calculate the scaled Gyro ADC
558+ for ( var axis = 0 ; axis < 3 ; axis ++ ) {
559+ destFrame [ fieldIndex ++ ] =
560+ ( gyroADC [ axis ] !== undefined ? that . gyroRawToDegreesPerSecond ( srcFrame [ gyroADC [ axis ] ] ) : 0 ) ;
561+ }
568562
569563 }
570564 }
@@ -921,13 +915,20 @@ FlightLog.prototype.rcCommandRawToDegreesPerSecond = function(value, axis) {
921915
922916 // ReWrite or LUXFloat only
923917
918+
924919 if ( axis == 2 /*YAW*/ ) {
925920 return ( ( this . settings [ 0 ] . parameters [ axis ] . value + 47 ) * value ) >> 7 ;
926921 } else { /*ROLL or PITCH */
927922 return ( ( this . settings [ 0 ] . parameters [ axis ] . value + 27 ) * value ) >> 6 ;
928923 }
929- } ;
930924
925+ // var sysConfig = this.getSysConfig();
926+ // if(axis==2 /*YAW*/) {
927+ // return ((this.getSysConfig().yRate + 47) * value ) >> 7;
928+ // } else { /*ROLL or PITCH */
929+ // return ((((axis==0)?this.getSysConfig().rRate:this.getSysConfig().pRate) + 27) * value ) >> 6;
930+ // }
931+ } ;
931932
932933FlightLog . prototype . getReferenceVoltageMillivolts = function ( ) {
933934 return this . vbatADCToMillivolts ( this . getSysConfig ( ) . vbatref ) ;
0 commit comments