feat: Move LED_COUNT from hwconfig to config.json
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
This commit is contained in:
@@ -28,7 +28,6 @@ RC522_SS = Pin.board.GP13
|
|||||||
|
|
||||||
# WS2812
|
# WS2812
|
||||||
LED_DIN = Pin.board.GP16
|
LED_DIN = Pin.board.GP16
|
||||||
LED_COUNT = 1
|
|
||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
BUTTON_VOLUP = Pin.board.GP17
|
BUTTON_VOLUP = Pin.board.GP17
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ RC522_SS = Pin.board.GP13
|
|||||||
|
|
||||||
# WS2812
|
# WS2812
|
||||||
LED_DIN = Pin.board.GP16
|
LED_DIN = Pin.board.GP16
|
||||||
LED_COUNT = 1
|
|
||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
BUTTON_VOLUP = Pin.board.GP17
|
BUTTON_VOLUP = Pin.board.GP17
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from mfrc522 import MFRC522
|
|||||||
from mp3player import MP3Player
|
from mp3player import MP3Player
|
||||||
from nfc import Nfc
|
from nfc import Nfc
|
||||||
from rp2_neopixel import NeoPixel
|
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
|
from webserver import start_webserver
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -55,11 +55,13 @@ def setup_wifi():
|
|||||||
|
|
||||||
DB_PATH = '/sd/tonberry.db'
|
DB_PATH = '/sd/tonberry.db'
|
||||||
|
|
||||||
|
config = Configuration()
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
asyncio.new_event_loop()
|
asyncio.new_event_loop()
|
||||||
# Setup LEDs
|
# 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
|
# Wifi with default config
|
||||||
setup_wifi()
|
setup_wifi()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import os
|
|||||||
|
|
||||||
class Configuration:
|
class Configuration:
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
|
'LED_COUNT': 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, config_path='/config.json'):
|
def __init__(self, config_path='/config.json'):
|
||||||
@@ -42,3 +43,6 @@ class Configuration:
|
|||||||
self._move_config_to_backup()
|
self._move_config_to_backup()
|
||||||
os.rename(self.config_path + '.new', self.config_path)
|
os.rename(self.config_path + '.new', self.config_path)
|
||||||
os.sync()
|
os.sync()
|
||||||
|
|
||||||
|
def get_led_count(self):
|
||||||
|
return self.config.get('LED_COUNT', self.DEFAULT_CONFIG['LED_COUNT'])
|
||||||
|
|||||||
Reference in New Issue
Block a user