-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathST7789.py
More file actions
693 lines (590 loc) · 19.6 KB
/
Copy pathST7789.py
File metadata and controls
693 lines (590 loc) · 19.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
#driver for Sainsmart 1.8" TFT display ST7789
#Translated by Guy Carver from the ST7789 sample code.
#Modirfied for micropython-esp32 by boochow
import machine
import time
from math import sqrt
#TFTRotations and TFTRGB are bits to set
# on MADCTL to control display rotation/color layout
#Looking at display with pins on top.
#00 = upper left printing right
#10 = does nothing (MADCTL_ML)
#20 = upper left printing down (backwards) (Vertical flip)
#40 = upper right printing left (backwards) (X Flip)
#80 = lower left printing right (backwards) (Y Flip)
#04 = (MADCTL_MH)
#60 = 90 right rotation
#C0 = 180 right rotation
#A0 = 270 right rotation
TFTRotations = [0x00, 0x60, 0xC0, 0xA0]
TFTBGR = 0x08 #When set color is bgr else rgb.
TFTRGB = 0x00
#@micropython.native
def clamp( aValue, aMin, aMax ) :
return max(aMin, min(aMax, aValue))
#@micropython.native
def TFTColor( aR, aG, aB ) :
'''Create a 16 bit rgb value from the given R,G,B from 0-255.
This assumes rgb 565 layout and will be incorrect for bgr.'''
return ((aR & 0xF8) << 8) | ((aG & 0xFC) << 3) | (aB >> 3)
ScreenSize = (240, 320)
boardName = "SKIDS_7789"
class TFT(object) :
"""Sainsmart TFT 7789 display driver."""
NOP = 0x0
SWRESET = 0x01
RDDID = 0x04
RDDST = 0x09
SLPIN = 0x10
SLPOUT = 0x11
PTLON = 0x12
NORON = 0x13
INVOFF = 0x20
INVON = 0x21
DISPOFF = 0x28
DISPON = 0x29
CASET = 0x2A
RASET = 0x2B
RAMWR = 0x2C
RAMRD = 0x2E
VSCRDEF = 0x33
VSCSAD = 0x37
COLMOD = 0x3A
MADCTL = 0x36
RAMCTRL = 0xB0
RGBCTRL = 0xB1
PORCTRL = 0xB2
FRCTRL1 = 0xB3
PARCTRL = 0xB5
GCTRL = 0xB7
VCOMS = 0xBB
LCMCTRL = 0xC0
VDVVRHEN = 0xC2
VRHS = 0xC3
VDVS = 0xC4
VCMOFSET = 0xC5
FRCTRL2 = 0xC6
PWCTRL1 = 0xD0
GMCTRP1 = 0xE0
GMCTRN1 = 0xE1
BLACK = 0
RED = TFTColor(0xFF, 0x00, 0x00)
MAROON = TFTColor(0x80, 0x00, 0x00)
GREEN = TFTColor(0x00, 0xFF, 0x00)
FOREST = TFTColor(0x00, 0x80, 0x80)
BLUE = TFTColor(0x00, 0x00, 0xFF)
NAVY = TFTColor(0x00, 0x00, 0x80)
CYAN = TFTColor(0x00, 0xFF, 0xFF)
YELLOW = TFTColor(0xFF, 0xFF, 0x00)
PURPLE = TFTColor(0xFF, 0x00, 0xFF)
WHITE = TFTColor(0xFF, 0xFF, 0xFF)
GRAY = TFTColor(0x80, 0x80, 0x80)
@staticmethod
def color( aR, aG, aB ) :
'''Create a 565 rgb TFTColor value'''
return TFTColor(aR, aG, aB)
def __init__( self, spi, aDC, aCS, aReset=None) :
"""aLoc SPI pin location is either 1 for 'X' or 2 for 'Y'.
aDC is the DC pin and aReset is the reset pin."""
self._size = ScreenSize
self._offset = bytearray([0,0])
self.rotate = 0 #Vertical with top toward pins.
self._rgb = True #color order of rgb.
self.tfa = 0 #top fixed area
self.bfa = 0 #bottom fixed area
self.dc = machine.Pin(aDC, machine.Pin.OUT, machine.Pin.PULL_DOWN)
if aReset is None:
self.reset = None
else:
self.reset = machine.Pin(aReset, machine.Pin.OUT, machine.Pin.PULL_DOWN)
self.cs = machine.Pin(aCS, machine.Pin.OUT, machine.Pin.PULL_DOWN)
self.cs(1)
self.spi = spi
self.colorData = bytearray(2)
self.windowLocData = bytearray(4)
def size( self ) :
return self._size
# @micropython.native
def on( self, aTF = True ) :
'''Turn display on or off.'''
self._writecommand(TFT.DISPON if aTF else TFT.DISPOFF)
# @micropython.native
def invertcolor( self, aBool ) :
'''Invert the color data IE: Black = White.'''
self._writecommand(TFT.INVON if aBool else TFT.INVOFF)
# @micropython.native
def rgb( self, aTF = True ) :
'''True = rgb else bgr'''
self._rgb = aTF
self._setMADCTL()
# @micropython.native
def rotation( self, aRot ) :
'''0 - 3. Starts vertical with top toward pins and rotates 90 deg
clockwise each step.'''
if (0 <= aRot < 4):
rotchange = self.rotate ^ aRot
self.rotate = aRot
#If switching from vertical to horizontal swap x,y
# (indicated by bit 0 changing).
if (rotchange & 1):
self._size =(self._size[1], self._size[0])
self._setMADCTL()
# @micropython.native
def pixel( self, aPos, aColor ) :
'''Draw a pixel at the given position'''
if 0 <= aPos[0] < self._size[0] and 0 <= aPos[1] < self._size[1]:
self._setwindowpoint(aPos)
self._pushcolor(aColor)
# @micropython.native
def text( self, aPos, aString, aColor, aFont, aSize = 1, nowrap = False ) :
'''Draw a text at the given position. If the string reaches the end of the
display it is wrapped to aPos[0] on the next line. aSize may be an integer
which will size the font uniformly on w,h or a or any type that may be
indexed with [0] or [1].'''
if aFont == None:
return
#Make a size either from single value or 2 elements.
if (type(aSize) == int) or (type(aSize) == float):
wh = (aSize, aSize)
else:
wh = aSize
px, py = aPos
width = wh[0] * aFont["Width"] + 1
for c in aString:
self.char((px, py), c, aColor, aFont, wh)
px += width
#We check > rather than >= to let the right (blank) edge of the
# character print off the right of the screen.
if px + width > self._size[0]:
if nowrap:
break
else:
py += aFont["Height"] * wh[1] + 1
px = aPos[0]
# @micropython.native
def char( self, aPos, aChar, aColor, aFont, aSizes ) :
'''Draw a character at the given position using the given font and color.
aSizes is a tuple with x, y as integer scales indicating the
# of pixels to draw for each pixel in the character.'''
if aFont == None:
return
startchar = aFont['Start']
endchar = aFont['End']
ci = ord(aChar)
if (startchar <= ci <= endchar):
fontw = aFont['Width']
fonth = aFont['Height']
ci = (ci - startchar) * fontw
charA = aFont["Data"][ci:ci + fontw]
px = aPos[0]
if aSizes[0] <= 1 and aSizes[1] <= 1 :
buf = bytearray(2 * fonth * fontw)
for q in range(fontw) :
c = charA[q]
for r in range(fonth) :
if c & 0x01 :
pos = 2 * (r * fontw + q)
buf[pos] = aColor >> 8
buf[pos + 1] = aColor & 0xff
c >>= 1
self.image(aPos[0], aPos[1], aPos[0] + fontw - 1, aPos[1] + fonth - 1, buf)
else:
for c in charA :
py = aPos[1]
for r in range(fonth) :
if c & 0x01 :
self.fillrect((px, py), aSizes, aColor)
py += aSizes[1]
c >>= 1
px += aSizes[0]
# @micropython.native
def line( self, aStart, aEnd, aColor ) :
'''Draws a line from aStart to aEnd in the given color. Vertical or horizontal
lines are forwarded to vline and hline.'''
if aStart[0] == aEnd[0]:
#Make sure we use the smallest y.
pnt = aEnd if (aEnd[1] < aStart[1]) else aStart
self.vline(pnt, abs(aEnd[1] - aStart[1]) + 1, aColor)
elif aStart[1] == aEnd[1]:
#Make sure we use the smallest x.
pnt = aEnd if aEnd[0] < aStart[0] else aStart
self.hline(pnt, abs(aEnd[0] - aStart[0]) + 1, aColor)
else:
px, py = aStart
ex, ey = aEnd
dx = ex - px
dy = ey - py
inx = 1 if dx > 0 else -1
iny = 1 if dy > 0 else -1
dx = abs(dx)
dy = abs(dy)
if (dx >= dy):
dy <<= 1
e = dy - dx
dx <<= 1
while (px != ex):
self.pixel((px, py), aColor)
if (e >= 0):
py += iny
e -= dx
e += dy
px += inx
else:
dx <<= 1
e = dx - dy
dy <<= 1
while (py != ey):
self.pixel((px, py), aColor)
if (e >= 0):
px += inx
e -= dy
e += dx
py += iny
# @micropython.native
def vline( self, aStart, aLen, aColor ) :
'''Draw a vertical line from aStart for aLen. aLen may be negative.'''
start = (clamp(aStart[0], 0, self._size[0]), clamp(aStart[1], 0, self._size[1]))
stop = (start[0], clamp(start[1] + aLen, 0, self._size[1]))
#Make sure smallest y 1st.
if (stop[1] < start[1]):
start, stop = stop, start
self._setwindowloc(start, stop)
self._setColor(aColor)
self._draw(aLen)
# @micropython.native
def hline( self, aStart, aLen, aColor ) :
'''Draw a horizontal line from aStart for aLen. aLen may be negative.'''
start = (clamp(aStart[0], 0, self._size[0]), clamp(aStart[1], 0, self._size[1]))
stop = (clamp(start[0] + aLen, 0, self._size[0]), start[1])
#Make sure smallest x 1st.
if (stop[0] < start[0]):
start, stop = stop, start
self._setwindowloc(start, stop)
self._setColor(aColor)
self._draw(aLen)
# @micropython.native
def rect( self, aStart, aSize, aColor ) :
'''Draw a hollow rectangle. aStart is the smallest coordinate corner
and aSize is a tuple indicating width, height.'''
self.hline(aStart, aSize[0], aColor)
self.hline((aStart[0], aStart[1] + aSize[1] - 1), aSize[0], aColor)
self.vline(aStart, aSize[1], aColor)
self.vline((aStart[0] + aSize[0] - 1, aStart[1]), aSize[1], aColor)
# @micropython.native
def fillrect( self, aStart, aSize, aColor ) :
'''Draw a filled rectangle. aStart is the smallest coordinate corner
and aSize is a tuple indicating width, height.'''
start = (clamp(aStart[0], 0, self._size[0]), clamp(aStart[1], 0, self._size[1]))
end = (clamp(start[0] + aSize[0] - 1, 0, self._size[0]), clamp(start[1] + aSize[1] - 1, 0, self._size[1]))
if (end[0] < start[0]):
tmp = end[0]
end = (start[0], end[1])
start = (tmp, start[1])
if (end[1] < start[1]):
tmp = end[1]
end = (end[0], start[1])
start = (start[0], tmp)
self._setwindowloc(start, end)
numPixels = (end[0] - start[0] + 1) * (end[1] - start[1] + 1)
self._setColor(aColor)
self._draw(numPixels)
# @micropython.native
def circle( self, aPos, aRadius, aColor ) :
'''Draw a hollow circle with the given radius and color with aPos as center.'''
self.colorData[0] = aColor >> 8
self.colorData[1] = aColor
xend = int(0.7071 * aRadius) + 1
rsq = aRadius * aRadius
for x in range(xend) :
y = int(sqrt(rsq - x * x))
xp = aPos[0] + x
yp = aPos[1] + y
xn = aPos[0] - x
yn = aPos[1] - y
xyp = aPos[0] + y
yxp = aPos[1] + x
xyn = aPos[0] - y
yxn = aPos[1] - x
self._setwindowpoint((xp, yp))
self._writedata(self.colorData)
self._setwindowpoint((xp, yn))
self._writedata(self.colorData)
self._setwindowpoint((xn, yp))
self._writedata(self.colorData)
self._setwindowpoint((xn, yn))
self._writedata(self.colorData)
self._setwindowpoint((xyp, yxp))
self._writedata(self.colorData)
self._setwindowpoint((xyp, yxn))
self._writedata(self.colorData)
self._setwindowpoint((xyn, yxp))
self._writedata(self.colorData)
self._setwindowpoint((xyn, yxn))
self._writedata(self.colorData)
# @micropython.native
def fillcircle( self, aPos, aRadius, aColor ) :
'''Draw a filled circle with given radius and color with aPos as center'''
rsq = aRadius * aRadius
for x in range(aRadius) :
y = int(sqrt(rsq - x * x))
y0 = aPos[1] - y
ey = y0 + y * 2
y0 = clamp(y0, 0, self._size[1])
ln = abs(ey - y0) + 1;
self.vline((aPos[0] + x, y0), ln, aColor)
self.vline((aPos[0] - x, y0), ln, aColor)
def fill( self, aColor = BLACK ) :
'''Fill screen with the given color.'''
print(aColor)
self.fillrect((0, 0), self._size, aColor)
def image( self, x0, y0, x1, y1, data ) :
self._setwindowloc((x0, y0), (x1, y1))
self._writedata(data)
def setvscroll(self, tfa, bfa) :
''' set vertical scroll area '''
self._writecommand(TFT.VSCRDEF)
data2 = bytearray([0, tfa])
self._writedata(data2)
data2[1] = 162 - tfa - bfa
self._writedata(data2)
data2[1] = bfa
self._writedata(data2)
self.tfa = tfa
self.bfa = bfa
def vscroll(self, value) :
a = value + self.tfa
if (a + self.bfa > 162) :
a = 162 - self.bfa
self._vscrolladdr(a)
def _vscrolladdr(self, addr) :
self._writecommand(TFT.VSCSAD)
data2 = bytearray([addr >> 8, addr & 0xff])
self._writedata(data2)
# @micropython.native
def _setColor( self, aColor ) :
self.colorData[0] = aColor >> 8
self.colorData[1] = aColor
self.buf = bytes(self.colorData) * 32
# @micropython.native
def _draw( self, aPixels ) :
'''Send given color to the device aPixels times.'''
self.dc(1)
self.cs(0)
for i in range(aPixels//32):
self.spi.write(self.buf)
rest = (int(aPixels) % 32)
if rest > 0:
buf2 = bytes(self.colorData) * rest
self.spi.write(buf2)
self.cs(1)
# @micropython.native
def _setwindowpoint( self, aPos ) :
'''Set a single point for drawing a color to.'''
x = self._offset[0] + int(aPos[0])
y = self._offset[1] + int(aPos[1])
self._writecommand(TFT.CASET) #Column address set.
self.windowLocData[0] = (x>>8)&0xFF
self.windowLocData[1] = x&0xFF
self.windowLocData[2] = (x>>8)&0xFF
self.windowLocData[3] = x&0xFF
self._writedata(self.windowLocData)
self._writecommand(TFT.RASET) #Row address set.
self.windowLocData[0] = (y>>8)&0xFF
self.windowLocData[1] = y&0xFF
self.windowLocData[2] = (y>>8)&0xFF
self.windowLocData[3] = y&0xFF
self._writedata(self.windowLocData)
self._writecommand(TFT.RAMWR) #Write to RAM.
# @micropython.native
def _setwindowloc( self, aPos0, aPos1 ) :
'''Set a rectangular area for drawing a color to.'''
x1 = self._offset[0] + int(aPos0[0])
x2 = self._offset[0] + int(aPos1[0])
self.windowLocData[0] = (x1>>8)&0xFF
self.windowLocData[1] = x1&0xFF
self.windowLocData[2] = (x2>>8)&0xFF
self.windowLocData[3] = x2&0xFF
self._writecommand(TFT.CASET) #Column address set.
self._writedata(self.windowLocData)
y1 = self._offset[1] + int(aPos0[1])
y2 = self._offset[1] + int(aPos1[1])
self.windowLocData[0] = (y1>>8)&0xFF
self.windowLocData[1] = y1&0xFF
self.windowLocData[2] = (y2>>8)&0xFF
self.windowLocData[3] = y2&0xFF
self._writecommand(TFT.RASET) #Row address set.
self._writedata(self.windowLocData)
self._writecommand(TFT.RAMWR) #Write to RAM.
#@micropython.native
def _writecommand( self, aCommand ) :
'''Write given command to the device.'''
self.dc(0)
self.cs(0)
self.spi.write(bytearray([aCommand]))
self.cs(1)
#@micropython.native
def _writedata( self, aData ) :
'''Write given data to the device. This may be
either a single int or a bytearray of values.'''
self.dc(1)
self.cs(0)
self.spi.write(aData)
self.cs(1)
#@micropython.native
def _pushcolor( self, aColor ) :
'''Push given color to the device.'''
self.colorData[0] = aColor >> 8
self.colorData[1] = aColor
self._writedata(self.colorData)
#@micropython.native
def _setMADCTL( self ) :
'''Set screen rotation and RGB/BGR format.'''
self._writecommand(TFT.MADCTL)
rgb = TFTRGB if self._rgb else TFTBGR
self._writedata(bytearray([TFTRotations[self.rotate] | rgb]))
#@micropython.native
def _reset( self ) :
'''Reset the device.'''
if self.reset is None:
self._writecommand(TFT.SWRESET)
time.sleep_ms(100)
else:
self.dc(0)
self.reset(1)
time.sleep_us(500)
self.reset(0)
time.sleep_us(500)
self.reset(1)
time.sleep_us(500)
def initr( self ) :
if boardName is 'SKIDS_7789':
print("skids_lcd_initr")
self.skids_lcd_initr()
else:
print("zj_initr")
self.zj_initr()
# for 7789 from zhongjingyuan
def zj_initr( self ) :
'''Initialize a red tab version.'''
self._reset()
self._writecommand(TFT.SLPOUT) #out of sleep mode.
time.sleep_us(500)
data1 = bytearray(1)
self._writecommand(TFT.MADCTL)
data1[0] = 0x00
self._writedata(data1)
self._writecommand(TFT.COLMOD)
data1[0] = 0x05
self._writedata(data1)
data5 = bytearray([0x0C, 0x0C, 0x00, 0x33, 0x33])
self._writecommand(TFT.PORCTRL)
self._writedata(data5)
self._writecommand(TFT.GCTRL)
data1[0] = 0x35
self._writedata(data1)
self._writecommand(TFT.VCOMS)
data1[0] = 0x19
self._writedata(data1)
self._writecommand(TFT.LCMCTRL) #Power control
data1[0] = 0x2c
self._writedata(data1)
data2 = bytearray(2)
self._writecommand(TFT.VDVVRHEN) #Power control
data1[0] = 0x01
self._writedata(data1)
self._writecommand(TFT.VRHS) #Power control
data1[0] = 0x12
self._writedata(data1)
self._writecommand(TFT.VDVS) #Power control
data1[0] = 0x20
self._writedata(data1)
self._writecommand(TFT.FRCTRL2) #FRCTRL2 control
data1[0] = 0x0F
self._writedata(data1)
self._writecommand(TFT.PWCTRL1)
data2[0] = 0xA4
data2[1] = 0xA1
self._writedata(data2)
dataGMCTRP = bytearray([0xd0, 0x04, 0x0d, 0x11, 0x13, 0x2b, 0x3f, 0x54, 0x4c,
0x18, 0x0d, 0x0b, 0x1f, 0x23])
self._writecommand(TFT.GMCTRP1)
self._writedata(dataGMCTRP)
dataGMCTRN = bytearray([0xd0, 0x04, 0x0d, 0x11, 0x13, 0x2b, 0x3f, 0x44, 0x51,
0x2F, 0x1F, 0x1F, 0x20, 0x23])
self._writecommand(TFT.GMCTRN1)
self._writedata(dataGMCTRN)
time.sleep_us(10)
self._writecommand(TFT.DISPON)
time.sleep_us(100)
self.cs(1)
def skids_lcd_initr( self ) :
'''Initialize a red tab version.'''
self._reset()
self._writecommand(TFT.SLPOUT) #out of sleep mode.
time.sleep_us(500)
data1 = bytearray(1)
self._writecommand(TFT.MADCTL)
data1[0] = 0x00
self._writedata(data1)
self._writecommand(TFT.COLMOD)
data1[0] = 0x05
self._writedata(data1)
data5 = bytearray([0x0C, 0x0C, 0x00, 0x33, 0x33])
self._writecommand(TFT.PORCTRL)
self._writedata(data5)
self._writecommand(TFT.GCTRL)
data1[0] = 0x35
self._writedata(data1)
self._writecommand(TFT.VCOMS)
data1[0] = 0x28
self._writedata(data1)
self._writecommand(TFT.LCMCTRL) #Power control
data1[0] = 0x2c
self._writedata(data1)
data2 = bytearray(2)
self._writecommand(TFT.VDVVRHEN) #Power control
data1[0] = 0x01
self._writedata(data1)
self._writecommand(TFT.VRHS) #Power control
data1[0] = 0x0b
self._writedata(data1)
self._writecommand(TFT.VDVS) #Power control
data1[0] = 0x20
self._writedata(data1)
self._writecommand(TFT.FRCTRL2) #FRCTRL2 control
data1[0] = 0x0F
self._writedata(data1)
self._writecommand(TFT.PWCTRL1)
data2[0] = 0xA4
data2[1] = 0xA1
self._writedata(data2)
dataGMCTRP = bytearray([0xd0, 0x01, 0x08, 0x0f, 0x11, 0x2a, 0x36, 0x55, 0x44,
0x3a, 0x0b, 0x06, 0x1f, 0x20])
self._writecommand(TFT.GMCTRP1)
self._writedata(dataGMCTRP)
dataGMCTRN = bytearray([0xd0, 0x02, 0x07, 0x0a, 0x0b, 0x18, 0x34, 0x43, 0x4a,
0x2b, 0x1b, 0x1c, 0x22, 0x1f])
self._writecommand(TFT.GMCTRN1)
self._writedata(dataGMCTRN)
time.sleep_us(10)
self._writecommand(TFT.DISPON)
time.sleep_us(100)
self.cs(1)
def maker( ) :
t = TFT(1, "X1", "X2")
print("Initializing")
t.initr()
t.fill(0)
return t
def makeb( ) :
t = TFT(1, "X1", "X2")
print("Initializing")
t.initb()
t.fill(0)
return t
def makeg( ) :
t = TFT(1, "X1", "X2")
print("Initializing")
t.initg()
t.fill(0)
return t