hall_filament_width_sensor: Add command descriptions

Signed-off-by: Ben Lye ben@lye.co.nz
This commit is contained in:
Ben Lye
2026-03-05 09:21:49 +00:00
committed by KevinOConnor
parent 4fba8e4829
commit e75c281f52

View File

@@ -63,19 +63,27 @@ class HallFilamentWidthSensor:
self.extrude_factor_update_event)
# Register commands
self.gcode = self.printer.lookup_object('gcode')
self.gcode.register_command('QUERY_FILAMENT_WIDTH', self.cmd_M407)
self.gcode.register_command('QUERY_FILAMENT_WIDTH',
self.cmd_M407,
desc=self.cmd_QUERY_FILAMENT_WIDTH_help)
self.gcode.register_command('RESET_FILAMENT_WIDTH_SENSOR',
self.cmd_ClearFilamentArray)
self.cmd_ClearFilamentArray,
desc=self.cmd_RESET_FILAMENT_WIDTH_SENSOR_help)
self.gcode.register_command('DISABLE_FILAMENT_WIDTH_SENSOR',
self.cmd_M406)
self.cmd_M406,
desc=self.cmd_DISABLE_FILAMENT_WIDTH_SENSOR_help)
self.gcode.register_command('ENABLE_FILAMENT_WIDTH_SENSOR',
self.cmd_M405)
self.cmd_M405,
desc=self.cmd_ENABLE_FILAMENT_WIDTH_SENSOR_help)
self.gcode.register_command('QUERY_RAW_FILAMENT_WIDTH',
self.cmd_Get_Raw_Values)
self.cmd_Get_Raw_Values,
desc=self.cmd_QUERY_RAW_FILAMENT_WIDTH_help)
self.gcode.register_command('ENABLE_FILAMENT_WIDTH_LOG',
self.cmd_log_enable)
self.cmd_log_enable,
desc=self.cmd_ENABLE_FILAMENT_WIDTH_LOG_help)
self.gcode.register_command('DISABLE_FILAMENT_WIDTH_LOG',
self.cmd_log_disable)
self.cmd_log_disable,
desc=self.cmd_DISABLE_FILAMENT_WIDTH_LOG_help)
self.runout_helper = filament_switch_sensor.RunoutHelper(config)
# Initialization
@@ -167,6 +175,8 @@ class HallFilamentWidthSensor:
else:
return self.reactor.NEVER
cmd_QUERY_FILAMENT_WIDTH_help = (
"Report the filament width in mm and show sensor status")
def cmd_M407(self, gcmd):
response = "Filament diameter: "
if self.is_active:
@@ -187,12 +197,16 @@ class HallFilamentWidthSensor:
+ (" ON" if self.enable_flow_compensation else " OFF"))
gcmd.respond_info(response)
cmd_RESET_FILAMENT_WIDTH_SENSOR_help = "Clear all filament width readings"
def cmd_ClearFilamentArray(self, gcmd):
self.filament_array = []
gcmd.respond_info("Filament width measurements cleared!")
# Set extrude multiplier to 100%
self.gcode.run_script_from_command("M221 S100")
cmd_ENABLE_FILAMENT_WIDTH_SENSOR_help = (
"Enable the filament width sensor and enable or disable flow "
+ "compensation")
def cmd_M405(self, gcmd):
flow_comp = gcmd.get_int("FLOW_COMPENSATION", None, minval=0, maxval=1)
if flow_comp is not None:
@@ -212,6 +226,8 @@ class HallFilamentWidthSensor:
self.reactor.NOW)
gcmd.respond_info(response)
cmd_DISABLE_FILAMENT_WIDTH_SENSOR_help = (
"Disable the filament width sensor")
def cmd_M406(self, gcmd):
response = "Filament width sensor: OFF"
self.is_active = False
@@ -224,6 +240,8 @@ class HallFilamentWidthSensor:
self.gcode.run_script_from_command("M221 S100")
gcmd.respond_info(response)
cmd_QUERY_RAW_FILAMENT_WIDTH_help = (
"Report the raw filament width sensor values")
def cmd_Get_Raw_Values(self, gcmd):
response = ("ADC1="+str(self.lastFilamentWidthReading))
response += (" ADC2="+str(self.lastFilamentWidthReading2))
@@ -231,6 +249,7 @@ class HallFilamentWidthSensor:
str(self.lastFilamentWidthReading
+self.lastFilamentWidthReading2))
gcmd.respond_info(response)
def get_status(self, eventtime):
status = self.runout_helper.get_status(eventtime)
status.update({'Diameter': self.diameter,
@@ -239,10 +258,15 @@ class HallFilamentWidthSensor:
'is_active':self.is_active,
'flow_compensation_enabled':self.enable_flow_compensation})
return status
cmd_ENABLE_FILAMENT_WIDTH_LOG_help = (
"Enable filament width sensor logging")
def cmd_log_enable(self, gcmd):
self.is_log = True
gcmd.respond_info("Filament width logging: ON")
cmd_DISABLE_FILAMENT_WIDTH_LOG_help = (
"Disable filament width sensor logging")
def cmd_log_disable(self, gcmd):
self.is_log = False
gcmd.respond_info("Filament width logging: OFF")