-
Notifications
You must be signed in to change notification settings - Fork 501
GH-582 & GH-575: Updated the sensors to adhere to guidelines #610
Conversation
- enum names - compas low pass filter is now a param - updated docs - public constructors on data and events - stating an already started sensor will throw - sensor use the same units on all platforms Added a unit conversion API. #575
This comment has been minimized.
This comment has been minimized.
@@ -29,7 +29,7 @@ void Barometer_ReadingChanged(object sender, BarometerChangedEventArgs e) | |||
|
|||
var d = await tcs.Task; | |||
|
|||
Assert.True(d.Pressure >= 0); | |||
Assert.True(d.PressureInHectopascals >= 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed the property
"User Interface" | ||
}; | ||
public string[] Speeds { get; } = | ||
Enum.GetNames(typeof(SensorSpeed)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the fancy Enum.GetNames
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
much better!
[InlineData(1000, 17.4533)] | ||
[InlineData(57295.7795, 1000)] | ||
[InlineData(0, 0)] | ||
public void DegreesPerSecondToRadiansPerSecond(double degrees, double radians) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests, baby, tests!
@@ -17,10 +17,10 @@ public static void Start(SensorSpeed sensorSpeed) | |||
throw new FeatureNotSupportedException(); | |||
|
|||
if (IsMonitoring) | |||
return; | |||
throw new InvalidOperationException("Accelerometer has already been started."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throw when the sensor is started.
@@ -68,19 +68,19 @@ internal static void OnChanged(AccelerometerChangedEventArgs e) | |||
|
|||
public class AccelerometerChangedEventArgs : EventArgs | |||
{ | |||
internal AccelerometerChangedEventArgs(AccelerometerData reading) => Reading = reading; | |||
public AccelerometerChangedEventArgs(AccelerometerData reading) => Reading = reading; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
events are public
|
||
public AccelerometerData Reading { get; } | ||
} | ||
|
||
public readonly struct AccelerometerData : IEquatable<AccelerometerData> | ||
{ | ||
internal AccelerometerData(double x, double y, double z) | ||
public AccelerometerData(double x, double y, double z) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data is public
return UnitConverters.CoordinatesToMiles(latitudeStart, longitudeStart, latitudeEnd, longitudeEnd); | ||
default: | ||
throw new ArgumentOutOfRangeException(nameof(units)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the conversion logic into the unit conversions API so we can be cool!
Default = 0, | ||
UI = 1, | ||
Game = 2, | ||
Fastest = 3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re ordered enums and renamed values
const double milesToKilometers = 1.609344; | ||
const double milesToMeters = 1609.344; | ||
const double kilometersToMiles = 1.0 / milesToKilometers; | ||
const double celsiusToKelvin = 273.15; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constants, baby, constants!
Updated the sensors to adhere to guidelines:
Added a unit conversion API