-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(sensors_plus): Configurable sample rate #2248
Conversation
Thank you for this valuable contribution. I will get to check your PRs by the end of this week. In the meantime, could you please fix formatting issues, so CI checks pass? |
…rAccelStreamHandler
…eterStreamHandler and gyroScopeStreamHandler to gyroscopeStreamHandler
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly fine to me except a few minor moments.
Will do some additional testing tomorrow on Android as results on real devices seemed a bit odd during testing today. Afterwards would be good to merge and release.
P.S. Sorry for getting back that late.
packages/sensors_plus/sensors_plus/example/ios/Runner.xcodeproj/project.pbxproj
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
As I mentioned in the previous comment on iOS everything works Ok, while on Android depending on version and device delays more than 200 ms don't always work and data is provided faster anyway.
However, it seems Ok based on the description of samplingPeriodUs
parameter: https://developer.android.com/reference/android/hardware/SensorManager.html#registerListener(android.hardware.SensorEventListener,%20android.hardware.Sensor,%20int)
Description
Support changing
samplingPeriod
for different sensors.Introduce
SensorInterval
class to provide 4 androids interval constants.Updated example
Rewrited ios platform-specific code in swift
Attention needed:
Implementation details:
xxx
EventStream
always return the same stream. If the method is called with differentsamplingPeriod
later, the stream is changed to the new value. All previous listeners are affected. Note that this is same behaviour as ios but different than android.In android, each registered handler has its own sampling period, and the system use the fastest sampling period value. For example, handler A with samplingPeriod=250ms and handler B with samplePeriod = 100ms are registered, the system try to update sensor every 100ms. But if handler B is unregistered later, system try to update sensor every 250ms then.
Known issue:
In previous version, FPPMagnetometerStreamHandlerPlus use
deviceMotion
instead ofmagnetometer
to allow iOS present calibration interaction. So, in iOS, userAccelerometerEventStream and magnetometerEventStream share the same sampling period. In android, they have their own sampling period. See also #2250.Related Issues
Resolve #439
Resolve #1318
Resolve #1381
#1280
Checklist
CHANGELOG.md
nor the plugin version inpubspec.yaml
files.flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?
!
in the title as explained in Conventional Commits).