Python adafruit_bus_device.i2c_device.I2CDevice() Examples
The following are 14
code examples of adafruit_bus_device.i2c_device.I2CDevice().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
adafruit_bus_device.i2c_device
, or try the search function
.
Example #1
Source File: ads1x15.py From Adafruit_CircuitPython_ADS1x15 with MIT License | 6 votes |
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)
Example #2
Source File: adafruit_ssd1306.py From Adafruit_CircuitPython_SSD1306 with MIT License | 6 votes |
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, )
Example #3
Source File: adafruit_lsm9ds1.py From Adafruit_CircuitPython_LSM9DS1 with MIT License | 6 votes |
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" )
Example #4
Source File: adafruit_amg88xx.py From Adafruit_CircuitPython_AMG88xx with MIT License | 5 votes |
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
Example #5
Source File: adafruit_adxl34x.py From Adafruit_CircuitPython_ADXL34x with MIT License | 5 votes |
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 = {}
Example #6
Source File: mcp230xx.py From Adafruit_CircuitPython_MCP230xx with MIT License | 5 votes |
def __init__(self, i2c, address): self._device = i2c_device.I2CDevice(i2c, address)
Example #7
Source File: i2c.py From Adafruit_CircuitPython_PN532 with MIT License | 5 votes |
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)
Example #8
Source File: ht16k33.py From Adafruit_CircuitPython_HT16K33 with MIT License | 5 votes |
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
Example #9
Source File: adafruit_pca9685.py From Adafruit_CircuitPython_PCA9685 with MIT License | 5 votes |
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()
Example #10
Source File: adafruit_ccs811.py From Adafruit_CircuitPython_CCS811 with MIT License | 5 votes |
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
Example #11
Source File: adafruit_bno055.py From Adafruit_CircuitPython_BNO055 with MIT License | 5 votes |
def __init__(self, i2c, address=0x28): self.buffer = bytearray(2) self.i2c_device = I2CDevice(i2c, address) super().__init__()
Example #12
Source File: adafruit_ds3231.py From Adafruit_CircuitPython_DS3231 with MIT License | 5 votes |
def __init__(self, i2c): self.i2c_device = I2CDevice(i2c, 0x68)
Example #13
Source File: adafruit_ina219.py From Adafruit_CircuitPython_INA219 with MIT License | 5 votes |
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
Example #14
Source File: seesaw.py From Adafruit_CircuitPython_seesaw with MIT License | 5 votes |
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()