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

[Vibration API] Confusing list indexing in spec

From: Justin Lebar <justin.lebar@gmail.com>
Date: Fri, 15 Jun 2012 17:41:51 -0400
Message-ID: <CAFWcpZ47m44C0d2ECMBX==8QEvZY+=D0Ca4XjPyy2HyC8XsUYg@mail.gmail.com>
To: public-device-apis@w3.org
"A vibration pattern represented by a list of time entries. Odd
entries represent vibration time in milliseconds, even entries still
periods in milliseconds between the vibrations."

This is pretty confusing, because it's not clear whether list indexing
starts at 0 or 1 [1].

The way I documented this in Mozilla's source is:

   *   This list of integers specifies a vibration pattern.  Given a list of
   *   numbers
   *
   *      [a_1, b_1, a_2, b_2, ..., a_n]
   *
   *   the device will vibrate for a_1 milliseconds, then be still for b_1
   *   milliseconds, then vibrate for a_2 milliseconds, and so on.
   *
   *   The list may contain an even or an odd number of elements, but if you
   *   pass an even number of elements (that is, if your list ends with b_n
   *   instead of a_n), the final element doesn't specify anything meaningful.

If you want something less verbose, how about:

"A list of numbers representing a vibration pattern.  For example, the
pattern [5, 10, 15] will cause the device to vibrate for 5ms, be still
for 10ms, and then vibrate for 15ms."

Regards,
-Justin

[1] https://github.com/mozilla-b2g/gaia/pull/1704/files#r995646
Received on Friday, 15 June 2012 21:42:42 UTC

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