@@ -27,6 +27,12 @@ void AccelerationSensor::initSensor()
2727 icm.startGyro (21 , 500 ); // Gyro ODR = 100 Hz, Full Scale Range = 2000 dps
2828 activeSensor = ICM42670X ;
2929 }
30+ else if (icm2.begin_I2C (0x68 , &Wire1))
31+ {
32+ icm2.setAccelRange (ICM20948_ACCEL_RANGE_8_G );
33+ icm2.setAccelRateDivisor (10.25 ); // 100 Hz sample rate
34+ activeSensor = ICM20948 ;
35+ }
3036 else
3137 {
3238 Serial.println (" No compatible acceleration sensor found" );
@@ -46,7 +52,7 @@ float probSett = 0.0;
4652float probStanding = 0.0 ;
4753float anomaly = 0.0 ;
4854
49- float prevAccTime = millis();
55+ // float prevAccTime = millis();
5056
5157bool AccelerationSensor::readSensorData ()
5258{
@@ -75,13 +81,25 @@ bool AccelerationSensor::readSensorData()
7581 buffer[ix++] = (imu_event.gyro [1 ]*2.0 )/6550.0 ;
7682 buffer[ix++] = (imu_event.gyro [2 ]*2.0 )/6550.0 ;
7783 }
84+ else if (activeSensor == ICM20948 )
85+ {
86+ sensors_event_t a, g, m, temp;
87+ icm2.getEvent (&a, &g, &m, &temp);
88+ buffer[ix++] = a.acceleration .x ;
89+ buffer[ix++] = a.acceleration .y ;
90+ buffer[ix++] = a.acceleration .z ;
91+ buffer[ix++] = g.gyro .x ;
92+ buffer[ix++] = g.gyro .y ;
93+ buffer[ix++] = g.gyro .z ;
94+ }
7895 else
7996 {
8097 return false ; // No sensor active
8198 }
8299
83- Serial.println (millis () - prevAccTime);
84- prevAccTime = millis ();
100+ // Serial.print("acc: ");
101+ // Serial.println(millis() - prevAccTime);
102+ // prevAccTime = millis();
85103
86104 // one second interval
87105 if (EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE <= ix)
0 commit comments