Add support for Turing 2.8" displays (same size as 2.1") by mathoudebine · Pull Request #889 · mathoudebine/turing-smart-screen-python · GitHub
Skip to content
Merged
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
3 changes: 1 addition & 2 deletions README.md
4 changes: 2 additions & 2 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ display:
# Display revision:
# - A for Turing 3.5" and UsbPCMonitor 3.5"/5"
# - B for Xuanfang 3.5" (inc. flagship)
# - C for Turing 2.1"/5"/8.8"
# - C for Turing 2.1"/2.8"/5"/8.8"
# - D for Kipye Qiye Smart Display 3.5"
# - WEACT_A for WeAct Studio Display FS V1 3.5"
# - WEACT_B for WeAct Studio Display FS V1 0.96"
Expand All @@ -76,4 +76,4 @@ display:
# By default, this program resets the display on startup, in case it is in a degraded state from previous runs.
# 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
RESET_ON_STARTUP: true
17 changes: 10 additions & 7 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,25 @@
SIZE_3_5_INCH = "3.5\""
SIZE_5_INCH = "5\""
SIZE_8_8_INCH = "8.8\""
SIZE_2_1_INCH = "2.1\""
SIZE_2_1_INCH = "2.1\"" # Only for retro compatibility
SIZE_2_x_INCH = "2.1\" / 2.8\""
SIZE_0_96_INCH = "0.96\""

size_list = (SIZE_0_96_INCH, SIZE_2_1_INCH, SIZE_3_5_INCH, SIZE_5_INCH, SIZE_8_8_INCH)
size_list = (SIZE_0_96_INCH, SIZE_2_x_INCH, SIZE_3_5_INCH, SIZE_5_INCH, SIZE_8_8_INCH)

# Maps between config.yaml values and GUI description
revision_and_size_to_model_map = {
('A', SIZE_3_5_INCH): TURING_MODEL, # Can also be UsbPCMonitor 3.5, does not matter since protocol is the same
('A', SIZE_5_INCH): USBPCMONITOR_MODEL,
('B', SIZE_3_5_INCH): XUANFANG_MODEL,
('C', SIZE_2_1_INCH): TURING_MODEL,
('C', SIZE_2_x_INCH): TURING_MODEL,
('C', SIZE_5_INCH): TURING_MODEL,
('C', SIZE_8_8_INCH): TURING_MODEL,
('D', SIZE_3_5_INCH): KIPYE_MODEL,
('WEACT_A', SIZE_3_5_INCH): WEACT_MODEL,
('WEACT_B', SIZE_0_96_INCH): WEACT_MODEL,
('SIMU', SIZE_0_96_INCH): SIMULATED_MODEL,
('SIMU', SIZE_2_1_INCH): SIMULATED_MODEL,
('SIMU', SIZE_2_x_INCH): SIMULATED_MODEL,
('SIMU', SIZE_3_5_INCH): SIMULATED_MODEL,
('SIMU', SIZE_5_INCH): SIMULATED_MODEL,
('SIMU', SIZE_8_8_INCH): SIMULATED_MODEL,
Expand All @@ -93,14 +94,14 @@
(USBPCMONITOR_MODEL, SIZE_3_5_INCH): 'A',
(USBPCMONITOR_MODEL, SIZE_5_INCH): 'A',
(XUANFANG_MODEL, SIZE_3_5_INCH): 'B',
(TURING_MODEL, SIZE_2_1_INCH): 'C',
(TURING_MODEL, SIZE_2_x_INCH): 'C',
(TURING_MODEL, SIZE_5_INCH): 'C',
(TURING_MODEL, SIZE_8_8_INCH): 'C',
(KIPYE_MODEL, SIZE_3_5_INCH): 'D',
(WEACT_MODEL, SIZE_3_5_INCH): 'WEACT_A',
(WEACT_MODEL, SIZE_0_96_INCH): 'WEACT_B',
(SIMULATED_MODEL, SIZE_0_96_INCH): 'SIMU',
(SIMULATED_MODEL, SIZE_2_1_INCH): 'SIMU',
(SIMULATED_MODEL, SIZE_2_x_INCH): 'SIMU',
(SIMULATED_MODEL, SIZE_3_5_INCH): 'SIMU',
(SIMULATED_MODEL, SIZE_5_INCH): 'SIMU',
(SIMULATED_MODEL, SIZE_8_8_INCH): 'SIMU',
Expand Down Expand Up @@ -312,7 +313,7 @@ def load_theme_preview(self):
try:
theme_preview = Image.open(MAIN_DIRECTORY + "res/themes/" + self.theme_cb.get() + "/preview.png")

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

# Guess display size from theme in the configuration
size = get_theme_size(self.config['config']['THEME'])
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"
try:
self.size_cb.set(size)
except:
Expand Down Expand Up @@ -505,6 +507,7 @@ def on_model_change(self, e=None):

def on_size_change(self, e=None):
size = self.size_cb.get()
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
themes = get_themes(size)
self.theme_cb.config(values=themes)

Expand Down
12 changes: 6 additions & 6 deletions library/lcd/lcd_comm_rev_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ class SleepInterval(Enum):


class SubRevision(Enum):
UNKNOWN = ""
REV_2INCH = "chs_21inch"
REV_5INCH = "chs_5inch"
REV_8INCH = "chs_88inch"
UNKNOWN = 0
REV_2INCH = 1 # For 2.1" and 2.8" models
REV_5INCH = 2
REV_8INCH = 3


WAKE_RETRIES = 15


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

# Some screens require different RGBA encoding
if self.rom_version > 88:
if self.sub_revision != SubRevision.REV_2INCH and self.rom_version > 88:
# BGRA mode on 4 bytes : [B, G, R, A]
img_data, pixel_size = image_to_BGRA(image)
else:
Expand Down
27 changes: 27 additions & 0 deletions tools/list-serial-ports.py