31
31
#pylint: enable-msg=bad-whitespace
32
32
33
33
34
- class SSD1306 :
35
- """base class for SSD1306 display driver"""
34
+ class _SSD1306 :
35
+ """Base class for SSD1306 display driver"""
36
36
def __init__ (self , framebuffer , width , height , external_vcc ):
37
37
self .framebuf = framebuffer
38
38
self .width = width
@@ -46,7 +46,7 @@ def __init__(self, framebuffer, width, height, external_vcc):
46
46
self .init_display ()
47
47
48
48
def init_display (self ):
49
- """base class initialize display"""
49
+ """Base class to initialize display"""
50
50
for cmd in (
51
51
SET_DISP | 0x00 , # off
52
52
# address setting
@@ -74,32 +74,32 @@ def init_display(self):
74
74
self .show ()
75
75
76
76
def poweroff (self ):
77
- """poweroff """
77
+ """Turn the device Power off """
78
78
self .write_cmd (SET_DISP | 0x00 )
79
79
80
80
def contrast (self , contrast ):
81
- """adjust the contrast"""
81
+ """Adjust the contrast"""
82
82
self .write_cmd (SET_CONTRAST )
83
83
self .write_cmd (contrast )
84
84
85
85
def invert (self , invert ):
86
- """invert the pixels on the display"""
86
+ """Invert the pixels on the display"""
87
87
self .write_cmd (SET_NORM_INV | (invert & 1 ))
88
88
89
89
def write_framebuf (self ):
90
- """"derived class must implement this"""
91
- pass
90
+ """Derived class must implement this"""
91
+ raise NotImplementedError
92
92
93
93
def write_cmd (self , cmd ):
94
- """"derived class must implement this"""
95
- pass
94
+ """Derived class must implement this"""
95
+ raise NotImplementedError
96
96
97
97
def poweron (self ):
98
- """"derived class must implement this"""
99
- pass
98
+ """Derived class must implement this"""
99
+ raise NotImplementedError
100
100
101
101
def show (self ):
102
- """update the display"""
102
+ """Update the display"""
103
103
xpos0 = 0
104
104
xpos1 = self .width - 1
105
105
if self .width == 64 :
@@ -115,22 +115,22 @@ def show(self):
115
115
self .write_framebuf ()
116
116
117
117
def fill (self , value ):
118
- """fill the display on or off"""
118
+ """Fill the display on or off"""
119
119
self .framebuf .fill (value )
120
120
121
121
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"""
123
123
self .framebuf .pixel (xpos , ypos , value )
124
124
125
125
def scroll (self , deltax , deltay ):
126
- """scroll the display content by delta x,y"""
126
+ """Scroll the display content by delta x,y"""
127
127
self .framebuf .scroll (deltax , deltay )
128
128
129
129
def text (self , string , xpos , ypos , col = 1 ):
130
- """place text on display"""
130
+ """Place text on display"""
131
131
self .framebuf .text (string , xpos , ypos , col )
132
132
133
- class SSD1306_I2C (SSD1306 ):
133
+ class SSD1306_I2C (_SSD1306 ):
134
134
""" I2C class for SSD1306
135
135
"""
136
136
@@ -162,11 +162,11 @@ def write_framebuf(self):
162
162
self .i2c_device .write (self .buffer )
163
163
164
164
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 )
167
167
168
168
#pylint: disable-msg=too-many-arguments
169
- class SSD1306_SPI (SSD1306 ):
169
+ class SSD1306_SPI (_SSD1306 ):
170
170
""" SPI class for SSD1306
171
171
"""
172
172
def __init__ (self , width , height , spi , dc , res , cs , * ,
0 commit comments