Can you set external triggers to toggle gcode?
-
So I have my printers lighting setup on Fan channel 1 (0 being primary fan)
Now I would like to set a momentary button to turn the leds on or off. Or even if possible several stages of brightness.
In c it would be something as simple as changing the state of a boolean light!=light;
But is it possible to make a trigger do a if statement? If fan1==0 ; fan1=1;... type thing? Or toggle a boolean?
Can complex scripts be stored in the .g config or trigger.g files?
-
https://duet3d.dozuki.com/Wiki/Gcode#Section_M581_Configure_external_trigger
You may be able to work out something with this.
The conditional scripting you describe isn't currently possible, but is being worked on.
-
Yeah I've been reading that already. That's fine for setting a state with a single button... Like an end atop or emergency stop. But I would like the ability to cycle through two states or more.
Is there any kind of expression system that can be used?
-
I have a dynamic button on my Duet, for one example, when a print starts, it is configured for trigger6
trigger6 contains a command for pause
pause contains a command to reconfigure the button for trigger7
trigger7 contains a command for resume
resume contains a command to reconfigure the button for trigger6
etc etc
should be easy to do it for LED stuff
-
Actually that sounds reasonable.... Thanks
-
Ok having a problem...
At the end of my config file I have
M106 P1 S1 ;Turns lights full bright
M581 T2 E3 S0 ;Light switchtrigger2.g
M106 P1 S0.66 ;Turns lights 1/3down
M581 T3 E3 S0 ;preps next triggertrigger3.g
M106 P1 S0.33 ;Turns lights 2/3down
M581 T4 E3 S0 ;preps next triggertrigger4.g
M106 P1 S0.0 ;Turns lights off
M581 T5 E3 S0 ;preps next triggertrigger5.g
M106 P1 S1 ;Turns lights Full on
M581 T2 E3 S0 ;preps next triggerThe lights will cycle down once and back to full bright as the button is pressed. But trigger5, the prep next trigger doesnt seem to work.
So i press the button from fresh restart, turns down 1/3 press again turns down another 1/3 press once more turns off, press again and turns on full bright, but pressing again does nothing. The lights would briefly flash off but isnt cycling down again.
Am i missing something?
-
When you create a new trigger to do something different next time the button is pressed, you should cancel the old one unless you want both trigger files to be run.
-
@dc42 Oh how do you cancel the old one?
I had assuming the new trigger declaration would over write the old one... -
@mangy_dog said in Can you set external triggers to toggle gcode?:
@dc42 Oh how do you cancel the old one?
I had assuming the new trigger declaration would over write the old one...Read the documentation for M581 on the GCodes wiki page.
-
I have read the docs and maybe I'm blind I can't see anything about canceling the previous trigger?
-
use S-1 to disable a trigger file
-
Thanks
s-1 wasnt listed on the doku gcode wiki... the reprap gcode wiki did mention it but as a delete all triggers option...Anyway its sorted now thanks
-
@mangy_dog said in Can you set external triggers to toggle gcode?:
Thanks
s-1 wasnt listed on the doku gcode wiki... the reprap gcode wiki did mention it but as a delete all triggers option...Anyway its sorted now thanks
From the doku wiki:
Using S-1 with no X Y Z or E parameters sets the trigger back to ignoring all inputs.