Socket
Socket
Sign inDemoInstall

cordova-plugin-barometer

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cordova-plugin-barometer

Cordova Device Barometer Plugin


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

Source

cordova-plugin-barometer

This plugin provides access to the device's barometer.

This plugin based on https://github.com/zanderso/cordova-plugin-barometer. Thanks Zachary Anderson for this work.

Installation

cordova plugin add cordova-plugin-barometer (from npm)
cordova plugin add https://github.com/olton/cordova-plugin-barometer.git (from git)

Supported Platforms

  • Android

Methods

  • navigator.barometer.getCurrentPressure
  • navigator.barometer.watchPressure
  • navigator.barometer.clearWatch

Objects

  • Pressure

navigator.barometer.getCurrentPressure

Get the current atmospheric pressure.

The pressure values are returned to the barometerSuccess callback function.

navigator.barometer.getCurrentPressure(barometerSuccess, barometerError);

Example

function onSuccess(pressure) {
    alert('Pressure: '  + pressure.val + '\n' +
          'Timestamp: ' + pressure.timestamp + '\n');
};

function onError() {
    alert('onError!');
};

navigator.barometer.getCurrentPressure(onSuccess, onError);

navigator.barometer.watchPressure

Retrieves the device's current Pressure at a regular interval, executing the barometerSuccess callback function each time. Specify the interval in milliseconds via the barometerOptions object's frequency parameter.

The returned watch ID references the barometers's watch interval, and can be used with navigator.barometer.clearWatch to stop watching the accelerometer.

var watchID = navigator.barometer.watchPressure(barometerSuccess,
                                                barometerError,
                                                [barometerOptions]);
  • barometerOptions: An object with the following optional keys:
  • frequency: How often to retrieve the Pressure in milliseconds. (Number) (Default: 10000)

Example

function onSuccess(pressure) {
    alert('Pressure: '  + pressure.val + '\n' +
          'Timestamp: ' + pressure.timestamp + '\n');
};

function onError() {
    alert('onError!');
};

var options = { frequency: 3000 };  // Update every 3 seconds

var watchID = navigator.barometer.watchPressure(onSuccess, onError, options);

navigator.barometer.clearWatch

Stop watching the Pressure referenced by the watchID parameter.

navigator.barometer.clearWatch(watchID);
  • watchID: The ID returned by navigator.barometer.watchPressure.

Example

var watchID = navigator.barometer.watchPressure(onSuccess, onError, options);

// ... later on ...

navigator.barometer.clearWatch(watchID);

Pressure

Contains Pressure data captured at a specific point in time.

Properties

  • val: Amount of pressure. (Number)
  • timestamp: Creation timestamp in milliseconds. (DOMTimeStamp)

Keywords

FAQs

Last updated on 06 May 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc