uc1701: Add support for a reset line on SSD1306 displays

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-08-17 22:03:51 -04:00
parent 05bb5484b4
commit 96fdb6ef36
2 changed files with 19 additions and 0 deletions

View File

@ -1404,6 +1404,10 @@
# mode. The parameters that start with "spi_" are optional and they # mode. The parameters that start with "spi_" are optional and they
# control the spi settings used to communicate with the chip. The # control the spi settings used to communicate with the chip. The
# default is to use i2c mode for ssd1306 displays. # 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: #menu_root:
# Entry point for menu, root menu container name. If this parameter # Entry point for menu, root menu container name. If this parameter
# is not provided then default menu root is used. When provided # is not provided then default menu root is used. When provided

View File

@ -200,10 +200,25 @@ class SSD1306(DisplayBase):
cs_pin = config.get("cs_pin", None) cs_pin = config.get("cs_pin", None)
if cs_pin is None: if cs_pin is None:
io = I2C(config, 60) io = I2C(config, 60)
io_bus = io.i2c
else: else:
io = SPI4wire(config, "dc_pin") 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) DisplayBase.__init__(self, io)
def init(self): 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 = [ init_cmds = [
0xAE, # Display off 0xAE, # Display off
0xD5, 0x80, # Set oscillator frequency 0xD5, 0x80, # Set oscillator frequency