aeyrium-sensor icon indicating copy to clipboard operation
aeyrium-sensor copied to clipboard

Event doesn't always cancel

Open lukehold opened this issue 3 years ago • 0 comments

Hi,

Great package but I'm seeing mixed results with cancelling the stream. I'm recording actions and my app grabs the pitch and roll at the start of a record session, then records events and deducts this first event from each record. I do this because the phone could be at any angle to start with and it needs to be normalised. So grabbing a first value of pitch and roll is vital, and hence I need the stream to close so it doesn't keep updating this value. I use:

_vectorStream = AeyriumSensor.sensorEvents.listen(
      (SensorEvent event) {
        if (event.pitch != null) {
          _sensorVectorOffset = Vector(event.pitch, event.roll);
          _vectorStream.cancel();
        }
      },
    );

Usually this works for the first four or five attempts and then after that it no longer closes the stream, and starts overriding this offset value.

Can you please advise what the issue is and how to close your stream consistently?

Luke

lukehold avatar Jul 19 '20 09:07 lukehold