tmc: DUMP_TMC optional REGISTER parameter

Add an optional REGISTER parameter to DUMP_TMC so that the output is more filtered/cleaner for manual TMC calibration.

Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
This commit is contained in:
Alex Voinea 2023-03-28 09:44:51 +02:00 committed by KevinOConnor
parent 36e0afea2d
commit c9731a6fe2
2 changed files with 28 additions and 12 deletions

View File

@ -1219,8 +1219,9 @@ The following commands are available when any of the
are enabled.
#### DUMP_TMC
`DUMP_TMC STEPPER=<name>`: This command will read the TMC driver
registers and report their values.
`DUMP_TMC STEPPER=<name>` [REGISTER=<name>]: This command will read all TMC
driver registers and report their values. If a REGISTER is provided, only
the specified register will be dumped.
#### INIT_TMC
`INIT_TMC STEPPER=<name>`: This command will initialize the TMC

View File

@ -413,7 +413,22 @@ class TMCCommandHelper:
cmd_DUMP_TMC_help = "Read and display TMC stepper driver registers"
def cmd_DUMP_TMC(self, gcmd):
logging.info("DUMP_TMC %s", self.name)
print_time = self.printer.lookup_object('toolhead').get_last_move_time()
reg_name = gcmd.get('REGISTER', None)
if reg_name is not None:
reg_name = reg_name.upper()
val = self.fields.registers.get(reg_name)
if (val is not None) and (reg_name not in self.read_registers):
# write-only register
gcmd.respond_info(self.fields.pretty_format(reg_name, val))
elif reg_name in self.read_registers:
# readable register
val = self.mcu_tmc.get_register(reg_name)
if self.read_translate is not None:
reg_name, val = self.read_translate(reg_name, val)
gcmd.respond_info(self.fields.pretty_format(reg_name, val))
else:
raise gcmd.error("Unknown register name '%s'" % (reg_name))
else:
gcmd.respond_info("========== Write-only registers ==========")
for reg_name, val in self.fields.registers.items():
if reg_name not in self.read_registers: