From c617eced1f2101151bc665612190d6312a20d663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Sun, 24 Jul 2022 10:13:00 +0200 Subject: [PATCH] added debugging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- main.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 399cde6..195f65d 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,16 @@ +def debug_print(message: str): + now = datetime.now() + current_time = now.strftime("%H:%M:%S") + print('[DEBUG]['+current_time+'] '+message) + +def error_print(message: str): + now = datetime.now() + current_time = now.strftime("%H:%M:%S") + print('[ERROR]['+current_time+'] '+message) + +debug_print("Importing modules") + + from string import whitespace import time from datetime import datetime @@ -14,15 +27,7 @@ except ImportError: print(ImportError) exit() -def debug_print(message: str): - now = datetime.now() - current_time = now.strftime("%H:%M:%S") - print('[DEBUG]['+current_time+'] '+message) - -def error_print(message: str): - now = datetime.now() - current_time = now.strftime("%H:%M:%S") - print('[ERROR]['+current_time+'] '+message) +debug_print("Imported modules") #relay def relay_controller(pin: int, state: str): @@ -60,6 +65,8 @@ def get_water_level(): rounded_distance = int(distance) return str(rounded_distance) +debug_print("Added water level detector") + #temperature def get_temperature(): i2c = busio.I2C(board.SCL, board.SDA) @@ -67,6 +74,8 @@ def get_temperature(): rounded_temp = int(bmp280.temperature) return str(rounded_temp) +debug_print("Added temperature sensor") + print(get_water_level()) print(get_temperature())