Skip to content

Commit

Permalink
Fix Sense HAT sample (#1257)
Browse files Browse the repository at this point in the history
* Fix Sense HAT sample

* Added units, fixed actual formatting issue

* percent
  • Loading branch information
CamSoper authored Nov 6, 2020
1 parent 9b7aad3 commit de328ca
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/devices/SenseHat/samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
using Iot.Device.SenseHat;
using UnitsNet;

// Sample for each device separately
// LedMatrix.Run();
// Joystick.Run();
// AccelerometerAndGyroscope.Run();
// Magnetometer.Run();
// TemperatureAndHumidity.Run();
// PressureAndTemperature.Run();

// set this to the current sea level pressure in the area for correct altitude readings
var defaultSeaLevelPressure = WeatherHelper.MeanSeaLevel;

Expand Down Expand Up @@ -51,12 +43,12 @@

Console.WriteLine($"Temperature Sensor 1: {tempValue.DegreesCelsius:0.#}\u00B0C");
Console.WriteLine($"Temperature Sensor 2: {temp2Value.DegreesCelsius:0.#}\u00B0C");
Console.WriteLine($"Pressure: {preValue:0.##}hPa");
Console.WriteLine($"Altitude: {altValue:0.##}m");
Console.WriteLine($"Acceleration: {sh.Acceleration}g");
Console.WriteLine($"Angular rate: {sh.AngularRate}DPS");
Console.WriteLine($"Magnetic induction: {sh.MagneticInduction}gauss");
Console.WriteLine($"Relative humidity: {humValue:0.#}%");
Console.WriteLine($"Pressure: {preValue.Hectopascals:0.##} hPa");
Console.WriteLine($"Altitude: {altValue.Meters:0.##} m");
Console.WriteLine($"Acceleration: {sh.Acceleration} g");
Console.WriteLine($"Angular rate: {sh.AngularRate} DPS");
Console.WriteLine($"Magnetic induction: {sh.MagneticInduction} gauss");
Console.WriteLine($"Relative humidity: {humValue.Percent:0.#}%");

// WeatherHelper supports more calculations, such as saturated vapor pressure, actual vapor pressure and absolute humidity.
Console.WriteLine($"Heat index: {WeatherHelper.CalculateHeatIndex(tempValue, humValue).DegreesCelsius:0.#}\u00B0C");
Expand Down

0 comments on commit de328ca

Please sign in to comment.