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:
parent
36e0afea2d
commit
c9731a6fe2
|
@ -1219,8 +1219,9 @@ The following commands are available when any of the
|
||||||
are enabled.
|
are enabled.
|
||||||
|
|
||||||
#### DUMP_TMC
|
#### DUMP_TMC
|
||||||
`DUMP_TMC STEPPER=<name>`: This command will read the TMC driver
|
`DUMP_TMC STEPPER=<name>` [REGISTER=<name>]: This command will read all TMC
|
||||||
registers and report their values.
|
driver registers and report their values. If a REGISTER is provided, only
|
||||||
|
the specified register will be dumped.
|
||||||
|
|
||||||
#### INIT_TMC
|
#### INIT_TMC
|
||||||
`INIT_TMC STEPPER=<name>`: This command will initialize the TMC
|
`INIT_TMC STEPPER=<name>`: This command will initialize the TMC
|
||||||
|
|
|
@ -413,17 +413,32 @@ class TMCCommandHelper:
|
||||||
cmd_DUMP_TMC_help = "Read and display TMC stepper driver registers"
|
cmd_DUMP_TMC_help = "Read and display TMC stepper driver registers"
|
||||||
def cmd_DUMP_TMC(self, gcmd):
|
def cmd_DUMP_TMC(self, gcmd):
|
||||||
logging.info("DUMP_TMC %s", self.name)
|
logging.info("DUMP_TMC %s", self.name)
|
||||||
print_time = self.printer.lookup_object('toolhead').get_last_move_time()
|
reg_name = gcmd.get('REGISTER', None)
|
||||||
gcmd.respond_info("========== Write-only registers ==========")
|
if reg_name is not None:
|
||||||
for reg_name, val in self.fields.registers.items():
|
reg_name = reg_name.upper()
|
||||||
if reg_name not in self.read_registers:
|
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:
|
||||||
|
gcmd.respond_info(self.fields.pretty_format(reg_name, val))
|
||||||
|
gcmd.respond_info("========== Queried registers ==========")
|
||||||
|
for reg_name in self.read_registers:
|
||||||
|
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))
|
gcmd.respond_info(self.fields.pretty_format(reg_name, val))
|
||||||
gcmd.respond_info("========== Queried registers ==========")
|
|
||||||
for reg_name in self.read_registers:
|
|
||||||
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))
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
Loading…
Reference in New Issue