Compare commits
6 Commits
7082ea3f8b
...
0f576467e1
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f576467e1 | |||
| 9d1a1f4c78 | |||
| 701e7f1491 | |||
| e652831ce5 | |||
| ebc28546bc | |||
| a51bfc1388 |
+1
-1
@@ -250,7 +250,7 @@ async def cooking_params():
|
|||||||
enhanced_filepath = enhance_image_for_ai(filepath)
|
enhanced_filepath = enhance_image_for_ai(filepath)
|
||||||
|
|
||||||
# Concurrent AI Execution
|
# Concurrent AI Execution
|
||||||
safety_task = asyncio.to_thread(safety_checker.check_dish_safety, enhanced_filepath)
|
safety_task = asyncio.to_thread(safety_checker.check_dish_safety, filepath)
|
||||||
planner_task = asyncio.to_thread(
|
planner_task = asyncio.to_thread(
|
||||||
microwave_cook_planner.generate_plan,
|
microwave_cook_planner.generate_plan,
|
||||||
image_path=enhanced_filepath,
|
image_path=enhanced_filepath,
|
||||||
|
|||||||
@@ -49,19 +49,26 @@ PING_PAYLOAD = {
|
|||||||
"type": deviceTypes.DEVICE_TYPES["MICROWAVE"]
|
"type": deviceTypes.DEVICE_TYPES["MICROWAVE"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
last_cooking_update = {}
|
||||||
|
|
||||||
|
|
||||||
def send_cooking_update(state=None, start_time=None, estimated_remaining_time=None, paused=None):
|
def send_cooking_update(state=None, start_time=None, estimated_remaining_time=None, paused=None):
|
||||||
"""Sends a flexible COOKING_UPDATE payload containing only populated fields."""
|
"""Sends a flexible COOKING_UPDATE payload containing only populated fields."""
|
||||||
|
global last_cooking_update
|
||||||
|
|
||||||
if not lora:
|
if not lora:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
send_reliably = False
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"id": DEVICE_ID,
|
"id": DEVICE_ID,
|
||||||
"action": LoraCommands.COOKING_UPDATE
|
"action": LoraCommands.COOKING_UPDATE
|
||||||
}
|
}
|
||||||
|
|
||||||
if state is not None:
|
if state is not None and state != last_cooking_update.get("cooking_state"):
|
||||||
payload["cooking_state"] = state
|
payload["cooking_state"] = state
|
||||||
|
send_reliably = True
|
||||||
if estimated_remaining_time is not None:
|
if estimated_remaining_time is not None:
|
||||||
payload["estimated_remaining_time"] = estimated_remaining_time
|
payload["estimated_remaining_time"] = estimated_remaining_time
|
||||||
if paused is not None:
|
if paused is not None:
|
||||||
@@ -70,8 +77,11 @@ def send_cooking_update(state=None, start_time=None, estimated_remaining_time=No
|
|||||||
# Only transmit if at least one field beyond id and action was provided
|
# Only transmit if at least one field beyond id and action was provided
|
||||||
if len(payload) > 2:
|
if len(payload) > 2:
|
||||||
log(f"[LoRa] Sending COOKING_UPDATE payload: {payload}")
|
log(f"[LoRa] Sending COOKING_UPDATE payload: {payload}")
|
||||||
|
last_cooking_update = payload.copy()
|
||||||
lora.send(payload)
|
if send_reliably:
|
||||||
|
lora.send_reliable(payload)
|
||||||
|
else:
|
||||||
|
lora.send(payload)
|
||||||
|
|
||||||
|
|
||||||
def on_new_alert(alert: Alert):
|
def on_new_alert(alert: Alert):
|
||||||
|
|||||||
@@ -815,16 +815,16 @@ async def monitor_dish_height_task():
|
|||||||
|
|
||||||
if dist is not None:
|
if dist is not None:
|
||||||
# Hysteresis Thresholds:
|
# Hysteresis Thresholds:
|
||||||
# - Must be > 1.2 cm to detect dish insertion
|
# - Must be > 1.5 cm to detect dish insertion
|
||||||
# - Must be < 0.8 cm to detect dish removal
|
# - Must be < 0.8 cm to detect dish removal
|
||||||
if dist > 1.2:
|
if dist > 2.0:
|
||||||
consecutive_present += 1
|
consecutive_present += 1
|
||||||
consecutive_absent = 0
|
consecutive_absent = 0
|
||||||
elif dist < 0.8:
|
elif dist < 1.0:
|
||||||
consecutive_absent += 1
|
consecutive_absent += 1
|
||||||
consecutive_present = 0
|
consecutive_present = 0
|
||||||
else:
|
else:
|
||||||
# Dead-zone (1.2cm to 0.8cm) -> Noise buffer
|
# Dead-zone (2.0cm to 1.0cm) -> Noise buffer
|
||||||
consecutive_present = 0
|
consecutive_present = 0
|
||||||
consecutive_absent = 0
|
consecutive_absent = 0
|
||||||
|
|
||||||
|
|||||||
@@ -16,14 +16,11 @@ camera_config = picam2.create_still_configuration(
|
|||||||
main={"size": (1640, 1232)}
|
main={"size": (1640, 1232)}
|
||||||
)
|
)
|
||||||
picam2.set_controls({
|
picam2.set_controls({
|
||||||
"AeEnable": False, # Disable Auto Exposure to lock settings
|
"AeEnable": True,
|
||||||
"ExposureTime": 60000, # 40 ms shutter time (brightens without grain)
|
"AwbEnable": True,
|
||||||
"AnalogueGain": 2.0, # Keep gain low to eliminate sensor noise
|
"ExposureTime": 60000,
|
||||||
"AwbEnable": False, # Disable Auto White Balance fluctuation
|
"Brightness": 0.25,
|
||||||
"ColourGains": (1.4, 1.2), # Balanced RGB gains for indoor warm LED
|
"Contrast": 1.1
|
||||||
"Brightness": 0.2, # Slight boost to shadow detail
|
|
||||||
"Contrast": 1.1, # Crisp edges around metallic surfaces
|
|
||||||
"ScalerCrop": [0, 0, max_width, max_height] # Uncrop the image
|
|
||||||
})
|
})
|
||||||
picam2.configure(camera_config)
|
picam2.configure(camera_config)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user