# 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_ds2413', [dirname(__file__)])
except ImportError:
import _pyupm_ds2413
return _pyupm_ds2413
if fp is not None:
try:
_mod = imp.load_module('_pyupm_ds2413', fp, pathname, description)
finally:
fp.close()
return _mod
_pyupm_ds2413 = swig_import_helper()
del swig_import_helper
else:
import _pyupm_ds2413
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_ds2413.getVersion()
getVersion = _pyupm_ds2413.getVersion
_pyupm_ds2413.DS2413_DEFAULT_UART_swigconstant(_pyupm_ds2413)
DS2413_DEFAULT_UART = _pyupm_ds2413.DS2413_DEFAULT_UART
[docs]class DS2413(_object):
"""
API for the DS2413 1-Wire Dual Channel Addressable Switch.
ID: ds2413
Name: 1-Wire Dual Channel Addressable Switch
Category: gpio
Manufacturer: maxim
Connection: uart
Link:https://learn.adafruit.com/adafruit-1-wire-gpio-breakout-
ds2413/overview The DS2413 is a dual-channel programmable I/O
1-Wire(r) chip. The PIO outputs are configured as open-drain and
provide up to 20mA continuous sink capability and off-state operating
voltage up to 28V. Control and sensing of the PIO pins is performed
with a dedicated device-level command protocol.
This device requires the use of a UART to provide access to a Dallas
1-wire bus, via a new facility supported by MRAA (once the relevant PR
is accepted), using the UartOW access class. It is important to
realize that the UART is only being used to access and control a
Dallas 1-wire compliant bus, it is not actually a UART device.
Multiple DS2413 devices can be connected to this bus. This module will
identify all such devices connected, and allow you to access them
using an index starting at 0.
C++ includes: ds2413.hpp
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, DS2413, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, DS2413, name)
__repr__ = _swig_repr
DS2413_FAMILY_CODE = _pyupm_ds2413.DS2413_DS2413_FAMILY_CODE
ACCESS_READ = _pyupm_ds2413.DS2413_ACCESS_READ
ACCESS_WRITE = _pyupm_ds2413.DS2413_ACCESS_WRITE
ACK_SUCCESS = _pyupm_ds2413.DS2413_ACK_SUCCESS
ACK_FAILURE = _pyupm_ds2413.DS2413_ACK_FAILURE
def __init__(self, uart=0):
"""
DS2413(int
uart=DS2413_DEFAULT_UART)
DS2413 object constructor
Parameters:
-----------
uart: Default UART to use (0 or 1). Default is 0.
"""
this = _pyupm_ds2413.new_DS2413(uart)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_ds2413.delete_DS2413
__del__ = lambda self: None
[docs] def init(self):
"""
void init()
This method will search the 1-wire bus and store information on each
device detected on the bus. If no devices are found, an exception is
thrown. Once this function completes successfully, you can use
devicesFound() to determine how many devices were detected.
"""
return _pyupm_ds2413.DS2413_init(self)
[docs] def devicesFound(self):
"""
int devicesFound()
This method will return the number of DS2413 devices that were found
on the bus.
number of DS2413's that were found on the bus
"""
return _pyupm_ds2413.DS2413_devicesFound(self)
[docs] def readGpios(self, index=0):
"""
int readGpios(int
index=0)
Read the GPIO latches and values for a given device. Only the lower 4
bits of the return value have any meaning. The bits are formatted as
follows (from msb to lsb): <gpioB latch>=""> <gpioB value>="">
<gpioA latch>=""> <gpioA value>="">
Parameters:
-----------
index: The device index to access (starts at 0). Default is the first
device (index = 0)
the 4 bit status of the 2 gpios
"""
return _pyupm_ds2413.DS2413_readGpios(self, index)
[docs] def writeGpios(self, index, value):
"""
void writeGpios(int
index, int value)
Write the given values to the gpio latches for a given device. Only
the lower 2 bits of the value have any meaning. The lsb is gor gpioA
and the next lsb is for gpioB: <gpioB latch>=""> <gpioA latch>="">
Parameters:
-----------
index: The device index to access (starts at 0).
value: the value to write to the gpio latches
"""
return _pyupm_ds2413.DS2413_writeGpios(self, index, value)
[docs] def getId(self, index):
"""
std::string getId(int
index)
Return an 8 byte string representing the unique device ID for a given
device index. If the index is invalid, an empty strig will be
returned.
Parameters:
-----------
index: The device index to access (starts at 0).
8 byte string representing the 1-wire device's unique rom code.
"""
return _pyupm_ds2413.DS2413_getId(self, index)
DS2413_swigregister = _pyupm_ds2413.DS2413_swigregister
DS2413_swigregister(DS2413)
[docs]class charArray(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, charArray, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, charArray, name)
__repr__ = _swig_repr
def __init__(self, nelements):
this = _pyupm_ds2413.new_charArray(nelements)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_ds2413.delete_charArray
__del__ = lambda self: None
def __getitem__(self, index):
return _pyupm_ds2413.charArray___getitem__(self, index)
def __setitem__(self, index, value):
return _pyupm_ds2413.charArray___setitem__(self, index, value)
[docs] def cast(self):
return _pyupm_ds2413.charArray_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _pyupm_ds2413.charArray_frompointer
if _newclass:
frompointer = staticmethod(_pyupm_ds2413.charArray_frompointer)
charArray_swigregister = _pyupm_ds2413.charArray_swigregister
charArray_swigregister(charArray)
def charArray_frompointer(t):
return _pyupm_ds2413.charArray_frompointer(t)
charArray_frompointer = _pyupm_ds2413.charArray_frompointer
# This file is compatible with both classic and new-style classes.