From 0671a37e0c86411e74f98daee4a4036da9051305 Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Thu, 23 Jul 2026 15:57:25 +0200 Subject: [PATCH] Refactor into config file --- orchestrateur/sensors/temp_hum.py | 30 ----------------------- orchestrateur/sensors/ultrasonicRanger.py | 5 ++-- shared/config.py | 5 +++- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/orchestrateur/sensors/temp_hum.py b/orchestrateur/sensors/temp_hum.py index b01adf5..79eb246 100644 --- a/orchestrateur/sensors/temp_hum.py +++ b/orchestrateur/sensors/temp_hum.py @@ -1,33 +1,3 @@ -# from sensors.lib import grove_i2c_temp_hum_mini - -# t= grove_i2c_temp_hum_mini.th02() - -# def get_temperature(): -# """Get the temperature in Celsius from the TH02 sensor.""" -# # try: -# return t.getTemperature() -# # except Exception as e: -# # print(f"Error reading temperature: {e}") -# # return None - -# def get_humidity(): -# """Get the humidity in percentage from the TH02 sensor.""" -# # try: -# return t.getHumidity() -# # except Exception as e: -# # print(f"Error reading humidity: {e}") -# # return None - -# import seeed_dht - -# sensor = seeed_dht.DHT("11", 4) # DHT11 sensor on GPIO pin 4 - -# def get_humidity_and_temperature(): -# humi, temp = sensor.read() -# return humi, temp - - -# import sensors.lib.grovepi as grovepi import grovepi import math from sensors.lock import grove_lock diff --git a/orchestrateur/sensors/ultrasonicRanger.py b/orchestrateur/sensors/ultrasonicRanger.py index b42c99e..2deabfb 100644 --- a/orchestrateur/sensors/ultrasonicRanger.py +++ b/orchestrateur/sensors/ultrasonicRanger.py @@ -1,5 +1,6 @@ import grovepi from sensors.lock import grove_lock +from shared import config # Connect the Grove Ultrasonic Ranger to digital port D4 # SIG,NC,VCC,GND @@ -25,8 +26,8 @@ def get_dish_height(): # Assuming the ultrasonic sensor is mounted at a fixed height above the dish # and pointing downwards, we can calculate the height of the dish. # For example, if the sensor is 30 cm above the dish when it's empty: - SENSOR_HEIGHT = 30 # cm - dish_height = SENSOR_HEIGHT - distance + # cm + dish_height = config.COOKING_COMPARTMENT_HEIGHT - distance return max(dish_height, 0) # Ensure height is not negative else: return None \ No newline at end of file diff --git a/shared/config.py b/shared/config.py index 502adb9..71ebd68 100644 --- a/shared/config.py +++ b/shared/config.py @@ -12,4 +12,7 @@ MQTT_KEEPALIVE = 30 USE_TLS = True MQTT_QOS = 1 # Long because messages are stored into the broker and will be sent when the orchestrator is back online. -MQTT_HELLO_INTERVAL = 30 \ No newline at end of file +MQTT_HELLO_INTERVAL = 30 + +# Microwave Model +COOKING_COMPARTMENT_HEIGHT = 30 # cm \ No newline at end of file