Created
May 6, 2012 04:39
-
-
Save factormystic/2613466 to your computer and use it in GitHub Desktop.
example #8 for http://factormystic.net/blog/using-reactive-extensions-to-smooth-compass-data-in-windows-phone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Observable.FromEvent<SensorReadingEventArgs<CompassReading>>(compass, "CurrentValueChanged") | |
.BufferWithTime(TimeSpan.FromSeconds(2)) | |
.Select(headings => headings.Select(e => e.EventArgs.SensorReading.TrueHeading).Sum() / headings.Count()) | |
.ObserveOnDispatcher() | |
.Subscribe(heading => this.ArrowRotation.Angle = 360 - heading); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment