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

GH-348: Add Barometer Sensor API #459

Merged
merged 14 commits into from
Aug 15, 2018
Merged

GH-348: Add Barometer Sensor API #459

merged 14 commits into from
Aug 15, 2018

Conversation

jamesmontemagno
Copy link
Collaborator

Description of Change

Describe your changes here.

Bugs Fixed

Provide links to issues here. Ensure that a GitHub issue was created for your feature or bug fix before sending PR.

API Changes

List all API changes here (or just put None), example:

API
public class Barometer
{
    bool IsMonitoring { get; private set; }
    void Start(SensorSpeed speed);
    void Stop();
    event BarometerChangedEventHandler ReadingChanged;
}

    public class BarometerChangedEventHandler : EventArgs
    {
        double Pressure {get; private set}; //In Hectopascals (hPA)
    }

Behavioral Changes

Describe any non-bug related behavioral changes that may change how users app behaves when upgrading to this version of the codebase.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Updated documentation (see walkthrough)

* Implemented Barometer across all platforms.

* Added tests modeling compass sensor tests

* Added more unit tests

* Added samples

* removed unused usings

* Added barometer to all sensor page

* Updated docs

* Removed unused ios properties

* Implemented maps as mentioned in branch name issue. also fixed a spelling mistake

* Fixed typo which caused ui bug

* Finished reset of fork

* removed proj items

* Android emulator has barometer

* Code cleanup, lazy introduction, access modifiers

* Modified barometer to be in sync with generic event handlers

* copy paste

* Updated barometer docs/en/Xamarin.Essentials/Barometer.xml

* Finished updating barometer docs

* Removed remnants from delegates

* Changes requested in pr

* iOS queue change

* Sensor Speed

* sensor reset
@jamesmontemagno jamesmontemagno added this to the 0.10.0-preview milestone Aug 9, 2018
@dend

This comment has been minimized.

@dend

This comment has been minimized.

@jamesmontemagno jamesmontemagno added the awaiting-review This PR needs to have a set of eyes on it label Aug 9, 2018
@dend

This comment has been minimized.

@dend
Copy link
Contributor

dend commented Aug 9, 2018

⚠️ Validation status: warnings

File Status Preview URL Details
⚠️Warning Details

  • Line 80: [Warning] Failed to run script W:\w41c-s_dependentPackages\ECMA2Yaml\tools\Run.ps1 with exit code -1

For more details, please refer to the build report.

Note: If you changed an existing file name or deleted a file, broken links in other files to the deleted or renamed file are listed only in the full build report.

@dend

This comment has been minimized.

static void OnChanged(BarometerChangedEventArgs e)
{
if (useSyncContext)
MainThread.BeginInvokeOnMainThread(() => ReadingChanged?.Invoke(null, e));
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we check here whether we are already in main thread? If so we should use the else branch

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is what BeginInvokeMainThread does :) and your fixes fix this :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that comment prompted my investigation. Irrelevant now :)

public BarometerData Reading { get; }
}

public struct BarometerData
Copy link
Contributor

Choose a reason for hiding this comment

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

make struct readonly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess the question is should the struct itself be readonly or should the property be readonly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah i guess cause auto property is readonly alreayd then the struct could be. I don't think this is an issue at all. All of them could be. Can you add that to your PR for other structs?

Copy link
Contributor

Choose a reason for hiding this comment

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

I already did, it is in my struct optimization pr.

@dend

This comment has been minimized.

true;
#elif __IOS__
// iphone 6 and never have a barometer. looking in how to test this.
Xamarin.Essentials.DeviceInfo.DeviceType == Xamarin.Essentials.DeviceType.Physical;
Copy link
Contributor

Choose a reason for hiding this comment

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

Still needs the iphone 6 and newer check

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think is fine, need to just document it.

@@ -176,6 +176,29 @@
<Button Grid.Row="5" Grid.Column="1" Text="Stop" Command="{Binding StopCommand}"
IsEnabled="{Binding IsActive}" />
</Grid>
<Label Text="Monitor barometer for changes." FontAttributes="Bold" Margin="12" />
<Grid x:Name="GridBarometer">
Copy link
Contributor

Choose a reason for hiding this comment

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

Compress this Layout?

@dend

This comment has been minimized.

@Mrnikbobjeff
Copy link
Contributor

The BarometerData struct is missing the override for GetHashCode and does not implement IEquatable yet

@dend

This comment has been minimized.

@dend

This comment has been minimized.

@dend
Copy link
Contributor

dend commented Aug 14, 2018

✅ Validation status: passed

