Skip to content

Commit dfdef41

Browse files
committed
moved and rename adafruit_ssd1306/ssd1306.py to adafruit_ssd1306.py. Implement i2c poweron. improved method doc strings
1 parent 09687a6 commit dfdef41

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

adafruit_ssd1306/ssd1306.py renamed to adafruit_ssd1306.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
#pylint: enable-msg=bad-whitespace
3232

3333

34-
class SSD1306:
35-
"""base class for SSD1306 display driver"""
34+
class _SSD1306:
35+
"""Base class for SSD1306 display driver"""
3636
def __init__(self, framebuffer, width, height, external_vcc):
3737
self.framebuf = framebuffer
3838
self.width = width
@@ -46,7 +46,7 @@ def __init__(self, framebuffer, width, height, external_vcc):
4646
self.init_display()
4747

4848
def init_display(self):
49-
"""base class initialize display"""
49+
"""Base class to initialize display"""
5050
for cmd in (
5151
SET_DISP | 0x00, # off
5252
# address setting
@@ -74,32 +74,32 @@ def init_display(self):
7474
self.show()
7575

7676
def poweroff(self):
77-
"""poweroff"""
77+
"""Turn the device Power off"""
7878
self.write_cmd(SET_DISP | 0x00)
7979

8080
def contrast(self, contrast):
81-
"""adjust the contrast"""
81+
"""Adjust the contrast"""
8282
self.write_cmd(SET_CONTRAST)
8383
self.write_cmd(contrast)
8484

8585
def invert(self, invert):
86-
"""invert the pixels on the display"""
86+
"""Invert the pixels on the display"""
8787
self.write_cmd(SET_NORM_INV | (invert & 1))
8888

8989
def write_framebuf(self):
90-
""""derived class must implement this"""
91-
pass
90+
"""Derived class must implement this"""
91+
raise NotImplementedError
9292

9393
def write_cmd(self, cmd):
94-
""""derived class must implement this"""
95-
pass
94+
"""Derived class must implement this"""
95+
raise NotImplementedError
9696

9797
def poweron(self):
98-
""""derived class must implement this"""
99-
pass
98+
"""Derived class must implement this"""
99+
raise NotImplementedError
100100

101101
def show(self):
102-
"""update the display"""
102+
"""Update the display"""
103103
xpos0 = 0
104104
xpos1 = self.width - 1
105105
if self.width == 64:
@@ -115,22 +115,22 @@ def show(self):
115115
self.write_framebuf()
116116

117117
def fill(self, value):
118-
"""fill the display on or off"""
118+
"""Fill the display on or off"""
119119
self.framebuf.fill(value)
120120

121121
def pixel(self, xpos, ypos, value):
122-
"""set a pixel to on or off at x,y"""
122+
"""Set a pixel to on or off at x,y"""
123123
self.framebuf.pixel(xpos, ypos, value)
124124

125125
def scroll(self, deltax, deltay):
126-
"""scroll the display content by delta x,y"""
126+
"""Scroll the display content by delta x,y"""
127127
self.framebuf.scroll(deltax, deltay)
128128

129129
def text(self, string, xpos, ypos, col=1):
130-
"""place text on display"""
130+
"""Place text on display"""
131131
self.framebuf.text(string, xpos, ypos, col)
132132

133-
class SSD1306_I2C(SSD1306):
133+
class SSD1306_I2C(_SSD1306):
134134
""" I2C class for SSD1306
135135
"""
136136

@@ -162,11 +162,11 @@ def write_framebuf(self):
162162
self.i2c_device.write(self.buffer)
163163

164164
def poweron(self):
165-
"""Turn power off on the device"""
166-
pass
165+
"""Turn power on the device"""
166+
self.write_cmd(SET_DISP | 0x01)
167167

168168
#pylint: disable-msg=too-many-arguments
169-
class SSD1306_SPI(SSD1306):
169+
class SSD1306_SPI(_SSD1306):
170170
""" SPI class for SSD1306
171171
"""
172172
def __init__(self, width, height, spi, dc, res, cs, *,

adafruit_ssd1306/__init__.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)