@@ -86,37 +86,75 @@ void getData()
8686 {
8787 // printDebug("getData: online.IMU = " + (String)online.IMU + "\r\n");
8888
89- if (myICM. dataReady () )
89+ if (settings. imuUseDMP == false )
9090 {
91- // printDebug("getData: myICM.dataReady = " + (String)myICM.dataReady() + "\r\n");
92-
93- myICM.getAGMT (); // Update values
94-
95- if (settings.logIMUAccel )
91+ if (myICM.dataReady ())
92+ {
93+ // printDebug("getData: myICM.dataReady = " + (String)myICM.dataReady() + "\r\n");
94+
95+ myICM.getAGMT (); // Update values
96+
97+ if (settings.logIMUAccel )
98+ {
99+ sprintf (tempData, " %.2f,%.2f,%.2f," , myICM.accX (), myICM.accY (), myICM.accZ ());
100+ strcat (outputData, tempData);
101+ }
102+ if (settings.logIMUGyro )
103+ {
104+ sprintf (tempData, " %.2f,%.2f,%.2f," , myICM.gyrX (), myICM.gyrY (), myICM.gyrZ ());
105+ strcat (outputData, tempData);
106+ }
107+ if (settings.logIMUMag )
108+ {
109+ sprintf (tempData, " %.2f,%.2f,%.2f," , myICM.magX (), myICM.magY (), myICM.magZ ());
110+ strcat (outputData, tempData);
111+ }
112+ if (settings.logIMUTemp )
113+ {
114+ sprintf (tempData, " %.2f," , myICM.temp ());
115+ strcat (outputData, tempData);
116+ }
117+ }
118+ // else
119+ // {
120+ // printDebug("getData: myICM.dataReady = " + (String)myICM.dataReady() + "\r\n");
121+ // }
122+ }
123+ else
124+ {
125+ myICM.readDMPdataFromFIFO (&dmpData);
126+ while (myICM.status == ICM_20948_Stat_FIFOMoreDataAvail)
96127 {
97- sprintf (tempData, " %.2f,%.2f,%.2f," , myICM.accX (), myICM.accY (), myICM.accZ ());
128+ myICM.readDMPdataFromFIFO (&dmpData); // Empty the FIFO - make sure data contains the most recent data
129+ }
130+ if (settings.imuLogDMPQuat6 )
131+ {
132+ sprintf (tempData, " %.3f,%.3f,%.3f," , ((double )dmpData.Quat6 .Data .Q1 ) / 1073741824.0 ,
133+ ((double )dmpData.Quat6 .Data .Q2 ) / 1073741824.0 , ((double )dmpData.Quat6 .Data .Q3 ) / 1073741824.0 );
98134 strcat (outputData, tempData);
99135 }
100- if (settings.logIMUGyro )
136+ if (settings.imuLogDMPQuat9 )
101137 {
102- sprintf (tempData, " %.2f,%.2f,%.2f," , myICM.gyrX (), myICM.gyrY (), myICM.gyrZ ());
138+ sprintf (tempData, " %.3f,%.3f,%.3f,%d," , ((double )dmpData.Quat9 .Data .Q1 ) / 1073741824.0 ,
139+ ((double )dmpData.Quat9 .Data .Q2 ) / 1073741824.0 , ((double )dmpData.Quat9 .Data .Q3 ) / 1073741824.0 , dmpData.Quat9 .Data .Accuracy );
103140 strcat (outputData, tempData);
104141 }
105- if (settings.logIMUMag )
142+ if (settings.imuLogDMPAccel )
106143 {
107- sprintf (tempData, " %.2f,%.2f,%.2f ," , myICM. magX (), myICM. magY (), myICM. magZ () );
144+ sprintf (tempData, " %d,%d,%d ," , dmpData. Raw_Accel . Data . X , dmpData. Raw_Accel . Data . Y , dmpData. Raw_Accel . Data . Z );
108145 strcat (outputData, tempData);
109146 }
110- if (settings.logIMUTemp )
147+ if (settings.imuLogDMPGyro )
148+ {
149+ sprintf (tempData, " %d,%d,%d," , dmpData.Raw_Gyro .Data .X , dmpData.Raw_Gyro .Data .Y , dmpData.Raw_Gyro .Data .Z );
150+ strcat (outputData, tempData);
151+ }
152+ if (settings.imuLogDMPCpass )
111153 {
112- sprintf (tempData, " %.2f, " , myICM. temp () );
154+ sprintf (tempData, " %d,%d,%d, " , dmpData. Compass . Data . X , dmpData. Compass . Data . Y , dmpData. Compass . Data . Z );
113155 strcat (outputData, tempData);
114156 }
115157 }
116- // else
117- // {
118- // printDebug("getData: myICM.dataReady = " + (String)myICM.dataReady() + "\r\n");
119- // }
120158 }
121159
122160 // Append all external sensor data on linked list to outputData
@@ -844,6 +882,91 @@ void gatherDeviceValues()
844882 }
845883 }
846884 break ;
885+ // case DEVICE_QWIIC_BUTTON:
886+ // {
887+ // QwiicButton *nodeDevice = (QwiicButton *)temp->classPtr;
888+ // struct_QWIIC_BUTTON *nodeSetting = (struct_QWIIC_BUTTON *)temp->configPtr;
889+ // if (nodeSetting->log == true)
890+ // {
891+ // long pressedPopped = 0;
892+ // while (nodeDevice->isPressedQueueEmpty() == false)
893+ // {
894+ // pressedPopped = nodeDevice->popPressedQueue();
895+ // }
896+ // if (nodeSetting->logPressed)
897+ // {
898+ // sprintf(tempData, "%.03f,", ((float)pressedPopped) / 1000.0); // Record only the most recent press - that's the best we can do
899+ // strcat(outputData, tempData);
900+ // }
901+ //
902+ // long clickedPopped = 0;
903+ // while (nodeDevice->isClickedQueueEmpty() == false)
904+ // {
905+ // clickedPopped = nodeDevice->popClickedQueue();
906+ // nodeSetting->ledState ^= 1; // Toggle nodeSetting->ledState on _every_ click (not just the most recent)
907+ // }
908+ // if (nodeSetting->logClicked)
909+ // {
910+ // sprintf(tempData, "%.03f,", ((float)clickedPopped) / 1000.0); // Record only the most recent click - that's the best we can do
911+ // strcat(outputData, tempData);
912+ // }
913+ //
914+ // if (nodeSetting->toggleLEDOnClick)
915+ // {
916+ // if (nodeSetting->ledState)
917+ // nodeDevice->LEDon(nodeSetting->ledBrightness);
918+ // else
919+ // nodeDevice->LEDoff();
920+ // sprintf(tempData, "%d,", nodeSetting->ledState);
921+ // strcat(outputData, tempData);
922+ // }
923+ // }
924+ // }
925+ // break;
926+ case DEVICE_BIO_SENSOR_HUB:
927+ {
928+ SparkFun_Bio_Sensor_Hub *nodeDevice = (SparkFun_Bio_Sensor_Hub *)temp->classPtr ;
929+ struct_BIO_SENSOR_HUB *nodeSetting = (struct_BIO_SENSOR_HUB *)temp->configPtr ;
930+ if (nodeSetting->log == true )
931+ {
932+ bioData body;
933+ if ((nodeSetting->logHeartrate ) || (nodeSetting->logConfidence ) || (nodeSetting->logOxygen ) || (nodeSetting->logStatus ) || (nodeSetting->logExtendedStatus ) || (nodeSetting->logRValue ))
934+ {
935+ body = nodeDevice->readBpm ();
936+ }
937+ if (nodeSetting->logHeartrate )
938+ {
939+ sprintf (tempData, " %d," , body.heartRate );
940+ strcat (outputData, tempData);
941+ }
942+ if (nodeSetting->logConfidence )
943+ {
944+ sprintf (tempData, " %d," , body.confidence );
945+ strcat (outputData, tempData);
946+ }
947+ if (nodeSetting->logOxygen )
948+ {
949+ sprintf (tempData, " %d," , body.oxygen );
950+ strcat (outputData, tempData);
951+ }
952+ if (nodeSetting->logStatus )
953+ {
954+ sprintf (tempData, " %d," , body.status );
955+ strcat (outputData, tempData);
956+ }
957+ if (nodeSetting->logExtendedStatus )
958+ {
959+ sprintf (tempData, " %d," , body.extStatus );
960+ strcat (outputData, tempData);
961+ }
962+ if (nodeSetting->logRValue )
963+ {
964+ sprintf (tempData, " %.01f," , body.rValue );
965+ strcat (outputData, tempData);
966+ }
967+ }
968+ }
969+ break ;
847970 default :
848971 SerialPrintf2 (" printDeviceValue unknown device type: %s\r\n " , getDeviceName (temp->deviceType ));
849972 break ;
@@ -887,14 +1010,30 @@ void printHelperText(bool terminalOnly)
8871010
8881011 if (online.IMU )
8891012 {
890- if (settings.logIMUAccel )
891- strcat (helperText, " aX,aY,aZ," );
892- if (settings.logIMUGyro )
893- strcat (helperText, " gX,gY,gZ," );
894- if (settings.logIMUMag )
895- strcat (helperText, " mX,mY,mZ," );
896- if (settings.logIMUTemp )
897- strcat (helperText, " imu_degC," );
1013+ if (settings.imuUseDMP == false )
1014+ {
1015+ if (settings.logIMUAccel )
1016+ strcat (helperText, " aX,aY,aZ," );
1017+ if (settings.logIMUGyro )
1018+ strcat (helperText, " gX,gY,gZ," );
1019+ if (settings.logIMUMag )
1020+ strcat (helperText, " mX,mY,mZ," );
1021+ if (settings.logIMUTemp )
1022+ strcat (helperText, " imu_degC," );
1023+ }
1024+ else
1025+ {
1026+ if (settings.imuLogDMPQuat6 )
1027+ strcat (helperText, " Q6_1,Q6_2,Q6_3," );
1028+ if (settings.imuLogDMPQuat9 )
1029+ strcat (helperText, " Q9_1,Q9_2,Q9_3,HeadAcc," );
1030+ if (settings.imuLogDMPAccel )
1031+ strcat (helperText, " RawAX,RawAY,RawAZ," );
1032+ if (settings.imuLogDMPGyro )
1033+ strcat (helperText, " RawGX,RawGY,RawGZ," );
1034+ if (settings.imuLogDMPCpass )
1035+ strcat (helperText, " RawMX,RawMY,RawMZ," );
1036+ }
8981037 }
8991038
9001039 // Step through list, printing values as we go
@@ -1244,6 +1383,40 @@ void printHelperText(bool terminalOnly)
12441383 }
12451384 }
12461385 break ;
1386+ // case DEVICE_QWIIC_BUTTON:
1387+ // {
1388+ // struct_QWIIC_BUTTON *nodeSetting = (struct_QWIIC_BUTTON *)temp->configPtr;
1389+ // if (nodeSetting->log)
1390+ // {
1391+ // if (nodeSetting->logPressed)
1392+ // strcat(helperText, "pressS,");
1393+ // if (nodeSetting->logClicked)
1394+ // strcat(helperText, "clickS,");
1395+ // if (nodeSetting->toggleLEDOnClick)
1396+ // strcat(helperText, "LED,");
1397+ // }
1398+ // }
1399+ // break;
1400+ case DEVICE_BIO_SENSOR_HUB:
1401+ {
1402+ struct_BIO_SENSOR_HUB *nodeSetting = (struct_BIO_SENSOR_HUB *)temp->configPtr ;
1403+ if (nodeSetting->log )
1404+ {
1405+ if (nodeSetting->logHeartrate )
1406+ strcat (helperText, " bpm," );
1407+ if (nodeSetting->logConfidence )
1408+ strcat (helperText, " conf%," );
1409+ if (nodeSetting->logOxygen )
1410+ strcat (helperText, " O2%," );
1411+ if (nodeSetting->logStatus )
1412+ strcat (helperText, " stat," );
1413+ if (nodeSetting->logExtendedStatus )
1414+ strcat (helperText, " eStat," );
1415+ if (nodeSetting->logRValue )
1416+ strcat (helperText, " O2R," );
1417+ }
1418+ }
1419+ break ;
12471420 default :
12481421 SerialPrintf2 (" \n printerHelperText device not found: %d\r\n " , temp->deviceType );
12491422 break ;
0 commit comments