Code Monkey home page Code Monkey logo

cordova-plugin-sensors's Introduction

Cordova Sensors Plugin

The sensors are capable of providing raw data with high precision and accuracy, and are useful if you want to monitor three-dimensional device movement or positioning, or you want to monitor changes in the ambient environment near a device. For example, a game might track readings from a device's gravity sensor to infer complex user gestures and motions, such as tilt, shake, rotation, or swing. Likewise, a weather application might use a device's temperature sensor and humidity sensor to calculate and report the dewpoint, or a travel application might use the geomagnetic field sensor and accelerometer to report a compass bearing.

At this moment this plugin is implemented only for Android!

Demos

See in https://github.com/fabiorogeriosj/cordova-plugin-sensors-demo

Install

$ cordova plugin add https://github.com/fabiorogeriosj/cordova-plugin-sensors.git

Methods

sensors.enableSensor("TYPE_SENSOR")

Enable sensor.

sensors.disableSensor()

Disable sensor.

sensors.getState(successCallback, errorCallback)

Get values sensor.

Using in Ionic

  APP.controller("indexController", function ($scope, $interval){

      function onSuccess(values) {
          $scope.state = values[0];
      };
      
      function onError(error) {
          throw error;
      };

      document.addEventListener("deviceready", function () {
        
        sensors.enableSensor("PROXIMITY");

        $interval(function(){
          sensors.getState(onSuccess, onError);
        }, 100);


      }, false);

  });

Type sensors

PROXIMITY - Measures the proximity of an object in cm relative to the view screen of a device.

ACCELEROMETER - Measures the acceleration force in m/s2 that is applied to a device on all three physical axes (x, y, and z), including the force of gravity.

GRAVITY - Measures the force of gravity in m/s2 that is applied to a device on all three physical axes (x, y, z).

GYROSCOPE - Measures a device's rate of rotation in rad/s around each of the three physical axes (x, y, and z).

GYROSCOPE_UNCALIBRATED - Rate of rotation (without drift compensation) around the x axis.

LINEAR_ACCELERATION - Measures the acceleration force in m/s2 that is applied to a device on all three physical axes (x, y, and z), excluding the force of gravity.

ROTATION_VECTOR - Measures the orientation of a device by providing the three elements of the device's rotation vector.

STEP_COUNTER - Number of steps taken by the user since the last reboot while the sensor was activated.

GAME_ROTATION_VECTOR - Rotation vector component along the x axis (x * sin(θ/2)).

GEOMAGNETIC_ROTATION_VECTOR - Rotation vector component along the x axis (x * sin(θ/2)).

MAGNETIC_FIELD - Measures the ambient geomagnetic field for all three physical axes (x, y, z) in μT.

MAGNETIC_FIELD_UNCALIBRATED - Geomagnetic field strength (without hard iron calibration) along the x axis.

ORIENTATION - Measures degrees of rotation that a device makes around all three physical axes (x, y, z).

AMBIENT_TEMPERATURE - Measures the ambient room temperature in degrees Celsius (°C). See note below.

LIGHT - Measures the ambient light level (illumination) in lx.

PRESSURE - Measures the ambient air pressure in hPa or mbar.

RELATIVE_HUMIDITY - Measures the relative ambient humidity in percent (%).

TEMPERATURE - Measures the temperature of the device in degrees Celsius (°C).

For more information about sensors Android see Android Sensors Overview

cordova-plugin-sensors's People

Contributors

aszmyd avatar fabiorogeriosj avatar quentinroy avatar rhalff avatar simpler1 avatar yxliang01 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.