Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

GH-582 & GH-575: Updated the sensors to adhere to guidelines #610

Merged
merged 1 commit into from
Nov 5, 2018

Conversation

mattleibow
Copy link
Contributor

  • Updated the sensors to adhere to guidelines:

    • 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

 - 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
@mattleibow mattleibow added this to the 1.0.0 milestone Nov 5, 2018
@mattleibow mattleibow added the awaiting-review This PR needs to have a set of eyes on it label Nov 5, 2018
@ghost

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);
Copy link
Contributor Author

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));
Copy link
Contributor Author

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

Copy link
Collaborator

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)
Copy link
Contributor Author

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.");
Copy link
Contributor Author

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;
Copy link
Contributor Author

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)
Copy link
Contributor Author

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));
}
Copy link
Contributor Author

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,
Copy link
Contributor Author

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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constants, baby, constants!

@mattleibow mattleibow merged commit 6cbf633 into dev/api-fix Nov 5, 2018
@mattleibow mattleibow deleted the dev/api-fix-sensors branch November 5, 2018 22:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting-review This PR needs to have a set of eyes on it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants