本文整理汇总了Python中adafruit_bus_device.i2c_device.I2CDevice方法的典型用法代码示例。如果您正苦于以下问题:Python i2c_device.I2CDevice方法的具体用法?Python i2c_device.I2CDevice怎么用?Python i2c_device.I2CDevice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类adafruit_bus_device.i2c_device
的用法示例。
在下文中一共展示了i2c_device.I2CDevice方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(
self,
i2c,
gain=1,
data_rate=None,
mode=Mode.SINGLE,
address=_ADS1X15_DEFAULT_ADDRESS,
):
# pylint: disable=too-many-arguments
self._last_pin_read = None
self.buf = bytearray(3)
self._data_rate = self._gain = self._mode = None
self.gain = gain
self.data_rate = self._data_rate_default() if data_rate is None else data_rate
self.mode = mode
self.i2c_device = I2CDevice(i2c, address)
示例2: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(
self, width, height, i2c, *, addr=0x3C, external_vcc=False, reset=None
):
self.i2c_device = i2c_device.I2CDevice(i2c, addr)
self.addr = addr
self.temp = bytearray(2)
# Add an extra byte to the data buffer to hold an I2C data/command byte
# to use hardware-compatible I2C transactions. A memoryview of the
# buffer is used to mask this byte from the framebuffer operations
# (without a major memory hit as memoryview doesn't copy to a separate
# buffer).
self.buffer = bytearray(((height // 8) * width) + 1)
self.buffer[0] = 0x40 # Set first byte of data buffer to Co=0, D/C=1
super().__init__(
memoryview(self.buffer)[1:],
width,
height,
external_vcc=external_vcc,
reset=reset,
)
示例3: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(
self,
i2c,
mag_address=_LSM9DS1_ADDRESS_MAG,
xg_address=_LSM9DS1_ADDRESS_ACCELGYRO,
):
if mag_address in (0x1C, 0x1E) and xg_address in (0x6A, 0x6B):
self._mag_device = i2c_device.I2CDevice(i2c, mag_address)
self._xg_device = i2c_device.I2CDevice(i2c, xg_address)
super().__init__()
else:
raise ValueError(
"address parmeters are incorrect. Read the docs at "
"circuitpython.rtfd.io/projects/lsm9ds1/en/latest"
"/api.html#adafruit_lsm9ds1.LSM9DS1_I2C"
)
示例4: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(self, i2c, addr=0x69):
self.i2c_device = I2CDevice(i2c, addr)
# enter normal mode
self._pctl = _NORMAL_MODE
# software reset
self._rst = _INITIAL_RESET
# disable interrupts by default
self._inten = False
# set to 10 FPS
self._fps = _FPS_10
示例5: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(self, i2c, address=_ADXL345_DEFAULT_ADDRESS):
self._i2c = i2c_device.I2CDevice(i2c, address)
self._buffer = bytearray(6)
# set the 'measure' bit in to enable measurement
self._write_register_byte(_REG_POWER_CTL, 0x08)
self._write_register_byte(_REG_INT_ENABLE, 0x0)
self._enabled_interrupts = {}
self._event_status = {}
示例6: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(self, i2c, address):
self._device = i2c_device.I2CDevice(i2c, address)
示例7: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(self, i2c, *, irq=None, reset=None, req=None, debug=False):
"""Create an instance of the PN532 class using I2C. Note that PN532
uses clock stretching. Optional IRQ pin (not used),
reset pin and debugging output.
"""
self.debug = debug
self._irq = irq
self._req = req
if reset:
_reset(reset)
self._i2c = i2c_device.I2CDevice(i2c, _I2C_ADDRESS)
super().__init__(debug=debug, reset=reset)
示例8: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(self, i2c, address=0x70, auto_write=True, brightness=1.0):
self.i2c_device = i2c_device.I2CDevice(i2c, address)
self._temp = bytearray(1)
self._buffer = bytearray(17)
self._auto_write = auto_write
self.fill(0)
self._write_cmd(_HT16K33_OSCILATOR_ON)
self._blink_rate = None
self._brightness = None
self.blink_rate = 0
self.brightness = brightness
示例9: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(self, i2c_bus, *, address=0x40, reference_clock_speed=25000000):
self.i2c_device = i2c_device.I2CDevice(i2c_bus, address)
self.channels = PCAChannels(self)
"""Sequence of 16 `PWMChannel` objects. One for each channel."""
self.reference_clock_speed = reference_clock_speed
"""The reference clock speed in Hz."""
self.reset()
示例10: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(self, i2c_bus, address=0x5A):
self.i2c_device = I2CDevice(i2c_bus, address)
# check that the HW id is correct
if self.hw_id != _HW_ID_CODE:
raise RuntimeError(
"Device ID returned is not correct! Please check your wiring."
)
# try to start the app
buf = bytearray(1)
buf[0] = 0xF4
with self.i2c_device as i2c:
i2c.write(buf, end=1)
time.sleep(0.1)
# make sure there are no errors and we have entered application mode
if self.error:
raise RuntimeError(
"Device returned a error! Try removing and reapplying power to "
"the device and running the code again."
)
if not self.fw_mode:
raise RuntimeError(
"Device did not enter application mode! If you got here, there may "
"be a problem with the firmware on your sensor."
)
self.interrupt_enabled = False
# default to read every second
self.drive_mode = DRIVE_MODE_1SEC
self._eco2 = None # pylint: disable=invalid-name
self._tvoc = None # pylint: disable=invalid-name
示例11: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(self, i2c, address=0x28):
self.buffer = bytearray(2)
self.i2c_device = I2CDevice(i2c, address)
super().__init__()
示例12: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(self, i2c):
self.i2c_device = I2CDevice(i2c, 0x68)
示例13: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(self, i2c_bus, addr=0x40):
self.i2c_device = I2CDevice(i2c_bus, addr)
self.i2c_addr = addr
# Set chip to known config values to start
self._cal_value = 0
self._current_lsb = 0
self._power_lsb = 0
self.set_calibration_32V_2A()
# config register break-up
示例14: __init__
# 需要导入模块: from adafruit_bus_device import i2c_device [as 别名]
# 或者: from adafruit_bus_device.i2c_device import I2CDevice [as 别名]
def __init__(self, i2c_bus, addr=0x49, drdy=None):
self._drdy = drdy
if drdy is not None:
drdy.switch_to_input()
self.i2c_device = I2CDevice(i2c_bus, addr)
self.sw_reset()