feat: Replace hardcoded timeouts in app with configurable

Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
This commit is contained in:
2025-11-28 19:41:44 +01:00
parent 2225906664
commit 83deb1b4c2
4 changed files with 41 additions and 10 deletions

View File

@@ -9,6 +9,8 @@ import os
class Configuration:
DEFAULT_CONFIG = {
'LED_COUNT': 1,
'IDLE_TIMEOUT_SECS': 60,
'TAG_TIMEOUT_SECS': 5,
}
def __init__(self, config_path='/config.json'):
@@ -44,5 +46,14 @@ class Configuration:
os.rename(self.config_path + '.new', self.config_path)
os.sync()
def _get(self, key):
return self.config.get(key, self.DEFAULT_CONFIG[key])
def get_led_count(self):
return self.config.get('LED_COUNT', self.DEFAULT_CONFIG['LED_COUNT'])
return self._get('LED_COUNT')
def get_idle_timeout(self):
return self._get('IDLE_TIMEOUT_SECS')
def get_tag_timeout(self):
return self._get('TAG_TIMEOUT_SECS')