Infinite loop?
-
Hi! I posted earlier about led controlling with loops. Now i got new firmware and variables are working but...
I cant do a infinite loop because printers status is then busy all the time and i cant do anything because of "busy"...
Does anyone have any idea how to do that?
Heres some code
; Configuration file for Duet3 ; Executed when Duet 3 is started M80 ; Power supplies ON ; General parameters G90 ; Absolute coordinate M83 ; Relative extrusion M550 P"Koistisen TC1" ; Printer's name M669 K1 ; Printer's kinematics = CoreXY ; Motor drivers M569 P1.0 S1 ; Motor 1.0 CW (X) M569 P1.1 S1 ; Motor 1.1 CW (Y) M569 P0.3 S1 ; Motor 1.2 CW (Z) M569 P0.0 S1 ; Motor 0.0 CW (C) M569 P0.1 S0 ; Motor 0.1 CCW (E0) M569 P0.2 S0 ; Motor 0.2 CCW (E1) M569 P0.5 S0 ; Motor 0.3 CCW (E2) M584 X1.0 Y1.1 Z0.3 C0.0 E0.1:0.2:0.5 ; Motor axis parameters M350 X16 Y16 Z16 I1 ; XYZ-Microstepping with integration M350 E16:16:16 I1 ; E-Microstepping with integration M350 C8 I0 ; C-Microstepping with integration ; Motor parameters M92 X200.00 Y200.00 Z3200.00 C100 E829.00:829.00:829.00 ; Step/mm M566 X500.00 Y500.00 Z100.00 C300.00 E500.00:500.00:500.00 ; Max allowable instantaneous speed change = Jerk (mm/min) M203 X17000.00 Y17000.00 Z800.00 C5000.00 E9000.00:9000.00:9000.00 ; Max speed (mm/min) M201 X1500.00 Y1500.00 Z300.00 C500.00 E2000.00:2000.00:2000.00 ; Acceleration (mm/s^2) M906 X1100 Y1100 Z1600 C400 E1300:1300:1300 I30 ; Motor current (mA) and motor idle factor in per cent M84 S30 ; Set idle timeout ; Axis limits M208 X0:365 Y0:362 Z0:509 C-120:120 ; Min/Max ; Endstops M574 X1 S1 P"1.io0.in" ; X-Endstop = 1.io0.in M574 Y1 S1 P"1.io1.in" ; Y-Endstop = 1.io1.in M574 Z1 S2 ; Z-Endstop = Z-Probe ; Z-Probe M558 P8 C"0.io8.in" H1 F120 T15000 ; Z-Probe = Microswitch. Measuring depth ja speed. Input = C"1.io2.in" G31 P1000 X0 Y0 Z0 ; Z-Probe triggervalue and offset M557 X0:367 Y50:310 S30 ; Bed calibration ; Heaters ; Bed M308 S0 P"1.temp0" Y"thermistor" T100000 B4138 A"Peti" ; Heat sensor 0 = 1.temp0 M950 H0 C"0.out0" T0 ; Heater 0 = 0.out0 = Heat sensor 0 M307 H0 B0 S1.00 ; PID-control, max PWM-value M140 H0 ; Bed = Heater 0 M143 H0 S120 ; Lämpöraja lämmitin 0 = 0-120C ; Tool 0 M308 S1 P"0.temp0" Y"thermistor" T100000 B4138 A"T0" ; Heat sensor 1 = 0.temp0 M950 H1 C"0.out1" T1 ; Heater 1 = 0.out1 = Heat sensor 1 M307 H1 B0 S1.00 ; PID-control, max PWM-value M143 H1 S280 ; Thermal limit for heater 1 = 0-280C ; Tool 1 M308 S2 P"0.temp1" Y"thermistor" T100000 B4138 A"T1" ; Heat sensor 2 = 0.temp1 M950 H2 C"0.out2" T2 ; Heater 2 = 0.out2 = Heat sensor 2 M307 H2 B0 S1.00 ; PID-control, max PWM-value M143 H2 S280 ; Thermal limit for heater 2 = 0-280C ; Tool 2 M308 S3 P"0.temp2" Y"thermistor" T100000 B4138 A"T2" ; Heat sensor 3 = 0.temp2 M950 H3 C"0.out3" T3 ; Heater 3 = 0.out3 = Heat sensor 3 M307 H3 B0 S1.00 ; PID-control, max PWM-value M143 H3 S280 ; Thermal limit for heater 3 = 0-280C ; Fans ; Tool 0 M950 F0 C"0.out7" Q500 ; Fan 0 = 0.out7 = 500hz M106 P0 C"T0/Kappale" S0.0 H-1 ; Fan 0 name = "Kappale". Without temperature control M950 F1 C"0.out4" Q500 ; Fan 1 = 0.out4 = 500hz M106 P1 C"T0/HotEnd" S1.0 H1 T50 L1.0 ; Fan 1 name = "HotEnd". Temperature control = Heat sensor 1 = 50C ; Tool 1 M950 F2 C"0.out8" Q500 ; Fan 2 = 0.out8 = 500hz M106 P2 C"T1/Kappale" S0.0 H-1 ; Fan 2 name = "Kappale". Without temperature control M950 F3 C"0.out5" Q500 ; Fan 3 = 0.out5 = 500hz M106 P3 C"T1/HotEnd" S1.0 H2 T50 L1.0 ; Fan 3 name = "HotEnd". Temperature control = Heat sensor 2 = 50C ; Tool 2 M950 F4 C"0.out9" Q500 ; Fan 4 = 0.out8 = 500hz M106 P4 C"T2/Kappale" S0.0 H-1 ; Fan 4 name = "Kappale". Without temperature control M950 F5 C"0.out6" Q500 ; Fan 5 = 0.out5 = 500hz M106 P5 C"T2/HotEnd" S1.0 H3 T50 L1.0 ; Fan 5 name = "HotEnd". Temperature control = Heat sensor 2 = 50C ; Tools ; Tool 0 "BMG1" M563 P0 S"BMG1" D0 H1 F0 ; Tool 0 parameters G10 P0 X0 Y0 Z0 ; Tool 0 offset G10 P0 R0 S0 ; Tool 0 valmius- ja käyttölämpötilat 0C/0C ;M591 D0 P7 S1 L7 C"0.io0.in" ; Tool 0 Filament sensor ; Tool 1 "BMG2" M563 P1 S"BMG2" D1 H2 F2 ; Tool 1 parameters G10 P1 X0 Y0 Z0 ; Tool 1 offset G10 P1 R0 S0 ; Tool 1 valmius- ja käyttölämpötilat 0C/0C ;M591 D1 P7 S1 L7 C"0.io1.in" ; Tool 1 Filament sensor ; Tool 2 "BMG3" M563 P2 S"BMG3" D2 H3 F4 ; Tool 2 parameters G10 P2 X0 Y0 Z0 ; Tool 2 offset G10 P2 R0 S0 ; Tool 2 valmius- ja käyttölämpötilat 0C/0C ;M591 D2 P7 S1 L7 C"0.io2.in" ; Tool 2 Filament sensor ; Tool 3 "JYRSIN" M563 P3 S"JYRSIN" F-1 ; Tool 3 parameters G10 P3 X0 Y0 Z0 ; Tool 3 offset ; Macros M98 P"0:/sys/VariableReset.g" ; Variable reset ;M98 P"0:/sys/LEDControl.g" ; LED Control Loop start <--printer wont start because of the loop M98 P"0:/sys/BedOrigin.g" ; Bed zeropoint G55 M98 P"0:/sys/ToolActive.g" ; Active tool reading ; Other M911 S23 R23.8 P"M500 M913 X0 Y0 C0 M150 S60 G91 M83 G1 Z2 E-1 F1000" ; Voltage threshold M501 ; Load saved parameters from config-override.g ; Tool Offsets G10 P0 X4.5 Y39 Z-46. ; Tool 0 offset G10 P1 X4.5 Y39 Z-45.95 ; Tool 1 offset G10 P2 X4.5 Y39 Z-45.85 ; Tool 2 offset G10 P3 X0 Y0 Z0 ; Tool 3 offset
; VariableReset.g ; Resets all variables ; 14.06.2021 16:16 ; LED Variable reset ; Mode----------------- global LEDMode = "OFF" global LEDModeLast = "OFF" var LEDModeMemory = "OFF" ; Color---------------------- global LEDAllColor = "White" global LEDBedColor = "White" global LEDFrameColor = "White" global LEDToolHeadColor = "White" ; Dimming-------------- global LEDAllDim = 0 global LEDBedDim = 0 global LEDFrameDim = 0 global LEDToolHeadDim = 0 ; All--------------- global AllRed = 0 global AllGreen = 0 global AllBlue = 0 global AllCustomRed = 0 global AllCustomGreen = 0 global AllCustomBlue = 0 ; Bed--------------- global BedRed = 0 global BedGreen = 0 global BedBlue = 0 global BedCustomRed = 0 global BedCustomGreen = 0 global BedCustomBlue = 0 ; Frame--------------- global FrameRed = 0 global FrameGreen = 0 global FrameBlue = 0 global FrameCustomRed = 0 global FrameCustomGreen = 0 global FrameCustomBlue = 0 ; ToolHead--------------- global ToolHeadRed = 0 global ToolHeadGreen = 0 global ToolHeadBlue = 0 global ToolHeadCustomRed = 0 global ToolHeadCustomGreen = 0 global ToolHeadCustomBlue = 0 ; Tool Variable reset var CurrentToolMemory = -1 ; Filament Variable reset global FilamentName = 0 global FilamentTemperature = 0 global FilamentRetract = 0
; LED-Control ; LED Control loop ; 10.06.2021 ; Signal colors ; Blue = Waiting ; Red = Error/emergency ; Yellow = Warning/operator ; Green = Running ; Global variables for mode: ; global.LEDMode = <Mode> ; global.LEDModeLast = <ModeLast>; This is used automatically ; <Mode> (Explanation) ; WorkLight (Bed static white, Frame static white, ToolHead static white) ; Homing (Bed flashing yellow, Frame static white, ToolHead flashing yellow) ; Printing (Bed static green, Frame static white, ToolHead static white) ; ToolChange (Bed flashing green, Frame static white, ToolHead flashing yellow) ; FilamentWait (Bed flashing blue, Frame static white, ToolHead static yellow) ; Wait (Bed flashing blue, Frame static white, ToolHead static white) ; PrintFinished (Bed flashing green slow low dim, Frame OFF, ToolHead OFF) ; OFF (Bed OFF, Frame OFF, ToolHead OFF) ; Warning (Bed flashing yellow, Frame static white, ToolHead static white) ; Error (Bed flashing red, Frame static red, ToolHead static White) ; Custom (Give your own parameters for color and dimming, will reset every time when Mode changed) ; Global variables for color: ; global.LEDAllColor = <Color> ; global.LEDBedColor = <Color> ; global.LEDFrameColor = <Color> ; global.LEDToolHeadColor = <Color> ; <Color>: Red, Green, Blue, White, Yellow, Custom ; Global variables for dimming ; global.LEDAllDim = <Dim> ; global.LEDBedDim = <Dim> ; global.LEDFrameDim = <Dim> ; global.LEDToolHeadDim = <Dim> ; <Dim>: 0-255 ; Global variables for custom color: ; global.AllCustomRed = <ColorRGB> ; global.AllCustomGreen = <ColorRGB> ; global.AllCustomBlue = <ColorRGB> ; global.BedCustomRed = <ColorRGB> ; global.BedCustomGreen = <ColorRGB> ; global.BedCustomBlue = <ColorRGB> ; global.FrameCustomRed = <ColorRGB> ; global.FrameCustomGreen = <ColorRGB> ; global.FrameCustomBlue = <ColorRGB> ; global.ToolHeadCustomRed = <ColorRGB> ; global.ToolHeadCustomGreen = <ColorRGB> ; global.ToolHeadCustomBlue = <ColorRGB> ; <ColorRGB>: Value 0-255 for each color ; M150 U255 R255 S18 P255 F1 ; LED Bed = Yellow ; M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White ; M150 R255 U255 B255 S3 P255 ; LED ToolHead = White M150 X0 Q3000000 while 1=1 ; Main control Loop set global.LEDMode = {global.LEDModeLast} ; Modes ; 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 ; Exit loop ; ToolChange (Bed flashing green, Frame static white, ToolHead flashing yellow) while global.LEDMode = "ToolChange" ; Enter loop M150 U255 S18 P255 F1 ; LED Bed = Green M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 S3 P255 ; LED ToolHead = Yellow G4 P1000 ; 1000ms time delay M150 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 != "ToolChange" set global.LEDModeLast = "ToolChange" break ; Exit loop ; Wait (Bed flashing blue, Frame static white, ToolHead static white) while global.LEDMode = "Wait" ; Enter loop M150 B255 S18 P255 F1 ; LED Bed = Blue M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 B255 S3 P255 ; LED ToolHead = White G4 P1000 ; 1000ms time delay M150 B255 S18 P0 ; LED Bed = OFF G4 P1000 ; 1000ms time delay if global.LEDMode != "Wait" set global.LEDModeLast = "Wait" break ; Exit loop ; PrintFinished (Bed flashing green slow low dim, Frame OFF, ToolHead OFF) while global.LEDMode = "PrintFinished"; Enter loop M150 U255 S18 P130 F1 ; LED Bed = Green M150 R255 U255 B255 S29 P0 F1 ; LED Frame = OFF M150 R255 U255 B255 S3 P0 ; LED ToolHead = OFF G4 P2000 ; 2000ms time delay M150 U255 S18 P0 ; LED Bed = OFF G4 P2000 ; 2000ms time delay if global.LEDMode != "PrintFinished" set global.LEDModeLast = "PrintFinished" break ; Exit loop ; OFF (Bed OFF, Frame OFF, ToolHead OFF) while global.LEDMode = "OFF" ; Enter loop M150 R255 U255 B255 S18 P0 F1 ; LED Bed = OFF M150 R255 U255 B255 S29 P0 F1 ; LED Frame = OFF M150 R255 U255 B255 S3 P0 ; LED ToolHead = OFF if global.LEDMode != "OFF" set global.LEDModeLast = "OFF" break ; Exit loop ; Warning (Bed flashing yellow, Frame static white, ToolHead static white) while global.LEDMode = "Warning" ; Enter loop M150 R255 U255 S18 P255 F1 ; LED Bed = Yellow M150 R255 U255 B255 S29 P255 F1 ; LED Frame = White M150 R255 U255 B255 S3 P255 ; LED ToolHead = White G4 P1000 ; 1000ms time delay M150 R255 U255 S18 P0 ; LED Bed = OFF G4 P1000 ; 1000ms time delay if global.LEDMode != "Warning" set global.LEDModeLast = "Warning" break ; Exit loop ; Error (Bed flashing red, Frame static red, ToolHead static White) while global.LEDMode = "Error" ; Enter loop M150 R255 S18 P255 F1 ; LED Bed = Red M150 R255 S29 P255 F1 ; LED Frame = Red M150 R255 U255 B255 S3 P255 ; LED ToolHead = White G4 P1000 ; 1000ms time delay M150 R255 S18 P0 ; LED Bed = OFF G4 P1000 ; 1000ms time delay if global.LEDMode != "Error" set global.LEDModeLast = "Error" break ; Exit loop ; Custom LEDs while global.LEDMode = "Custom" ; All colors-------------------- if global.LEDAllColor = "Custom" set global.AllRed = {global.AllCustomRed} set global.AllGreen = {global.AllCustomGreen} set global.AllBlue = {global.AllCustomBlue} if global.LEDAllColor = "Red" set global.AllRed = 255 set global.AllGreen = 0 set global.AllBlue = 0 if global.LEDAllColor = "Green" set global.AllRed = 0 set global.AllGreen = 255 set global.AllBlue = 0 if global.LEDAllColor = "Blue" set global.AllRed = 0 set global.AllGreen = 0 set global.AllBlue = 255 if global.LEDAllColor = "Yellow" set global.AllRed = 255 set global.AllGreen = 255 set global.AllBlue = 0 if global.LEDAllColor = "White" set global.AllRed = 255 set global.AllGreen = 255 set global.AllBlue = 255 ; Bed colors-------------------- if global.LEDBedColor = "Custom" set global.BedRed = {global.BedCustomRed} set global.BedGreen = {global.BedCustomGreen} set global.BedBlue = {global.BedCustomBlue} if global.LEDBedColor = "Red" set global.BedRed = 255 set global.BedGreen = 0 set global.BedBlue = 0 if global.LEDBedColor = "Green" set global.BedRed = 0 set global.BedGreen = 255 set global.BedBlue = 0 if global.LEDBedColor = "Blue" set global.BedRed = 0 set global.BedGreen = 0 set global.BedBlue = 255 if global.LEDBedColor = "Yellow" set global.BedRed = 255 set global.BedGreen = 255 set global.BedBlue = 0 if global.LEDBedColor = "White" set global.BedRed = 255 set global.BedGreen = 255 set global.BedBlue = 255 ; Frame colors-------------------- if global.LEDFrameColor = "Custom" set global.FrameRed = {global.FrameCustomRed} set global.FrameGreen = {global.FrameCustomGreen} set global.FrameBlue = {global.FrameCustomBlue} if global.LEDFrameColor = "Red" set global.FrameRed = 255 set global.FrameGreen = 0 set global.FrameBlue = 0 if global.LEDFrameColor = "Green" set global.FrameRed = 0 set global.FrameGreen = 255 set global.FrameBlue = 0 if global.LEDFrameColor = "Blue" set global.FrameRed = 0 set global.FrameGreen = 0 set global.FrameBlue = 255 if global.LEDFrameColor = "Yellow" set global.FrameRed = 255 set global.FrameGreen = 255 set global.FrameBlue = 0 if global.LEDFrameColor = "White" set global.FrameRed = 255 set global.FrameGreen = 255 set global.FrameBlue = 255 ; ToolHead colors-------------------- if global.LEDToolHeadColor = "Custom" set global.ToolHeadRed = {global.ToolHeadCustomRed} set global.ToolHeadGreen = {global.ToolHeadCustomGreen} set global.ToolHeadBlue = {global.ToolHeadCustomBlue} if global.LEDToolHeadColor = "Red" set global.ToolHeadRed = 255 set global.ToolHeadGreen = 0 set global.ToolHeadBlue = 0 if global.LEDToolHeadColor = "Green" set global.ToolHeadRed = 0 set global.ToolHeadGreen = 255 set global.ToolHeadBlue = 0 if global.LEDToolHeadColor = "Blue" set global.ToolHeadRed = 0 set global.ToolHeadGreen = 0 set global.ToolHeadBlue = 255 if global.LEDToolHeadColor = "Yellow" set global.ToolHeadRed = 255 set global.ToolHeadGreen = 255 set global.ToolHeadBlue = 0 if global.LEDToolHeadColor = "White" set global.ToolHeadRed = 255 set global.ToolHeadGreen = 255 set global.ToolHeadBlue = 255 M150 R{global.BedRed} U{global.BedGreen} B{global.BedBlue} P{global.LEDBedDim} S18 F1 ; LED Bed M150 R{global.FrameRed} U{global.FrameGreen} B{global.FrameBlue} P{global.LEDFrameDim} S29 F1 ; LED Frame M150 R{global.ToolHeadRed} U{global.ToolHeadGreen} B{global.ToolHeadBlue} P{global.LEDToolHeadDim} S3 ; LED ToolHead if global.LEDMode != "Custom" set global.LEDModeLast = "Custom" break
-
@k01571n3n where did you put the LED code: in daemon.g or somewhere else?
-
@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