bed_mesh: save mesh state to 'default' profile after calibration

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2018-10-02 18:23:34 -04:00 committed by KevinOConnor
parent 822616ae7f
commit d29eb731a9
1 changed files with 12 additions and 2 deletions

View File

@ -75,6 +75,7 @@ class BedMesh:
def printer_state(self, state): def printer_state(self, state):
if state == 'connect': if state == 'connect':
self.toolhead = self.printer.lookup_object('toolhead') self.toolhead = self.printer.lookup_object('toolhead')
self.calibrate.load_default_profile()
def set_mesh(self, mesh): def set_mesh(self, mesh):
# Assign the current mesh. If set to None, no transform # Assign the current mesh. If set to None, no transform
# is applied # is applied
@ -278,6 +279,9 @@ class BedMeshCalibrate:
else: else:
self.gcode.respond_info( self.gcode.respond_info(
"No profile named [%s] to remove" % (prof_name)) "No profile named [%s] to remove" % (prof_name))
def load_default_profile(self):
if "default" in self.profiles:
self.load_profile("default")
cmd_BED_MESH_PROFILE_help = "Bed Mesh Persistent Storage management" cmd_BED_MESH_PROFILE_help = "Bed Mesh Persistent Storage management"
def cmd_BED_MESH_PROFILE(self, params): def cmd_BED_MESH_PROFILE(self, params):
options = collections.OrderedDict({ options = collections.OrderedDict({
@ -288,9 +292,14 @@ class BedMeshCalibrate:
for key in options: for key in options:
name = self.gcode.get_str(key, params, None) name = self.gcode.get_str(key, params, None)
if name is not None: if name is not None:
if name == "default" and key is not 'LOAD':
self.gcode.respond_info(
"Profile 'default' is reserved, please chose"
" another profile name.")
else:
options[key](name) options[key](name)
return return
self.gcode.respond_error( self.gcode.respond_info(
"Invalid syntax '%s'" % (params['#original'])) "Invalid syntax '%s'" % (params['#original']))
cmd_BED_MESH_MAP_help = "Probe the bed and serialize output" cmd_BED_MESH_MAP_help = "Probe the bed and serialize output"
def cmd_BED_MESH_MAP(self, params): def cmd_BED_MESH_MAP(self, params):
@ -358,6 +367,7 @@ class BedMeshCalibrate:
raise self.gcode.error(e.message) raise self.gcode.error(e.message)
self.bedmesh.set_mesh(mesh) self.bedmesh.set_mesh(mesh)
self.gcode.respond_info("Mesh Bed Leveling Complete") self.gcode.respond_info("Mesh Bed Leveling Complete")
self.save_profile("default")
class MoveSplitter: class MoveSplitter: