Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large Overhaul #15

Merged
merged 5 commits into from
Aug 22, 2022
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
232 changes: 232 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
---
config:
# Configuration values to set up basic communication
# Set your COM port e.g. COM3 for Windows, /dev/ttyACM0 for Linux...
# COM_PORT: "/dev/ttyACM0"
# COM_PORT: "COM3"
COM_PORT: "AUTO"
display:
# Display size
DISPLAY_WIDTH: 320
DISPLAY_HEIGHT: 480
# Display Brightness
# Set this as the desired %, 0 being completely dark and 100 being max brightness
BRIGHTNESS: 10
# Serial Number - Used for auto-detecting the display
SERIAL_NUMBER: USB35INCHIPSV2
static_images:
# Specify what static images we want to show on the display
# You can create additional records here, the name of the entry must be unique and contain at a minimum the PATH.
# Images are drawn in the order they are listed below, the top image will be drawn first (so places images back to front)
# IMAGE_NAME:
# PATH:
# X:
# Y:
# WIDTH:
# HEIGHT:
BACKGROUND:
# PATH: res/backgrounds/600px_solid_Black.png
PATH: res/themes/Terminal_theme_background.png
X: 0
Y: 0
WIDTH: 320
HEIGHT: 480
static_text:
# Specify what static text we want to show on the display
# You can create additional records here, the name of the entry must be unique and contain at a minimum the PATH.
# Text are drawn in the order they are listed below, the top text will be drawn first (so places text back to front)
# IMAGE_NAME:
# TEXT:
# X:
# Y:
# FONT:
# FONT_SIZE:
# FONT_COLOR: 0, 0, 0
# BACKGROUND_COLOR=255, 255, 255
# BACKGROUND_IMAGE
BASICTEXT:
TEXT: Basic text
X: 50
Y: 100
CUSTOMITALICTEXTSOLIDBACKGROUND:
TEXT: Custom italic text
X: 5
Y: 150
FONT: roboto/Roboto-Italic.ttf
FONT_SIZE: 30
FONT_COLOR: 0, 0, 255
BACKGROUND_COLOR: 255, 255, 0
CUSTOMTEXTTRANSPARENTBACKGROUND:
TEXT: Transparent bold text
X: 5
Y: 300
FONT: geforce/GeForce-Bold.ttf
FONT_SIZE: 30
FONT_COLOR: 255, 255, 255
BACKGROUND_IMAGE: res/example.png
TEXTOVERFLOWS:
TEXT: Text overflow!
X: 5
Y: 430
FONT: roboto/Roboto-Bold.ttf
FONT_SIZE: 60
FONT_COLOR: 255, 255, 255
BACKGROUND_IMAGE: res/example.png
STATS:
CPU:
PERCENTAGE:
# In seconds. Longer intervals cause this to refresh more slowly.
# Setting to lower values will display near real time data,
# but may cause significant CPU usage or the display not to update properly
INTERVAL: 1
TEXT:
SHOW: False
X: 100
Y: 20
FONT: roboto/Roboto-Bold.ttf
FONT_SIZE: 20
FONT_COLOR: 255, 255, 255
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: res/backgrounds/600px_solid_Black.png
GRAPH:
SHOW: True
X: 115
Y: 71
WIDTH: 178
HEIGHT: 13
MIN_VALUE: 0
MAX_VALUE: 100
BAR_COLOR: 255, 0, 0
BAR_OUTLINE: False
BACKGROUND_COLOR: 0, 0, 0
# BACKGROUND_IMAGE: res/progressbars/320px-Green_Progress_bar_100.png
FREQUENCY:
# In seconds. Longer intervals cause this to refresh more slowly.
# Setting to lower values will display near real time data,
# but may cause significant CPU usage or the display not to update properly
INTERVAL: 5
TEXT:
SHOW: True
X: 100
Y: 87
FONT: roboto/Roboto-Bold.ttf
FONT_SIZE: 13
FONT_COLOR: 200, 200, 200
BACKGROUND_COLOR: 50, 50, 50
LOAD:
# In seconds. Longer intervals cause this to refresh more slowly.
# Setting to lower values will display near real time data,
# but may cause significant CPU usage or the display not to update properly
INTERVAL: 5
ONE:
TEXT:
SHOW: True
X: 110
Y: 106
FONT: roboto/Roboto-Bold.ttf
FONT_SIZE: 13
FONT_COLOR: 200, 200, 200
BACKGROUND_COLOR: 50, 50, 50
FIVE:
TEXT:
SHOW: TRUE
X: 183
Y: 106
FONT: roboto/Roboto-Bold.ttf
FONT_SIZE: 13
FONT_COLOR: 200, 200, 200
BACKGROUND_COLOR: 50, 50, 50
FIFTEEN:
TEXT:
SHOW: TRUE
X: 265
Y: 106
FONT: roboto/Roboto-Bold.ttf
FONT_SIZE: 13
FONT_COLOR: 200, 200, 200
BACKGROUND_COLOR: 50, 50, 50
GPU:
# In seconds. Longer intervals cause this to refresh more slowly.
# Setting to lower values will display near real time data,
# but may cause significant CPU usage or the display not to update properly
INTERVAL: 1
PERCENTAGE:
GRAPH:
SHOW: True
X: 115
Y: 197
WIDTH: 178
HEIGHT: 13
MIN_VALUE: 0
MAX_VALUE: 100
BAR_COLOR: 255, 0, 0
BAR_OUTLINE: False
BACKGROUND_COLOR: 0, 0, 0
# BACKGROUND_IMAGE: res/progressbars/320px-Green_Progress_bar_100.png
MEMORY:
GRAPH:
SHOW: True
X: 115
Y: 215
WIDTH: 178
HEIGHT: 13
MIN_VALUE: 0
MAX_VALUE: 100
BAR_COLOR: 255, 0, 0
BAR_OUTLINE: False
BACKGROUND_COLOR: 0, 0, 0
# BACKGROUND_IMAGE: res/progressbars/320px-Green_Progress_bar_100.png
TEMPERATURE:
TEXT:
SHOW: TRUE
X: 115
Y: 231
FONT: roboto/Roboto-Bold.ttf
FONT_SIZE: 13
FONT_COLOR: 200, 200, 200
BACKGROUND_COLOR: 50, 50, 50
MEMORY:
# In seconds. Longer intervals cause this to refresh more slowly.
# Setting to lower values will display near real time data,
# but may cause significant CPU usage or the display not to update properly
INTERVAL: 5
SWAP:
GRAPH:
SHOW: True
X: 115
Y: 285
WIDTH: 178
HEIGHT: 13
MIN_VALUE: 0
MAX_VALUE: 100
BAR_COLOR: 255, 0, 0
BAR_OUTLINE: False
BACKGROUND_COLOR: 0, 0, 0
# BACKGROUND_IMAGE: res/progressbars/320px-Green_Progress_bar_100.png
VIRTUAL:
GRAPH:
SHOW: True
X: 115
Y: 303
WIDTH: 178
HEIGHT: 13
MIN_VALUE: 0
MAX_VALUE: 100
BAR_COLOR: 255, 0, 0
BAR_OUTLINE: False
BACKGROUND_COLOR: 0, 0, 0
# BACKGROUND_IMAGE: res/progressbars/320px-Green_Progress_bar_100.png
DISK:
INTERVAL: 10
GRAPH:
SHOW: True
X: 115
Y: 357
WIDTH: 178
HEIGHT: 13
MIN_VALUE: 0
MAX_VALUE: 100
BAR_COLOR: 255, 0, 0
BAR_OUTLINE: False
BACKGROUND_COLOR: 0, 0, 0
# BACKGROUND_IMAGE: res/progressbars/320px-Green_Progress_bar_100.png
49 changes: 49 additions & 0 deletions library/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import logging
import os
import queue
import sys

import serial
import yaml
from serial.tools.list_ports import comports


def load_yaml(configfile):
if not os.path.exists(configfile):
logging.critical("No YAML file found")
exit()

with open(configfile, "r") as stream:
try:
yamlconfig = yaml.safe_load(stream)
except yaml.YAMLError:
logging.critical("Failed loading YAML configuration file")
exit()

return yamlconfig


def auto_detect_com_port():
comports = serial.tools.list_ports.comports()
auto_comport = None

for comport in comports:
if comport.serial_number == CONFIG_DATA['display']['SERIAL_NUMBER']:
auto_comport = comport.device

return auto_comport


PATH = sys.path[0]
CONFIG_DATA = load_yaml("config.yaml")

if CONFIG_DATA['config']['COM_PORT'] == 'AUTO':
lcd_com_port = auto_detect_com_port()
lcd_comm = serial.Serial(lcd_com_port, 115200, timeout=1, rtscts=1)
print(f"Auto detected comm port: {lcd_com_port}")
else:
lcd_com_port = CONFIG_DATA["config"]["COM_PORT"]
print(f"Static comm port: {lcd_com_port}")
lcd_comm = serial.Serial(lcd_com_port, 115200, timeout=1, rtscts=1)

update_queue = queue.Queue()
Loading