Barometer Barometer Barometer Barometer Class
Definition
Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Prerelease APIs are identified by a Prerelease label.
[Contains prerelease APIs.]
Provides an interface for a barometric sensor to measure atmospheric pressure.
For an example implementation, see the barometer sample.
public : sealed class Barometer : IBarometerpublic sealed class Barometer : IBarometerPublic NotInheritable Class Barometer Implements IBarometer// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Properties
DeviceId DeviceId DeviceId DeviceId
Gets the device identifier.
public : PlatForm::String DeviceId { get; }public string DeviceId { get; }Public ReadOnly Property DeviceId As string// You can use this property in JavaScript.
- Value
- PlatForm::String string string string
The device identifier.
MaxBatchSize MaxBatchSize MaxBatchSize MaxBatchSize
Prerelease. Gets or sets the delay between batches of sensor information.
public : unsigned int MaxBatchSize { get; }public uint MaxBatchSize { get; }Public ReadOnly Property MaxBatchSize As uint// You can use this property in JavaScript.
- Value
- unsigned int uint uint uint
The delay between batches of sensor information in milliseconds.
| Device family |
Windows 10 Insider Preview (introduced v10.0.16257.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v5)
|
Remarks
This property is in reference to the frequency of ReadingChanged events.
Not all sensors support ReportLatency. If the sensor does not support this property, it will function the same as if you set this value to 0. Setting this value to 0 will use the default latency for the sensor.
If you set ReportLatency to a value higher than the maximum supported latency, the sensor will use the maximum supported latency. However, this property will not change in value. The maximum possible ReportLatency equals the MaxBatchSize times the ReportInterval.
Be aware that multiple applications could be dependent on a single sensor. Each of those applications can set a different value for ReportLatency. In this scenario, the sensor needs to try to accommodate the lowest value for ReportLatency. Because of this, the actual latency may not match the latency defined by this property in your application. This property corresponds to your ideal latency, which may not be the same latency on the sensor.
For more information about sensor batching, see Sensors.
MinimumReportInterval MinimumReportInterval MinimumReportInterval MinimumReportInterval
The smallest report interval that is supported by this barometer sensor.
public : unsigned int MinimumReportInterval { get; }public uint MinimumReportInterval { get; }Public ReadOnly Property MinimumReportInterval As uint// You can use this property in JavaScript.
- Value
- unsigned int uint uint uint
The smallest ReportInterval supported by the sensor.
ReportInterval ReportInterval ReportInterval ReportInterval
Gets or sets the current report interval for the barometer.
public : unsigned int ReportInterval { get; set; }public uint ReportInterval { get; set; }Public ReadWrite Property ReportInterval As uint// You can use this property in JavaScript.
- Value
- unsigned int uint uint uint
The current report interval.
Remarks
The report interval is specified in milliseconds.
The report interval will be set to a default value that will vary based on the sensor driver’s implementation. If your app does not want to use this default value, you should set the report interval to a non-zero value prior to registering an event handler or calling GetCurrentReading. The sensor will then attempt to allocate resources to satisfy the application’s requirements but the sensor also has to balance the needs of other apps using the sensor.
Changes to the report interval after an event handler has been registered or GetCurrentReading has been called may apply to the delivery of subsequent sensor readings.
Conversely, when an application is finished with the sensor, it should explicitly return the sensor to its default report interval by setting it to zero. This is important for power conservation, especially when using a language that may keep the sensor object active for an indefinite period prior to garbage collection.
Your application should consult the MinimumReportInterval property prior to setting the report interval to ensure that the sensor can honor the requested report interval. Setting a value below the minimum supported interval will either trigger an exception or have undefined results.
Setting a value of zero requests the driver to use its default report interval. As with requesting a specific interval, the driver may choose a different interval based on other client requests and internal logic.
ReportLatency ReportLatency ReportLatency ReportLatency
Prerelease. Gets or sets the delay between batches of sensor information.
public : unsigned int ReportLatency { get; set; }public uint ReportLatency { get; set; }Public ReadWrite Property ReportLatency As uint// You can use this property in JavaScript.
- Value
- unsigned int uint uint uint
The delay between batches of sensor information in milliseconds.
| Device family |
Windows 10 Insider Preview (introduced v10.0.16257.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v5)
|
Remarks
This property is in reference to the frequency of ReadingChanged events.
Not all sensors support ReportLatency. If the sensor does not support this property, it will function the same as if you set this value to 0. Setting this value to 0 will use the default latency for the sensor.
If you set ReportLatency to a value higher than the maximum supported latency, the sensor will use the maximum supported latency. However, this property will not change in value. The maximum possible ReportLatency equals the MaxBatchSize times the ReportInterval.
Be aware that multiple applications could be dependent on a single sensor. Each of those applications can set a different value for ReportLatency. In this scenario, the sensor needs to try to accommodate the lowest value for ReportLatency. Because of this, the actual latency may not match the latency defined by this property in your application. This property corresponds to your ideal latency, which may not be the same latency on the sensor.
For more information about sensor batching, see Sensors.
Methods
FromIdAsync(String) FromIdAsync(String) FromIdAsync(String) FromIdAsync(String)
Prerelease. Asynchronously obtains the sensor from its identifier.
public : static IAsyncOperation<Barometer> FromIdAsync(PlatForm::String deviceId)public static IAsyncOperation<Barometer> FromIdAsync(String deviceId)Public Static Function FromIdAsync(deviceId As String) As IAsyncOperation( Of Barometer )// You can use this method in JavaScript.
- deviceId
- PlatForm::String String String String
Returns the Barometer object from its identifier.
| Device family |
Windows 10 Insider Preview (introduced v10.0.16257.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v5)
|
GetCurrentReading() GetCurrentReading() GetCurrentReading() GetCurrentReading()
Gets the current reading for the barometer.
public : BarometerReading GetCurrentReading()public BarometerReading GetCurrentReading()Public Function GetCurrentReading() As BarometerReading// You can use this method in JavaScript.
The current atmospheric pressure according to this sensor.
GetDefault() GetDefault() GetDefault() GetDefault()
Returns the default barometer sensor.
public : static Barometer GetDefault()public static Barometer GetDefault()Public Static Function GetDefault() As Barometer// You can use this method in JavaScript.
Remarks
If no barometer sensor is available, this method will return the null pointer.
GetDeviceSelector() GetDeviceSelector() GetDeviceSelector() GetDeviceSelector()
Prerelease. Gets the device selector.
public : static PlatForm::String GetDeviceSelector()public static string GetDeviceSelector()Public Static Function GetDeviceSelector() As string// You can use this method in JavaScript.
Returns the device selector, if it exists; otherwise, null.
| Device family |
Windows 10 Insider Preview (introduced v10.0.16257.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v5)
|
Events
ReadingChanged ReadingChanged ReadingChanged ReadingChanged
Occurs each time the barometer sensor reports a new value.
public : event TypedEventHandler ReadingChanged<Barometer, BarometerReadingChangedEventArgs>public event TypedEventHandler ReadingChanged<Barometer, BarometerReadingChangedEventArgs>Public Event ReadingChanged<Barometer, BarometerReadingChangedEventArgs>// You can use this event in JavaScript.
Remarks
An application may register this event handler to obtain sensor readings. The application must establish a desired ReportInterval. This sets the frequency of the ReadingChanged event.