Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
mathoudebine committed May 29, 2021
1 parent fdbac31 commit 83b275f
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

# PyCharm
.idea/
24 changes: 23 additions & 1 deletion README.md
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


78 changes: 78 additions & 0 deletions main.py
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()
Binary file added res/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/smart-screen-1.webp
Binary file not shown.
Binary file added res/smart-screen-2.webp
Binary file not shown.
Binary file added res/smart-screen-3.webp
Binary file not shown.

0 comments on commit 83b275f

Please sign in to comment.