diff --git a/.gitignore b/.gitignore index 58b824dbe10129c5624a203a3b021662ea809eed..6bbc21e9e2d93d91dba1af9ef3a18ec629bfd38c 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,4 @@ dmypy.json cython_debug/ module_config.json +hw_config.json \ No newline at end of file diff --git a/config.py b/config.py index 379783ce768cc2d59a7dfdd8d6be9a3137bbf4f4..19dfd5c9fc36e40612b28355782b40a9fc7710cd 100644 --- a/config.py +++ b/config.py @@ -1,12 +1,46 @@ -PROP_SCREEN_WIDTH = 240 -PROP_SCREEN_HEIGHT = 280 +import os.path +import json + +default_config = { + "screen_width": 240, + "screen_height": 280, + "window_fullscreen": True, + "hide_mouse": True, + "window_scale": 2, + "leds_driver": "npixel", + "leds_location": "D12", + "leds_length": 15, + "flask_debug": False, + "flask_host": "0.0.0.0", + "flask_port": 5000 +} + +config = default_config.copy() +if os.path.exists("config.json"): + with open("config.json", "r") as f: + config.update(json.load(f)) + +with open("config.json", "w") as f: + json.dump(config, f, indent=4) + +PROP_SCREEN_WIDTH = config["screen_width"] +PROP_SCREEN_HEIGHT = config["screen_height"] + +PROP_WINDOW_FULLSCREEN = config["window_fullscreen"] + +PROP_HIDE_MOUSE = config["hide_mouse"] -PROP_WINDOW_FULLSCREEN = False +# Make the window scale larger for development +PROP_WINDOW_SCALE = config["window_scale"] -PROP_HIDE_MOUSE = False +PROP_FLASK_DEBUG = config["flask_debug"] +PROP_FLASK_HOST = config["flask_host"] +PROP_FLASK_PORT = config["flask_port"] + +PROP_LEDS_DRIVER = config["leds_driver"] +PROP_LEDS_LOCATION = config["leds_location"] +PROP_LEDS_LENGTH = config["leds_length"] -# Make the window scale larger for development -PROP_WINDOW_SCALE = 3 PROP_AVAILABLE_WIDGETS = [ "IPShowWidget", @@ -19,15 +53,3 @@ PROP_AVAILABLE_PATTERNS = [ "RainbowPattern", "SolidColorPattern" ] - -PROP_FLASK_DEBUG = False -PROP_FLASK_HOST = "0.0.0.0" -PROP_FLASK_PORT = 5000 - -PROP_LEDS_DRIVER = "dummy" -PROP_LEDS_LOCATION="" -PROP_LEDS_LENGTH = 15 - -# PROP_LEDS_DRIVER="npixel" -# PROP_LEDS_LOCATION="D12" -# PROP_LEDS_LENGTH = 15