Triggering 'Load Filament' prompt with a macro
-
@droftarts Not quite right, M701 is triggered by the "load filament" dialog when a filament is selected.
@Surgikill The dialog itself is a DWC-only feature. But you might be able to implement a work-around using a multiple choice M291 dialog (M291 S4). Otherwise you'd have to write a DWC plugin or fork DWC.
-
@chrishamm Oops! Though could you trigger it by raising an event? eg
M957 E"filament-error" D0 P3
Ref
https://docs.duet3d.com/en/User_manual/Reference/Gcodes#m957-raise-event
https://docs.duet3d.com/User_manual/RepRapFirmware/Events
https://docs.duet3d.com/User_manual/Connecting_hardware/Sensors_filament#event-system-filament-error-eventsIan
-
@droftarts If I trigger it using a filament error event, then it's just going to go into the 'filament-error.g' macro, and I end up in the same boat of not being able to get the dialog to pop up on screen with a physical input. It seems like the only way to trigger this dialog is with the button on DWC.
@chrishamm I know I can do it with M291, but that seems pretty clunky, unless there is a way I can extract the filaments by filepath in a subdirectory. I'm not sure of a way to do this.
-
@droftarts No, that dialog is a DWC-only feature and it isn't coupled to any firmware mechanism.
@Surgikill You could write a DWC plugin which reacts to a specific global variable change and which displays a filament dialog whenever that variable changes. But of course that would require some coding skills, yet it should be technically possible.
-
@chrishamm So I'm guessing there is no way I can implement a M291 prompt that pulls variables based on filepaths inside a folder?
-
@Surgikill you can certainly have a trigger generate a M291 dialog.
-
@dc42 Yes, I am doing that now. However, I want the prompt to contain options that are dynamically created based on the content of "0:/filaments". I don't want to update the prompt every time I add a filament, or modify the name of a filament. Just like how DWC creates the prompt when pressing the 'Load Filament' button.
-
@Surgikill As far as I'm aware, the list of filaments isn't stored in the Object Model, only the filaments directory (though do check here: https://github.com/Duet3D/RepRapFirmware/wiki/Object-Model-Documentation). I don't know if you could read the filaments directory contents in as an array, then use that as your list. Someone better at Meta Gcode than me would have to advise you if this is possible.
Ian
-
@Surgikill Not without a DWC plugin or a custom fork.
-
@Surgikill said in Triggering 'Load Filament' prompt with a macro:
@dc42 Yes, I am doing that now. However, I want the prompt to contain options that are dynamically created based on the content of "0:/filaments". I don't want to update the prompt every time I add a filament, or modify the name of a filament. Just like how DWC creates the prompt when pressing the 'Load Filament' button.
At present RRF doesn't have any string handling routines and no way of extracting file information or file lists.
The best you can do is use the object model item
move.extruders[0].filament
which will show the currently loaded filament (or null)
I ran into a similar issue trying to create a filament change macro to use from PanelDue as my printer is in the shed and my computer inside.
I had to manually list all the filament types I use in an array.This is what I came up with.
It may (or may not) help in your case.; ChangeFilament.g ; requires RRF 3.5 or later! ; list of filaments must follow rules for array ; https://docs.duet3d.com/User_manual/Reference/Gcode_meta_commands#array-expressions var filaments = {"ABS","ABS-CF","ABS-GF","ASA","EDGE","eFlex","eLastic","FLEX","HIPS","NGEN","NYLON","PA-CF","PC","PCABS","PDVF","PEEK","PEI","PEKK","PET","PETG","PLA","POM","PP","PSU","PVA","SCAFF","TPE","TPU",} ; list your filaments here var maxBtns = 10; Max number of buttons per page on PanelDue. Adjust as required. 5 works OK on 7"paneldue - 9 is max! ; don't change below here var thisTool = state.currentTool var allTools = vector(#tools,null) if var.thisTool = -1 if #tools > 1 while iterations < #tools set var.allTools[iterations] = tools[iterations].name ^ "" M291 S4 P"Select tool" K{var.allTools} F0 T{input} G4 S1 if state.currentTool = -1 abort "No tool selected" else set var.thisTool = state.currentTool else T1 var thisExtruder = 0 var allExtruders = vector(#tools[var.thisTool].extruders,null) if #tools[var.thisTool].extruders > 1 while iterations < #tools[var.thisTool].extruders set var.allExtruders[iterations] = iterations ^ "" M291 P"Select extruder" S4 K{var.allExtruders} F0 set var.thisExtruder = input var thisFilament = move.extruders[tools[var.thisTool].extruders[var.thisExtruder]].filament var newFilament = null if var.maxBtns > 10 set var.maxBtns = 10 echo "Paneldue can only display 10 buttons in total" echo "Max buttons has been reset" var thisPage = vector(var.maxBtns,"") var numPages = floor(#var.filaments / (var.maxBtns - 1)) if mod(#var.filaments , var.maxBtns - 1) > 0 set var.numPages = var.numPages + 1 var pagesDone = 0; var btnsDone = 0 var nextFilament = "" var nextItem = 0 while var.pagesDone < var.numPages set var.thisPage = vector(var.maxBtns,"") set var.btnsDone = 0 while var.btnsDone < var.maxBtns-1 set var.nextItem = iterations + (var.pagesDone * (var.maxBtns-1)) if var.nextItem = #var.filaments break set var.thisPage[var.btnsDone] = var.filaments[var.nextItem] set var.nextFilament = var.filaments[var.nextItem] set var.btnsDone = var.btnsDone + 1 if var.pagesDone = var.numPages - 1 set var.thisPage[{var.maxBtns-1}] = "Cancel" else set var.thisPage[{var.maxBtns-1}] = "Next" set var.pagesDone = var.pagesDone + 1 M291 P"Select filament" S4 K{var.thisPage} if input = var.maxBtns-1 continue else set var.newFilament = var.thisPage[input] break if (var.newFilament = null) || (var.newFilament = "") abort "No filaments chosen" else echo "Filament chosen : ", var.newFilament, " : commence change" ; M701 only works if the tool only has one extruder ; If more than one extruder is present on the tool, we'll directly call the macros for load, unload and config ; It's unclear if the filament will be marked as loaded in DWC after this approach. if var.newFilament = "noFilament" if #tools[var.thisTool].extruders > 1 M98 P{directories.filaments ^ var.newFilament ^ "/load.g"} S{var.thisExtruder} M98 P{directories.filaments ^ var.newFilament ^ "/config.g"} S{var.thisExtruder} else M701 S{var.newFilament} if result != 0 abort "Error during loading" M703 else if (var.thisFilament != "noFilament") && (var.thisFilament != null) if #tools[var.thisTool].extruders > 1 ; M701 only works if the too only has one extruder M98 P{directories.filaments ^ var.newFilament ^ "/unload.g"} S{var.thisExtruder} M98 P{directories.filaments ^ var.newFilament ^ "/load.g"} S{var.thisExtruder} M98 P{directories.filaments ^ var.newFilament ^ "/config.g"} S{var.thisExtruder} else M702 M701 S{var.newFilament} if result != 0 abort "Error during loading" M703