From 96fdb6ef369b822961e7484c7f8d04f3c191ad62 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 17 Aug 2019 22:03:51 -0400 Subject: [PATCH] uc1701: Add support for a reset line on SSD1306 displays Signed-off-by: Kevin O'Connor --- config/example-extras.cfg | 4 ++++ klippy/extras/display/uc1701.py | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/config/example-extras.cfg b/config/example-extras.cfg index 92e6ef24..8567ead7 100644 --- a/config/example-extras.cfg +++ b/config/example-extras.cfg @@ -1404,6 +1404,10 @@ # mode. The parameters that start with "spi_" are optional and they # control the spi settings used to communicate with the chip. The # default is to use i2c mode for ssd1306 displays. +#reset_pin: +# A reset pin may be specified on ssd1306 displays. If it is not +# specified then the hardware must have a pull-up on the +# corresponding lcd line. #menu_root: # Entry point for menu, root menu container name. If this parameter # is not provided then default menu root is used. When provided diff --git a/klippy/extras/display/uc1701.py b/klippy/extras/display/uc1701.py index 3766fa13..45d13c2b 100644 --- a/klippy/extras/display/uc1701.py +++ b/klippy/extras/display/uc1701.py @@ -200,10 +200,25 @@ class SSD1306(DisplayBase): cs_pin = config.get("cs_pin", None) if cs_pin is None: io = I2C(config, 60) + io_bus = io.i2c else: io = SPI4wire(config, "dc_pin") + io_bus = io.spi + self.mcu_reset = None + reset_pin_desc = config.get("reset_pin", None) + if reset_pin_desc is not None: + self.mcu_reset = extras.bus.MCU_bus_digital_out( + io_bus.get_mcu(), reset_pin_desc, io_bus.get_command_queue()) DisplayBase.__init__(self, io) def init(self): + if self.mcu_reset is not None: + mcu = self.mcu_reset.get_mcu() + curtime = mcu.get_printer().get_reactor().monotonic() + print_time = mcu.estimated_print_time(curtime) + minclock = mcu.print_time_to_clock(print_time + .100) + self.mcu_reset.update_digital_out(0, minclock=minclock) + minclock = mcu.print_time_to_clock(print_time + .200) + self.mcu_reset.update_digital_out(1, minclock=minclock) init_cmds = [ 0xAE, # Display off 0xD5, 0x80, # Set oscillator frequency