Skip to content

Commit f3a3c07

Browse files
authored
Merge pull request #889 from mathoudebine/dev/add-turing-2.8-support
2 parents a9e2cfe + 8a694c0 commit f3a3c07

File tree

5 files changed

+46
-17
lines changed

5 files changed

+46
-17
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Supported operating systems : macOS, Windows, Linux (incl. Raspberry Pi), basica
2222
| <img src="res/docs/turing.webp"/> | <img src="res/docs/xuanfang.webp"/> | <img src="res/docs/turing5inch.png"/> |
2323
| also improperly called "revision A" by the resellers | revision B & flagship (with backplate & RGB LEDs) | basic support (no video or storage for now) |
2424

25-
| ⚠️ Turing Smart Screen 8.8" | ✅ Turing Smart Screen 2.1" |
25+
| ⚠️ Turing Smart Screen 8.8" | ✅ Turing Smart Screen 2.1" / 2.8" |
2626
|---------------------------------------------|------------------------------------------------------------------|
2727
| <img src="res/docs/turing8inch.webp"/> | <img src="res/docs/turing2inch.webp" width="60%" height="60%"/> |
2828
| basic support (no video or storage for now)<br/>⚠️ [New revision V1.1 not supported!](https://github.com/mathoudebine/turing-smart-screen-python/issues/727) | basic support (no video or storage for now) |
@@ -135,4 +135,3 @@ If you have trouble running the program as described in the wiki, please check [
135135
## Star History
136136

137137
[![Star History Chart](https://api.star-history.com/svg?repos=mathoudebine/turing-smart-screen-python&type=Date)](https://star-history.com/#mathoudebine/turing-smart-screen-python&Date)
138-

config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ display:
5454
# Display revision:
5555
# - A for Turing 3.5" and UsbPCMonitor 3.5"/5"
5656
# - B for Xuanfang 3.5" (inc. flagship)
57-
# - C for Turing 2.1"/5"/8.8"
57+
# - C for Turing 2.1"/2.8"/5"/8.8"
5858
# - D for Kipye Qiye Smart Display 3.5"
5959
# - WEACT_A for WeAct Studio Display FS V1 3.5"
6060
# - WEACT_B for WeAct Studio Display FS V1 0.96"
@@ -76,4 +76,4 @@ display:
7676
# By default, this program resets the display on startup, in case it is in a degraded state from previous runs.
7777
# This behavior causes the display to disconnect/reconnect, and the COM port to change.
7878
# On some displays (like rev. A) it can be an issue, in this case change the value to "false".
79-
RESET_ON_STARTUP: true
79+
RESET_ON_STARTUP: true

configure.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,25 @@
6666
SIZE_3_5_INCH = "3.5\""
6767
SIZE_5_INCH = "5\""
6868
SIZE_8_8_INCH = "8.8\""
69-
SIZE_2_1_INCH = "2.1\""
69+
SIZE_2_1_INCH = "2.1\"" # Only for retro compatibility
70+
SIZE_2_x_INCH = "2.1\" / 2.8\""
7071
SIZE_0_96_INCH = "0.96\""
7172

72-
size_list = (SIZE_0_96_INCH, SIZE_2_1_INCH, SIZE_3_5_INCH, SIZE_5_INCH, SIZE_8_8_INCH)
73+
size_list = (SIZE_0_96_INCH, SIZE_2_x_INCH, SIZE_3_5_INCH, SIZE_5_INCH, SIZE_8_8_INCH)
7374

7475
# Maps between config.yaml values and GUI description
7576
revision_and_size_to_model_map = {
7677
('A', SIZE_3_5_INCH): TURING_MODEL, # Can also be UsbPCMonitor 3.5, does not matter since protocol is the same
7778
('A', SIZE_5_INCH): USBPCMONITOR_MODEL,
7879
('B', SIZE_3_5_INCH): XUANFANG_MODEL,
79-
('C', SIZE_2_1_INCH): TURING_MODEL,
80+
('C', SIZE_2_x_INCH): TURING_MODEL,
8081
('C', SIZE_5_INCH): TURING_MODEL,
8182
('C', SIZE_8_8_INCH): TURING_MODEL,
8283
('D', SIZE_3_5_INCH): KIPYE_MODEL,
8384
('WEACT_A', SIZE_3_5_INCH): WEACT_MODEL,
8485
('WEACT_B', SIZE_0_96_INCH): WEACT_MODEL,
8586
('SIMU', SIZE_0_96_INCH): SIMULATED_MODEL,
86-
('SIMU', SIZE_2_1_INCH): SIMULATED_MODEL,
87+
('SIMU', SIZE_2_x_INCH): SIMULATED_MODEL,
8788
('SIMU', SIZE_3_5_INCH): SIMULATED_MODEL,
8889
('SIMU', SIZE_5_INCH): SIMULATED_MODEL,
8990
('SIMU', SIZE_8_8_INCH): SIMULATED_MODEL,
@@ -93,14 +94,14 @@
9394
(USBPCMONITOR_MODEL, SIZE_3_5_INCH): 'A',
9495
(USBPCMONITOR_MODEL, SIZE_5_INCH): 'A',
9596
(XUANFANG_MODEL, SIZE_3_5_INCH): 'B',
96-
(TURING_MODEL, SIZE_2_1_INCH): 'C',
97+
(TURING_MODEL, SIZE_2_x_INCH): 'C',
9798
(TURING_MODEL, SIZE_5_INCH): 'C',
9899
(TURING_MODEL, SIZE_8_8_INCH): 'C',
99100
(KIPYE_MODEL, SIZE_3_5_INCH): 'D',
100101
(WEACT_MODEL, SIZE_3_5_INCH): 'WEACT_A',
101102
(WEACT_MODEL, SIZE_0_96_INCH): 'WEACT_B',
102103
(SIMULATED_MODEL, SIZE_0_96_INCH): 'SIMU',
103-
(SIMULATED_MODEL, SIZE_2_1_INCH): 'SIMU',
104+
(SIMULATED_MODEL, SIZE_2_x_INCH): 'SIMU',
104105
(SIMULATED_MODEL, SIZE_3_5_INCH): 'SIMU',
105106
(SIMULATED_MODEL, SIZE_5_INCH): 'SIMU',
106107
(SIMULATED_MODEL, SIZE_8_8_INCH): 'SIMU',
@@ -312,7 +313,7 @@ def load_theme_preview(self):
312313
try:
313314
theme_preview = Image.open(MAIN_DIRECTORY + "res/themes/" + self.theme_cb.get() + "/preview.png")
314315

315-
if theme_data['display'].get("DISPLAY_SIZE", '3.5"') == '2.1"':
316+
if theme_data['display'].get("DISPLAY_SIZE", '3.5"') == SIZE_2_1_INCH:
316317
# This is a circular screen: apply a circle mask over the preview
317318
theme_preview.paste(circular_mask, mask=circular_mask)
318319
except:
@@ -380,6 +381,7 @@ def load_config_values(self):
380381

381382
# Guess display size from theme in the configuration
382383
size = get_theme_size(self.config['config']['THEME'])
384+
size = size.replace(SIZE_2_1_INCH, SIZE_2_x_INCH) # If a theme is for 2.1" then it also is for 2.8"
383385
try:
384386
self.size_cb.set(size)
385387
except:
@@ -505,6 +507,7 @@ def on_model_change(self, e=None):
505507

506508
def on_size_change(self, e=None):
507509
size = self.size_cb.get()
510+
size = size.replace(SIZE_2_x_INCH, SIZE_2_1_INCH) # For '2.1" / 2.8"' size, keep '2.1"' as size to get themes for
508511
themes = get_themes(size)
509512
self.theme_cb.config(values=themes)
510513

library/lcd/lcd_comm_rev_c.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@ class SleepInterval(Enum):
115115

116116

117117
class SubRevision(Enum):
118-
UNKNOWN = ""
119-
REV_2INCH = "chs_21inch"
120-
REV_5INCH = "chs_5inch"
121-
REV_8INCH = "chs_88inch"
118+
UNKNOWN = 0
119+
REV_2INCH = 1 # For 2.1" and 2.8" models
120+
REV_5INCH = 2
121+
REV_8INCH = 3
122122

123123

124124
WAKE_RETRIES = 15
125125

126126

127-
# This class is for Turing Smart Screen 2.1" / 5" / 8" screens
127+
# This class is for Turing Smart Screen 2.1" / 2.8" / 5" / 8" screens
128128
class LcdCommRevC(LcdComm):
129129
def __init__(self, com_port: str = "AUTO", display_width: int = 480, display_height: int = 800,
130130
update_queue: Optional[queue.Queue] = None):
@@ -431,7 +431,7 @@ def _generate_update_image(
431431
img_raw_data = bytearray()
432432

433433
# Some screens require different RGBA encoding
434-
if self.rom_version > 88:
434+
if self.sub_revision != SubRevision.REV_2INCH and self.rom_version > 88:
435435
# BGRA mode on 4 bytes : [B, G, R, A]
436436
img_data, pixel_size = image_to_BGRA(image)
437437
else:

tools/list-serial-ports.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
# SPDX-License-Identifier: GPL-3.0-or-later
3+
#
4+
# turing-smart-screen-python - a Python system monitor and library for USB-C displays like Turing Smart Screen or XuanFang
5+
# https://github.com/mathoudebine/turing-smart-screen-python/
6+
#
7+
# Copyright (C) 2021 Matthieu Houdebine (mathoudebine)
8+
#
9+
# This program is free software: you can redistribute it and/or modify
10+
# it under the terms of the GNU General Public License as published by
11+
# the Free Software Foundation, either version 3 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# This program is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
22+
# list-serial-ports.py: To list all serial ports available in your system, with their names and IDs
23+
24+
from serial.tools.list_ports import comports
25+
for com_port in comports():
26+
if com_port.vid and com_port.pid:
27+
print("Serial=%s VID=%x PID=%x" % (com_port.serial_number, com_port.vid, com_port.pid))

0 commit comments

Comments
 (0)