aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/display/uc1701.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-11-21 13:43:48 -0500
committerKevin O'Connor <kevin@koconnor.net>2018-11-21 20:45:53 -0500
commite231ac74221fcfa6e26ace1027d322c7fe111e38 (patch)
treec8ac2cc21d8bc08ccbad740783030148fb63e3a9 /klippy/extras/display/uc1701.py
parenta00d7b418f88c1ff453f3477b278e25044fb61ed (diff)
downloadkutter-e231ac74221fcfa6e26ace1027d322c7fe111e38.tar.gz
kutter-e231ac74221fcfa6e26ace1027d322c7fe111e38.tar.xz
kutter-e231ac74221fcfa6e26ace1027d322c7fe111e38.zip
uc1701: Add support for SSD1306 displays
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras/display/uc1701.py')
-rw-r--r--klippy/extras/display/uc1701.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/klippy/extras/display/uc1701.py b/klippy/extras/display/uc1701.py
index ba564395..6b42cdef 100644
--- a/klippy/extras/display/uc1701.py
+++ b/klippy/extras/display/uc1701.py
@@ -12,6 +12,7 @@ BACKGROUND_PRIORITY_CLOCK = 0x7fffffff00000000
TextGlyphs = { 'right_arrow': '\x1a', 'degrees': '\xf8' }
class UC1701:
+ DATA_PIN_NAME = "a0_pin"
CURRENT_BUF, OLD_BUF = 0, 1
EMPTY_CHAR = (0, 32, 255)
def __init__(self, config):
@@ -20,7 +21,7 @@ class UC1701:
mcu = self.spi.get_mcu()
# Create a0 pin
ppins = config.get_printer().lookup_object('pins')
- a0_pin_params = ppins.lookup_pin(config.get('a0_pin'))
+ a0_pin_params = ppins.lookup_pin(config.get(self.DATA_PIN_NAME))
if a0_pin_params['chip'] != mcu:
raise ppins.error("uc1701 all pins must be on same mcu")
self.a0_oid = mcu.create_oid()
@@ -158,3 +159,29 @@ class UC1701:
page[:] = zeros
def get_dimensions(self):
return (16, 4)
+
+# The SSD1306 (in 4-wire SPI mode) differs from UC1701 only in display init
+class SSD1306(UC1701):
+ DATA_PIN_NAME = "dc_pin"
+ def init(self):
+ init_cmds = [
+ 0xAE, # Display off
+ 0xD5, 0x80, # Set oscillator frequency
+ 0xA8, 0x3f, # Set multiplex ratio
+ 0xD3, 0x00, # Set display offset
+ 0x40, # Set display start line
+ 0x8D, 0x14, # Charge pump setting
+ 0x20, 0x02, # Set Memory addressing mode
+ 0xA1, # Set Segment re-map
+ 0xC8, # Set COM output scan direction
+ 0xDA, 0x12, # Set COM pins hardware configuration
+ 0x81, 0xEF, # Set contrast control
+ 0xD9, 0xA1, # Set pre-charge period
+ 0xDB, 0x00, # Set VCOMH deselect level
+ 0x2E, # Deactivate scroll
+ 0xA4, # Output ram to display
+ 0xA6, # Normal display
+ 0xAF, # Display on
+ ]
+ self.send(init_cmds)
+ self.flush()