Skip to content

This plugin helps to get intensity from the light sensor in a device through cordova platform

Notifications You must be signed in to change notification settings

DeshanKTD/cordova-plugin-lightsensor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cordova-plugin-lightsensor

This plugin can be use to get intensity level that falls in to the device. The API supports to one time call and repeated calls which will directed to callback functions.

A successful response receive as a JSON, {"intensity":5} The value that get from reading object is in Lux (measurement unit)

Installation

cordova plugin add https://github.com/DeshanKTD/cordova-plugin-lightsensor

Methods

  • window.plugin.lightsensor.getReading
  • window.plugin.lightsensor.watchReadings
  • window.plugin.lightsensor.stop

window.plugin.lightsensor.getReading

This method get a single reading from the lightsensor sensor


	window.plugin.lightsensor.getReading(
	    function success(reading){
	      console.log(JSON.stringify(reading)); 
	      alert(JSON.stringify(reading));
	      // Output: {"intensity": 25}
	    }, 
	    function error(message){
	     console.log(message);
	    }
  	)
  

reading object properties

  • intensity

window.plugin.lightsensor.watchReadings

This helps get reapeated readings from the lightsensor sensor.

	
		window.plugin.lightsensor.watchReadings(
		    function success(reading){
		      console.log(JSON.stringify(reading));
		      alert(JSON.stringify(reading)); 
		      // Output: {"intensity": 25}
		    }, 
		    function error(message){
		     console.log(message);
		    }
		  )
	

reading object properties

  • intensity

window.plugin.lightsensor.stop

Stops getting readings from the lightsensor sensor.

	
	  window.plugin.lightsensor.stop([watchID])
	

Supported Platforms

  • Android

About

This plugin helps to get intensity from the light sensor in a device through cordova platform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published