Skip to content

expose line function #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions adafruit_ssd1306.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ class _SSD1306:
"""Base class for SSD1306 display driver"""
def __init__(self, framebuffer, width, height, external_vcc):
self.framebuf = framebuffer
# note this is a breaking change:
# previously these functions were wrapped
# with a default color of "1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should go in the PR message not the code. I bet col=1 below is actually column not color too.

self.fill = self.framebuf.fill
self.pixel = self.framebuf.pixel
self.line = self.framebuf.line
self.text = self.framebuf.text
self.scroll = self.framebuf.scroll
self.blit = self.framebuf.blit
self.vline = self.framebuf.vline
self.hline = self.framebuf.hline
self.fill_rect = self.framebuf.fill_rect

self.width = width
self.height = height
self.external_vcc = external_vcc
Expand Down Expand Up @@ -114,22 +127,6 @@ def show(self):
self.write_cmd(self.pages - 1)
self.write_framebuf()

def fill(self, value):
"""Fill the display on or off"""
self.framebuf.fill(value)

def pixel(self, xpos, ypos, value):
"""Set a pixel to on or off at x,y"""
self.framebuf.pixel(xpos, ypos, value)

def scroll(self, deltax, deltay):
"""Scroll the display content by delta x,y"""
self.framebuf.scroll(deltax, deltay)

def text(self, string, xpos, ypos, col=1):
"""Place text on display"""
self.framebuf.text(string, xpos, ypos, col)

class SSD1306_I2C(_SSD1306):
"""
I2C class for SSD1306
Expand All @@ -152,7 +149,7 @@ def __init__(self, width, height, i2c, *, addr=0x3c, external_vcc=False):
# buffer).
self.buffer = bytearray(((height // 8) * width) + 1)
self.buffer[0] = 0x40 # Set first byte of data buffer to Co=0, D/C=1
framebuffer = framebuf.FrameBuffer1(memoryview(self.buffer)[1:], width, height)
framebuffer = framebuf.FrameBuffer(memoryview(self.buffer)[1:], width, height)
super().__init__(framebuffer, width, height, external_vcc)

def write_cmd(self, cmd):
Expand Down Expand Up @@ -194,7 +191,7 @@ def __init__(self, width, height, spi, dc, res, cs, *,
self.dc_pin = dc
self.reset_pin = res
self.buffer = bytearray((height // 8) * width)
framebuffer = framebuf.FrameBuffer1(self.buffer, width, height)
framebuffer = framebuf.FrameBuffer(self.buffer, width, height)
super().__init__(framebuffer, width, height, external_vcc)

def write_cmd(self, cmd):
Expand Down