Infinite loop?
-
@dc42 what you mean by led code? do you mean that led control loop? and what is daemon.g?
-
@k01571n3n said in Infinite loop?:
@dc42 what you mean by led code? do you mean that led control loop? and what is daemon.g?
I mean the third file that you listed in your original post in this thread.
daemon.g is a file that you can have in your /sys folder on the SD card to execute background tasks.
-
@dc42 Hi, yesterday I couldn't answer because this site said i was spamming...
tried that daemon file but it didnt work
it was something like that
set global.LEDMode = {global.LEDModeLast} ; WorkLight (Bed static white, Frame static white, ToolHead static white) while global.LEDMode = "WorkLight" ; Enter loop M150 R255 U255 B255 S18 P255 F1 ; LED Bed = White M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 B255 S3 P255 ; LED ToolHead = White if global.LEDMode != "WorkLight" set global.LEDModeLast = "Worklight" break ; Exit loop ; Homing (Bed flashing yellow, Frame static white, ToolHead flashing yellow) while global.LEDMode = "Homing" ; Enter loop M150 R255 U255 S18 P255 F1 ; LED Bed = Yellow M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 S3 P255 ; LED ToolHead = Yellow G4 P1000 ; 1000ms time delay M150 R255 U255 S18 P0 F1 ; LED Bed = OFF M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 S3 P0 ; LED ToolHead = OFF G4 P1000 ; 1000ms time delay if global.LEDMode != "Homing" set global.LEDModeLast = "Homing" break ; Exit loop ; Printing (Bed static green, Frame static white, ToolHead static white) while global.LEDMode = "Printing" ; Enter loop M150 U255 S18 P255 F1 ; LED Bed = Green M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 B255 S3 P255 ; LED ToolHead = White if global.LEDMode != "Printing" set global.LEDModeLast = "Printing" break
i also tried to change while to if
set global.LEDMode = {global.LEDModeLast} ; WorkLight (Bed static white, Frame static white, ToolHead static white) if global.LEDMode = "WorkLight" ; Enter loop M150 R255 U255 B255 S18 P255 F1 ; LED Bed = White M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 B255 S3 P255 ; LED ToolHead = White set global.LEDModeLast = "Worklight" ; Homing (Bed flashing yellow, Frame static white, ToolHead flashing yellow) if global.LEDMode = "Homing" ; Enter loop M150 R255 U255 S18 P255 F1 ; LED Bed = Yellow M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 S3 P255 ; LED ToolHead = Yellow G4 P1000 ; 1000ms time delay M150 R255 U255 S18 P0 F1 ; LED Bed = OFF M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 S3 P0 ; LED ToolHead = OFF G4 P1000 ; 1000ms time delay set global.LEDModeLast = "Homing" ; Printing (Bed static green, Frame static white, ToolHead static white) if global.LEDMode = "Printing" ; Enter loop M150 U255 S18 P255 F1 ; LED Bed = Green M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 B255 S3 P255 ; LED ToolHead = White set global.LEDModeLast = "Printing"
i also tested that the daemon.g is executed by adding m291 there and it works. but the led control dont work
-
@k01571n3n how are you setting LEDMode to begin with? and how are you switching between the different modes?
-
@jay_s_uk in config.g is M98 P"VariableReset.g" and all variables are resetted to something i want in that VariableReset.g. LEDMode is "OFF" and for example, in tool change macro have set global.LEDMod = "ToolChange", when printing LEDMode = "Printing" etc
-
@k01571n3n can I suggest something like this?
; WorkLight (Bed static white, Frame static white, ToolHead static white) if {global.LEDMode == "WorkLight" && global.LEDModeLast != "WorkLight"} ; Enter loop M150 R255 U255 B255 S18 P255 F1 ; LED Bed = White M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 B255 S3 P255 ; LED ToolHead = White set global.LEDModeLast = "Worklight" ; Homing (Bed flashing yellow, Frame static white, ToolHead flashing yellow) if {global.LEDMode == "Homing" && global.LEDModeLast != "Homing"} ; Enter loop M150 R255 U255 S18 P255 F1 ; LED Bed = Yellow M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 S3 P255 ; LED ToolHead = Yellow G4 P1000 ; 1000ms time delay M150 R255 U255 S18 P0 F1 ; LED Bed = OFF M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 S3 P0 ; LED ToolHead = OFF G4 P1000 ; 1000ms time delay set global.LEDModeLast = "Homing" ; Printing (Bed static green, Frame static white, ToolHead static white) if {global.LEDMode == "Printing" && global.LEDModeLast != "Printing"} ; Enter loop M150 U255 S18 P255 F1 ; LED Bed = Green M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 B255 S3 P255 ; LED ToolHead = White set global.LEDModeLast = "Printing"
I know it won't loop the homing routine (can work on that next) but theres no point running the other two over and over. Let me know if it works
-
@jay_s_uk the reason for global.LEDModeLast is:
Printer is printing -> LEDMode = "Printing"
Toolchange comesToolchange macro set global.LEDMode = "ToolChange" tool change stuff set global.LEDMode = {global.LEDModeLast}
When LEDMode is changed to something from "Printing", it sets LEDModeLast = "Printing"
if global.LEDMode = "Printing" ; Enter loop M150 U255 S18 P255 F1 ; LED Bed = Green M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 B255 S3 P255 ; LED ToolHead = White set global.LEDModeLast = "Printing" <------ here
So when the toolchange is completed, LEDMode is back at "Printing" or whatever was the last state of LED, you got the point?
-
@k01571n3n yea, but at the end of your tpost, you can just change it back to printing.
-
@jay_s_uk yes i can but.. if im not printing, it will change it to wrong mode, thats why there is that last state in memory
-
@k01571n3n rather than using a variable, why not just check the printer state? that has different cases like idle, printing, toolchanging etc
-
@jay_s_uk but why wouldn’t you want to use variables? i dont get your point for that
-
@k01571n3n it is so easy to customise almost everything with variables
-
@k01571n3n look, it was a suggestion. i also said code that i thought would work compared to your code that doesn't. i'm sorry i couldn't help you
-
@jay_s_uk i understand but that's why i told you why ModeLast exists. and checking printer state is one option too