-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added binding to Band distance sensor.
- Loading branch information
1 parent
a7198c4
commit 5c2ba8a
Showing
9 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
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
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
77 changes: 77 additions & 0 deletions
77
Microsoft.Band.WindowsRuntime/Sensors/BandDistanceReading.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.Band.Sensors; | ||
|
||
namespace Microsoft.Band.WindowsRuntime.Sensors | ||
{ | ||
internal sealed class BandDistanceReading : BandSensorReadingBase, IBandDistanceReading | ||
{ | ||
private readonly Band.Sensors.IBandDistanceReading reading; | ||
|
||
public BandDistanceReading(Band.Sensors.IBandDistanceReading reading) | ||
: base(reading) | ||
{ | ||
if (reading == null) | ||
{ | ||
throw new ArgumentNullException("reading"); | ||
} | ||
|
||
this.reading = reading; | ||
} | ||
|
||
#region IBandDistanceReading Members | ||
|
||
public MotionType CurrentMotion | ||
{ | ||
get | ||
{ | ||
return FromMotionType(this.reading.CurrentMotion); | ||
} | ||
} | ||
|
||
public double Pace | ||
{ | ||
get | ||
{ | ||
return this.reading.Pace; | ||
} | ||
} | ||
|
||
public double Speed | ||
{ | ||
get | ||
{ | ||
return this.reading.Speed; | ||
} | ||
} | ||
|
||
public long TotalDistance | ||
{ | ||
get | ||
{ | ||
return this.reading.TotalDistance; | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
private static MotionType FromMotionType(Band.Sensors.MotionType currentMotion) | ||
{ | ||
switch (currentMotion) | ||
{ | ||
case Band.Sensors.MotionType.Idle: return MotionType.Idle; | ||
case Band.Sensors.MotionType.Jogging: return MotionType.Jogging; | ||
case Band.Sensors.MotionType.Running: return MotionType.Running; | ||
case Band.Sensors.MotionType.Unknown: return MotionType.Unknown; | ||
case Band.Sensors.MotionType.Walking: return MotionType.Walking; | ||
|
||
default: | ||
|
||
throw new ArgumentOutOfRangeException("currentMotion"); | ||
} | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Microsoft.Band.WindowsRuntime/Sensors/BandDistanceSensor.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.Band.Sensors; | ||
|
||
namespace Microsoft.Band.WindowsRuntime.Sensors | ||
{ | ||
internal sealed class BandDistanceSensor : BandSensorBase<Band.Sensors.IBandDistanceReading, BandDistanceSensorReadingEventArgs>, IBandDistanceSensor | ||
{ | ||
public BandDistanceSensor(Band.Sensors.IBandSensor<Band.Sensors.IBandDistanceReading> sensor) | ||
: base(sensor) | ||
{ | ||
} | ||
|
||
protected override BandDistanceSensorReadingEventArgs CreateEventArgs(Band.Sensors.IBandDistanceReading reading) | ||
{ | ||
return new BandDistanceSensorReadingEventArgs(new BandDistanceReading(reading)); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Microsoft.Band.WindowsRuntime/Sensors/BandDistanceSensorReadingEventArgs.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
|
||
namespace Microsoft.Band.WindowsRuntime.Sensors | ||
{ | ||
public sealed class BandDistanceSensorReadingEventArgs | ||
{ | ||
public BandDistanceSensorReadingEventArgs(IBandDistanceReading sensorReading) | ||
{ | ||
if (sensorReading == null) | ||
{ | ||
throw new ArgumentNullException("sensorReading"); | ||
} | ||
|
||
this.SensorReading = sensorReading; | ||
} | ||
|
||
public IBandDistanceReading SensorReading { get; } | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Microsoft.Band.WindowsRuntime/Sensors/IBandDistanceReading.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Band.WindowsRuntime.Sensors | ||
{ | ||
public interface IBandDistanceReading : IBandSensorReading | ||
{ | ||
MotionType CurrentMotion { get; } | ||
|
||
double Pace { get; } | ||
|
||
double Speed { get; } | ||
|
||
long TotalDistance { get; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Microsoft.Band.WindowsRuntime/Sensors/IBandDistanceSensor.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Band.WindowsRuntime.Sensors | ||
{ | ||
public interface IBandDistanceSensor : IBandSensor | ||
{ | ||
event EventHandler<BandDistanceSensorReadingEventArgs> ReadingChanged; | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Microsoft.Band.WindowsRuntime.Sensors | ||
{ | ||
public enum MotionType | ||
{ | ||
Unknown = 0, | ||
|
||
Idle, | ||
Jogging, | ||
Running, | ||
Walking | ||
} | ||
} |