diff options
author | rjpatawaran <rjpatawaran@me.com> | 2020-09-10 11:07:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-09 23:07:40 -0400 |
commit | c7ea4b89c961b5f0db4c88eef3ae1fc8f3db074a (patch) | |
tree | ff71047b42062767321980ed40ed9d716af74cd0 /klippy/extras/display | |
parent | 1f5848fc1a388b764fc507ccc3d56538605d5500 (diff) | |
download | kutter-c7ea4b89c961b5f0db4c88eef3ae1fc8f3db074a.tar.gz kutter-c7ea4b89c961b5f0db4c88eef3ae1fc8f3db074a.tar.xz kutter-c7ea4b89c961b5f0db4c88eef3ae1fc8f3db074a.zip |
uc1701: Add x_offset (Used to add horizontal offset on SSD1306/SH1106 displays) (#3284)
Signed-off-by: RJ Patawaran <rjpatawaran@me.com>
Diffstat (limited to 'klippy/extras/display')
-rw-r--r-- | klippy/extras/display/uc1701.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/klippy/extras/display/uc1701.py b/klippy/extras/display/uc1701.py index 93dc42cf..2044d205 100644 --- a/klippy/extras/display/uc1701.py +++ b/klippy/extras/display/uc1701.py @@ -13,10 +13,11 @@ BACKGROUND_PRIORITY_CLOCK = 0x7fffffff00000000 TextGlyphs = { 'right_arrow': '\x1a', 'degrees': '\xf8' } class DisplayBase: - def __init__(self, io, columns=128): + def __init__(self, io, columns=128, x_offset=0): self.send = io.send # framebuffers self.columns = columns + self.x_offset = x_offset self.vram = [bytearray(self.columns) for i in range(8)] self.all_framebuffers = [(self.vram[i], bytearray('~'*self.columns), i) for i in range(8)] @@ -71,6 +72,7 @@ class DisplayBase: if x + len(data) > 16: data = data[:16 - min(x, 16)] pix_x = x * 8 + pix_x += self.x_offset page_top = self.vram[y * 2] page_bot = self.vram[y * 2 + 1] for c in bytearray(data): @@ -83,6 +85,7 @@ class DisplayBase: return bits_top, bits_bot = self._swizzle_bits(data) pix_x = x * 8 + pix_x += self.x_offset page_top = self.vram[y * 2] page_bot = self.vram[y * 2 + 1] for i in range(8): @@ -93,6 +96,7 @@ class DisplayBase: if icon is not None and x < 15: # Draw icon in graphics mode pix_x = x * 8 + pix_x += self.x_offset page_idx = y * 2 self.vram[page_idx][pix_x:pix_x+16] = icon[0] self.vram[page_idx + 1][pix_x:pix_x+16] = icon[1] @@ -192,7 +196,7 @@ class UC1701(DisplayBase): # The SSD1306 supports both i2c and "4-wire" spi class SSD1306(DisplayBase): - def __init__(self, config, columns=128): + def __init__(self, config, columns=128, x_offset=0): cs_pin = config.get("cs_pin", None) if cs_pin is None: io = I2C(config, 60) @@ -201,7 +205,7 @@ class SSD1306(DisplayBase): io = SPI4wire(config, "dc_pin") io_bus = io.spi self.reset = ResetHelper(config.get("reset_pin", None), io_bus) - DisplayBase.__init__(self, io, columns) + DisplayBase.__init__(self, io, columns, x_offset) self.contrast = config.getint('contrast', 239, minval=0, maxval=255) self.vcomh = config.getint('vcomh', 0, minval=0, maxval=63) self.invert = config.getboolean('invert', False) @@ -232,4 +236,5 @@ class SSD1306(DisplayBase): # the SH1106 is SSD1306 compatible with up to 132 columns class SH1106(SSD1306): def __init__(self, config): - SSD1306.__init__(self, config, 132) + x_offset = config.getint('x_offset', 0, minval=0, maxval=3) + SSD1306.__init__(self, config, 132, x_offset=x_offset) |