I’m working on backlash compensation logic for Klipper and already implemented working method for GCodeMove class.
As a newbie in both Python and Klipper, I got to the point when I need some help from more experienced community members.
The issue I stuck at is adding a custom config section, let’s say [backlash_compensation]. When I put it into printer.cfg I’m getting an error:
Section ‘backlash_compensation’ is not a valid config section.
It seems that Klipper requires new sections and their options to be registered in the first place, but I have no idea how and reading through configfile.py didn’t added clarity.
I also failed to find anything relevant in Google.
Could someone explain that misterious part to me?
The file name in the /klippy/extras
directory is the config section name. So backlash_compensation.py
is registered as [backlash_compensation]
.
You need a function def load_config(config):
at the bottom of the file to return an object that will process the config. But the type of that object can be anything you want.
Thanks, @garethky! So simple
In my case I modified cmd_G1() method of GCodeMove class. I beleive it’s the right place to manipulate coordinates. So I’m going to move backlash settings to [gcode_move] section. Does that approach looks good from your prospective?
There are several modules like bed_mesh
and z_thermal_adjust
that make changes to the toolhead position based on some external model. Take a look at set_move_transform()
.
The code in z_thermal_adjust
is probably the simplest one to learn/copy from.
These adjust function all form a chain and each adjusts the toolhead location for each move.