[Vibration API] Confusing list indexing in spec

"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