diff --git a/.DS_Store b/.DS_Store index 24f3624..ab547da 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/cbpi/cli.py b/cbpi/cli.py index f9f8256..b4c5d11 100644 --- a/cbpi/cli.py +++ b/cbpi/cli.py @@ -14,6 +14,7 @@ import pathlib import shutil import yaml import click +from subprocess import call from jinja2 import Template @@ -61,6 +62,23 @@ def create_home_folder_structure(): print("Folder created") +def setup_one_wire(): + print("Setting up 1Wire") + with open('/boot/config.txt', 'wb') as f: + f.write("dtoverlay=w1-gpio,gpiopin=4,pullup=on") + print("/boot/config.txt created") + +def list_one_wire(): + print("List 1Wire") + call(["modprobe", "w1-gpio"]) + call(["modprobe", "w1-therm"]) + try: + for dirname in os.listdir('/sys/bus/w1/devices'): + if (dirname.startswith("28") or dirname.startswith("10")): + print(dirname) + except Exception as e: + print(e) + def copy_splash(): srcfile = os.path.join(MAIN_DIR, "config", "splash.png") destfile = os.path.join(MAIN_DIR, 'config') @@ -208,6 +226,16 @@ def setup(): create_config_file() +@click.command() +@click.option('--list', is_flag=True) +def onewire(list): + if list is True: + list_one_wire() + + else: + print("Setting up 1Wire") + setup_one_wire() + @click.command() def start(): if check_for_setup() is False: @@ -248,6 +276,7 @@ def create(name): main.add_command(setup) main.add_command(start) main.add_command(plugins) +main.add_command(onewire) main.add_command(add) main.add_command(remove) main.add_command(create) diff --git a/cbpi/extension/onewire/__init__.py b/cbpi/extension/onewire/__init__.py index 02b2304..da1653c 100644 --- a/cbpi/extension/onewire/__init__.py +++ b/cbpi/extension/onewire/__init__.py @@ -17,7 +17,7 @@ def getSensors(): arr.append(dirname) return arr except: - return ["ABC","DEF"] + return [] class ReadThread (threading.Thread): diff --git a/config/cbpi_dashboard_1.json b/config/cbpi_dashboard_1.json index 36e33eb..f2628ea 100644 --- a/config/cbpi_dashboard_1.json +++ b/config/cbpi_dashboard_1.json @@ -80,7 +80,19 @@ 160 ], [ - 215, + 285, + 175 + ], + [ + 430, + 420 + ], + [ + 240, + 350 + ], + [ + 220, 160 ] ],