Added option for info-section
When info-section is set in the web-ui, a small section at the bottom of the display will show the time of last update.
This commit is contained in:
@@ -16,7 +16,7 @@ class Layout:
|
||||
"""Page layout handling"""
|
||||
|
||||
def __init__(self, model=None, width=None, height=None,
|
||||
supports_colour=False):
|
||||
supports_colour=False, use_info_section=True):
|
||||
"""Initialize parameters for specified epaper model
|
||||
Use model parameter to specify display OR
|
||||
Crate a custom display with given width and height"""
|
||||
@@ -35,20 +35,30 @@ class Layout:
|
||||
}
|
||||
|
||||
self.display_height, self.display_width = display_dimensions[model]
|
||||
self.display_size = display_dimensions[model]
|
||||
|
||||
# if 'colour' was found in the display name, set supports_colour to True
|
||||
if 'colour' in model:
|
||||
self.supports_colour = True
|
||||
else:
|
||||
self.supports_colour = False
|
||||
|
||||
# If a custom width and height was specified, use those values instead
|
||||
elif width and height:
|
||||
self.display_height = width
|
||||
self.display_width = height
|
||||
self.supports_colour = supports_colour
|
||||
|
||||
else:
|
||||
print("Can't create a layout without given sizes")
|
||||
raise
|
||||
raise Exception("Can't create a layout without given sizes")
|
||||
|
||||
# If the info section should be used, reduce the canvas size to 95%
|
||||
if not isinstance(use_info_section, bool):
|
||||
raise ValueError('use_info_section should be a boolean (True/False)')
|
||||
|
||||
if use_info_section == True:
|
||||
self.display_height = int(self.display_height*0.95)
|
||||
|
||||
self.display_size = self.display_width, self.display_height
|
||||
|
||||
self.top_section_width = self.display_width
|
||||
self.middle_section_width = self.display_width
|
||||
|
@@ -31,7 +31,8 @@ class Settings:
|
||||
]
|
||||
|
||||
def __init__(self, settings_file_path):
|
||||
"""Load settings from path (folder or settings.json file)"""
|
||||
"""Load settings from path (folder or settings.json file)
|
||||
Set show_info_section to False to hide the info section"""
|
||||
try:
|
||||
if settings_file_path.endswith('settings.json'):
|
||||
folder = settings_file_path.split('/settings.json')[0]
|
||||
@@ -60,7 +61,11 @@ class Settings:
|
||||
self._validate()
|
||||
|
||||
# Get the height-percentages of the modules
|
||||
self.Layout = Layout(model=self.model)
|
||||
if self.info_section == True:
|
||||
self.Layout = Layout(model=self.model, use_info_section = True)
|
||||
else:
|
||||
self.Layout = Layout(model=self.model, use_info_section = False)
|
||||
|
||||
all_heights = [_['height'] for _ in self._settings['panels']]
|
||||
num_modules = len(self.active_modules())
|
||||
|
||||
@@ -105,7 +110,7 @@ class Settings:
|
||||
settings = self._settings
|
||||
|
||||
required = ['language', 'units', 'hours', 'model', 'calibration_hours',
|
||||
'display_orientation']
|
||||
'display_orientation', 'info_section']
|
||||
|
||||
# Check if all required settings exist
|
||||
for param in required:
|
||||
@@ -121,6 +126,7 @@ class Settings:
|
||||
self.update_interval = settings['update_interval']
|
||||
self.calibration_hours = settings['calibration_hours']
|
||||
self.display_orientation = settings['display_orientation']
|
||||
self.info_section = settings['info_section']
|
||||
|
||||
# Validate the parameters
|
||||
if (not isinstance(self.language, str) or self.language not in
|
||||
@@ -157,6 +163,10 @@ class Settings:
|
||||
print('display orientation not supported, switching to fallback, normal')
|
||||
self.display_orientation = 'normal'
|
||||
|
||||
if (not isinstance(self.info_section, bool)):
|
||||
print('info_section must be True/False. Switching to fallback: False')
|
||||
self.info_section = False
|
||||
|
||||
print('Settings file OK!')
|
||||
|
||||
def active_modules(self):
|
||||
|
Reference in New Issue
Block a user