bed_screws: Finish bed_screws_adjust after n consecutive accepts (#4521)
Changed the bed_screws_adjust command so that it finishes after 4 consecutive accepts. Before if you had 4 screws and adjusted the first one you had to accept 7 times to finish the bed_screws_adjust. Signed-off-by: Christian Enderle <mail@chrenderle.de>
This commit is contained in:
parent
1bc4f90fb0
commit
afd80c1de9
|
@ -17,7 +17,8 @@ class BedScrews:
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
self.state = None
|
self.state = None
|
||||||
self.current_screw = 0
|
self.current_screw = 0
|
||||||
self.adjust_again = False
|
self.accepted_screws = 0
|
||||||
|
self.number_of_screws = 0
|
||||||
# Read config
|
# Read config
|
||||||
screws = []
|
screws = []
|
||||||
fine_adjust = []
|
fine_adjust = []
|
||||||
|
@ -34,6 +35,7 @@ class BedScrews:
|
||||||
fine_adjust.append((fine_coord, screw_name))
|
fine_adjust.append((fine_coord, screw_name))
|
||||||
if len(screws) < 3:
|
if len(screws) < 3:
|
||||||
raise config.error("bed_screws: Must have at least three screws")
|
raise config.error("bed_screws: Must have at least three screws")
|
||||||
|
self.number_of_screws = len(screws)
|
||||||
self.states = {'adjust': screws, 'fine': fine_adjust}
|
self.states = {'adjust': screws, 'fine': fine_adjust}
|
||||||
self.speed = config.getfloat('speed', 50., above=0.)
|
self.speed = config.getfloat('speed', 50., above=0.)
|
||||||
self.lift_speed = config.getfloat('probe_speed', 5., above=0.)
|
self.lift_speed = config.getfloat('probe_speed', 5., above=0.)
|
||||||
|
@ -73,22 +75,26 @@ class BedScrews:
|
||||||
def cmd_BED_SCREWS_ADJUST(self, gcmd):
|
def cmd_BED_SCREWS_ADJUST(self, gcmd):
|
||||||
if self.state is not None:
|
if self.state is not None:
|
||||||
raise gcmd.error("Already in bed_screws helper; use ABORT to exit")
|
raise gcmd.error("Already in bed_screws helper; use ABORT to exit")
|
||||||
self.adjust_again = False
|
# reset accepted screws
|
||||||
|
self.accepted_screws = 0
|
||||||
self.move((None, None, self.horizontal_move_z), self.speed)
|
self.move((None, None, self.horizontal_move_z), self.speed)
|
||||||
self.move_to_screw('adjust', 0)
|
self.move_to_screw('adjust', 0)
|
||||||
cmd_ACCEPT_help = "Accept bed screw position"
|
cmd_ACCEPT_help = "Accept bed screw position"
|
||||||
def cmd_ACCEPT(self, gcmd):
|
def cmd_ACCEPT(self, gcmd):
|
||||||
self.unregister_commands()
|
self.unregister_commands()
|
||||||
if self.current_screw + 1 < len(self.states[self.state]):
|
self.accepted_screws = self.accepted_screws + 1
|
||||||
|
if self.current_screw + 1 < len(self.states[self.state]) \
|
||||||
|
and self.accepted_screws < self.number_of_screws:
|
||||||
# Continue with next screw
|
# Continue with next screw
|
||||||
self.move_to_screw(self.state, self.current_screw + 1)
|
self.move_to_screw(self.state, self.current_screw + 1)
|
||||||
return
|
return
|
||||||
if self.adjust_again:
|
if self.accepted_screws < self.number_of_screws:
|
||||||
# Retry coarse adjustments
|
# Retry coarse adjustments
|
||||||
self.adjust_again = False
|
|
||||||
self.move_to_screw('adjust', 0)
|
self.move_to_screw('adjust', 0)
|
||||||
return
|
return
|
||||||
if self.state == 'adjust' and self.states['fine']:
|
if self.state == 'adjust' and self.states['fine']:
|
||||||
|
# Reset accepted screws for fine adjustment
|
||||||
|
self.accepted_screws = 0
|
||||||
# Perform fine screw adjustments
|
# Perform fine screw adjustments
|
||||||
self.move_to_screw('fine', 0)
|
self.move_to_screw('fine', 0)
|
||||||
return
|
return
|
||||||
|
@ -99,7 +105,7 @@ class BedScrews:
|
||||||
cmd_ADJUSTED_help = "Accept bed screw position after notable adjustment"
|
cmd_ADJUSTED_help = "Accept bed screw position after notable adjustment"
|
||||||
def cmd_ADJUSTED(self, gcmd):
|
def cmd_ADJUSTED(self, gcmd):
|
||||||
self.unregister_commands()
|
self.unregister_commands()
|
||||||
self.adjust_again = True
|
self.accepted_screws = -1
|
||||||
self.cmd_ACCEPT(gcmd)
|
self.cmd_ACCEPT(gcmd)
|
||||||
cmd_ABORT_help = "Abort bed screws tool"
|
cmd_ABORT_help = "Abort bed screws tool"
|
||||||
def cmd_ABORT(self, gcmd):
|
def cmd_ABORT(self, gcmd):
|
||||||
|
|
Loading…
Reference in New Issue