# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_pyupm_mma7660', [dirname(__file__)])
except ImportError:
import _pyupm_mma7660
return _pyupm_mma7660
if fp is not None:
try:
_mod = imp.load_module('_pyupm_mma7660', fp, pathname, description)
finally:
fp.close()
return _mod
_pyupm_mma7660 = swig_import_helper()
del swig_import_helper
else:
import _pyupm_mma7660
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr_nondynamic(self, class_type, name, static=1):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
if (not static):
return object.__getattr__(self, name)
else:
raise AttributeError(name)
def _swig_getattr(self, class_type, name):
return _swig_getattr_nondynamic(self, class_type, name, 0)
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object:
pass
_newclass = 0
def getVersion():
return _pyupm_mma7660.getVersion()
getVersion = _pyupm_mma7660.getVersion
def new_intp():
return _pyupm_mma7660.new_intp()
new_intp = _pyupm_mma7660.new_intp
def copy_intp(value):
return _pyupm_mma7660.copy_intp(value)
copy_intp = _pyupm_mma7660.copy_intp
def delete_intp(obj):
return _pyupm_mma7660.delete_intp(obj)
delete_intp = _pyupm_mma7660.delete_intp
def intp_assign(obj, value):
return _pyupm_mma7660.intp_assign(obj, value)
intp_assign = _pyupm_mma7660.intp_assign
def intp_value(obj):
return _pyupm_mma7660.intp_value(obj)
intp_value = _pyupm_mma7660.intp_value
def new_floatp():
return _pyupm_mma7660.new_floatp()
new_floatp = _pyupm_mma7660.new_floatp
def copy_floatp(value):
return _pyupm_mma7660.copy_floatp(value)
copy_floatp = _pyupm_mma7660.copy_floatp
def delete_floatp(obj):
return _pyupm_mma7660.delete_floatp(obj)
delete_floatp = _pyupm_mma7660.delete_floatp
def floatp_assign(obj, value):
return _pyupm_mma7660.floatp_assign(obj, value)
floatp_assign = _pyupm_mma7660.floatp_assign
def floatp_value(obj):
return _pyupm_mma7660.floatp_value(obj)
floatp_value = _pyupm_mma7660.floatp_value
_pyupm_mma7660.MMA7660_DEFAULT_I2C_BUS_swigconstant(_pyupm_mma7660)
MMA7660_DEFAULT_I2C_BUS = _pyupm_mma7660.MMA7660_DEFAULT_I2C_BUS
_pyupm_mma7660.MMA7660_DEFAULT_I2C_ADDR_swigconstant(_pyupm_mma7660)
MMA7660_DEFAULT_I2C_ADDR = _pyupm_mma7660.MMA7660_DEFAULT_I2C_ADDR
_pyupm_mma7660.MMA7660_REG_XOUT_swigconstant(_pyupm_mma7660)
MMA7660_REG_XOUT = _pyupm_mma7660.MMA7660_REG_XOUT
_pyupm_mma7660.MMA7660_REG_YOUT_swigconstant(_pyupm_mma7660)
MMA7660_REG_YOUT = _pyupm_mma7660.MMA7660_REG_YOUT
_pyupm_mma7660.MMA7660_REG_ZOUT_swigconstant(_pyupm_mma7660)
MMA7660_REG_ZOUT = _pyupm_mma7660.MMA7660_REG_ZOUT
_pyupm_mma7660.MMA7660_REG_TILT_swigconstant(_pyupm_mma7660)
MMA7660_REG_TILT = _pyupm_mma7660.MMA7660_REG_TILT
_pyupm_mma7660.MMA7660_REG_SRST_swigconstant(_pyupm_mma7660)
MMA7660_REG_SRST = _pyupm_mma7660.MMA7660_REG_SRST
_pyupm_mma7660.MMA7660_REG_SPCNT_swigconstant(_pyupm_mma7660)
MMA7660_REG_SPCNT = _pyupm_mma7660.MMA7660_REG_SPCNT
_pyupm_mma7660.MMA7660_REG_INTSU_swigconstant(_pyupm_mma7660)
MMA7660_REG_INTSU = _pyupm_mma7660.MMA7660_REG_INTSU
_pyupm_mma7660.MMA7660_REG_MODE_swigconstant(_pyupm_mma7660)
MMA7660_REG_MODE = _pyupm_mma7660.MMA7660_REG_MODE
_pyupm_mma7660.MMA7660_REG_SR_swigconstant(_pyupm_mma7660)
MMA7660_REG_SR = _pyupm_mma7660.MMA7660_REG_SR
_pyupm_mma7660.MMA7660_REG_PDET_swigconstant(_pyupm_mma7660)
MMA7660_REG_PDET = _pyupm_mma7660.MMA7660_REG_PDET
_pyupm_mma7660.MMA7660_REG_PD_swigconstant(_pyupm_mma7660)
MMA7660_REG_PD = _pyupm_mma7660.MMA7660_REG_PD
_pyupm_mma7660.MMA7660_INTR_NONE_swigconstant(_pyupm_mma7660)
MMA7660_INTR_NONE = _pyupm_mma7660.MMA7660_INTR_NONE
_pyupm_mma7660.MMA7660_INTR_FBINT_swigconstant(_pyupm_mma7660)
MMA7660_INTR_FBINT = _pyupm_mma7660.MMA7660_INTR_FBINT
_pyupm_mma7660.MMA7660_INTR_PLINT_swigconstant(_pyupm_mma7660)
MMA7660_INTR_PLINT = _pyupm_mma7660.MMA7660_INTR_PLINT
_pyupm_mma7660.MMA7660_INTR_PDINT_swigconstant(_pyupm_mma7660)
MMA7660_INTR_PDINT = _pyupm_mma7660.MMA7660_INTR_PDINT
_pyupm_mma7660.MMA7660_INTR_ASINT_swigconstant(_pyupm_mma7660)
MMA7660_INTR_ASINT = _pyupm_mma7660.MMA7660_INTR_ASINT
_pyupm_mma7660.MMA7660_INTR_GINT_swigconstant(_pyupm_mma7660)
MMA7660_INTR_GINT = _pyupm_mma7660.MMA7660_INTR_GINT
_pyupm_mma7660.MMA7660_INTR_SHINTZ_swigconstant(_pyupm_mma7660)
MMA7660_INTR_SHINTZ = _pyupm_mma7660.MMA7660_INTR_SHINTZ
_pyupm_mma7660.MMA7660_INTR_SHINTY_swigconstant(_pyupm_mma7660)
MMA7660_INTR_SHINTY = _pyupm_mma7660.MMA7660_INTR_SHINTY
_pyupm_mma7660.MMA7660_INTR_SHINTX_swigconstant(_pyupm_mma7660)
MMA7660_INTR_SHINTX = _pyupm_mma7660.MMA7660_INTR_SHINTX
_pyupm_mma7660.MMA7660_MODE_MODE_swigconstant(_pyupm_mma7660)
MMA7660_MODE_MODE = _pyupm_mma7660.MMA7660_MODE_MODE
_pyupm_mma7660.MMA7660_MODE_TON_swigconstant(_pyupm_mma7660)
MMA7660_MODE_TON = _pyupm_mma7660.MMA7660_MODE_TON
_pyupm_mma7660.MMA7660_MODE_AWE_swigconstant(_pyupm_mma7660)
MMA7660_MODE_AWE = _pyupm_mma7660.MMA7660_MODE_AWE
_pyupm_mma7660.MMA7660_MODE_ASE_swigconstant(_pyupm_mma7660)
MMA7660_MODE_ASE = _pyupm_mma7660.MMA7660_MODE_ASE
_pyupm_mma7660.MMA7660_MODE_SCPS_swigconstant(_pyupm_mma7660)
MMA7660_MODE_SCPS = _pyupm_mma7660.MMA7660_MODE_SCPS
_pyupm_mma7660.MMA7660_MODE_IPP_swigconstant(_pyupm_mma7660)
MMA7660_MODE_IPP = _pyupm_mma7660.MMA7660_MODE_IPP
_pyupm_mma7660.MMA7660_MODE_IAH_swigconstant(_pyupm_mma7660)
MMA7660_MODE_IAH = _pyupm_mma7660.MMA7660_MODE_IAH
_pyupm_mma7660.MMA7660_BF_UNKNOWN_swigconstant(_pyupm_mma7660)
MMA7660_BF_UNKNOWN = _pyupm_mma7660.MMA7660_BF_UNKNOWN
_pyupm_mma7660.MMA7660_BF_LYING_FRONT_swigconstant(_pyupm_mma7660)
MMA7660_BF_LYING_FRONT = _pyupm_mma7660.MMA7660_BF_LYING_FRONT
_pyupm_mma7660.MMA7660_BF_LYING_BACK_swigconstant(_pyupm_mma7660)
MMA7660_BF_LYING_BACK = _pyupm_mma7660.MMA7660_BF_LYING_BACK
_pyupm_mma7660.MMA7660_LP_UNKNOWN_swigconstant(_pyupm_mma7660)
MMA7660_LP_UNKNOWN = _pyupm_mma7660.MMA7660_LP_UNKNOWN
_pyupm_mma7660.MMA7660_LP_LANDSCAPE_LEFT_swigconstant(_pyupm_mma7660)
MMA7660_LP_LANDSCAPE_LEFT = _pyupm_mma7660.MMA7660_LP_LANDSCAPE_LEFT
_pyupm_mma7660.MMA7660_LP_LANDSCAPE_RIGHT_swigconstant(_pyupm_mma7660)
MMA7660_LP_LANDSCAPE_RIGHT = _pyupm_mma7660.MMA7660_LP_LANDSCAPE_RIGHT
_pyupm_mma7660.MMA7660_LP_VERT_DOWN_swigconstant(_pyupm_mma7660)
MMA7660_LP_VERT_DOWN = _pyupm_mma7660.MMA7660_LP_VERT_DOWN
_pyupm_mma7660.MMA7660_LP_VERT_UP_swigconstant(_pyupm_mma7660)
MMA7660_LP_VERT_UP = _pyupm_mma7660.MMA7660_LP_VERT_UP
_pyupm_mma7660.MMA7660_AUTOSLEEP_120_swigconstant(_pyupm_mma7660)
MMA7660_AUTOSLEEP_120 = _pyupm_mma7660.MMA7660_AUTOSLEEP_120
_pyupm_mma7660.MMA7660_AUTOSLEEP_64_swigconstant(_pyupm_mma7660)
MMA7660_AUTOSLEEP_64 = _pyupm_mma7660.MMA7660_AUTOSLEEP_64
_pyupm_mma7660.MMA7660_AUTOSLEEP_32_swigconstant(_pyupm_mma7660)
MMA7660_AUTOSLEEP_32 = _pyupm_mma7660.MMA7660_AUTOSLEEP_32
_pyupm_mma7660.MMA7660_AUTOSLEEP_16_swigconstant(_pyupm_mma7660)
MMA7660_AUTOSLEEP_16 = _pyupm_mma7660.MMA7660_AUTOSLEEP_16
_pyupm_mma7660.MMA7660_AUTOSLEEP_8_swigconstant(_pyupm_mma7660)
MMA7660_AUTOSLEEP_8 = _pyupm_mma7660.MMA7660_AUTOSLEEP_8
_pyupm_mma7660.MMA7660_AUTOSLEEP_4_swigconstant(_pyupm_mma7660)
MMA7660_AUTOSLEEP_4 = _pyupm_mma7660.MMA7660_AUTOSLEEP_4
_pyupm_mma7660.MMA7660_AUTOSLEEP_2_swigconstant(_pyupm_mma7660)
MMA7660_AUTOSLEEP_2 = _pyupm_mma7660.MMA7660_AUTOSLEEP_2
_pyupm_mma7660.MMA7660_AUTOSLEEP_1_swigconstant(_pyupm_mma7660)
MMA7660_AUTOSLEEP_1 = _pyupm_mma7660.MMA7660_AUTOSLEEP_1
[docs]class MMA7660(_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
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, MMA7660, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, MMA7660, name)
__repr__ = _swig_repr
def __init__(self, bus, address=0x4c):
"""
MMA7660(int bus,
uint8_t address=MMA7660_DEFAULT_I2C_ADDR)
MMA7660 constructor
Parameters:
-----------
bus: I2C bus to use
address: Address for this sensor; default is 0x55
"""
this = _pyupm_mma7660.new_MMA7660(bus, address)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_mma7660.delete_MMA7660
__del__ = lambda self: None
[docs] def writeByte(self, reg, byte):
"""
bool
writeByte(uint8_t reg, uint8_t byte)
Writes a byte value into a register
Parameters:
-----------
reg: Register location to write into
byte: Byte to write
True if successful
"""
return _pyupm_mma7660.MMA7660_writeByte(self, reg, byte)
[docs] def readByte(self, reg):
"""
uint8_t
readByte(uint8_t reg)
Reads a byte value from a register
Parameters:
-----------
reg: Register location to read from
Value in a specified register
"""
return _pyupm_mma7660.MMA7660_readByte(self, reg)
[docs] def getVerifiedAxis(self, axis):
"""
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.
Parameters:
-----------
axis: Axis to read
Axis value
"""
return _pyupm_mma7660.MMA7660_getVerifiedAxis(self, axis)
[docs] def getVerifiedTilt(self):
"""
uint8_t
getVerifiedTilt()
Reads the tilt register, verifying its validity
Tilt value
"""
return _pyupm_mma7660.MMA7660_getVerifiedTilt(self)
[docs] def setModeActive(self):
"""
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.
"""
return _pyupm_mma7660.MMA7660_setModeActive(self)
[docs] def setModeStandby(self):
"""
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.
"""
return _pyupm_mma7660.MMA7660_setModeStandby(self)
[docs] def tiltBackFront(self):
"""
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
"""
return _pyupm_mma7660.MMA7660_tiltBackFront(self)
[docs] def tiltLandscapePortrait(self):
"""
uint8_t
tiltLandscapePortrait()
Reads tiltLandscapePortrait bits
The value returned is one of the MMA7660_TILT_LP_T values
Bits corresponding to the LandscapePortrait tilt status
"""
return _pyupm_mma7660.MMA7660_tiltLandscapePortrait(self)
[docs] def tiltTap(self):
"""
bool tiltTap()
Reads the tiltTap status
True if a tap is detected
"""
return _pyupm_mma7660.MMA7660_tiltTap(self)
[docs] def tiltShake(self):
"""
bool tiltShake()
Reads the tiltShake status
True if a shake is detected
"""
return _pyupm_mma7660.MMA7660_tiltShake(self)
[docs] def uninstallISR(self):
"""
void
uninstallISR()
Uninstalls the previously installed ISR
"""
return _pyupm_mma7660.MMA7660_uninstallISR(self)
[docs] def setInterruptBits(self, ibits):
"""
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.
Parameters:
-----------
ibits: Sets the requested interrupt bits
True if successful
"""
return _pyupm_mma7660.MMA7660_setInterruptBits(self, ibits)
[docs] def setSampleRate(self, sr):
"""
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.
Parameters:
-----------
sr: One of the MMA7660_AUTOSLEEP_T values
True if successful
"""
return _pyupm_mma7660.MMA7660_setSampleRate(self, sr)
[docs] def getAcceleration(self, *args):
"""
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.
"""
return _pyupm_mma7660.MMA7660_getAcceleration(self, *args)
[docs] def getRawValues(self, *args):
"""
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.
"""
return _pyupm_mma7660.MMA7660_getRawValues(self, *args)
[docs] def installISR(self, pin, isr, arg):
"""
void installISR(int
pin, void(*isr)(void *), void *arg)
Installs an interrupt service routine (ISR) to be called when an
interrupt occurs
Parameters:
-----------
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.
"""
return _pyupm_mma7660.MMA7660_installISR(self, pin, isr, arg)
MMA7660_swigregister = _pyupm_mma7660.MMA7660_swigregister
MMA7660_swigregister(MMA7660)
# This file is compatible with both classic and new-style classes.