Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (check): check that temperature over 30° #7

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/alarm_clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ def checks(self):
check ever probe and return status
"""
button = myCheck.check_buttons()
temp, value = myCheck.check_temperature()
if button == 2:
self.log(logging.DEBUG, "Wrong wire Boom")
self.beep()
if button == 1:
if button == 1 and temp:
self.log(logging.DEBUG, "checks done")
return True
self.log(logging.DEBUG, "checks failed")
self.log(logging.DEBUG, f"checks failed wire {button} temp {temp}/{value}")
return False

def make_clear(self):
Expand Down
19 changes: 19 additions & 0 deletions src/modules/checks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""
Checks for ending the alarm before time
"""
from os import path
from gpiozero import Button


def check_buttons():
"""
Checks that the wire connected to GPIO 16 is cut and the one to GPIO26 not
Expand All @@ -15,3 +17,20 @@ def check_buttons():
if button_true.is_pressed and not button_false.is_pressed:
return 1
return 2

def read_temperature_device(dev):
"""read from sensore type D18S20"""
master = "/sys/bus/w1/devices/w1_bus_master1"
file = path.join( master, dev, "w1_slave")
with open(file, encoding='utf-8') as file_temp:
string_value = file_temp.read().split("t=")[1]
temperature = int(string_value.strip())/1000.0
return temperature

def check_temperature():
"""checks that a flame is near the nail"""
slave = '10-000803b33dd1'
temp = read_temperature_device(slave)
if temp > 32:
return True, temp
return False, temp
7 changes: 7 additions & 0 deletions src/modules/checks_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ def check_buttons():
return 2
sleep(2)
return 0


def check_temperature():
"""checks that a flame is near the nail"""
if TEST_RUN > 8:
return True, TEST_RUN
return False, TEST_RUN
Loading