mirror of https://github.com/Desuuuu/klipper.git
adxl345: Add accelerometer chip name to the raw data file name
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
This commit is contained in:
parent
891852ed9c
commit
0fb2449be0
|
@ -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
|
||||
|
|
|
@ -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-<name>.csv`
|
||||
where `<name>` 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-<chip>-<name>.csv` where `<chip>` is the name of the
|
||||
accelerometer chip (`my_chip_name` from `[adxl345 my_chip_name]`) and
|
||||
`<name>` 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]`) <chip> part of the name is not generated.
|
||||
- `ACCELEROMETER_QUERY [CHIP=<config_name>] [RATE=<value>]`: queries
|
||||
accelerometer for the current value. If CHIP is not specified it
|
||||
defaults to "default". If RATE is not specified, the default value
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue