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

add a default YAML and change config to use it. #142

Merged
merged 3 commits into from
Jan 18, 2023
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
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ config:
# - Cyberpunk
# - bash-dark-green
# - bash-dark-green-gpu
# - BigClock
THEME: 3.5inchTheme2

# Hardware sensors reading
Expand Down
12 changes: 12 additions & 0 deletions library/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def load_yaml(configfile):

PATH = sys.path[0]
CONFIG_DATA = load_yaml("config.yaml")
THEME_DEFAULT = load_yaml("res/themes/default.yaml")

try:
theme_path = "res/themes/" + CONFIG_DATA['config']['THEME'] + "/"
Expand All @@ -48,5 +49,16 @@ def load_yaml(configfile):
except:
os._exit(0)

def copy_default(default, theme):
"recursively supply default values into a dict of dicts of dicts ...."
for k,v in default.items():
if k not in theme:
theme[k] = v
if type(v) == type({}):
copy_default(default[k], theme[k])


copy_default(THEME_DEFAULT, THEME_DATA)

# Queue containing the serial requests to send to the screen
update_queue = queue.Queue()
4 changes: 2 additions & 2 deletions library/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def initialize_display(self):
self.lcd.SetOrientation(_get_theme_orientation())

def display_static_images(self):
if THEME_DATA['static_images']:
if THEME_DATA.get('static_images', False):
for image in THEME_DATA['static_images']:
logger.debug(f"Drawing Image: {image}")
self.lcd.DisplayBitmap(
Expand All @@ -109,7 +109,7 @@ def display_static_images(self):
)

def display_static_text(self):
if THEME_DATA['static_text']:
if THEME_DATA.get('static_text', False):
for text in THEME_DATA['static_text']:
logger.debug(f"Drawing Text: {text}")
self.lcd.DisplayText(
Expand Down
Binary file added res/themes/BigClock/blackground-landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions res/themes/BigClock/theme.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
display:
# Specify the display orientation for this theme: portrait or landscape
DISPLAY_ORIENTATION: landscape

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: blackground-landscape.png
X: 0
Y: 0
WIDTH: 480
HEIGHT: 320

STATS:
# Backplate RGB LED color (for HW revision 'flagship' devices only)
DISPLAY_RGB_LED: 255, 0, 0
DATE:
# 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
DAY:
TEXT:
SHOW: True
X: 10
Y: 16
FONT: roboto/Roboto-Bold.ttf
FONT_SIZE: 80
FONT_COLOR: 200, 200, 200
BACKGROUND_COLOR: 0, 0, 0
HOUR:
TEXT:
SHOW: True
X: 10
Y: 160
FONT: roboto/Roboto-Bold.ttf
FONT_SIZE: 80
FONT_COLOR: 200, 200, 200
BACKGROUND_COLOR: 50, 0, 0
135 changes: 135 additions & 0 deletions res/themes/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
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
GRAPH:
SHOW: False
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: False
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: False
FIVE:
TEXT:
SHOW: False
FIFTEEN:
TEXT:
SHOW: False
TEMPERATURE:
INTERVAL: 5
TEXT:
SHOW: False
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: False
TEXT:
SHOW: False
MEMORY:
GRAPH:
SHOW: False
TEXT:
SHOW: False
SHOW_UNIT: False
TEMPERATURE:
TEXT:
SHOW: False
SHOW_UNIT: False
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: False
VIRTUAL:
GRAPH:
SHOW: False
USED:
SHOW: False
SHOW_UNIT: False
FREE:
SHOW: False
SHOW_UNIT: False
PERCENT_TEXT:
SHOW: False
SHOW_UNIT: False
DISK:
INTERVAL: 10
USED:
GRAPH:
SHOW: False
TEXT:
SHOW: False
SHOW_UNIT: False
PERCENT_TEXT:
SHOW: False
SHOW_UNIT: False
TOTAL:
TEXT:
SHOW: False
SHOW_UNIT: False
FREE:
TEXT:
SHOW: False
SHOW_UNIT: False
NET:
INTERVAL: 1
WLO:
UPLOAD:
TEXT:
SHOW: False
UPLOADED:
TEXT:
SHOW: False
DOWNLOAD:
TEXT:
SHOW: False
DOWNLOADED:
TEXT:
SHOW: False
ETH:
UPLOAD:
TEXT:
SHOW: False
UPLOADED:
TEXT:
SHOW: False
DOWNLOAD:
TEXT:
SHOW: False
DOWNLOADED:
TEXT:
SHOW: False
DATE:
# 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
DAY:
TEXT:
SHOW: False
HOUR:
TEXT:
SHOW: False