Skip to content
Open
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Supported operating systems : macOS, Windows, Linux (incl. Raspberry Pi), basica
| ✅ Turing Smart Screen / TURZX |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| <img src="res/docs/turing.webp" width="30%" height="30%"/> <img src="res/docs/turing46inch.png" width="30%" height="30%"/> <img src="res/docs/turing5inch.png" width="30%" height="30%"/> <br/> <img src="res/docs/turing2inch.webp" width="30%" height="30%"/> <img src="res/docs/turing8inch.png" width="30%" height="30%"/> <img src="res/docs/turing8inch.webp" width="30%" height="30%"/> |
| All available sizes and hardware revisions supported: **2.1" / 2.8" / 3.5" / 4.6" / 5" / 5.2" / 8.0" / 8.8" / 9.2" / 12.3"** <br/>UART and USB protocols supported. Note: no video or storage support for now |
| All available sizes and hardware revisions supported: **2.1" / 2.8" / 3.5" / 4.6" / 5" / 5.2" / 8.0" / 8.8" / 9.2" / 12.3"** <br/>UART and USB protocols supported. Note: no video or storage support for now, except the [rev C 2.1" video face](res/docs/rev-c-video-face.md) |

| ✅ XuanFang 3.5" | ✅ [UsbPCMonitor 3.5" / 5"](https://aliexpress.com/item/1005003931363455.html) | ✅ Kipye Qiye Smart Display 3.5" |
|---------------------------------------------------|-----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
Expand Down Expand Up @@ -94,6 +94,8 @@ Some themes are already included for a quick start!
### [> Themes shared by the community](https://github.com/mathoudebine/turing-smart-screen-python/discussions/categories/themes)
<img src="https://user-images.githubusercontent.com/79225820/203648707-6f043068-5c9d-454d-9c0a-3d9ea02ece77.jpg" height="150" /> <img src="https://user-images.githubusercontent.com/121983479/210663324-994c987a-6489-4482-8883-db74ef566014.jpg" height="150" />
<img src="https://user-images.githubusercontent.com/120036534/208128675-897f60cd-5647-40b7-b074-b56b67e775dd.png" height="150" /> <img src="https://user-images.githubusercontent.com/65172896/217549510-149913ac-ef4e-4f61-8f5e-6d768483a02c.png" height="150" /> and more... Share yours!
### [> Animated video face for 2.1" round rev C screens](res/docs/rev-c-video-face.md)
<img src="res/docs/rev-c-video-face.gif" height="150" />

## Control the display from your Python projects

Expand Down
24 changes: 24 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,27 @@ display:
# This behavior causes the display to disconnect/reconnect, and the COM port to change.
# On some displays (like rev. A) it can be an issue, in this case change the value to "false".
RESET_ON_STARTUP: true

# Optional: only used by video-face-rev-c.py (animated video face for the 2.1" round rev C screen)
# See res/docs/rev-c-video-face.md. All keys are optional, the values below are the defaults.
video_face:
# Rows to display, top to bottom, among CPU / GPU / RAM
ROWS: [CPU, GPU, RAM]

# Seconds between sensor samples (one new bar each time)
SAMPLE_PERIOD: 0.5

# Directory of the screen where the video is stored, and name prefix of the video file in it.
# Older videos with this prefix are deleted when a new one is uploaded (the storage is only about 1.2 MB)
REMOTE_DIR: /root/video/
REMOTE_PREFIX: video_face_

# Bar colors [R, G, B] by value (%): LOW up to BLUE_UNTIL, blend to MID until YELLOW_FROM, MID until YELLOW_UNTIL,
# blend to HIGH until RED_FROM, HIGH above
BAR_COLOR_LOW: [25, 160, 230]
BAR_COLOR_MID: [255, 215, 40]
BAR_COLOR_HIGH: [255, 50, 40]
BLUE_UNTIL: 50
YELLOW_FROM: 65
YELLOW_UNTIL: 80
RED_FROM: 95
17 changes: 17 additions & 0 deletions library/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ def load_yaml(configfile):
FONTS_DIR = str(MAIN_DIRECTORY / "res" / "fonts") + "/"
CONFIG_DATA = load_yaml(MAIN_DIRECTORY / "config.yaml")
THEME_DEFAULT = load_yaml(MAIN_DIRECTORY / "res/themes/default.yaml")

# Optional "video_face" section of config.yaml, only used by video-face-rev-c.py (see res/docs/rev-c-video-face.md)
VIDEO_FACE_DEFAULT = {
"ROWS": ["CPU", "GPU", "RAM"], # rows to display, among CPU / GPU / RAM
"SAMPLE_PERIOD": 0.5, # seconds between sensor samples (one new bar each)
"REMOTE_DIR": "/root/video/", # directory of the screen where the video is stored
"REMOTE_PREFIX": "video_face_", # name prefix of the video on the screen (older ones with it are replaced)
"BAR_COLOR_LOW": [25, 160, 230], # light blue
"BAR_COLOR_MID": [255, 215, 40], # yellow
"BAR_COLOR_HIGH": [255, 50, 40], # red
"BLUE_UNTIL": 50, # bars up to this value (%) are BAR_COLOR_LOW
"YELLOW_FROM": 65, # between BLUE_UNTIL and this value: blend from LOW to MID
"YELLOW_UNTIL": 80, # bars up to this value are BAR_COLOR_MID
"RED_FROM": 95, # between YELLOW_UNTIL and this value: blend from MID to HIGH; above: HIGH
}
_video_face_user = CONFIG_DATA.get("video_face")
VIDEO_FACE_DATA = {**VIDEO_FACE_DEFAULT, **(_video_face_user if isinstance(_video_face_user, dict) else {})}
THEME_DATA = None


Expand Down
9 changes: 6 additions & 3 deletions library/lcd/lcd_comm_rev_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,15 @@ def DisplayPILImage(
payload=bytearray(self._generate_full_image(image)),
readsize=1024)
self._send_command(Command.QUERY_STATUS, readsize=1024)
# The display expects the render count of partial updates to restart at 0 after each full frame
Count.Start = 0
else:
with self.update_queue_mutex:
img, pyd = self._generate_update_image(image, x, y, Count.Start, Command.UPDATE_BITMAP)
self._send_command(Command.SEND_PAYLOAD, payload=pyd)
self._send_command(Command.SEND_PAYLOAD, payload=img)
self._send_command(Command.QUERY_STATUS, readsize=1024)
Count.Start += 1
Count.Start += 1

def _generate_full_image(self, image: Image.Image) -> bytes:
if self.sub_revision == SubRevision.REV_8INCH:
Expand Down Expand Up @@ -460,8 +462,9 @@ def _generate_update_image(
payload.extend(Padding.NULL.value * 3)
payload.extend(count.to_bytes(4, 'big'))

if len(img_raw_data) > 250:
img_raw_data = bytearray(b'\x00').join(chunked(bytes(img_raw_data), 249))
# The display reads 249 data bytes per 250-byte packet, the last byte of each packet being a separator.
# The "ef69" terminator is part of this data stream, so it must be added before chunking.
img_raw_data += b'\xef\x69'
img_raw_data = bytearray(b'\x00').join(chunked(bytes(img_raw_data), 249))

return img_raw_data, payload
Loading