diff --git a/docs/Config_Changes.md b/docs/Config_Changes.md index 335e0e72..2e2375f2 100644 --- a/docs/Config_Changes.md +++ b/docs/Config_Changes.md @@ -6,6 +6,10 @@ All dates in this document are approximate. # Changes +20210201: The `ACCELEROMETER_MEASURE` command will now append the name +of the accelerometer chip to the output file name if the chip was given +a name in the corresponding adxl345 section of the printer.cfg. + 20201222: The `step_distance` setting in the stepper config sections is deprecated. It is advised to update the config to use the [`rotation_distance`](Rotation_Distance.md) setting. Support for diff --git a/docs/G-Codes.md b/docs/G-Codes.md index c61a6031..c6f99658 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -704,10 +704,13 @@ The following commands are available when an the first time, it starts the measurements, next execution stops them. If RATE is not specified, then the default value is used (either from `printer.cfg` or `3200` default value). The results of - measurements are written to a file named `/tmp/adxl345-.csv` - where `` is the optional NAME parameter. If NAME is not - specified it defaults to the current time in "YYYYMMDD_HHMMSS" - format. + measurements are written to a file named + `/tmp/adxl345--.csv` where `` is the name of the + accelerometer chip (`my_chip_name` from `[adxl345 my_chip_name]`) and + `` is the optional NAME parameter. If NAME is not specified it + defaults to the current time in "YYYYMMDD_HHMMSS" format. If the + accelerometer does not have a name in its config section (simply + `[adxl345]`) part of the name is not generated. - `ACCELEROMETER_QUERY [CHIP=] [RATE=]`: queries accelerometer for the current value. If CHIP is not specified it defaults to "default". If RATE is not specified, the default value diff --git a/klippy/extras/adxl345.py b/klippy/extras/adxl345.py index c29d5451..7bf1ab59 100644 --- a/klippy/extras/adxl345.py +++ b/klippy/extras/adxl345.py @@ -125,17 +125,17 @@ class ADXL345: mcu.register_response(self._handle_adxl345_start, "adxl345_start", oid) mcu.register_response(self._handle_adxl345_data, "adxl345_data", oid) # Register commands - name = "default" + self.name = "default" if len(config.get_name().split()) > 1: - name = config.get_name().split()[1] + self.name = config.get_name().split()[1] gcode = self.printer.lookup_object('gcode') - gcode.register_mux_command("ACCELEROMETER_MEASURE", "CHIP", name, + gcode.register_mux_command("ACCELEROMETER_MEASURE", "CHIP", self.name, self.cmd_ACCELEROMETER_MEASURE, desc=self.cmd_ACCELEROMETER_MEASURE_help) - gcode.register_mux_command("ACCELEROMETER_QUERY", "CHIP", name, + gcode.register_mux_command("ACCELEROMETER_QUERY", "CHIP", self.name, self.cmd_ACCELEROMETER_QUERY, desc=self.cmd_ACCELEROMETER_QUERY_help) - if name == "default": + if self.name == "default": gcode.register_mux_command("ACCELEROMETER_MEASURE", "CHIP", None, self.cmd_ACCELEROMETER_MEASURE) gcode.register_mux_command("ACCELEROMETER_QUERY", "CHIP", None, @@ -229,7 +229,10 @@ class ADXL345: return res = self.finish_measurements() # Write data to file - filename = "/tmp/adxl345-%s.csv" % (name,) + if self.name == "default": + filename = "/tmp/adxl345-%s.csv" % (name,) + else: + filename = "/tmp/adxl345-%s-%s.csv" % (self.name, name,) res.write_to_file(filename) cmd_ACCELEROMETER_MEASURE_help = "Start/stop accelerometer" def cmd_ACCELEROMETER_MEASURE(self, gcmd):