-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fdbac31
commit 83b275f
Showing
7 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,6 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# PyCharm | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,24 @@ | ||
# turing-smart-screen-python | ||
A simple Python manager for Turing Smart Screen 3.5" TFT USB | ||
A simple Python manager for "Turing Smart Screen" 3.5" IPS USB-C (UART) display, also known as : | ||
- Turing USB35INCHIPS / USB35INCHIPSV2 | ||
- 3.5 Inch Mini Screen | ||
- [3.5 Inch 320*480 Mini Capacitive Touch Screen IPS Module](https://www.aliexpress.com/item/1005002505149293.html) | ||
|
||
Operating systems supported : macOS, Windows, Linux (incl. Raspberry Pi) and all OS that support Python3 | ||
|
||
<img src="res/smart-screen-3.webp" width="500"/> | ||
|
||
This is a 3.5" USB-C display that shows as a serial port once connected. | ||
It cannot be seen by the operating system as a monitor but picture can be displayed on it. | ||
|
||
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. | ||
This software allows creating themes to display your computer sensors on the display, but does not offer a simple way to display custom pictures. | ||
|
||
This Python script has been created to do some simple operations on this display like : | ||
- **Display custom picture** | ||
- Clear the screen (blank) | ||
- Turn the screen on/off | ||
- Display soft reset | ||
- Set brightness | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import struct | ||
from time import sleep | ||
|
||
import serial # Install pyserial : pip install pyserial | ||
from PIL import Image # Install PIL or Pillow | ||
|
||
# Set your COM port e.g. COM3 for Windows, /dev/ttyACM0 for Linux... | ||
COM_PORT = "/dev/ttyACM1" | ||
# COM_PORT = "COM5" | ||
|
||
def SendReg(ser, reg, x, y, ex, ey): | ||
byteBuffer = bytearray(6) | ||
byteBuffer[0] = (x >> 2) | ||
byteBuffer[1] = (((x & 3) << 6) + (y >> 4)) | ||
byteBuffer[2] = (((y & 15) << 4) + (ex >> 6)) | ||
byteBuffer[3] = (((ex & 63) << 2) + (ey >> 8)) | ||
byteBuffer[4] = (ey & 255) | ||
byteBuffer[5] = reg | ||
ser.write(bytes(byteBuffer)) | ||
|
||
|
||
def Reset(ser): | ||
SendReg(ser, 101, 0, 0, 0, 0) | ||
|
||
|
||
def Clear(ser): | ||
SendReg(ser, 102, 0, 0, 0, 0) | ||
|
||
|
||
def ScreenOff(ser): | ||
SendReg(ser, 108, 0, 0, 0, 0) | ||
|
||
|
||
def ScreenOn(ser): | ||
SendReg(ser, 109, 0, 0, 0, 0) | ||
|
||
|
||
def SetBrightness(ser, level): | ||
# Level : 0 (bright) - 255 (darkest) | ||
SendReg(ser, 110, level, 0, 0, 0) | ||
|
||
|
||
def PrintImage(ser, image): | ||
im = Image.open(image) | ||
image_height = im.size[1] | ||
image_width = im.size[0] | ||
|
||
SendReg(ser, 197, 0, 0, image_width - 1, image_height - 1) | ||
|
||
pix = im.load() | ||
for h in range(image_height): | ||
line = bytes() | ||
for w in range(image_width): | ||
if w < image_width: | ||
R = pix[w, h][0] >> 3 | ||
G = pix[w, h][1] >> 2 | ||
B = pix[w, h][2] >> 3 | ||
|
||
rgb = (R << 11) | (G << 5) | B | ||
line += struct.pack('H', rgb) | ||
ser.write(line) | ||
|
||
sleep(0.01) # Wait 10 ms after picture display | ||
|
||
|
||
if __name__ == "__main__": | ||
ser = serial.Serial(COM_PORT, 115200, timeout=1, rtscts=1) | ||
|
||
# Clear screen (blank) | ||
Clear(ser) | ||
|
||
# Set brightness to max value | ||
SetBrightness(ser, 0) | ||
|
||
# Display sample picture | ||
PrintImage(ser, "res/example.png") | ||
|
||
ser.close() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.