2016-06-07 22:57:41 +01:00
|
|
|
.. currentmodule:: pyb
|
2017-10-10 15:24:44 +01:00
|
|
|
.. _pyb.Accel:
|
2016-06-07 22:57:41 +01:00
|
|
|
|
2014-10-31 22:21:37 +00:00
|
|
|
class Accel -- accelerometer control
|
|
|
|
====================================
|
2014-10-31 01:37:19 +00:00
|
|
|
|
|
|
|
Accel is an object that controls the accelerometer. Example usage::
|
|
|
|
|
|
|
|
accel = pyb.Accel()
|
|
|
|
for i in range(10):
|
|
|
|
print(accel.x(), accel.y(), accel.z())
|
|
|
|
|
|
|
|
Raw values are between -32 and 31.
|
|
|
|
|
|
|
|
|
|
|
|
Constructors
|
|
|
|
------------
|
|
|
|
|
2022-06-21 05:33:23 +01:00
|
|
|
.. class:: Accel()
|
2014-10-31 01:37:19 +00:00
|
|
|
|
|
|
|
Create and return an accelerometer object.
|
2019-12-04 04:02:54 +00:00
|
|
|
|
2014-10-31 01:37:19 +00:00
|
|
|
Methods
|
|
|
|
-------
|
|
|
|
|
2016-06-08 14:21:28 +01:00
|
|
|
.. method:: Accel.filtered_xyz()
|
2014-10-31 01:37:19 +00:00
|
|
|
|
|
|
|
Get a 3-tuple of filtered x, y and z values.
|
|
|
|
|
2015-07-08 11:10:51 +01:00
|
|
|
Implementation note: this method is currently implemented as taking the
|
|
|
|
sum of 4 samples, sampled from the 3 previous calls to this function along
|
|
|
|
with the sample from the current call. Returned values are therefore 4
|
|
|
|
times the size of what they would be from the raw x(), y() and z() calls.
|
|
|
|
|
2016-06-08 14:21:28 +01:00
|
|
|
.. method:: Accel.tilt()
|
2014-10-31 01:37:19 +00:00
|
|
|
|
|
|
|
Get the tilt register.
|
|
|
|
|
2016-06-08 14:21:28 +01:00
|
|
|
.. method:: Accel.x()
|
2014-10-31 01:37:19 +00:00
|
|
|
|
|
|
|
Get the x-axis value.
|
|
|
|
|
2016-06-08 14:21:28 +01:00
|
|
|
.. method:: Accel.y()
|
2014-10-31 01:37:19 +00:00
|
|
|
|
|
|
|
Get the y-axis value.
|
|
|
|
|
2016-06-08 14:21:28 +01:00
|
|
|
.. method:: Accel.z()
|
2014-10-31 01:37:19 +00:00
|
|
|
|
|
|
|
Get the z-axis value.
|
2016-11-08 07:14:56 +00:00
|
|
|
|
|
|
|
Hardware Note
|
|
|
|
-------------
|
|
|
|
|
|
|
|
The accelerometer uses I2C bus 1 to communicate with the processor. Consequently
|
|
|
|
when readings are being taken pins X9 and X10 should be unused (other than for
|
|
|
|
I2C). Other devices using those pins, and which therefore cannot be used
|
|
|
|
concurrently, are UART 1 and Timer 4 channels 1 and 2.
|