@fcwilt
This should work. I only did one test and it seems to have gone well.
This is the variable declaration at the bottom of the config.g:
global Bed_layers_initial_number = 1
global Bed_layers_initial_temperature = 2
global Bed_layers_limit_number = 3
global Bed_layers_limit_lower_temperature = 4
global Bed_layers_limit_highest_temperature = 5
This is the "variabili.g" macro with which the values passed via gcode are set:
;variabili.g
set global.Bed_layers_initial_number = param.A
set global.Bed_layers_initial_temperature = param.B
set global.Bed_layers_limit_number = param.C
set global.Bed_layers_limit_lower_temperature = param.D
set global.Bed_layers_limit_highest_temperature = param.E
This is the gcode line in the superslicer settings for PETG filament:
; Filament gcode
M98 P"variabili.g" A15 B{first_layer_bed_temperature} C44 D40 E{bed_temperature}
This is the same gcode line in the print file:
; Filament gcode
M98 P"variabili.g" A15 B60 C44 D40 E50
And finally, this is my updated daemon.g file:
if job.build != null
if job.layer != null && job.layer < {global.Bed_layers_initial_number}
M140 S{global.Bed_layers_initial_temperature}
if job.layer != null && job.layer >= {global.Bed_layers_initial_number} && job.layer < (job.file.numLayers*{global.Bed_layers_limit_number})/100
if heat.heaters[0].current < {global.Bed_layers_limit_lower_temperature}
M140 S{global.Bed_layers_limit_highest_temperature}
if heat.heaters[0].current > {global.Bed_layers_limit_highest_temperature}
M140 S{global.Bed_layers_limit_lower_temperature}
if job.layer != null && job.layer > (job.file.numLayers*{global.Bed_layers_limit_number})/100
M140 S0