mirror of https://github.com/Desuuuu/klipper.git
bed_mesh: Report actual mesh profiles as status
Report the actual profiles available via BED_MESH_PROFILE via the status for use by clients. Signed-off-by: Kurt Haenen <kurt.haenen@gmail.com>
This commit is contained in:
parent
131cca2b51
commit
8b0c6fcb08
|
@ -16,6 +16,8 @@ The following information is available in the
|
|||
[bed_mesh](Config_Reference.md#bed_mesh) object:
|
||||
- `profile_name`, `mesh_min`, `mesh_max`, `probed_matrix`,
|
||||
`mesh_matrix`: Information on the currently active bed_mesh.
|
||||
- `profiles`: The set of currently defined profiles as setup
|
||||
using BED_MESH_PROFILE.
|
||||
|
||||
## configfile
|
||||
|
||||
|
|
|
@ -221,7 +221,8 @@ class BedMesh:
|
|||
"mesh_min": (0., 0.),
|
||||
"mesh_max": (0., 0.),
|
||||
"probed_matrix": [[]],
|
||||
"mesh_matrix": [[]]
|
||||
"mesh_matrix": [[]],
|
||||
"profiles": self.pmgr.get_profiles()
|
||||
}
|
||||
if self.z_mesh is not None:
|
||||
params = self.z_mesh.get_mesh_params()
|
||||
|
@ -1134,6 +1135,8 @@ class ProfileManager:
|
|||
self._check_incompatible_profiles()
|
||||
if "default" in self.profiles:
|
||||
self.load_profile("default")
|
||||
def get_profiles(self):
|
||||
return self.profiles
|
||||
def get_current_profile(self):
|
||||
return self.current_profile
|
||||
def _check_incompatible_profiles(self):
|
||||
|
@ -1170,9 +1173,12 @@ class ProfileManager:
|
|||
for key, value in mesh_params.items():
|
||||
configfile.set(cfg_name, key, value)
|
||||
# save copy in local storage
|
||||
self.profiles[prof_name] = profile = {}
|
||||
# ensure any self.profiles returned as status remains immutable
|
||||
profiles = dict(self.profiles)
|
||||
profiles[prof_name] = profile = {}
|
||||
profile['points'] = probed_matrix
|
||||
profile['mesh_params'] = collections.OrderedDict(mesh_params)
|
||||
self.profiles = profiles
|
||||
self.current_profile = prof_name
|
||||
self.gcode.respond_info(
|
||||
"Bed Mesh state has been saved to profile [%s]\n"
|
||||
|
@ -1197,7 +1203,9 @@ class ProfileManager:
|
|||
if prof_name in self.profiles:
|
||||
configfile = self.printer.lookup_object('configfile')
|
||||
configfile.remove_section('bed_mesh ' + prof_name)
|
||||
del self.profiles[prof_name]
|
||||
profiles = dict(self.profiles)
|
||||
del profiles[prof_name]
|
||||
self.profiles = profiles
|
||||
self.gcode.respond_info(
|
||||
"Profile [%s] removed from storage for this session.\n"
|
||||
"The SAVE_CONFIG command will update the printer\n"
|
||||
|
|
Loading…
Reference in New Issue