Skip to content

Commit b460de1

Browse files
authored
Merge pull request #253 from mathoudebine/feature/81-5-inch-support
Add support for Turing 5" displays, for the same feature set as the 3.5" version (no storage or video for now)
2 parents d1ca6ed + 5ae19b1 commit b460de1

File tree

378 files changed

+2279
-125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

378 files changed

+2279
-125
lines changed

.github/workflows/simple-program-linux.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
- 'releases/**'
88
pull_request:
99

10-
1110
jobs:
1211
simple-program:
1312

@@ -16,7 +15,7 @@ jobs:
1615
strategy:
1716
fail-fast: false
1817
matrix:
19-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
18+
python-version: ["3.7", "3.11"]
2019

2120
steps:
2221
- uses: actions/checkout@v3

.github/workflows/simple-program-macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
18+
python-version: ["3.7", "3.11"]
1919

2020
steps:
2121
- uses: actions/checkout@v3

.github/workflows/simple-program-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
18+
python-version: ["3.7", "3.11"]
1919

2020
steps:
2121
- uses: actions/checkout@v3

.github/workflows/system-monitor-linux.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
19-
theme: [ "3.5inchTheme2", "Cyberpunk", "Cyberpunk-net", "Landscape6Grid", "Terminal", "bash-dark-green", "bash-dark-green-gpu",
20-
"LandscapeMagicBlue", "BigClock", "LandscapeEarth" ]
18+
python-version: ["3.7", "3.11"]
19+
theme: [ "3.5inchTheme2" ]
2120

2221
steps:
2322
- uses: actions/checkout@v3

.github/workflows/system-monitor-macos.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
19-
theme: [ "3.5inchTheme2", "Cyberpunk", "Cyberpunk-net", "Landscape6Grid", "Terminal", "bash-dark-green", "bash-dark-green-gpu",
20-
"LandscapeMagicBlue", "BigClock", "LandscapeEarth" ]
18+
python-version: ["3.7", "3.11"]
19+
theme: [ "3.5inchTheme2" ]
2120

2221
steps:
2322
- uses: actions/checkout@v3

.github/workflows/system-monitor-windows.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
19-
theme: [ "3.5inchTheme2", "Cyberpunk", "Cyberpunk-net", "Landscape6Grid", "Terminal", "bash-dark-green", "bash-dark-green-gpu",
20-
"LandscapeMagicBlue", "BigClock", "LandscapeEarth" ]
18+
python-version: ["3.7", "3.11"]
19+
theme: [ "3.5inchTheme2" ]
2120

2221
steps:
2322
- uses: actions/checkout@v3

.github/workflows/themes-screenshot-on-pr.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Set up Python 3.10
1414
uses: actions/setup-python@v4
1515
with:
16-
python-version: "3.10"
16+
python-version: "3.11"
1717

1818
- name: Install dependencies
1919
run: |
@@ -22,9 +22,6 @@ jobs:
2222
2323
- name: Configure system monitor for screenshot
2424
run: |
25-
# For tests there is no real HW: use simulated LCD mode
26-
sed -i "/REVISION:/c\ REVISION: SIMU" config.yaml
27-
2825
# Use static data
2926
sed -i "/HW_SENSORS:/c\ HW_SENSORS: STATIC" config.yaml
3027
@@ -40,9 +37,18 @@ jobs:
4037
echo "Using theme $theme"
4138
sed -i "/THEME:/c\ THEME: $theme" config.yaml
4239
43-
# Run system-monitor for 5 seconds
40+
# For tests there is no real HW: use simulated LCD mode
41+
# Check if theme is for 5"
42+
orientation=$(grep 'DISPLAY_SIZE' $dir/theme.yaml | sed 's/ //g')
43+
if [ "$orientation" == "DISPLAY_SIZE:5\"" ]; then
44+
sed -i "/REVISION:/c\ REVISION: SIMU5" config.yaml
45+
else
46+
sed -i "/REVISION:/c\ REVISION: SIMU" config.yaml
47+
fi
48+
49+
# Run system-monitor for 10 seconds
4450
python3 main.py > output.log 2>&1 &
45-
sleep 5
51+
sleep 10
4652
killall -9 python3
4753

