28
28
* Author(s): Radomir Dopieralski, Michael McWethy
29
29
"""
30
30
31
- import time
32
-
33
31
try :
34
32
import struct
35
33
except ImportError :
86
84
_GMCTRP1 = const (0xE0 )
87
85
_GMCTRN1 = const (0xE1 )
88
86
89
- _TSTCMD1 = const (0xF0 )
90
- _DISRPSM1 = const (0xF6 )
91
-
92
-
93
87
class ST7735 (DisplaySPI ):
94
88
"""
95
89
A simple driver for the ST7735-based displays.
@@ -203,37 +197,39 @@ class ST7735S(ST7735):
203
197
"""A simple driver for the ST7735S-based displays."""
204
198
_INIT = (
205
199
# Frame Rate
206
- (_FRMCTR1 , b'\x01 \x2c \x2d ' ), # B1
207
- (_FRMCTR2 , b'\x01 \x2c \x2d ' ), # B2
208
- (_FRMCTR3 , b'\x01 \x2c \x2d \x01 \x2c \x2d ' ), # B3
200
+ (_FRMCTR1 , b'\x01 \x2c \x2d ' ),
201
+ (_FRMCTR2 , b'\x01 \x2c \x2d ' ),
202
+ (_FRMCTR3 , b'\x01 \x2c \x2d \x01 \x2c \x2d ' ),
209
203
210
204
# Column inversion
211
- (_INVCTR , b'\x07 ' ), # B4
205
+ (_INVCTR , b'\x07 ' ),
212
206
213
207
# Power Sequence
214
- (_PWCTR1 , b'\xa2 \x02 \x84 ' ), # C0
215
- (_PWCTR2 , b'\xc5 ' ), # C1
216
- (_PWCTR3 , b'\x0a \x00 ' ), # C2
217
- (_PWCTR4 , b'\x8a \x2a ' ), # C3
218
- (_PWCTR5 , b'\x8a \xee ' ), # C4
208
+ (_PWCTR1 , b'\xa2 \x02 \x84 ' ),
209
+ (_PWCTR2 , b'\xc5 ' ),
210
+ (_PWCTR3 , b'\x0a \x00 ' ),
211
+ (_PWCTR4 , b'\x8a \x2a ' ),
212
+ (_PWCTR5 , b'\x8a \xee ' ),
219
213
220
214
# VCOM
221
- (_VMCTR1 , b'\x0e ' ), # C5
215
+ (_VMCTR1 , b'\x0e ' ),
222
216
223
217
# Gamma
224
- (_GMCTRP1 , b'\x0f \x1a \x0f \x18 \x2f \x28 \x20 \x22 ' # E0
218
+ (_GMCTRP1 , b'\x0f \x1a \x0f \x18 \x2f \x28 \x20 \x22 '
225
219
b'\x1f \x1b \x23 \x37 \x00 \x07 \x02 \x10 ' ),
226
220
227
- (_GMCTRN1 , b'\x0f \x1b \x0f \x17 \x33 \x2c \x29 \x2e ' # E1
221
+ (_GMCTRN1 , b'\x0f \x1b \x0f \x17 \x33 \x2c \x29 \x2e '
228
222
b'\x30 \x30 \x39 \x3f \x00 \x07 \x03 \x10 ' ),
229
223
# Enable test command
230
- (_TSTCMD1 , b'\x01 ' ), # F0
224
+ # (_TSTCMD1, b'\x01'),
231
225
# Disable ram power save mode
232
- (_DISRPSM1 , b'\x00 ' ), # F6
226
+ # (_DISRPSM1, b'\x00'),
233
227
# 65k mode
234
- (_COLMOD , b'\x05 ' ), # 3A
228
+ (_COLMOD , b'\x05 ' ),
235
229
# set scan direction: up to down, right to left
236
- (_MADCTL , b'\x60 ' ), # 36
230
+ (_MADCTL , b'\x60 ' ),
231
+ (_SLPOUT , None ),
232
+ (_DISPON , None ),
237
233
)
238
234
239
235
#pylint: disable-msg=useless-super-delegation, too-many-arguments
@@ -242,37 +238,8 @@ def __init__(self, spi, dc, cs, bl, rst=None, width=128, height=160,
242
238
x_offset = 2 , y_offset = 1 , rotation = 0 , bgr = False ):
243
239
self ._bl = bl
244
240
# Turn on backlight
245
- print ('turn on backlight' )
246
241
self ._bl .switch_to_output (value = 1 )
247
242
super ().__init__ (spi , dc , cs , rst , width , height ,
248
243
baudrate = baudrate , polarity = polarity , phase = phase ,
249
244
x_offset = x_offset , y_offset = y_offset , rotation = rotation )
250
245
251
- # def reset(self):
252
- # print('reset')
253
- # self.rst.value = 1
254
- # time.sleep(0.100)
255
- # self.rst.value = 0
256
- # time.sleep(0.100)
257
- # self.rst.value = 1
258
- # time.sleep(0.100)
259
-
260
- def init (self ):
261
-
262
- super ().init ()
263
- print ('last commands of init' )
264
-
265
- # cols = struct.pack('>HH', 0, self.width - 1)
266
- # rows = struct.pack('>HH', 0, self.height - 1)
267
-
268
- # for command, data in (
269
- # (_CASET, cols),
270
- # (_RASET, rows),
271
- # (_NORON, None),
272
- # (_DISPON, None),
273
- # ):
274
- # self.write(command, data)
275
- time .sleep (0.200 )
276
- self .write (_SLPOUT )
277
- time .sleep (0.120 )
278
- self .write (_DISPON )
0 commit comments