Motion - iOS Sensor Readings: accelerometer, magnetometer, gyroscope and more

Hello everyone!

As a first test of Fuse’s Foreign Code support I decided to implement all the available iOS sensor readings related to motion. My goal was to make the data easily available via observables as well as through a JS API. I also hoped to learn some Uno and ObjC while I was at it, since I’ve never used either before. The whole of the library was finished some months ago, however I’ve been waiting for the new event system that came in Fuse 0.30.0 (great work, there!) that enables us to create reliable event emitters from Uno that are usable in JS. Since its release I’ve finalised Motion and I believe it’s ready to use, if someone can find a good use for it.

More information, examples and source available here: https://github.com/AlexGustafsson/fuse-motion

Example usage in UX

<StackPanel Background="0,0,0,0.2" Padding="10, 5, 5, 5">
	<Text Value="{accelerometer.acceleration.x}" FontSize="20"/>
	<Text Value="{accelerometer.acceleration.y}" FontSize="20"/>
	<Text Value="{accelerometer.acceleration.z}" FontSize="20"/>
</StackPanel>

Example usage in JS

var Motion = require("Motion");

//Subscribe to all available sensors with a delay of 200ms (0.2sec)
Motion.Subscribe("accelerometer magnetometer gyroscope motion activity", 0.2);

Motion.on("gyroscopeChanged", function(values){
  values = JSON.parse(values);

  if(!values.error)
    console.log(values);
});

I’d also like to thank Olle Fredriksson who helped me sort out the final problem I had.

Awesome work, love it! :slight_smile: