def __init__(self, bus: int = 1, device_addr: int = 0x3c, font_size: int = 16, contrast: int = 0x7F): """ :param bus: I2C bus identfier :param device_addr: I2C device address :param font_size: :param contrast: """ SMBus.__init__(self, bus, force=True) self.device_addr = device_addr self.width = 128 self.height = 32 # display controller specific stuff self._pages = self.height // 8 self.buffer = bytearray(self.width * self._pages) # PIL objects self.image = Image.new('1', (self.width, self.height)) self.draw = ImageDraw.Draw(self.image) self.set_font( os.path.join(os.path.abspath(os.path.dirname(__file__)), "fonts/isocpeur.ttf"), font_size) # isocpeur.ttf looks betters than the default font of PIL # self.font = ImageFont.load_default() self._contrast = contrast self._configure() self.update(0) # clean
def __init__(self, bus=1, device_address=0x1b): """ c'tor :param bus: I2C bus id, on raspi normally 1 :param device_address: device address, 0x1b or 0x1a, selected by A_SEL_FAULT pin """ SMBus.__init__(self, bus, force=True) self.addr = device_address
def __init__(self, bus: Union[int, str] = 1, device_addr: int = 0x40) -> None: """Initialize :param bus: I2C bus identification number or a filesystem name like `/dev/i2c-something` :param device_addr: I2C device address, normally 0x40 """ SMBus.__init__(self, bus, force=True) self.device_addr = device_addr self._configure()
def __init__(self, bus: Union[int, str] = 1, device_addr: int = 0x76, altitude: float = 500.0): """Initialize Object. :param bus: I2C bus identification number or a filesystem name like `/dev/i2c-something` :param device_addr: I2C address 0x76 or 0x77 :param altitude: altitude as meters above sea level """ SMBus.__init__(self, bus, force=True) self.device_addr = device_addr self.altitude = altitude self._temperature = None self._pressure = None self.t_fine = 0 modified = self._configure() if modified is not None: time.sleep(4.0)