Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
30 changes: 30 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,33 @@ 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 colours: bars are a vertical gradient (like btop), the colour of each pixel row depends on its level (%, distance
# from the centre line relative to the max bar height), not on the bar value, so a bar "stops" at the colour of its
# level. List of [level %, [R, G, B]] stops, sorted by level, from 0 to 100; colours are linearly interpolated
# between stops. Replaces the former BAR_COLOR_* / *_UNTIL / *_FROM keys (ignored with a warning if still present)
BAR_GRADIENT:
- [0, [25, 160, 230]] # light blue
- [25, [25, 160, 230]] # light blue until 25 %
- [35, [110, 210, 240]] # light cyan
- [42, [235, 245, 205]] # pale cream (bright bridge, avoids a muddy blue-yellow mix)
- [50, [255, 235, 90]] # pale yellow
- [60, [255, 210, 40]] # golden yellow
- [70, [255, 170, 30]] # amber
- [82, [255, 120, 25]] # orange
- [94, [255, 50, 40]] # red
- [100, [255, 50, 40]]
24 changes: 24 additions & 0 deletions library/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,30 @@ 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 colours by level (%, 0 = centre line of the row, 100 = max bar extent): [level, [R, G, B]] stops, sorted,
# from 0 to 100, colours are linearly interpolated between stops
"BAR_GRADIENT": [
[0, [25, 160, 230]], # light blue
[25, [25, 160, 230]], # light blue until 25 %
[35, [110, 210, 240]], # light cyan
[42, [235, 245, 205]], # pale cream (bright bridge, avoids a muddy blue-yellow mix)
[50, [255, 235, 90]], # pale yellow
[60, [255, 210, 40]], # golden yellow
[70, [255, 170, 30]], # amber
[82, [255, 120, 25]], # orange
[94, [255, 50, 40]], # red
[100, [255, 50, 40]],
],
}
_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