4854
# Rename screen capture

.github/workflows/themes-screenshot-on-push.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Set up Python 3.10
2828
uses: actions/setup-python@v4
2929
with:
30-
python-version: "3.10"
30+
python-version: "3.11"
3131

3232
- name: Install dependencies
3333
run: |
@@ -36,9 +36,6 @@ jobs:
3636
3737
- name: Configure system monitor for screenshot
3838
run: |
39-
# For tests there is no real HW: use simulated LCD mode
40-
sed -i "/REVISION:/c\ REVISION: SIMU" config.yaml
41-
4239
# Use static data
4340
sed -i "/HW_SENSORS:/c\ HW_SENSORS: STATIC" config.yaml
4441
@@ -54,9 +51,18 @@ jobs:
5451
echo "Using theme $theme"
5552
sed -i "/THEME:/c\ THEME: $theme" config.yaml
5653
57-
# Run system-monitor for 5 seconds
54+
# For tests there is no real HW: use simulated LCD mode
55+
# Check if theme is for 5"
56+
orientation=$(grep 'DISPLAY_SIZE' $dir/theme.yaml | sed 's/ //g')
57+
if [ "$orientation" == "DISPLAY_SIZE:5\"" ]; then
58+
sed -i "/REVISION:/c\ REVISION: SIMU5" config.yaml
59+
else
60+
sed -i "/REVISION:/c\ REVISION: SIMU" config.yaml
61+
fi
62+
63+
# Run system-monitor for 10 seconds
5864
python3 main.py > output.log 2>&1 &
59-
sleep 5
65+
sleep 10
6066
killall -9 python3
6167

6268
# Copy screen capture on theme folder
@@ -73,8 +79,4 @@ jobs:
7379

