I'm working with MP 1.18 on a ESP32 TTGO-Display Board (with a small TFT) using st7789py_mpy library by russhughes. When my module is loading, I want to show a splash-screen. Inizializing the screen takes around 1,3 seconds, which I find ok.
My Problem is the following code, which loads the configuration for the Display as the Code should be compatible with different modules. Loading a small JSON takes 5 seconds to run - does someone have an idea why? (And how to fix)
Code: Select all
class BoardConfig:
"""
Loads board config from JSON
"""
CONF_FILE = 'config/board_config.json'
def __init__(self):
self.erika_rts = None
self.erika_cts = None
self.erika_rx = None
self.erika_tx= None
self.screen_display_type = None
self.screen_rst = None
self.screen_scl = None
self.screen_sda = None
self.load()
def load(self):
"""
Loads config from JSON
Returns: dict or False (if config_file cannot be opend)
"""
try:
with open(self.CONF_FILE, 'r') as f:
data = json.load(f)
for k,v in data.items():
setattr(self,k,v)
except:
return False
def __repr__(self):
return str(self.__dict__)