Skip to content

Commit 978a429

Browse files
committed
subclass framebuf for cleaner code
1 parent 4860c4e commit 978a429

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

adafruit_pcd8544.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
_PCD8544_SETVOP = const(0x80)
7373

7474

75-
class PCD8544(object):
75+
class PCD8544(framebuf.FrameBuffer):
7676
"""Nokia 5110/3310 PCD8544-based LCD display."""
7777
# pylint: disable=too-many-instance-attributes
7878

@@ -87,20 +87,8 @@ def __init__(self, spi, dc_pin, cs_pin, reset_pin=None, *,
8787
if reset_pin:
8888
reset_pin.switch_to_output(value=True)
8989

90-
self.width = _LCDWIDTH
91-
self.height = _LCDHEIGHT
92-
self.buffer = bytearray((self.height // 8) * self.width)
93-
self.framebuf = framebuf.FrameBuffer1(self.buffer, self.width, self.height)
94-
self.fill = self.framebuf.fill
95-
self.pixel = self.framebuf.pixel
96-
self.line = self.framebuf.line
97-
self.text = self.framebuf.text
98-
self.scroll = self.framebuf.scroll
99-
self.blit = self.framebuf.blit
100-
self.vline = self.framebuf.vline
101-
self.hline = self.framebuf.hline
102-
self.fill_rect = self.framebuf.fill_rect
103-
self.rect = self.framebuf.rect
90+
self.buffer = bytearray((_LCDHEIGHT // 8) * _LCDWIDTH)
91+
super().__init__(self.buffer, _LCDWIDTH, _LCDHEIGHT)
10492

10593
self._contrast = None
10694
self._bias = None

0 commit comments

Comments
 (0)