7480
- name: Run if changes have been detected
7581
if: steps.auto-commit-action.outputs.changes_detected == 'true'
76-
run: echo "Changes!"
77-
78-
- name: Run if no changes have been detected
79-
if: steps.auto-commit-action.outputs.changes_detected == 'false'
80-
run: echo "No Changes!"
82+
run: echo "Theme previews have changed!"

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@ This project is an open-source alternative software, NOT the USBMonitor.exe / Ex
1212
![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black) ![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white) ![macOS](https://img.shields.io/badge/mac%20os-000000?style=for-the-badge&logo=apple&logoColor=white) ![Raspberry Pi](https://img.shields.io/badge/Raspberry%20Pi-A22846?style=for-the-badge&logo=Raspberry%20Pi&logoColor=white) ![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54) [![Licence](https://img.shields.io/github/license/mathoudebine/turing-smart-screen-python?style=for-the-badge)](./LICENSE)
1313

1414

15-
A Python system monitor program and a library for 3.5" IPS USB-C (UART) displays.
15+
A Python system monitor program and a library for **3.5" & 5" IPS USB-C (UART) displays.**
1616

17-
Supported operating systems : macOS, Windows, Linux (incl. Raspberry Pi), basically all OS that support Python 3.x
17+
Supported operating systems : macOS, Windows, Linux (incl. Raspberry Pi), basically all OS that support Python 3.7+
1818

1919
Supported smart screens models:
20-
| **Turing Smart Screen 3.5"** | **XuanFang 3.5"** |
21-
|--------|----------|
22-
| <img src="res/docs/turing.webp" height="300" /> | <img src="res/docs/xuanfang.webp" height="300" /> |
23-
| also improperly called "revision A" by the resellers | revision B & flagship (with backplate & RGB LEDs) |
20+
21+
| **Turing Smart Screen 3.5"** | **XuanFang 3.5"** | **Turing Smart Screen 5"** |
22+
|------------------------------------------------------|---------------------------------------------------|-----------------------------------------------------|
23+
| <img src="res/docs/turing.webp" height="300" /> | <img src="res/docs/xuanfang.webp" height="300" /> | <img src="res/docs/turing5inch.png" height="300" /> |
24+
| also improperly called "revision A" by the resellers | revision B & flagship (with backplate & RGB LEDs) | experimental support (no video or storage for now) |
2425

2526
### [> What is my smart screen model?](https://github.com/mathoudebine/turing-smart-screen-python/wiki/Hardware-revisions)
2627

27-
**Please note the Turing and the XuanFang screens are 2 different products** designed and produced by different companies, despite having a similar appearance. The communication protocol is also different.
28-
This project support both products, including backplate RGB LEDs for available models!
28+
**Please note the Turing and the XuanFang screens are different products** designed and produced by different companies, despite having a similar appearance. The communication protocol is also different.
29+
This project support products from both manufacturers, including backplate RGB LEDs for available models!
2930

3031
If you haven't received your screen yet but want to start developing your theme now, you can use the [**"simulated LCD" mode!**](https://github.com/mathoudebine/turing-smart-screen-python/wiki/Simulated-display)
3132

@@ -49,15 +50,15 @@ Some themes are already included for a quick start!
4950

5051
* Fully functional multi-OS code base (operates out of the box, tested on Windows, Linux & MacOS).
5152
* Display configuration using GUI configuration wizard or `config.yaml` file: no Python code to edit.
52-
* Support for all [3.5" smart screen models (Turing and XuanFang)](https://github.com/mathoudebine/turing-smart-screen-python/wiki/Hardware-revisions). Backplate RGB LEDs are also supported for available models!
53+
* Support for [3.5" & 5" smart screen models (Turing and XuanFang)](https://github.com/mathoudebine/turing-smart-screen-python/wiki/Hardware-revisions). Backplate RGB LEDs are also supported for available models!
5354
* Support [multiple hardware sensors and metrics (CPU/GPU usage, temperatures, memory, disks, etc)](https://github.com/mathoudebine/turing-smart-screen-python/wiki/System-monitor-:-themes#stats-entry) with configurable refresh intervals.
5455
* Allow [creation of themes (see `res/themes`) with `theme.yaml` files using theme editor](https://github.com/mathoudebine/turing-smart-screen-python/wiki/System-monitor-:-themes) to be [shared with the community!](https://github.com/mathoudebine/turing-smart-screen-python/discussions/categories/themes)
5556
* Easy to expand: additional code that pulls specific information can be written in a modular way without impacting existing code.
5657
* Auto detect comm port. No longer need to hard set it, or if it changes on you then the config is wrong.
5758
* Tray icon with Exit option, useful when the program is running in background
5859

5960
Screenshots from the latest version using included themes (click on the thumbnails to see a bigger preview):
60-
<img src="res/docs/Theme3.5Inch.jpg" height="300" /> <img src="res/docs/ThemeTerminal.jpg" height="300" /> <img src="res/docs/ThemeCyberpunk.png" height="300" /> <img src="res/docs/ThemeBashDarkGreenGpu.png" height="300" /> <img src="res/docs/ThemeLandscape6Grid.jpg" width="300" /> <img src="res/docs/ThemeLandscapeMagicBlue.png" width="300" />
61+
<img src="res/themes/3.5inchTheme2/preview.png" height="300" /> <img src="res/themes/Terminal/preview.png" height="300" /> <img src="res/themes/Cyberpunk-net/preview.png" height="300" /> <img src="res/themes/bash-dark-green-gpu/preview.png" height="300" /> <img src="res/themes/Landscape6Grid/preview.png" width="300" /> <img src="res/themes/LandscapeMagicBlue/preview.png" width="300" /> <img src="res/themes/LandscapeEarth/preview.png" width="300" />
6162

6263
### [> Themes creation/edition (using theme editor)](https://github.com/mathoudebine/turing-smart-screen-python/wiki/System-monitor-:-themes)
6364
### [> Themes shared by the community:](https://github.com/mathoudebine/turing-smart-screen-python/discussions/categories/themes)

config.yaml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,7 @@ config:
88
COM_PORT: "AUTO"
99

1010
# Theme to use (located in res/themes)
11-
# Available themes:
12-
# - 3.5inchTheme2
13-
# - Terminal
14-
# - Landscape6Grid
15-
# - LandscapeMagicBlue
16-
# - Cyberpunk
17-
# - Cyberpunk-net
18-
# - bash-dark-green
19-
# - bash-dark-green-gpu
20-
# - BigClock
11+
# Use the name of the folder as value
2112
THEME: 3.5inchTheme2
2213

2314
# Hardware sensors reading
@@ -36,7 +27,8 @@ config:
3627
WLO: "" # Wi-Fi Card
3728

3829
display:
39-
# Display revision: A or B (for "flagship" version, use B) or SIMU for simulated LCD (image written in screencap.png)
30+
# Display revision: A for Turing 3.5", B for Xuanfang 3.5" (inc. flagship), C for Turing 5"
31+
# Use SIMU for 3.5" simulated LCD (image written in screencap.png) or SIMU5 for 5" simulated LCD
4032
# To identify your revision: https://github.com/mathoudebine/turing-smart-screen-python/wiki/Hardware-revisions
4133
REVISION: A
4234

@@ -49,10 +41,3 @@ display:
4941
# Set to true to reverse display orientation (landscape <-> reverse landscape, portrait <-> reverse portrait)
5042
# Note: Display basic orientation (portrait or landscape) is defined by the theme you have selected
5143
DISPLAY_REVERSE: false
52-
53-
# Display resolution in portrait orientation
54-
# Do not use this setting to rotate display! The selected theme handles landscape/portrait orientation
55-
DISPLAY_WIDTH: 320 # Do not change unless you have a good reason
56-
DISPLAY_HEIGHT: 480 # Do not change unless you have a good reason
57-
58-

configure.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# turing-smart-screen-python - a Python system monitor and library for 3.5" USB-C displays like Turing Smart Screen or XuanFang
2+
# turing-smart-screen-python - a Python system monitor and library for USB-C displays like Turing Smart Screen or XuanFang
33
# https://github.com/mathoudebine/turing-smart-screen-python/
44

55
# Copyright (C) 2021-2023 Matthieu Houdebine (mathoudebine)
@@ -58,22 +58,29 @@
5858
os._exit(0)
5959

6060
# Maps between config.yaml values and GUI description
61-
revision_map = {'A': "Turing / rev. A", 'B': "XuanFang / rev. B / flagship", 'SIMU': "Simulated screen"}
61+
revision_map = {'A': "Turing 3.5\" / rev. A", 'B': "XuanFang / rev. B / flagship", 'C': "Turing 5\"",
62+
'SIMU': "Simulated 3.5\" screen", 'SIMU5': "Simulated 5\" screen"}
6263
hw_lib_map = {"AUTO": "Automatic", "LHM": "LibreHardwareMonitor (admin.)", "PYTHON": "Python libraries",
6364
"STUB": "Fake random data", "STATIC": "Fake static data"}
6465
reverse_map = {False: "classic", True: "reverse"}
66+
revision_size = {'A': '3.5"', 'B': '3.5"', 'C': '5"', 'SIMU': '3.5"', 'SIMU5': '5"'}
6567

6668

67-
def get_themes():
69+
def get_themes(revision: str):
6870
themes = []
6971
directory = 'res/themes/'
7072
for filename in os.listdir('res/themes'):
71-
f = os.path.join(directory, filename)
72-
# checking if it is a file
73-
if os.path.isdir(f):
74-
theme = os.path.join(f, 'theme.yaml')
73+
dir = os.path.join(directory, filename)
74+
# checking if it is a directory
75+
if os.path.isdir(dir):
76+
# Check if a theme.yaml file exists
77+
theme = os.path.join(dir, 'theme.yaml')
7578
if os.path.isfile(theme):
76-
themes.append(filename)
79+
# Get display size from theme.yaml
80+
with open(theme, "rt", encoding='utf8') as stream:
81+
theme_data, ind, bsi = ruamel.yaml.util.load_yaml_guess_indent(stream)
82+
if theme_data['display'].get("DISPLAY_SIZE", '3.5"') == revision_size[revision]:
83+
themes.append(filename)
7784
return sorted(themes, key=str.casefold)
7885

7986

@@ -112,7 +119,7 @@ def __init__(self):
112119

113120
self.theme_label = ttk.Label(self.window, text='Theme')
114121
self.theme_label.place(x=320, y=35)
115-
self.theme_cb = ttk.Combobox(self.window, values=get_themes(), state='readonly')
122+
self.theme_cb = ttk.Combobox(self.window, state='readonly')
116123
self.theme_cb.place(x=500, y=30, width=210)
117124
self.theme_cb.bind('<<ComboboxSelected>>', self.on_theme_change)
118125

@@ -283,7 +290,7 @@ def on_theme_change(self, e=None):
283290
self.load_theme_preview()
284291

285292
def on_theme_editor_click(self):
286-
subprocess.Popen(os.path.join(os.getcwd(), "theme-editor.py") + " " + self.theme_cb.get(), shell=True)
293+
subprocess.Popen(os.path.join(os.getcwd(), "theme-editor.py") + " \"" + self.theme_cb.get() + "\"", shell=True)
287294

288295
def on_save_click(self):
289296
self.save_config_values()
@@ -299,7 +306,8 @@ def on_brightness_change(self, e=None):
299306

300307
def on_model_change(self, e=None):
301308
self.show_hide_brightness_warning()
302-
if [k for k, v in revision_map.items() if v == self.model_cb.get()][0] == "SIMU":
309+
revision = [k for k, v in revision_map.items() if v == self.model_cb.get()][0]
310+
if revision == "SIMU" or revision == "SIMU5":
303311
self.com_cb.configure(state="disabled", foreground="#C0C0C0")
304312
self.orient_cb.configure(state="disabled", foreground="#C0C0C0")
305313
self.brightness_slider.configure(state="disabled")
@@ -310,6 +318,13 @@ def on_model_change(self, e=None):
310318
self.brightness_slider.configure(state="normal")
311319
self.brightness_val_label.configure(foreground="#000")
312320

321+
themes = get_themes(revision)
322+
self.theme_cb.config(values=themes)
323+
324+
if not self.theme_cb.get() in themes:
325+
# The selected theme does not exist anymore / is not allowed for this screen model : select 1st theme avail.
326+
self.theme_cb.set(themes[0])
327+
313328
def on_hwlib_change(self, e=None):
314329
hwlib = [k for k, v in hw_lib_map.items() if v == self.hwlib_cb.get()][0]
315330
if hwlib == "STUB" or hwlib == "STATIC":

library/config.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# turing-smart-screen-python - a Python system monitor and library for 3.5" USB-C displays like Turing Smart Screen or XuanFang
1+
# turing-smart-screen-python - a Python system monitor and library for USB-C displays like Turing Smart Screen or XuanFang
22
# https://github.com/mathoudebine/turing-smart-screen-python/
33

44
# Copyright (C) 2021-2023 Matthieu Houdebine (mathoudebine)
@@ -38,6 +38,9 @@ def load_yaml(configfile):
3838
THEME_DEFAULT = load_yaml("res/themes/default.yaml")
3939
THEME_DATA = None
4040

41+
# Matching between hardware revision and display size in inches
42+
revision_size = {'A': '3.5"', 'B': '3.5"', 'C': '5"', 'SIMU': '3.5"', 'SIMU5': '5"'}
43+
4144

4245
def copy_default(default, theme):
4346
"""recursively supply default values into a dict of dicts of dicts ...."""
@@ -65,6 +68,18 @@ def load_theme():
6568
copy_default(THEME_DEFAULT, THEME_DATA)
6669

6770

71+
def check_theme_compatible():
72+
global THEME_DATA
73+
# Check if theme is compatible with hardware revision
74+
if revision_size[CONFIG_DATA["display"]["REVISION"]] != THEME_DATA['display'].get("DISPLAY_SIZE", '3.5"'):
75+
logger.error("The selected theme " + CONFIG_DATA['config'][
76+
'THEME'] + " is not compatible with your display revision " + CONFIG_DATA["display"]["REVISION"])
77+
try:
78+
sys.exit(0)
79+
except:
80+
os._exit(0)
81+
82+
6883
# Load theme on import
6984
load_theme()
7085

0 commit comments

Comments
 (0)