# 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_mma7361', [dirname(__file__)])
except ImportError:
import _pyupm_mma7361
return _pyupm_mma7361
if fp is not None:
try:
_mod = imp.load_module('_pyupm_mma7361', fp, pathname, description)
finally:
fp.close()
return _mod
_pyupm_mma7361 = swig_import_helper()
del swig_import_helper
else:
import _pyupm_mma7361
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_mma7361.getVersion()
getVersion = _pyupm_mma7361.getVersion
def new_intp():
return _pyupm_mma7361.new_intp()
new_intp = _pyupm_mma7361.new_intp
def copy_intp(value):
return _pyupm_mma7361.copy_intp(value)
copy_intp = _pyupm_mma7361.copy_intp
def delete_intp(obj):
return _pyupm_mma7361.delete_intp(obj)
delete_intp = _pyupm_mma7361.delete_intp
def intp_assign(obj, value):
return _pyupm_mma7361.intp_assign(obj, value)
intp_assign = _pyupm_mma7361.intp_assign
def intp_value(obj):
return _pyupm_mma7361.intp_value(obj)
intp_value = _pyupm_mma7361.intp_value
def new_floatp():
return _pyupm_mma7361.new_floatp()
new_floatp = _pyupm_mma7361.new_floatp
def copy_floatp(value):
return _pyupm_mma7361.copy_floatp(value)
copy_floatp = _pyupm_mma7361.copy_floatp
def delete_floatp(obj):
return _pyupm_mma7361.delete_floatp(obj)
delete_floatp = _pyupm_mma7361.delete_floatp
def floatp_assign(obj, value):
return _pyupm_mma7361.floatp_assign(obj, value)
floatp_assign = _pyupm_mma7361.floatp_assign
def floatp_value(obj):
return _pyupm_mma7361.floatp_value(obj)
floatp_value = _pyupm_mma7361.floatp_value
[docs]class MMA7361(_object):
"""
API for the DFRobot MMA7361 Analog Accelerometer.
ID: mma7361
Name: Triaxial Analog Accelerometer
Category: accelerometer
Manufacturer: dfrobot
Connection: analog gpio
Link:http://www.dfrobot.com/index.php?route=product/product&path=36&product_id=507#.V7YEj99ytNJ
This library was tested with the DFRobot MMA7361 Analog Accelerometer.
It supports 3 Axes with a selectable 1.5G and 6G sensitivity.
C++ includes: mma7361.hpp
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, MMA7361, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, MMA7361, name)
__repr__ = _swig_repr
def __init__(self, x_pin, y_pin, z_pin, selftest_pin, sleep_pin, freefall_pin, range_pin, a_ref=5.0):
"""
MMA7361(int x_pin, int
y_pin, int z_pin, int selftest_pin, int sleep_pin, int freefall_pin,
int range_pin, float a_ref=5.0)
MMA7361 object constructor
Parameters:
-----------
x_pin: Analog pin to use for X axis. -1 to disable.
y_pin: Analog pin to use for Y axis. -1 to disable.
z_pin: Analog pin to use for Z axis. -1 to disable.
selftest_pin: GPIO pin to use for self test. -1 to disable.
sleep_pin: GPIO pin to use for sleep function. -1 to disable.
freefall_pin: GPIO pin to use for free fall (0g) detection. -1 to
disable.
range_pin: GPIO pin to select range (1.5g or 6g). -1 to disable.
a_ref: The analog reference voltage in use. Default 5.0.
"""
this = _pyupm_mma7361.new_MMA7361(x_pin, y_pin, z_pin, selftest_pin, sleep_pin, freefall_pin, range_pin, a_ref)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_mma7361.delete_MMA7361
__del__ = lambda self: None
[docs] def setRange(self, range):
"""
void setRange(bool
range)
Set the range of the device. This device supports two G ranges: 1.5
and 6. The default is 1.5G.
Parameters:
-----------
range: true for 6G, false for 1.5G
"""
return _pyupm_mma7361.MMA7361_setRange(self, range)
[docs] def setSleep(self, sleep):
"""
void setSleep(bool
sleep)
Set sleep mode. When in sleep mode the sensor uses minimal power.
Parameters:
-----------
sleep: true to go into sleep mode, false to wake up
"""
return _pyupm_mma7361.MMA7361_setSleep(self, sleep)
[docs] def isInFreefall(self):
"""
bool
isInFreefall()
Get freefall detection status.
true if a freefall condition is detected, false otherwise.
"""
return _pyupm_mma7361.MMA7361_isInFreefall(self)
[docs] def enableSelftest(self, enable):
"""
void
enableSelftest(bool enable)
Enable self test mode.
Parameters:
-----------
enable: true to enable the self test mode, false otherwise.
"""
return _pyupm_mma7361.MMA7361_enableSelftest(self, enable)
[docs] def update(self):
"""
void update()
Read the sensor status an update internal state. update() must have
been called before calling getAcceleration(), getNormalized(), or
getVolts().
"""
return _pyupm_mma7361.MMA7361_update(self)
[docs] def setOffset(self, x, y, z):
"""
void setOffset(float
x, float y, float z)
Set sensor offset. This offset is applied to the return values before
scaling. Default is 0.0.
Parameters:
-----------
x: Offset to apply to X value
y: Offset to apply to Y value
z: Offset to apply to Z value
"""
return _pyupm_mma7361.MMA7361_setOffset(self, x, y, z)
[docs] def setScale(self, x, y, z):
"""
void setScale(float x,
float y, float z)
Set sensor scale. The acceleration return values are scaled by this
value before the offset is applied. Default is 1.0.
Parameters:
-----------
x: Scale to apply to X value
y: Scale to apply to Y value
z: Scale to apply to Z value
"""
return _pyupm_mma7361.MMA7361_setScale(self, x, y, z)
[docs] def getAcceleration(self, *args):
"""
float *
getAcceleration()
Get computed acceleration from the sensor. update() must have been
called prior to calling this function.
a pointer to a statically allocated array of 3 floats containing the
X, Y, and Z componenets.
"""
return _pyupm_mma7361.MMA7361_getAcceleration(self, *args)
[docs] def getVolts(self, *args):
"""
float * getVolts()
Get the measured volts from the sensor. update() must have been called
prior to calling this function.
a pointer to a statically allocated array of 3 floats containing the
X, Y, and Z componenets.
"""
return _pyupm_mma7361.MMA7361_getVolts(self, *args)
[docs] def getNormalized(self, *args):
"""
float *
getNormalized()
Get the normalized ADC values from the sensor. update() must have been
called prior to calling this function.
a pointer to a statically allocated array of 3 ints containing the X,
Y, and Z componenets.
"""
return _pyupm_mma7361.MMA7361_getNormalized(self, *args)
MMA7361_swigregister = _pyupm_mma7361.MMA7361_swigregister
MMA7361_swigregister(MMA7361)
# This file is compatible with both classic and new-style classes.