Просмотр исходного кода

Auto choose homing method based on config filename

the home() function will now send a $config command and read the output, checking for the "sensorless" string in the filename, if the string is detected, it will use the home command .
otherwise, it will fallback to the old "bruteforce" homing.
Fabio De Simone 11 месяцев назад
Родитель
Сommit
9165f67803
1 измененных файлов с 20 добавлено и 1 удалено
  1. 20 1
      dune_weaver_flask/modules/serial/serial_manager.py

+ 20 - 1
dune_weaver_flask/modules/serial/serial_manager.py

@@ -190,7 +190,26 @@ def send_grbl_coordinates(x, y, speed=600, timeout=2, home=False):
 
 
 def home():
 def home():
     logger.info(f"Homing with speed {state.speed}")
     logger.info(f"Homing with speed {state.speed}")
-    send_grbl_coordinates(0, -110/5, state.speed, home=True)
+    
+    # Check config for sensorless homing
+    with serial_lock:
+        ser.flush()
+        ser.write("$config\n".encode())
+        response = ser.readline().decode().strip()
+        logger.debug(f"Config response: {response}")
+                
+    if "sensorless" in response.lower():
+        logger.info("Using sensorless homing")
+        with serial_lock:
+            ser.write("$H\n".encode())
+            ser.write("G1 Y0 F100\n".encode())
+            ser.flush()
+            
+    else:
+        logger.info("Using sensor-based homing")
+        send_grbl_coordinates(0, -110/5, state.speed, home=True)
+    
+    
     state.current_theta = state.current_rho = 0
     state.current_theta = state.current_rho = 0
     update_machine_position()
     update_machine_position()