Skip to content

Commit

Permalink
add bed_mesh_default option to config (#143)
Browse files Browse the repository at this point in the history
* add bed_mesh_default to config

* Update README.md and Config_Reference.md
  • Loading branch information
lraithel15133 authored Feb 3, 2024
1 parent b76172c commit e37eb82
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ If I want my printer to light itself on fire, I should be able to make my printe

- [force_move: turn on by default](https://github.com/DangerKlippers/danger-klipper/pull/135)

- [bed_mesh: add bed_mesh_default config option](https://github.com/DangerKlippers/danger-klipper/pull/143)


If you're feeling adventurous, take a peek at the extra features in the bleeding-edge branch:

- [dmbutyugin's advanced-features branch](https://github.com/DangerKlippers/danger-klipper/pull/69) [dmbutyugin/advanced-features](https://github.com/dmbutyugin/klipper/commits/advanced-features)
Expand Down
3 changes: 3 additions & 0 deletions docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,9 @@ Visual Examples:
#adaptive_margin:
# An optional margin (in mm) to be added around the bed area used by
# the defined print objects when generating an adaptive mesh.
#bed_mesh_default:
# Optionally provide the name of a profile you would like loaded on init.
# By default, no profile is loaded.
```

### [bed_tilt]
Expand Down
11 changes: 11 additions & 0 deletions klippy/extras/bed_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def __init__(self, config):
self.printer.register_event_handler(
"klippy:connect", self.handle_connect
)
config_file = self.printer.lookup_object("configfile")
self.last_position = [0.0, 0.0, 0.0, 0.0]
self.bmc = BedMeshCalibrate(config, self)
self.z_mesh = None
Expand All @@ -131,6 +132,16 @@ def __init__(self, config):
# setup persistent storage
self.pmgr = ProfileManager(config, self)
self.save_profile = self.pmgr.save_profile
self.default_mesh_name = config.get("bed_mesh_default", None)
if self.default_mesh_name:
if self.default_mesh_name in self.pmgr.get_profiles():
self.pmgr.load_profile(self.default_mesh_name)
else:
config_file.warn(
"config",
f"Selected default bed mesh profile '{self.default_mesh_name}' not found in available profiles.",
"Invalid profile name",
)
# register gcodes
self.gcode.register_command(
"BED_MESH_OUTPUT",
Expand Down

0 comments on commit e37eb82

Please sign in to comment.