Skip to content
This repository was 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
mattleibow merged 1 commit intodev/api-fixfrom
dev/api-fix-sensors
Nov 5, 2018
Merged

GH-582 & GH-575: Updated the sensors to adhere to guidelines#610
mattleibow merged 1 commit intodev/api-fixfrom
dev/api-fix-sensors

Conversation

@mattleibow
Copy link
Copy Markdown
Member

  • 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.

var d = await tcs.Task;

Assert.True(d.Pressure >= 0);
Assert.True(d.PressureInHectopascals >= 0);
Copy link
Copy Markdown
Member 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
Copy Markdown
Member 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
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Tests, baby, tests!


if (IsMonitoring)
return;
throw new InvalidOperationException("Accelerometer has already been started.");
Copy link
Copy Markdown
Member 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.

public class AccelerometerChangedEventArgs : EventArgs
{
internal AccelerometerChangedEventArgs(AccelerometerData reading) => Reading = reading;
public AccelerometerChangedEventArgs(AccelerometerData reading) => Reading = reading;
Copy link
Copy Markdown
Member 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 readonly struct AccelerometerData : IEquatable<AccelerometerData>
{
internal AccelerometerData(double x, double y, double z)
public AccelerometerData(double x, double y, double z)
Copy link
Copy Markdown
Member 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
Copy Markdown
Member 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
Copy Markdown
Member 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
Copy Markdown
Member 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