# 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_mhz16', [dirname(__file__)])
except ImportError:
import _pyupm_mhz16
return _pyupm_mhz16
if fp is not None:
try:
_mod = imp.load_module('_pyupm_mhz16', fp, pathname, description)
finally:
fp.close()
return _mod
_pyupm_mhz16 = swig_import_helper()
del swig_import_helper
else:
import _pyupm_mhz16
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_mhz16.getVersion()
getVersion = _pyupm_mhz16.getVersion
def new_intp():
return _pyupm_mhz16.new_intp()
new_intp = _pyupm_mhz16.new_intp
def copy_intp(value):
return _pyupm_mhz16.copy_intp(value)
copy_intp = _pyupm_mhz16.copy_intp
def delete_intp(obj):
return _pyupm_mhz16.delete_intp(obj)
delete_intp = _pyupm_mhz16.delete_intp
def intp_assign(obj, value):
return _pyupm_mhz16.intp_assign(obj, value)
intp_assign = _pyupm_mhz16.intp_assign
def intp_value(obj):
return _pyupm_mhz16.intp_value(obj)
intp_value = _pyupm_mhz16.intp_value
[docs]class MHZ16(_object):
"""
API support for the Grove CO2 sensor.
ID: mhz16
Name: CO2 Sensor
Other Names: MHZ16 Serial CO2 Sensor
Category: gaseous
Manufacturer: seeed
Connection: uart
Link:http://wiki.seeed.cc/Grove-CO2_Sensor/ This class implements
support for the Grove CO2 sensor.
Its CO2 detection range is 0-2,000 ppm. It requires a 2-3 minute warm-
up time before reporting valid data.
C++ includes: mhz16.hpp
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, MHZ16, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, MHZ16, name)
__repr__ = _swig_repr
def __init__(self, uart):
"""
MHZ16(int uart)
MHZ16 constructor
Parameters:
-----------
uart: Default UART to use (0 or 1)
"""
this = _pyupm_mhz16.new_MHZ16(uart)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_mhz16.delete_MHZ16
__del__ = lambda self: None
[docs] def dataAvailable(self, millis):
"""
bool
dataAvailable(unsigned int millis)
Checks to see if there is data available for reading
Parameters:
-----------
millis: Number of milliseconds to wait; 0 means no waiting.
True if there is data available for reading
"""
return _pyupm_mhz16.MHZ16_dataAvailable(self, millis)
[docs] def readData(self, buffer, len):
"""
int readData(char
*buffer, int len)
Reads any available data in a user-supplied buffer. Note: the call
blocks until data is available to be read. Use dataAvailable() to
determine whether there is data available beforehand, to avoid
blocking.
Parameters:
-----------
buffer: Buffer to hold the data read
len: Length of the buffer
Number of bytes read
"""
return _pyupm_mhz16.MHZ16_readData(self, buffer, len)
[docs] def writeData(self, buffer, len):
"""
int writeData(char
*buffer, int len)
Writes the data in the buffer to the device
Parameters:
-----------
buffer: Buffer to hold the data read
len: Length of the buffer
Number of bytes written
"""
return _pyupm_mhz16.MHZ16_writeData(self, buffer, len)
[docs] def setupTty(self, *args):
"""
bool setupTty(speed_t
baud=B9600)
Sets up proper tty I/O modes and the baud rate. The default baud rate
is 9,600 (B9600).
Parameters:
-----------
baud: Desired baud rate.
True if successful
"""
return _pyupm_mhz16.MHZ16_setupTty(self, *args)
[docs] def verifyPacket(self, pkt, len):
"""
bool
verifyPacket(uint8_t *pkt, int len)
Verifies the packet header and indicates its validity
Parameters:
-----------
pkt: Packet to check
True if the checksum is valid, false otherwise
"""
return _pyupm_mhz16.MHZ16_verifyPacket(self, pkt, len)
[docs] def getData(self):
"""
bool getData()
Queries the sensor and gets the gas (CO2) concentration and
temperature data. Should be called before other "get" functions.
True if successful
"""
return _pyupm_mhz16.MHZ16_getData(self)
[docs] def getGas(self):
"""
int getGas()
Returns the gas (CO2) concentration data.
Gas concentration
"""
return _pyupm_mhz16.MHZ16_getGas(self)
[docs] def getTemperature(self):
"""
int
getTemperature()
Returns the temperature data.
Temperature in Celsius
"""
return _pyupm_mhz16.MHZ16_getTemperature(self)
[docs] def calibrateZeroPoint(self):
"""
void
calibrateZeroPoint()
Sets the zero point of the sensor
"""
return _pyupm_mhz16.MHZ16_calibrateZeroPoint(self)
MHZ16_swigregister = _pyupm_mhz16.MHZ16_swigregister
MHZ16_swigregister(MHZ16)
cvar = _pyupm_mhz16.cvar
MHZ16_DEFAULT_UART = cvar.MHZ16_DEFAULT_UART
MHZ16_START = cvar.MHZ16_START
MHZ16_END = cvar.MHZ16_END
# This file is compatible with both classic and new-style classes.