How to configure logger to log only when some conditions are satisfied
Hello. I am developing an iOS application that can log sensor data to MMS+ and retrieve stored data.
My question is that it is possible to log accelerometer, gyro data only when certain conditions are met (e.g. if data.x > 0.5 & data.y > 0.5 & data.z > 0.5 => start log) and stop when they are unsatisfied. Also, data stored before logging is stopped should not be deleted when logging is restarted.(I hope the data to be logged following the existing data after restarting.) Since it takes a long time between device startup and data retrieval, I want to save device memory as much as possible.
The normal way to do this would be to use the DataProcessor system. There is a passthrough filter, which can act as a switch on incoming data. The comparison filter could check your x, y, or z threshold and then, for instance, allow the next 10 samples through by changing the state of the passthrough filter. Implementing the AND condition would need several filters cascaded -- that is, if the x passes the comparison, allow a sample to pass to a y comparison, if that passes, allow a sample to pass to the z comparison, if that passes, allow a sample through to the logger.