pyupm_mma7660 module¶
-
class
pyupm_mma7660.
MMA7660
(bus, address=76)[source]¶ Bases:
object
API for the MMA7660 I2C 3-Axis Digital Accelerometer.
ID: mma7660
Name: I2C 3-axis Digital Accelerometer (1.5g)
Other Names: Grove 3-Axis Digital Accelerometer (1.5g)
Category: accelerometer
Manufacturer: seeed
Connection: i2c gpio
Link:http://www.nxp.com/products/sensors/accelerometers/3-axis- accelerometers/1.5g-low-g-digital-accelerometer:MMA7660FC UPM module for the MMA7660 I2C 3-axis digital accelerometer. This device supports a variety of capabilities, including the generation of interrupts for various conditions, tilt and basic gesture detection, and X/Y/Z-axis measurements of g-forces being applied (up to 1.5g)
This module was tested with the Grove 3-Axis Digital Accelerometer (1.5g)
C++ includes: mma7660.hpp
-
getAcceleration
(*args)[source]¶ std::vector<float> getAcceleration()
Reads the current acceleration values. The returned memory is statically allocated and will be overwritten on each call.
std::vector containing x, y, z.
-
getRawValues
(*args)[source]¶ std::vector<int> getRawValues()
Reads the current value of conversion. The returned memory is statically allocated and will be overwritten on each call.
std::vector containing x, y, z.
-
getVerifiedAxis
(axis)[source]¶ int getVerifiedAxis(MMA7660_REG_T axis)
Reads an axis, verifying its validity. The value passed must be one of REG_XOUT, REG_YOUT, or REG_ZOUT.
axis: Axis to read
Axis value
-
getVerifiedTilt
()[source]¶ uint8_t getVerifiedTilt()
Reads the tilt register, verifying its validity
Tilt value
-
installISR
(pin, isr, arg)[source]¶ void installISR(int pin, void(*isr)(void *), void *arg)
Installs an interrupt service routine (ISR) to be called when an interrupt occurs
pin: GPIO pin to use as the interrupt pin
isr: Pointer to a function to be called on interrupt
arg: Pointer to an object to be supplied as an argument to the ISR.
-
readByte
(reg)[source]¶ uint8_t readByte(uint8_t reg)
Reads a byte value from a register
reg: Register location to read from
Value in a specified register
-
setInterruptBits
(ibits)[source]¶ bool setInterruptBits(uint8_t ibits)
Enables interrupt generation based on passed interrupt bits. The bits are a bitmask of the requested MMA7660_INTR_T values. Note: the device must be in the standby mode to set this register.
ibits: Sets the requested interrupt bits
True if successful
-
setModeActive
()[source]¶ void setModeActive()
Puts the device in the active mode. In this mode, register writes are not allowed. Place the device in the standby mode before attempting to write registers.
-
setModeStandby
()[source]¶ void setModeStandby()
Puts the device in the standby (power saving) mode. Note: when in the standby mode, there is no valid data in the registers. In addition, the only way to write a register is to put the device in the standby mode.
-
setSampleRate
(sr)[source]¶ bool setSampleRate(MMA7660_AUTOSLEEP_T sr)
Sets the sampling rate of the sensor. The value supplied must be one of the MMA7660_AUTOSLEEP_T values.
sr: One of the MMA7660_AUTOSLEEP_T values
True if successful
-
tiltBackFront
()[source]¶ uint8_t tiltBackFront()
Reads tiltBackFront bits
The value returned is one of the MMA7660_TILT_BF_T values
Bits corresponding to the BackFront tilt status
-