Skip to content

Commit 83b275f

Browse files
committed
Initial release
1 parent fdbac31 commit 83b275f

7 files changed

+104
-1
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,6 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
# PyCharm
132+
.idea/

README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
11
# turing-smart-screen-python
2-
A simple Python manager for Turing Smart Screen 3.5" TFT USB
2+
A simple Python manager for "Turing Smart Screen" 3.5" IPS USB-C (UART) display, also known as :
3+
- Turing USB35INCHIPS / USB35INCHIPSV2
4+
- 3.5 Inch Mini Screen
5+
- [3.5 Inch 320*480 Mini Capacitive Touch Screen IPS Module](https://www.aliexpress.com/item/1005002505149293.html)
6+
7+
Operating systems supported : macOS, Windows, Linux (incl. Raspberry Pi) and all OS that support Python3
8+
9+
<img src="res/smart-screen-3.webp" width="500"/>
10+
11+
This is a 3.5" USB-C display that shows as a serial port once connected.
12+
It cannot be seen by the operating system as a monitor but picture can be displayed on it.
13+
14+
A Windows-only software is [available here](https://translate.google.com/translate?sl=auto&u=https://gitee.com/emperg/usblcd/raw/master/dev0/realse.ini) to manage this display.
15+
This software allows creating themes to display your computer sensors on the display, but does not offer a simple way to display custom pictures.
16+
17+
This Python script has been created to do some simple operations on this display like :
18+
- **Display custom picture**
19+
- Clear the screen (blank)
20+
- Turn the screen on/off
21+
- Display soft reset
22+
- Set brightness
23+
24+

main.py

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import struct
2+
from time import sleep
3+
4+
import serial # Install pyserial : pip install pyserial
5+
from PIL import Image # Install PIL or Pillow
6+
7+
# Set your COM port e.g. COM3 for Windows, /dev/ttyACM0 for Linux...
8+
COM_PORT = "/dev/ttyACM1"
9+
# COM_PORT = "COM5"
10+
11+
def SendReg(ser, reg, x, y, ex, ey):
12+
byteBuffer = bytearray(6)
13+
byteBuffer[0] = (x >> 2)
14+
byteBuffer[1] = (((x & 3) << 6) + (y >> 4))
15+
byteBuffer[2] = (((y & 15) << 4) + (ex >> 6))
16+
byteBuffer[3] = (((ex & 63) << 2) + (ey >> 8))
17+
byteBuffer[4] = (ey & 255)
18+
byteBuffer[5] = reg
19+
ser.write(bytes(byteBuffer))
20+
21+
22+
def Reset(ser):
23+
SendReg(ser, 101, 0, 0, 0, 0)
24+
25+
26+
def Clear(ser):
27+
SendReg(ser, 102, 0, 0, 0, 0)
28+
29+
30+
def ScreenOff(ser):
31+
SendReg(ser, 108, 0, 0, 0, 0)
32+
33+
34+
def ScreenOn(ser):
35+
SendReg(ser, 109, 0, 0, 0, 0)
36+
37+
38+
def SetBrightness(ser, level):
39+
# Level : 0 (bright) - 255 (darkest)
40+
SendReg(ser, 110, level, 0, 0, 0)
41+
42+
43+
def PrintImage(ser, image):
44+
im = Image.open(image)
45+
image_height = im.size[1]
46+
image_width = im.size[0]
47+
48+
SendReg(ser, 197, 0, 0, image_width - 1, image_height - 1)
49+
50+
pix = im.load()
51+
for h in range(image_height):
52+
line = bytes()
53+
for w in range(image_width):
54+
if w < image_width:
55+
R = pix[w, h][0] >> 3
56+
G = pix[w, h][1] >> 2
57+
B = pix[w, h][2] >> 3
58+
59+
rgb = (R << 11) | (G << 5) | B
60+
line += struct.pack('H', rgb)
61+
ser.write(line)
62+
63+
sleep(0.01) # Wait 10 ms after picture display
64+
65+
66+
if __name__ == "__main__":
67+
ser = serial.Serial(COM_PORT, 115200, timeout=1, rtscts=1)
68+
69+
# Clear screen (blank)
70+
Clear(ser)
71+
72+
# Set brightness to max value
73+
SetBrightness(ser, 0)
74+
75+
# Display sample picture
76+
PrintImage(ser, "res/example.png")
77+
78+
ser.close()

res/example.png

272 KB
Loading

res/smart-screen-1.webp

179 KB
Binary file not shown.

res/smart-screen-2.webp

159 KB
Binary file not shown.

res/smart-screen-3.webp

84.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)