def __init__(self, address=None, i2c_driver=None): # As noted above, to run this device on a Raspberry Pi, # clock streching is needed. # # Lets check if it's enabled. This is done only once in # the session if QwiicCcs811._RPiCheck == False: _checkForRPiI2CClockStretch() QwiicCcs811._RPiCheck = True # Did the user specify an I2C address? self.address = address if address != None else self.available_addresses[ 0] # load the I2C driver if one isn't provided if i2c_driver == None: self._i2c = qwiic_i2c.getI2CDriver() if self._i2c == None: print("Unable to load I2C driver for this platform.") return else: self._i2c = i2c_driver # qir quality values returned from the sensor self.refResistance = 10000. self._resistance = 0.0 self._TVOC = 0 self._CO2 = 0 self.vrefCounts = 0 self.ntcCounts = 0 self._temperature = 0.0
def __init__(self, address=None, pixel_width=_LCDWIDTH, pixel_height=_LCDHEIGHT, i2c_driver=None): # Did the user specify an I2C address? self.address = address if address is not None else self.available_addresses[ 0] # Screen size: self.LCDHEIGHT = pixel_height self.LCDWIDTH = pixel_width # Load the I2C driver if one isn't provided if i2c_driver is None: self._i2c = qwiic_i2c.getI2CDriver() if self._i2c is None: print("Unable to load I2C driver for this platform.") return else: self._i2c = i2c_driver # define the screen buffer - since this is a two color display, only bits are used # So the height is 8 bits / byte or LCDHEIGHT/8 self._screenbuffer = bytearray(self.LCDWIDTH * int(math.ceil(self.LCDHEIGHT / 8.))) # Set initial contents self._screenbuffer = [0x00] * int( self.LCDWIDTH * self.LCDHEIGHT / 8) #Screen Area in bytes (Total Pixels/8) # Display SparkFun Logo oled_logos.add_logo(self._screenbuffer) # Display ans Clear Page # self.display() # time.sleep(2) # self.clear(self.PAGE) self.cursorX = 0 self.cursorY = 0 self.foreColor = self.WHITE self.drawMode = self.NORM # self.fontWidth = 0 # self.fontHeight = 0 # self.fontStartChar = 0 # self.fontTotalChar = 0 self.fontType = 0 # self.fontData = None self._font = None self.nFonts = oled_fonts.count()
def get_i2c_driver(cls): if cls.i2c_driver is None: cls.i2c_driver = qwiic_i2c.getI2CDriver() if cls.i2c_driver is None: print("Unable to get the plaform I2C driver for QWIIC.") return cls.i2c_driver
def __init__(self, min_value, max_value, i2c_driver=None, address=0x28, min_output=1638, max_output=14745, units=PressureUnits.PSI, k=None, zero=0): self.address = address self.min_output = min_output self.max_output = max_output self.min_value = min_value self.max_value = max_value self.units = units self.k = k self._data = [] self._data_to_keep = 40 self._data_insert_position = 0 self._flow_data = [] self._flow_data_to_keep = 40 self._flow_data_insert_position = 0 if self.units == PressureUnits.PSI: self.to_pascal = 6894.7572932 self.to_cmh20 = 70.30696 # TODO: Add more from and to conversions self._pressure = 0 self._raw_pressure = 0 self._raw_pressure_avg = 0 self._temperature = 0 self._flow = 0 self._raw_flow_avg = 0 self._noise_min = ((self.max_value - self.min_value) / (self.max_output - self.min_output)) self._zero_offset = zero self._zero_measurements_to_take = 300 self._zero_offset_set_samples_left = self._zero_measurements_to_take self._zero_offset_rate = (2 / self._zero_measurements_to_take) self._zero_offset_slow_rate = self._zero_offset_rate / 20 if i2c_driver is None: self._i2c = qwiic_i2c.getI2CDriver() if self._i2c is None: print("Unable to load I2C driver for this platform.") return else: self._i2c = i2c_driver
def _getI2CDriver(): global _i2cDriver if _i2cDriver != None: return _i2cDriver _i2cDriver = qwiic_i2c.getI2CDriver() if _i2cDriver == None: print("Unable to get the plaform I2C driver for QWIIC.") return _i2cDriver
def __init__(self, address=None, i2c_driver=None): # Did the user specify an I2C address? self.address = address if address != None else self.available_addresses[0] # load the I2C driver if one isn't provided if i2c_driver == None: self._i2c = qwiic_i2c.getI2CDriver() if self._i2c == None: print("Unable to load I2C driver for this platform.") return else: self._i2c = i2c_driver
def __init__(self, address=None, i2c_driver=None): # Did the user specify an I2C address? self._address = address if address is not None else self.available_addresses[ 0] # load the I2C driver if one isn't provided if i2c_driver is None: self._i2c = qwiic_i2c.getI2CDriver() if self._i2c is None: print("Unable to load I2C driver for this platform.") return else: self._i2c = i2c_driver self._buffer = bytearray(16) self._content = [None] * 4 self._auto_write = True self._blink_rate = 0 self._brightness = 1.0
def __init__(self, address=None, debug=None, i2c_driver=None): """ This method initializes the class object. If no 'address' or 'i2c_driver' are inputted or 'None' is specified, the method will use the defaults. :param address: The I2C address to use for the device. If not provided, the method will default to the first address in the 'available_addresses' list. Default = 0x40 :param debug: Designated whether or not to print debug statements. 0- Don't print debug statements 1- Print debug statements :param i2c_driver: An existing i2c driver object. If not provided a driver object is created from the 'qwiic_i2c' I2C driver of the SparkFun Qwiic library. """ # Did the user specify an I2C address? # Defaults to 0x40 if unspecified. self.address = address if address != None else self.available_addresses[ 0] # Load the I2C driver if one isn't provided if i2c_driver == None: self._i2c = qwiic_i2c.getI2CDriver() if self._i2c == None: print("Unable to load I2C driver for this platform.") return else: self._i2c = i2c_driver # Do you want debug statements? if debug == None: self.debug = 0 # Debug Statements Disabled else: self.debug = debug # Debug Statements Enabled (1)
def __init__(self, address=None, i2c_driver=None): # Did the user specify an I2C address? self.address = address if address is not None else self.available_addresses[ 0] # load the I2C driver if one isn't provided if i2c_driver is None: self._i2c = qwiic_i2c.getI2CDriver() if self._i2c is None: print("Unable to load I2C driver for this platform.") return else: self._i2c = i2c_driver # define the screen buffer - since this is a two color display, only bits are used # So the height is 8 bits / byte or LCDHEIGHT/8 # self._screenbuffer = bytearray(LCDWIDTH * int(math.ceil(LCDHEIGHT/8.))) self._screenbuffer = [0] * (LCDWIDTH * int(math.ceil(LCDHEIGHT / 8.))) # Set initial contents _setSplashScreen(self._screenbuffer) self.cursorX = 0 self.cursorY = 0 self.foreColor = self.WHITE self.drawMode = self.NORM # self.fontWidth = 0 # self.fontHeight = 0 # self.fontStartChar = 0 # self.fontTotalChar = 0 self.fontType = 0 # self.fontData = None self._font = None self.nFonts = mfonts.count()
def __init__(self, address=None, i2c_driver=None): # Did the user specify an I2C address? self.address = self.available_addresses[ 0] if address is None else address # load the I2C driver if one isn't provided if i2c_driver is None: self._i2c = qwiic_i2c.getI2CDriver() if self._i2c is None: print("Unable to load I2C driver for this platform.") return else: self._i2c = i2c_driver # create a dictionary to stash our calibration data for the sensor self.calibration = {} self.t_fine = 0 self._referencePressure = 101325.0