Source code for pyupm_bh1750

# 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_bh1750', [dirname(__file__)])
        except ImportError:
            import _pyupm_bh1750
            return _pyupm_bh1750
        if fp is not None:
            try:
                _mod = imp.load_module('_pyupm_bh1750', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _pyupm_bh1750 = swig_import_helper()
    del swig_import_helper
else:
    import _pyupm_bh1750
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_bh1750.getVersion()
getVersion = _pyupm_bh1750.getVersion

_pyupm_bh1750.BH1750_DEFAULT_I2C_BUS_swigconstant(_pyupm_bh1750)
BH1750_DEFAULT_I2C_BUS = _pyupm_bh1750.BH1750_DEFAULT_I2C_BUS

_pyupm_bh1750.BH1750_DEFAULT_I2C_ADDR_swigconstant(_pyupm_bh1750)
BH1750_DEFAULT_I2C_ADDR = _pyupm_bh1750.BH1750_DEFAULT_I2C_ADDR

_pyupm_bh1750.BH1750_CMD_POWER_DOWN_swigconstant(_pyupm_bh1750)
BH1750_CMD_POWER_DOWN = _pyupm_bh1750.BH1750_CMD_POWER_DOWN

_pyupm_bh1750.BH1750_CMD_POWER_UP_swigconstant(_pyupm_bh1750)
BH1750_CMD_POWER_UP = _pyupm_bh1750.BH1750_CMD_POWER_UP

_pyupm_bh1750.BH1750_CMD_RESET_swigconstant(_pyupm_bh1750)
BH1750_CMD_RESET = _pyupm_bh1750.BH1750_CMD_RESET

_pyupm_bh1750.BH1750_CMD_CONT_H_RES_MODE1_swigconstant(_pyupm_bh1750)
BH1750_CMD_CONT_H_RES_MODE1 = _pyupm_bh1750.BH1750_CMD_CONT_H_RES_MODE1

_pyupm_bh1750.BH1750_CMD_CONT_H_RES_MODE2_swigconstant(_pyupm_bh1750)
BH1750_CMD_CONT_H_RES_MODE2 = _pyupm_bh1750.BH1750_CMD_CONT_H_RES_MODE2

_pyupm_bh1750.BH1750_CMD_CONT_L_RES_MODE_swigconstant(_pyupm_bh1750)
BH1750_CMD_CONT_L_RES_MODE = _pyupm_bh1750.BH1750_CMD_CONT_L_RES_MODE

_pyupm_bh1750.BH1750_CMD_ONETIME_H_RES_MODE1_swigconstant(_pyupm_bh1750)
BH1750_CMD_ONETIME_H_RES_MODE1 = _pyupm_bh1750.BH1750_CMD_ONETIME_H_RES_MODE1

_pyupm_bh1750.BH1750_CMD_ONETIME_H_RES_MODE2_swigconstant(_pyupm_bh1750)
BH1750_CMD_ONETIME_H_RES_MODE2 = _pyupm_bh1750.BH1750_CMD_ONETIME_H_RES_MODE2

_pyupm_bh1750.BH1750_CMD_ONETIME_L_RES_MODE_swigconstant(_pyupm_bh1750)
BH1750_CMD_ONETIME_L_RES_MODE = _pyupm_bh1750.BH1750_CMD_ONETIME_L_RES_MODE

_pyupm_bh1750.BH1750_MAX_MEAS_TIME_H_swigconstant(_pyupm_bh1750)
BH1750_MAX_MEAS_TIME_H = _pyupm_bh1750.BH1750_MAX_MEAS_TIME_H

_pyupm_bh1750.BH1750_MAX_MEAS_TIME_L_swigconstant(_pyupm_bh1750)
BH1750_MAX_MEAS_TIME_L = _pyupm_bh1750.BH1750_MAX_MEAS_TIME_L

_pyupm_bh1750.BH1750_OPMODE_H1_CONT_swigconstant(_pyupm_bh1750)
BH1750_OPMODE_H1_CONT = _pyupm_bh1750.BH1750_OPMODE_H1_CONT

_pyupm_bh1750.BH1750_OPMODE_H2_CONT_swigconstant(_pyupm_bh1750)
BH1750_OPMODE_H2_CONT = _pyupm_bh1750.BH1750_OPMODE_H2_CONT

_pyupm_bh1750.BH1750_OPMODE_L_CONT_swigconstant(_pyupm_bh1750)
BH1750_OPMODE_L_CONT = _pyupm_bh1750.BH1750_OPMODE_L_CONT

_pyupm_bh1750.BH1750_OPMODE_H1_ONCE_swigconstant(_pyupm_bh1750)
BH1750_OPMODE_H1_ONCE = _pyupm_bh1750.BH1750_OPMODE_H1_ONCE

_pyupm_bh1750.BH1750_OPMODE_H2_ONCE_swigconstant(_pyupm_bh1750)
BH1750_OPMODE_H2_ONCE = _pyupm_bh1750.BH1750_OPMODE_H2_ONCE

_pyupm_bh1750.BH1750_OPMODE_L_ONCE_swigconstant(_pyupm_bh1750)
BH1750_OPMODE_L_ONCE = _pyupm_bh1750.BH1750_OPMODE_L_ONCE
[docs]class BH1750(_object): """ UPM C API for the DFRobot I2C BH1750 Light Sensor. ID: bh1750 Name: Digital Light Sensor Category: light Manufacturer: dfrobot Connection: i2c Link:http://www.dfrobot.com/index.php?route=product/product&product_id=531 This driver was developed with the DFRobot Light Sensor based on the BH1750. It has a sensitivity of .5 10 65535 Lux. It supports voltages from 3-5vdc and is connected via I2C. C++ includes: bh1750.hpp """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, BH1750, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, BH1750, name) __repr__ = _swig_repr def __init__(self, bus=0, addr=0x23, mode=BH1750_OPMODE_H2_ONCE): """ BH1750(int bus=BH1750_DEFAULT_I2C_BUS, int addr=BH1750_DEFAULT_I2C_ADDR, BH1750_OPMODES_T mode=BH1750_OPMODE_H2_ONCE) BH1750 object constructor (Analog mode) Parameters: ----------- bus: The I2C bus to use addr: The I2C address of the device mode: The mode to start operation under. One of the BH1750_OPMODES_T values. The default is the highest precision, lowest power mode. """ this = _pyupm_bh1750.new_BH1750(bus, addr, mode) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_bh1750.delete_BH1750 __del__ = lambda self: None
[docs] def reset(self): """ void reset() Reset the device. This doesn't really have much purpose. The device must be powered up for this command to work. In addition, this command will simply clear the measurement register to 0. """ return _pyupm_bh1750.BH1750_reset(self)
[docs] def getLux(self): """ float getLux() Get the measured light intensity in Lux. The measured light intensity in Lux. """ return _pyupm_bh1750.BH1750_getLux(self)
[docs] def powerUp(self): """ void powerUp() Power up the device. """ return _pyupm_bh1750.BH1750_powerUp(self)
[docs] def powerDown(self): """ void powerDown() Power down the device. """ return _pyupm_bh1750.BH1750_powerDown(self)
[docs] def setOpmode(self, mode): """ void setOpmode(BH1750_OPMODES_T mode) Setup the device to match the selected operating mode. Parameters: ----------- mode: operating mode, one of the BH1750_OPMODES_T values """ return _pyupm_bh1750.BH1750_setOpmode(self, mode)
BH1750_swigregister = _pyupm_bh1750.BH1750_swigregister BH1750_swigregister(BH1750) # This file is compatible with both classic and new-style classes.