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)
|
||||
|
||||
# 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(
|
||||
microwave_cook_planner.generate_plan,
|
||||
image_path=enhanced_filepath,
|
||||
|
||||
@@ -49,19 +49,26 @@ PING_PAYLOAD = {
|
||||
"type": deviceTypes.DEVICE_TYPES["MICROWAVE"]
|
||||
}
|
||||
|
||||
last_cooking_update = {}
|
||||
|
||||
|
||||
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."""
|
||||
global last_cooking_update
|
||||
|
||||
if not lora:
|
||||
return
|
||||
|
||||
send_reliably = False
|
||||
|
||||
payload = {
|
||||
"id": DEVICE_ID,
|
||||
"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
|
||||
send_reliably = True
|
||||
if estimated_remaining_time is not None:
|
||||
payload["estimated_remaining_time"] = estimated_remaining_time
|
||||
if paused is not None:
|
||||
@@ -70,7 +77,10 @@ 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
|
||||
if len(payload) > 2:
|
||||
log(f"[LoRa] Sending COOKING_UPDATE payload: {payload}")
|
||||
|
||||
last_cooking_update = payload.copy()
|
||||
if send_reliably:
|
||||
lora.send_reliable(payload)
|
||||
else:
|
||||
lora.send(payload)
|
||||
|
||||
|
||||
|
||||
@@ -815,16 +815,16 @@ async def monitor_dish_height_task():
|
||||
|
||||
if dist is not None:
|
||||
# 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
|
||||
if dist > 1.2:
|
||||
if dist > 2.0:
|
||||
consecutive_present += 1
|
||||
consecutive_absent = 0
|
||||
elif dist < 0.8:
|
||||
elif dist < 1.0:
|
||||
consecutive_absent += 1
|
||||
consecutive_present = 0
|
||||
else:
|
||||
# Dead-zone (1.2cm to 0.8cm) -> Noise buffer
|
||||
# Dead-zone (2.0cm to 1.0cm) -> Noise buffer
|
||||
consecutive_present = 0
|
||||
consecutive_absent = 0
|
||||
|
||||
|
||||
@@ -16,14 +16,11 @@ camera_config = picam2.create_still_configuration(
|
||||
main={"size": (1640, 1232)}
|
||||
)
|
||||
picam2.set_controls({
|
||||
"AeEnable": False, # Disable Auto Exposure to lock settings
|
||||
"ExposureTime": 60000, # 40 ms shutter time (brightens without grain)
|
||||
"AnalogueGain": 2.0, # Keep gain low to eliminate sensor noise
|
||||
"AwbEnable": False, # Disable Auto White Balance fluctuation
|
||||
"ColourGains": (1.4, 1.2), # Balanced RGB gains for indoor warm LED
|
||||
"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
|
||||
"AeEnable": True,
|
||||
"AwbEnable": True,
|
||||
"ExposureTime": 60000,
|
||||
"Brightness": 0.25,
|
||||
"Contrast": 1.1
|
||||
})
|
||||
picam2.configure(camera_config)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user