You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if( isrFired ){ // If our isr flag is set then clear the interrupts on the ICM
216
220
isrFired = false;
217
221
myICM.getAGMT(); // get the A, G, M, and T readings
218
-
// printScaledAGMT( myICM.agmt); // This function takes into account the sclae settings from when the measurement was made to calculate the values with units
222
+
// printScaledAGMT( myICM.agmt); // This function takes into account the scale settings from when the measurement was made to calculate the values with units
219
223
SERIAL_PORT.println(F("Shock detected"));
220
224
digitalWrite(LED_PIN, HIGH);
221
-
lastTrigerred=millis();
225
+
lastTriggered = millis();
222
226
delay(30);
223
227
myICM.clearInterrupts(); // This would be efficient... but not compatible with Uno
224
228
}
225
229
226
-
myICM.clearInterrupts(); // clear interrupts for next time -
227
-
// usually you'd do this only if an interrupt has occurred, however
230
+
myICM.clearInterrupts(); // clear interrupts for next time -
231
+
// usually you'd do this only if an interrupt has occurred, however
228
232
// on the 328p I2C usage can block interrupts. This means that sometimes
229
233
// an interrupt is missed. When missed, if using an edge-based interrupt
230
-
// and only clearing interrupts when one was detected there will be no more
231
-
// edges to respond to, so no more interrupts will be detected. Here are
234
+
// and only clearing interrupts when one was detected there will be no more
235
+
// edges to respond to, so no more interrupts will be detected. Here are
232
236
// some possible solutions:
233
237
// 1. use a level based interrupt
234
238
// 2. use the pulse-based interrupt in ICM settings (set cfgIntLatch to false)
235
239
// 3. use a microcontroller with nestable interrupts
236
240
// 4. clear the interrupts often
237
-
if(millis()-lastTrigerred>1000)
238
-
digitalWrite(LED_PIN, LOW);;
241
+
242
+
if(millis() - lastTriggered > 1000) // Turn the LED off after one second
0 commit comments