Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@factormystic
Created May 6, 2012 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save factormystic/2613466 to your computer and use it in GitHub Desktop.
Save factormystic/2613466 to your computer and use it in GitHub Desktop.
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