W3C home > Mailing lists > Public > public-device-apis@w3.org > June 2015

[sensors] Add a threshold option

From: Tobie Langel via GitHub <sysbot+gh@w3.org>
Date: Fri, 05 Jun 2015 10:12:33 +0000
To: public-device-apis@w3.org
Message-ID: <issues.opened-85498455-1433499152-sysbot+gh@w3.org>
tobie has just created a new issue for https://github.com/w3c/sensors:

== Add a threshold option ==
Johnn-Five implements a [treshold attribute][1] which determines the 
amount of change necessary of the value of the sensor to trigger a 
`change` event. Given we want to support sensors with multiple values,
 we'd at least need to add an attribute for each value. It might be 
simpler to add a method that would compare the current values with the
 last emitted ones and return a boolean (which would be used 
internally to decide whether or nor to trigger the `change` event). So
 for example setting up a geoloc sensor to only trigger when changing 
hemisphere:

```js
new Sensor({
    change: function(prev, curr) {
        return Math.sign(prev.latitude) !== Math.sign(curr.latitude);
    }
});
```

[1]: https://github.com/rwaldron/johnny-five/wiki/Sensor#events

See https://github.com/w3c/sensors/issues/25
Received on Friday, 5 June 2015 10:12:35 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 14:54:05 UTC