Rx Compass Smoothing Example for Windows Phone
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Properties
.gitignore
App.xaml
App.xaml.cs
ApplicationIcon.png
Background.png
MainPage.xaml
MainPage.xaml.cs
README.md
Rx Compass Smoothing.csproj
SplashScreenImage.jpg
compass.arrow.dark.png

README.md

Rx Compass Smoothing Example for Windows Phone

Companion blog post: http://factormystic.net/blog/using-reactive-extensions-to-smooth-compass-data-in-windows-phone

Reactive Extensions at work:

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);

Rotates the compass arrow:

<Image Stretch="None" Source="compass.arrow.dark.png" RenderTransformOrigin="0.5,0.5">
    <Image.RenderTransform>
        <RotateTransform x:Name="ArrowRotation" CenterX="0.5" CenterY="0.5" />
    </Image.RenderTransform>
</Image>