Skip to content
rseetham edited this page Aug 17, 2014 · 4 revisions

Library for controlling accelerometer MMA7660 with the Beaglebone Black's I2C's pins.
This library can be used for tap detection, shake detection and orientation detection. Datasheet is available here


API

MMA7660(i2c_no)

Creates an instance of the class MMA7660 i2c_no can be 1 or 2 based on the i2c bus used

MMA7660.getX()

Returns the value of X dimension. Value of X can be from -31 to 32

MMA7660.getY()

Returns the value of Y dimension. Value of Y can be from -31 to 32

MMA7660.getZ()

Returns the value of Z dimension. Value of Z can be from -31 to 32

MMA7660.getXYZ()

Returns a list of X,Y and Z dimension values. Values of X, Y and Z can be from -31 to 32

MMA7660.setInterrupt(configuration, interrupt_pin, callback_funtion)

Sets interrupt on interrupt_pin and calls callback_funtion when interrupt occurs

configuration :
INT_FB - Front/Back position change causes an interrupt
INT_PL - Up/Down/Right/Left position change causes interrupt
INT_PD - Successful tap detection causes an interrupt
INT_SHX - Shake detected on the X-axis causes an interrupt
INT_SHY - Shake detected on the Y-axis causes an interrupt
INT_SHZ - Shake detected on the Z-axis causes an interrupt

######callback_funtion : has to take(back_front, portrait_landscape, tap, shake) as parameters.
back_front = 1 - Front: Equipment is lying on its front
back_front = 2 - Back: Equipment is lying on its back

portrait_landscape = 1 - Left: Equipment is in landscape mode to the left
portrait_landscape = 2 - Right: Equipment is in landscape mode to the right
portrait_landscape = 5 - Down: Equipment standing vertically in inverted orientation
portrait_landscape = 6 - Up: Equipment standing vertically in normal orientation

tap = 0 - Tap Not Detected
tap = 1 - Tap Detected

shake = 0 - Shake Not Detected
shake = 1 - Shake Detected

MMA7660.settapthreshold(value)

sets tap detection threshold Tap detection threshold = +/-value counts

MMA7660.settiltfilter(value)

Sets the rate of tilt debounce filtering When value = 0 - Tilt debounce filtering is disabled. For other values, value number of samples have to match before the device updates portrait/ landscape data.

MMA7660.setTapDebounce(value)

Sets the tap detection debounce filtering to value The tap detection debounce filtering requires value adjacent tap detection tests to be the same to trigger a tap event

MMA7660.getOrientation()

returns a list with the back_front and portrait_landscape data.

back_front = 1 - Front: Equipment is lying on its front back_front = 2 - Back: Equipment is lying on its back

portrait_landscape = 1 - Left: Equipment is in landscape mode to the left portrait_landscape = 2 - Right: Equipment is in landscape mode to the right portrait_landscape = 5 - Down: Equipment standing vertically in inverted orientation portrait_landscape = 6 - Up: Equipment standing vertically in normal orientation

MMA7660.removeInterrupt()

Detaches the interrupt

MMA7660.close()

sets the device in standby mode and closes the connection to the device.

Clone this wiki locally