2828* Author(s): Radomir Dopieralski, Michael McWethy
2929"""
3030
31- import time
32-
3331try :
3432 import struct
3533except ImportError :
8684_GMCTRP1 = const (0xE0 )
8785_GMCTRN1 = const (0xE1 )
8886
89- _TSTCMD1 = const (0xF0 )
90- _DISRPSM1 = const (0xF6 )
91-
92-
9387class ST7735 (DisplaySPI ):
9488 """
9589 A simple driver for the ST7735-based displays.
@@ -203,37 +197,39 @@ class ST7735S(ST7735):
203197 """A simple driver for the ST7735S-based displays."""
204198 _INIT = (
205199 # 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 ' ),
209203
210204 # Column inversion
211- (_INVCTR , b'\x07 ' ), # B4
205+ (_INVCTR , b'\x07 ' ),
212206
213207 # 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 ' ),
219213
220214 # VCOM
221- (_VMCTR1 , b'\x0e ' ), # C5
215+ (_VMCTR1 , b'\x0e ' ),
222216
223217 # Gamma
224- (_GMCTRP1 , b'\x0f \x1a \x0f \x18 \x2f \x28 \x20 \x22 ' # E0
218+ (_GMCTRP1 , b'\x0f \x1a \x0f \x18 \x2f \x28 \x20 \x22 '
225219 b'\x1f \x1b \x23 \x37 \x00 \x07 \x02 \x10 ' ),
226220
227- (_GMCTRN1 , b'\x0f \x1b \x0f \x17 \x33 \x2c \x29 \x2e ' # E1
221+ (_GMCTRN1 , b'\x0f \x1b \x0f \x17 \x33 \x2c \x29 \x2e '
228222 b'\x30 \x30 \x39 \x3f \x00 \x07 \x03 \x10 ' ),
229223 # Enable test command
230- (_TSTCMD1 , b'\x01 ' ), # F0
224+ # (_TSTCMD1, b'\x01'),
231225 # Disable ram power save mode
232- (_DISRPSM1 , b'\x00 ' ), # F6
226+ # (_DISRPSM1, b'\x00'),
233227 # 65k mode
234- (_COLMOD , b'\x05 ' ), # 3A
228+ (_COLMOD , b'\x05 ' ),
235229 # set scan direction: up to down, right to left
236- (_MADCTL , b'\x60 ' ), # 36
230+ (_MADCTL , b'\x60 ' ),
231+ (_SLPOUT , None ),
232+ (_DISPON , None ),
237233 )
238234
239235 #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,
242238 x_offset = 2 , y_offset = 1 , rotation = 0 , bgr = False ):
243239 self ._bl = bl
244240 # Turn on backlight
245- print ('turn on backlight' )
246241 self ._bl .switch_to_output (value = 1 )
247242 super ().__init__ (spi , dc , cs , rst , width , height ,
248243 baudrate = baudrate , polarity = polarity , phase = phase ,
249244 x_offset = x_offset , y_offset = y_offset , rotation = rotation )
250245
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