From b2fe0c8453071d26bb905828ff372ae1c995cdd5 Mon Sep 17 00:00:00 2001 From: Manuel Fritsch Date: Sat, 6 Feb 2021 14:11:30 +0100 Subject: [PATCH] setup one wire added --- .DS_Store | Bin 6148 -> 6148 bytes cbpi/cli.py | 29 +++++++++++++++++++++++++++++ cbpi/extension/onewire/__init__.py | 2 +- config/cbpi_dashboard_1.json | 14 +++++++++++++- 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/.DS_Store b/.DS_Store index 24f36241604638f3931fbc2f88d8f6d20b50ae5d..ab547da374c22bfb794cc3d24bf1de3f79231434 100644 GIT binary patch delta 28 kcmZoMXfc@J&&aYdU^g=(%Vr*yzlg^#8AMH$zZ~u3#4-x zN*U6DygVSU1Sppa7E1)Pb%DG@u$%&ek!MbRa#Buy5(5K+01)$o@P8-(vT@oHLYg%x g#mPBI`T04FKr=Z|+-JmK1ee@csLi;Uo#QV*0N!;uLI3~& 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 ] ],