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

Re: [sensors] Should unit option's behavior be defined in the Generic Sensor API?

From: Anssi Kostiainen via GitHub <sysbot+gh@w3.org>
Date: Thu, 03 Sep 2015 11:22:19 +0000
To: public-device-apis@w3.org
Message-ID: <issue_comment.created-137411433-1441279338-sysbot+gh@w3.org>
I see the following three buckets:

* Only one sensible default unit. Never raises an error. For example:

`new sensors.AmbientLight(); // lux (default)`
`new sensors.AmbientLight({ unit: 'lx' }); // lux`

* Multiple possible default units. Conversion between the units always
 possible, thus every implementation supports all units. Never raises 
an error either. For example:

`new sensors.Temperature(); // Celsius (default)`
`new sensors.Temperature({ unit: 'C' }); // Celsius`
`new sensors.Temperature({ unit: 'F' }); // Fahrenheit`
`new sensors.Temperature({ unit: 'K' }); // kelvin`

* Multiple possible default units. Conversion between the units is not
 always possible. Raises an error if an implementation is not able to 
support the required unit. For example:

`new sensors.Orientation(); // Tait–Bryan angles (default, for Device 
Orientation compat)`
`new sensors.Orientation({ unit: 'tait-bryan' }); // Tait–Bryan 
angles`
`new sensors.Orientation({ unit: 'rotation-matrix' }); // Rotation 
matrix, may raise an error`
`new sensors.Orientation({ unit: 'quaternion' }); // Quaternion, may 
raise an error`

Specifically related to device orientation, based on what I see in the
 awesome [Device Orientation API article][1] by @richtr a conversion 
is possible between various representations assuming the platform 
provides an extra bit of information that the `window.orientation` API
 provides (do all relevant platform APIs expose corresponding data?).

So I guess my conclusion is we should define a default unit for each 
concrete sensor and also raise an error if the unit required is not 
supported. The latter behaviour should be defined in the Generic 
Sensor API spec.

Can we learn something from Johnny-Five or other platforms -- how 
they're handling the third case where the platform may not support all
 the unit options?

[1]: https://dev.opera.com/articles/w3c-device-orientation-usage/

-- 
GitHub Notif of comment by anssiko
See https://github.com/w3c/sensors/issues/62#issuecomment-137411433
Received on Thursday, 3 September 2015 11:22:20 UTC

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