File Status Preview URL Details
DeviceTests/DeviceTests.Shared/Barometer_Shared.cs ✅Succeeded
DeviceTests/DeviceTests.Shared/HardwareSupport.cs ✅Succeeded
DeviceTests/DeviceTests.Shared/Traits.cs ✅Succeeded
Samples/Samples/View/AllSensorsPage.xaml ✅Succeeded
Samples/Samples/View/AllSensorsPage.xaml.cs ✅Succeeded
Samples/Samples/View/BarometerPage.xaml ✅Succeeded
Samples/Samples/View/BarometerPage.xaml.cs ✅Succeeded
Samples/Samples/ViewModel/BarometerViewModel.cs ✅Succeeded
Samples/Samples/ViewModel/CompassViewModel.cs ✅Succeeded
Samples/Samples/ViewModel/HomeViewModel.cs ✅Succeeded
Tests/Barometer_Tests.cs ✅Succeeded
Xamarin.Essentials/Accelerometer/Accelerometer.shared.cs ✅Succeeded
Xamarin.Essentials/Barometer/Barometer.android.cs ✅Succeeded
Xamarin.Essentials/Barometer/Barometer.ios.cs ✅Succeeded
Xamarin.Essentials/Barometer/Barometer.netstandard.cs ✅Succeeded
Xamarin.Essentials/Barometer/Barometer.shared.cs ✅Succeeded
Xamarin.Essentials/Barometer/Barometer.uwp.cs ✅Succeeded
Xamarin.Essentials/Compass/Compass.shared.cs ✅Succeeded
Xamarin.Essentials/Gyroscope/Gyroscope.shared.cs ✅Succeeded
Xamarin.Essentials/Magnetometer/Magnetometer.shared.cs ✅Succeeded
Xamarin.Essentials/OrientationSensor/OrientationSensor.shared.cs ✅Succeeded
docs/en/FrameworksIndex/xamarin-essentials-android.xml ✅Succeeded
docs/en/FrameworksIndex/xamarin-essentials-ios.xml ✅Succeeded
docs/en/FrameworksIndex/xamarin-essentials-uwp.xml ✅Succeeded
docs/en/FrameworksIndex/xamarin-essentials.xml ✅Succeeded
docs/en/Xamarin.Essentials/Barometer.xml ✅Succeeded
docs/en/Xamarin.Essentials/BarometerChangedEventArgs.xml ✅Succeeded
docs/en/Xamarin.Essentials/BarometerData.xml ✅Succeeded
docs/en/Xamarin.Essentials/DeviceInfo.xml ✅Succeeded
docs/en/index.xml ✅Succeeded

For more details, please refer to the build report.

Note: If you changed an existing file name or deleted a file, broken links in other files to the deleted or renamed file are listed only in the full build report.

@dend
Copy link
Contributor

dend commented Aug 15, 2018

✅ Validation status: passed

File Status Preview URL Details
DeviceTests/DeviceTests.Shared/Barometer_Shared.cs ✅Succeeded
DeviceTests/DeviceTests.Shared/HardwareSupport.cs ✅Succeeded
DeviceTests/DeviceTests.Shared/Traits.cs ✅Succeeded
Samples/Samples/View/AllSensorsPage.xaml ✅Succeeded
Samples/Samples/View/AllSensorsPage.xaml.cs ✅Succeeded
Samples/Samples/View/BarometerPage.xaml ✅Succeeded
Samples/Samples/View/BarometerPage.xaml.cs ✅Succeeded
Samples/Samples/ViewModel/BarometerViewModel.cs ✅Succeeded
Samples/Samples/ViewModel/CompassViewModel.cs ✅Succeeded
Samples/Samples/ViewModel/HomeViewModel.cs ✅Succeeded
Tests/Barometer_Tests.cs ✅Succeeded
Xamarin.Essentials/Accelerometer/Accelerometer.shared.cs ✅Succeeded
Xamarin.Essentials/Barometer/Barometer.android.cs ✅Succeeded
Xamarin.Essentials/Barometer/Barometer.ios.cs ✅Succeeded
Xamarin.Essentials/Barometer/Barometer.netstandard.cs ✅Succeeded
Xamarin.Essentials/Barometer/Barometer.shared.cs ✅Succeeded
Xamarin.Essentials/Barometer/Barometer.uwp.cs ✅Succeeded
Xamarin.Essentials/Compass/Compass.shared.cs ✅Succeeded
Xamarin.Essentials/Gyroscope/Gyroscope.shared.cs ✅Succeeded
Xamarin.Essentials/Magnetometer/Magnetometer.shared.cs ✅Succeeded
Xamarin.Essentials/OrientationSensor/OrientationSensor.shared.cs ✅Succeeded
docs/en/FrameworksIndex/xamarin-essentials-android.xml ✅Succeeded
docs/en/FrameworksIndex/xamarin-essentials-ios.xml ✅Succeeded
docs/en/FrameworksIndex/xamarin-essentials-uwp.xml ✅Succeeded
docs/en/FrameworksIndex/xamarin-essentials.xml ✅Succeeded
docs/en/Xamarin.Essentials/Barometer.xml ✅Succeeded
docs/en/Xamarin.Essentials/BarometerChangedEventArgs.xml ✅Succeeded
docs/en/Xamarin.Essentials/BarometerData.xml ✅Succeeded
docs/en/Xamarin.Essentials/DeviceInfo.xml ✅Succeeded
docs/en/index.xml ✅Succeeded

For more details, please refer to the build report.

Note: If you changed an existing file name or deleted a file, broken links in other files to the deleted or renamed file are listed only in the full build report.

@mattleibow mattleibow merged commit fee59d6 into master Aug 15, 2018
@mattleibow mattleibow deleted the feature/issue-348 branch August 15, 2018 15:08
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.

4 participants