Sensor API: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 15: Line 15:
     sequence<Sensor> listSensors(); // List the available sensors on the device
     sequence<Sensor> listSensors(); // List the available sensors on the device
     attribute Function onSensorAvailable;
     attribute Function onSensorAvailable;
}
};
interface Sensor : EventTarget {
interface Sensor : EventTarget {
readonly attribute DOMString type;            // Vocabulary to be defined ("Acceleration", "AmbientLight")
  // Vocabulary to be defined ("Acceleration", "AmbientLight")
readonly attribute DOMString name;           // ("Accelerometer", "Compass", "Thermometer")
readonly attribute DOMString type;        
// ("Accelerometer", "Compass", "Thermometer")
readonly attribute DOMString name;           
// Another method to retrieve capabilities??
// Another method to retrieve capabilities??
}
};
interface SensorSession : EventTarget {
interface SensorSession : EventTarget {
     readonly attribute Sensor sensor;
     readonly attribute Sensor sensor;
Line 34: Line 36:
     attribute Function onSensorData;
     attribute Function onSensorData;
     attribute Function onError;
     attribute Function onError;
}
};
interface SensorData {
interface SensorData {
     readonly attribute any value;
     readonly attribute any value;
}
};
// New DOM Event 'sensordata'
// New DOM Event 'sensordata'
interface SensorDataEvent : Event {
interface SensorDataEvent : Event {
Line 45: Line 47:
                                 in boolean cancelable,
                                 in boolean cancelable,
                                 in SensorData data);
                                 in SensorData data);
}
};
interface SensorWatchOptions {
interface SensorWatchOptions {
     attribute  any highThreshold; // High threshold. If the sensor value is higher a data event will be raised
     attribute  any highThreshold; // High threshold. If the sensor value is higher a data event will be raised
Line 51: Line 53:
     attribute double relativeThreshold; // Notify only when a relative change in the magnitude meausured by the sensor occurs  
     attribute double relativeThreshold; // Notify only when a relative change in the magnitude meausured by the sensor occurs  
     attribute double interval; // Interval at which values will be provided by the sensor (milliseconds)
     attribute double interval; // Interval at which values will be provided by the sensor (milliseconds)
}
};




172

edits