def __init__( self, E: int, RS: int, D4: int, D5: int, D6: int, D7: int, command: bool, chars_per_line: int = 16, char_mode: bool = True, ): """ Initialize and clear display """ self.command = command self.E = E self.RS = RS self.D4 = D4 self.D5 = D5 self.D6 = D6 self.D7 = D7 self.hi_bits = {0x10: D4, 0x20: D5, 0x40: D6, 0x80: D7} self.lo_bits = {0x01: D4, 0x02: D5, 0x04: D6, 0x08: D7} self.chars_per_line = chars_per_line self.char_mode = char_mode GPIO.setwarnings(False) # Use BCM GPIO numbers GPIO.setmode(GPIO.BCM) # Set GPIO's to output mode for pin in [E, RS, D4, D5, D6, D7]: GPIO.setup(pin, GPIO.OUT) self.write(0x33, command) # Initialize self.write(0x32, command) # Set to 4-bit mode self.write(0x06, command) # Cursor move direction self.write(0x0C, command) # Turn cursor off self.write(0x28, command) # 2 line display self.write(0x01, command) # Clear display # Delay to allow commands to process time.sleep(0.0005)
(config.gpio_heat, spi_reserved_gpio)) if config.max6675: from kilner.max6675 import MAX6675, MAX6675Error log.info("import MAX6675") sensor_available = True except ImportError: log.exception( "Could not initialize temperature sensor, using dummy values!") sensor_available = False try: from kilner.config import GPIO GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(config.gpio_heat, GPIO.OUT) # GPIO.setup(config.gpio_cool, GPIO.OUT) # GPIO.setup(config.gpio_air, GPIO.OUT) # GPIO.setup(config.gpio_door, GPIO.IN, pull_up_down=GPIO.PUD_UP) gpio_available = True except ImportError: msg = "Could not initialize GPIOs, oven operation will only be simulated!" log.warning(msg) gpio_available = False class Oven(threading.Thread): STATE_IDLE = "IDLE" STATE_RUNNING = "RUNNING"