mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-05-06 22:27:00 +02:00
adxl345: Fix possible double registration of default gcode mux commands
Allow specifying only one unnamed accelerometer in the configuration file, which becomes the default. Signed-off-by: Maksim Bolgov <maksim8024@gmail.com>
This commit is contained in:
committed by
KevinOConnor
parent
f2b36b71ff
commit
d487925b24
@@ -114,8 +114,16 @@ class AccelCommandHelper:
|
||||
self.name = name_parts[-1]
|
||||
self.register_commands(self.name)
|
||||
if len(name_parts) == 1:
|
||||
if self.name == "adxl345" or not config.has_section("adxl345"):
|
||||
# Try to register default mux commands for the accelerometer
|
||||
# without explicit name. If default accelerometer has already
|
||||
# been registered, raise an error.
|
||||
try:
|
||||
self.register_commands(None)
|
||||
except config.error:
|
||||
raise config.error(
|
||||
"Default accelerometer already defined; section '%s' must "
|
||||
"include an additional name, e.g. '%s second_accelerometer'"
|
||||
% (self.base_name, self.base_name))
|
||||
def register_commands(self, name):
|
||||
# Register commands
|
||||
gcode = self.printer.lookup_object('gcode')
|
||||
|
||||
Reference in New Issue
Block a user