Based on our experience designing hardware programming APIs for Johnny-Five, we proposed an alternative device sensory programming model for the Web Platform, that establishes a generic sensor class for all sensors to inherit from. That proposal was adopted and became the foundation for the Generic Sensor API. Working with Tobie Langel and Anssi Kostiainen at the W3C, we were able to drive interest and development, resulting in the suite of modern sensory APIs coming to the Web Platform.
Designing A Generic Sensor API For The Web Platform
Creating a set of web APIs for interacting with the physical world
Physical device sensor APIs for the web were originally introduced to the web platform as DeviceMotionEvent, DeviceOrientationEvent along with their respective
window.* event handlers:
oncompassneedscalibration. These early APIs were essentially just ports from the Core Motion APIs to WebKit JS APIs. Despite opening up exciting new possibilities for human interaction with web applications, this API design was identified as an anti-pattern that prohibited the platform from supporting multiple sensors of a given kind and abetted the proliferation of new sensor APIs that were unintuitive and nonsensical for the web platform. In 2012, other platform implementers announced work (Fri, 7 Dec 2012, Tue, 18 Dec 2012) on implementations and proposals for standardization of more new sensor APIs that attempted to force the same strange design pattern (DeviceLightEvent, DeviceProximityEvent). To be fair, we must mention that these designs were well-intentioned, with the assumption that API design consistency was a desirable trait.
By providing a clear and consistent way to describe programming interfaces for device sensors, the Generic Sensor API has opened the door for a wave of new web platform capabilities that are powerful and intuitive. Additionally, its strength as a thoughtfully designed base class has inspired a rebooting of several extant sensor APIs, for example
DeviceOrientationEvent have been superseded by the
Geolocation Sensor and
To track the progress of these new capabilities in the web platform, take a look at the latest test results for each new API: Accelerometer, Ambient Light, Generic Sensor, Geolocation Sensor, Gyroscope, Magnetometer, Orientation Sensor, and Proximity.
To see demonstration examples of these sensors, check out Intel's Generic Sensors Demo.
We'd love to hear from you. Get in touch!
P.O. Box 961436
Boston, MA 02196