Skip to content
Anders Bech Mellson edited this page Aug 25, 2014 · 9 revisions

Kiosker can send updates from the light sensor to a loaded webpage.

For this to work you have to implement a JavaScript function on your webpage with this signature

lightSensorUpdate(lux, deviceId)

lux is a float value ranging from 0.0 to 32768.0. The value is in SI lux units (m/s^2).

deviceId is a String with the id of the device calling the function.

You can start the lightsensor by using the sensorBridge object injected into your javascript. To get the sensorBridge object you need to have the setting addSensorBridge set to true in your settings.

To start the lightsensor call sensorBridge.startLightSensor() You stop the sensor again by calling sensorBridge.stopightSensor()

You can adjust the interval between updates by calling sensorBridge.setLightSensorDelaySpeed(int) the possible values range from 0 (fastest) to 3 (normal). These speeds follows the Android SensorManager delay speeds found here. You can only change the interval when the sensor is stopped.

Example JavaScript function

function lightSensorUpdate(lux, deviceId) {
      document.getElementById("lightsensorId").innerHTML = lux;
      document.getElementById("lightsensorUpdaterId").innerHTML = "updated by " + deviceId;
  }

You can see a demo webpage that uses the sensorBridge here.

Clone this wiki locally