gcode: Extend register_command() so that it can also unregister a command
If register_command() is passed None as the function to call, then treat it as an unregister command request. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
47bb8b7cc2
commit
51e1085dbc
|
@ -52,6 +52,12 @@ class GCodeParser:
|
||||||
self.speed = 25.0
|
self.speed = 25.0
|
||||||
self.axis2pos = {'X': 0, 'Y': 1, 'Z': 2, 'E': 3}
|
self.axis2pos = {'X': 0, 'Y': 1, 'Z': 2, 'E': 3}
|
||||||
def register_command(self, cmd, func, when_not_ready=False, desc=None):
|
def register_command(self, cmd, func, when_not_ready=False, desc=None):
|
||||||
|
if func is None:
|
||||||
|
if cmd in self.ready_gcode_handlers:
|
||||||
|
del self.ready_gcode_handlers[cmd]
|
||||||
|
if cmd in self.base_gcode_handlers:
|
||||||
|
del self.base_gcode_handlers[cmd]
|
||||||
|
return
|
||||||
if not (len(cmd) >= 2 and not cmd[0].isupper() and cmd[1].isdigit()):
|
if not (len(cmd) >= 2 and not cmd[0].isupper() and cmd[1].isdigit()):
|
||||||
origfunc = func
|
origfunc = func
|
||||||
func = lambda params: origfunc(self.get_extended_params(params))
|
func = lambda params: origfunc(self.get_extended_params(params))
|
||||||
|
|
Loading…
Reference in New Issue