@phaedrux said in Make use of variables:
There are some examples of config file sets that put a lot of work into parameterizing the whole thing, making system state switches by calling macros. This can be tedious to troubleshoot as you have to chase down the issues between macros to see how the system state is being altered through each step of the way. But it does allow for keeping sets of configuration variables in one place to edit, and then apply everywhere the macro is called.
Having $variables defined in one place would let macros become a lot more readable and you could refer back to the single variable definition file to see what is what. Currently the state of a gcode is always explicitly defined when it's called.
That's one reason to have variables. Less effort, more control over system state (as it is defined in one place). and better readability.
I'd be curious to see if people would find that more difficult or less difficult than it is now. And beyond the initial setup of the machine, you're not really editing those variables very often.
Well, having many parametrised macros is certainly quite messy the bigger the number. And if someone does not like to use variables then they could still use the existing approach.
A facility to make this possible is already planned!
@dc42 can't wait to use it. Bedcenter is just an example, where it variables would be helpful. Running a z-probe repeatabilty test would be much easier to implement too. Let's assume I want to repeat the test in other places than bedcenter (to spot a mechanical issue). Again, I would need to create yet another macro to set the location of the probing to take place. With vars, one could
; StartProbeLocationMacro.g:
Set probing location coords $X $Y at bedcenter
Run repeatProbe.g and record results in log file
Set probing location coords $X $Y at front left
Run repeatProbe.g
Set probing location coords $X $Y at front right
......
Reset probing location to default state $defaultBedCenterX $defaultBedCenterY
; StartProbeSpeedMacro.g:
Set probing feedrate, speed, height
Run repeatProbe.g
Change probing parameter
Run repeatProbe.g
....
Reset probing params to default state
This does seem like something that is more useful for a machine that is in development
@SupraGuy Absolutely. Either to setup and fine tune the configuration during development, but also to perform quality control upon setup of a new machine or to run maintenance tests.
As for the changes in the slicer as you pointed out:
G1 BED_X_CENTRE BED_Y_CENTRE 5.0
M280 PBL_TOUCH_PIN I1 S10
Hmmm, true. I don't see a use case for that - yet. Both lines are likely to bo into the start or end code scripts. Plus, that could just as well be done with macros containing the variables. But then how can you instruct your slicer to run a macro (apart from onstart, onlayerchange etc events)
As for the #define statements, I think the "gcode everywhere" approach is a MUCH better fit, due to adherence to coding standards and coherence.
I think it is important to point out that the value of the variables can be altered by
Mxx0 Kkeyname VNewValue
Thanks everyone for your input!