def load_hardware(self): self._dimmer_running = False self._device = None try: gpio_pins = self.get_address().split(',') self._device = pca9685_driver.Device(int('0x' + gpio_pins[0], 16)) self._device.set_pwm_frequency(1000) except Exception as ex: print('load_hardware exception') print(ex)
def _load_hardware(self): # address is expected as `[relay_number],[i2c_address],[I2C bus number]` address = self._address if len(address) == 1: address.append(self._DEFAULT_ADDRESS) if not address[1].startswith('0x'): address[1] = '0x' + address[1] self._device['switch'] = int(address[0]) self._device['device'] = pca9685_driver.Device( int(address[1], 16), None if len(address) != 3 else int(address[2])) self._device['device'].set_pwm_frequency(self._DIMMER_FREQ) return self._device['device']