W3C home > Mailing lists > Public > public-device-apis-log@w3.org > November 2016

Re: [magnetometer] Provide API to access uncalibrated magnetometer values

From: Alexander Shalamov via GitHub <sysbot+gh@w3.org>
Date: Tue, 15 Nov 2016 12:37:33 +0000
To: public-device-apis-log@w3.org
Message-ID: <issue_comment.created-260630242-1479213452-sysbot+gh@w3.org>
> What about option 3bis:

I think we should not derive uncalibrated reading interface from 
calibrated. This can produce unwanted side effects when developer 
checks what kind of reading is provided by sensor.

Omited constructors and init dicts to shorten example:

```
interface Magnetometer : Sensor {
   // Not needed, just to illustrate that the reading interface is 
changed
   // depending on the passed SensorOptions.
   readonly attribute (MagnetometerReading or MagnetometerRawReading) 
reading;
};

interface MagnetometerReading : SensorReading {
  readonly attribute double x;
  readonly attribute double y;
  readonly attribute double z;
};

interface MagnetometerRawReading : SensorReading {
  readonly attribute double x;
  readonly attribute double y;
  readonly attribute double z;
  readonly attribute double xBias;
  readonly attribute double yBias;
  readonly attribute double zBias;
};
```


Therefore:

```
rawMagn.reading instanceof MagnetometerRawReading; // true
rawMagn.reading instanceof MagnetometerReading; // false
```

@tobie What do you think?

-- 
GitHub Notification of comment by alexshalamov
Please view or discuss this issue at 
https://github.com/w3c/magnetometer/issues/16#issuecomment-260630242 
using your GitHub account
Received on Tuesday, 15 November 2016 12:37:40 UTC

This archive was generated by hypermail 2.4.0 : Monday, 4 July 2022 12:47:53 UTC