🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

cordova-plugin-barometer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

cordova-plugin-barometer

Cordova Device Barometer Plugin

unpublished
latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
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

phonegap

FAQs

Package last updated on 06 May 2016

Did you know?

Socket

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