pyb.Accel.rst 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. .. currentmodule:: pyb
  2. .. _pyb.Accel:
  3. class Accel -- accelerometer control
  4. ====================================
  5. Accel is an object that controls the accelerometer. Example usage::
  6. accel = pyb.Accel()
  7. for i in range(10):
  8. print(accel.x(), accel.y(), accel.z())
  9. Raw values are between -32 and 31.
  10. Constructors
  11. ------------
  12. .. class:: pyb.Accel()
  13. Create and return an accelerometer object.
  14. Methods
  15. -------
  16. .. method:: Accel.filtered_xyz()
  17. Get a 3-tuple of filtered x, y and z values.
  18. Implementation note: this method is currently implemented as taking the
  19. sum of 4 samples, sampled from the 3 previous calls to this function along
  20. with the sample from the current call. Returned values are therefore 4
  21. times the size of what they would be from the raw x(), y() and z() calls.
  22. .. method:: Accel.tilt()
  23. Get the tilt register.
  24. .. method:: Accel.x()
  25. Get the x-axis value.
  26. .. method:: Accel.y()
  27. Get the y-axis value.
  28. .. method:: Accel.z()
  29. Get the z-axis value.
  30. Hardware Note
  31. -------------
  32. The accelerometer uses I2C bus 1 to communicate with the processor. Consequently
  33. when readings are being taken pins X9 and X10 should be unused (other than for
  34. I2C). Other devices using those pins, and which therefore cannot be used
  35. concurrently, are UART 1 and Timer 4 channels 1 and 2.