Closed colinta closed 10 years ago
I like it! However, do you feel like this should go into BubbleWrap? What about making it its own thing?
It could, but it bears a striking resemblance to BW::Compass and BW::Location... I like that we have a collection of "Core-*" wrappers in a community project, too.
Looks good - I wonder if CMDeviceMotion#attitude
, CMDeviceMotion#gravity
, CMAttitude#rotationMatrix
and CMAttitude#quarternion
should have their own convenience methods, since (I believe) the only way to get those with this API is with device.every
.
or maybe allow BW::Motion.device
to be scoped like BW::Motion.device(:attitude, :gravity, :matrix)
etc?
I looked at the device motion stuff again, and it's not able to be scoped; the data will be there regardless, so might as well have it in the result
object.
I'm not a big fan of how the result
objects looks for the BW::Motion.device
interface, though. It would make sense to 'scope' those results, so that they look like the other result objects.
The hash interface was meant to be similar to the other Location & Compass result objects.
Hi, this is a first-draft of an interface for CoreMotion. @markrickert, @clayallsopp - what do you guys think?
Motion
Interface for the accelerometer, gyroscope, and magnetometer sensors (the CoreMotion framework). You can access each sensor individually, or you can get data from all of them at once using the
BW::Motion.device
interface, which delegates toCMMotionManager#deviceMotion
.Each sensor has an
every
andonce
method.every
expects a time interval, and you will need to retain the object it returns and call#stop
on it when you are done with the data.The
every
andonce
methods can accept a:queue
option. The default value is a queue that runs on the main loop, so that UI updates can be processed in the block. This is useful, but not recommended by Apple, since the events can come in at a high rate. If you want to use a background queue, you can either specify an NSOperationQueue object, or you can use one of these symbols::main
-NSOperationQueue.mainQueue
, this is the default value.:background
- BubbleWrap will create a newNSOperationQueue
.:current
- BubbleWrap will useNSOperationQueue.currentQueue
.If you pass a string instead, a new queue will be created and its
name
property will be set to that string.The
CMDeviceMotion
interface (BW::Motion.device
) accepts a:reference
option, which specifies theCMAttitudeReferenceFrame
. The default value is the same as the one thatCMMotionManager
uses, which is returned by theCMMotionManager#attitudeReferenceFrame
method. This option should be passed to theevery
oronce
method.Accelerometer
Gyroscope
Magnetometer
Device Motion
This is an amalgam of all the motion sensor data.