diff --git a/software/src/hwconfig_Rev1/hwconfig.py b/software/src/hwconfig_Rev1/hwconfig.py index c9240a7..6ad9afc 100644 --- a/software/src/hwconfig_Rev1/hwconfig.py +++ b/software/src/hwconfig_Rev1/hwconfig.py @@ -28,7 +28,6 @@ RC522_SS = Pin.board.GP13 # WS2812 LED_DIN = Pin.board.GP16 -LED_COUNT = 1 # Buttons BUTTON_VOLUP = Pin.board.GP17 diff --git a/software/src/hwconfig_breadboard/hwconfig.py b/software/src/hwconfig_breadboard/hwconfig.py index 9243682..12df6bb 100644 --- a/software/src/hwconfig_breadboard/hwconfig.py +++ b/software/src/hwconfig_breadboard/hwconfig.py @@ -27,7 +27,6 @@ RC522_SS = Pin.board.GP13 # WS2812 LED_DIN = Pin.board.GP16 -LED_COUNT = 1 # Buttons BUTTON_VOLUP = Pin.board.GP17 diff --git a/software/src/main.py b/software/src/main.py index 813b036..5db7f15 100644 --- a/software/src/main.py +++ b/software/src/main.py @@ -18,7 +18,7 @@ from mfrc522 import MFRC522 from mp3player import MP3Player from nfc import Nfc from rp2_neopixel import NeoPixel -from utils import BTreeFileManager, Buttons, SDContext, TimerManager, LedManager +from utils import BTreeFileManager, Buttons, SDContext, TimerManager, LedManager, Configuration from webserver import start_webserver try: @@ -55,11 +55,13 @@ def setup_wifi(): DB_PATH = '/sd/tonberry.db' +config = Configuration() + def run(): asyncio.new_event_loop() # Setup LEDs - np = NeoPixel(hwconfig.LED_DIN, hwconfig.LED_COUNT, sm=1) + np = NeoPixel(hwconfig.LED_DIN, config.get_led_count(), sm=1) # Wifi with default config setup_wifi() diff --git a/software/src/utils/config.py b/software/src/utils/config.py index ea9b050..b2fd95f 100644 --- a/software/src/utils/config.py +++ b/software/src/utils/config.py @@ -8,6 +8,7 @@ import os class Configuration: DEFAULT_CONFIG = { + 'LED_COUNT': 1, } def __init__(self, config_path='/config.json'): @@ -42,3 +43,6 @@ class Configuration: self._move_config_to_backup() os.rename(self.config_path + '.new', self.config_path) os.sync() + + def get_led_count(self): + return self.config.get('LED_COUNT', self.DEFAULT_CONFIG['LED_COUNT'])