diff --git a/docs/Config_Changes.md b/docs/Config_Changes.md index 24d4b3e4..13fefdad 100644 --- a/docs/Config_Changes.md +++ b/docs/Config_Changes.md @@ -8,6 +8,10 @@ All dates in this document are approximate. ## Changes +20210830: The default adxl345 name is now "adxl345". The default CHIP +parameter for the `ACCELEROMETER_MEASURE` and `ACCELEROMETER_QUERY` is +now also "adxl345". + 20210830: The adxl345 ACCELEROMETER_MEASURE command no longer supports a RATE parameter. To alter the query rate, update the printer.cfg file and issue a RESTART command. diff --git a/docs/G-Codes.md b/docs/G-Codes.md index 1c2644f3..dbc176ac 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -727,7 +727,7 @@ The following commands are available when an [adxl345 config section](Config_Reference.md#adxl345) is enabled: - `ACCELEROMETER_MEASURE [CHIP=] [NAME=]`: Starts accelerometer measurements at the requested number of samples per - second. If CHIP is not specified it defaults to "default". The + second. If CHIP is not specified it defaults to "adxl345". The command works in a start-stop mode: when executed for the first time, it starts the measurements, next execution stops them. The results of measurements are written to a file named @@ -740,7 +740,7 @@ The following commands are available when an 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 + defaults to "adxl345". If RATE is not specified, the default value is used. This command is useful to test the connection to the ADXL345 accelerometer: one of the returned values should be a free-fall acceleration (+/- some noise of the chip). diff --git a/klippy/extras/adxl345.py b/klippy/extras/adxl345.py index 9d2f8945..428da1e3 100644 --- a/klippy/extras/adxl345.py +++ b/klippy/extras/adxl345.py @@ -83,11 +83,9 @@ class ADXLCommandHelper: self.printer = config.get_printer() self.chip = chip self.bg_client = None - self.name = "default" - if len(config.get_name().split()) > 1: - self.name = config.get_name().split()[1] + self.name = config.get_name().split()[-1] self.register_commands(self.name) - if self.name == "default": + if self.name == "adxl345": self.register_commands(None) def register_commands(self, name): # Register commands @@ -121,7 +119,7 @@ class ADXLCommandHelper: self.bg_client = None bg_client.finish_measurements() # Write data to file - if self.name == "default": + if self.name == "adxl345": filename = "/tmp/adxl345-%s.csv" % (name,) else: filename = "/tmp/adxl345-%s-%s.csv" % (self.name, name,) @@ -246,9 +244,7 @@ class ADXL345: # API server endpoints self.api_dump = motion_report.APIDumpHelper( self.printer, self._api_update, self._api_startstop, 0.100) - self.name = "default" - if len(config.get_name().split()) > 1: - self.name = config.get_name().split()[1] + self.name = config.get_name().split()[-1] wh = self.printer.lookup_object('webhooks') wh.register_mux_endpoint("adxl345/dump_adxl345", "sensor", self.name, self._handle_dump_adxl345)