setup one wire added

This commit is contained in:
Manuel Fritsch 2021-02-06 14:11:30 +01:00
parent aa2ab888d5
commit b2fe0c8453
4 changed files with 43 additions and 2 deletions

BIN
.DS_Store vendored

Binary file not shown.

View file

@ -14,6 +14,7 @@ import pathlib
import shutil import shutil
import yaml import yaml
import click import click
from subprocess import call
from jinja2 import Template from jinja2 import Template
@ -61,6 +62,23 @@ def create_home_folder_structure():
print("Folder created") 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(): def copy_splash():
srcfile = os.path.join(MAIN_DIR, "config", "splash.png") srcfile = os.path.join(MAIN_DIR, "config", "splash.png")
destfile = os.path.join(MAIN_DIR, 'config') destfile = os.path.join(MAIN_DIR, 'config')
@ -208,6 +226,16 @@ def setup():
create_config_file() 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() @click.command()
def start(): def start():
if check_for_setup() is False: if check_for_setup() is False:
@ -248,6 +276,7 @@ def create(name):
main.add_command(setup) main.add_command(setup)
main.add_command(start) main.add_command(start)
main.add_command(plugins) main.add_command(plugins)
main.add_command(onewire)
main.add_command(add) main.add_command(add)
main.add_command(remove) main.add_command(remove)
main.add_command(create) main.add_command(create)

View file

@ -17,7 +17,7 @@ def getSensors():
arr.append(dirname) arr.append(dirname)
return arr return arr
except: except:
return ["ABC","DEF"] return []
class ReadThread (threading.Thread): class ReadThread (threading.Thread):

View file

@ -80,7 +80,19 @@
160 160
], ],
[ [
215, 285,
175
],
[
430,
420
],
[
240,
350
],
[
220,
160 160
] ]
], ],