Temp gradient using neopixel and Duet 3 mini 5+
-
I am looking for help with getting this script to go past yellow. It does the white, green and Yellow just fine but wont progress to orange and red. Any help would be appreciated.
Thank you in advance.
; LED control if {state.status} == "paused" M150 R255 B255 P255 S20 ; purple M300 S4000 P50 G4 P300 M300 S4000 P50 ; double beep elif {state.status} == "processing" || {state.status} == "busy" M150 R255 U255 B255 P255 S20 ; white elif {heat.heaters[1].current} <= 70 M150 R255 U255 B0 P255 S20 F1 ; yellow elif {heat.heaters[1].current} > 170 M150 R255 U80 B0 P255 S20 F1 ; orange elif {heat.heaters[1].current} >= 230 M150 R255 U0 B0 P255 S20 F1 ; red elif {state.status} == "idle" M150 R0 U255 B0 P255 S20 ; green else M150 R150 U0 B150 P255 S20 ; purple
-
The if/elif conditional is exclusive, that means as soon as one condition evaluates to "true", it stops looking at the rest.
For example, as soon as your status is processing or busy, the leds will ALWAYS be white, everything after that won't even be checked.The same applies to the temp checks, you are checking if the temperature is above 170°C and after that, you check for the temperature being > 230°C, but 230°C is also > 170°C, so it will never actually end up executing this code.
It appears (from the way you wrote this), you'd want to use a bunch of non exclusive conditionals or switch around the order to make more sense.
; LED control if {state.status} == "paused" M150 R255 B255 P255 S20 ; purple M300 S4000 P50 G4 P300 M300 S4000 P50 ; double beep if {state.status} == "processing" || {state.status} == "busy" M150 R255 U255 B255 P255 S20 ; white if {heat.heaters[1].current} <= 70 M150 R255 U255 B0 P255 S20 F1 ; yellow if {heat.heaters[1].current} > 170 M150 R255 U80 B0 P255 S20 F1 ; orange if {heat.heaters[1].current} >= 230 M150 R255 U0 B0 P255 S20 F1 ; red if {state.status} == "idle" M150 R0 U255 B0 P255 S20 ; green
For the purple, you'll have to come up with some other condition depending on when exactly you actually want that to show up.
-
Thank you so much I will give it a shot.
-
I got it to work thank you so much for pointing me in the right direction. Here is the damon.g i came up with.
; LED control if {state.status} == "paused" M150 R255 B255 P255 S20 ; purple M300 S4000 P50 G4 P300 M300 S4000 P50 ; double beep if {state.status} == "processing" || {state.status} == "busy" M150 R255 U255 B255 P255 S20 ; white if {heat.heaters[1].current} <= 40 M150 R0 U0 B255 P0 S20 F1 ; blue if {heat.heaters[1].current} <= 70 M150 R255 U255 B0 P255 S20 F1 ; yellow if {heat.heaters[1].current} <= 170 M150 R255 U80 B0 P255 S20 F1 ; orange if {heat.heaters[1].current} >= 230 M150 R255 U0 B0 P255 S1 F1 ; red M150 R255 U255 B255 P255 S20 F1 ; white if {state.status} == "idle" M150 R0 U0 B0 P255 S20 ; green
-
My next question, is there a way to adapt this klipper macro to our set up?
Skip to content Product Solutions Open Source Pricing Search Sign in Sign up MapleLeafMakers / KlipperMacros Public Code Issues Pull requests Actions Projects Security Insights KlipperMacros/temperature_color.cfg @MapleLeafMakers MapleLeafMakers Rename example delayed macro Latest commit 93aff99 on Jul 4, 2022 History 1 contributor 165 lines (156 sloc) 4.82 KB ## Neopixel Temperature Indicator # Source: https://github.com/MapleLeafMakers/KlipperMacros/ # Usage: # To begin monitoring a temperature: # SET_TEMPERATURE_LED LED=<led_name> [INDEX=<index>] [SENSOR=heater_bed] [COOL_TEMP=22] [HOT_TEMP=100] [BRIGHTNESS=1.0] # # To stop monitoring a temperature, and resume normal LED control # CLEAR_TEMPERATURE_LED LED=<led_name> [INDEX=<index>] # # You can automate this by adding a delayed gcode macro to your printer.cfg, for example: # # [delayed_gcode set_temeperature_leds] # initial_duration: 1 # gcode: # SET_TEMPERATURE_LED LED=bed_light SENSOR=heater_bed # SET_TEMPERATURE_LED LED=sb_leds INDEX=1 SENSOR=extruder [gcode_macro SET_TEMPERATURE_LED] description: Set one or more neopixels to track a temperature gcode: {% set sensor = params.SENSOR|default('heater_bed') %} {% set cool_temp = params.COOL_TEMP|default(22.0)|float %} {% set hot_temp = params.HOT_TEMP|default(100)|float %} {% set brightness = params.BRIGHTNESS|default(1.0)|float %} {% set led = params.LED %} {% set index = params.INDEX %} SET_LED_TEMPLATE LED={led}{% if index is defined %} INDEX={index}{% endif %} TEMPLATE=temperature_color param_sensor="'{sensor}'" param_cool_temp={cool_temp} param_hot_temp={hot_temp} param_brightness={brightness} [gcode_macro CLEAR_TEMPERATURE_LED] description: Set one or more neopixels to stop tracking a temperature and return to normal operation gcode: {% set led = params.LED %} {% set index = params.INDEX %} SET_LED_TEMPLATE LED={led}{% if index is defined %} INDEX={index}{% endif %} TEMPLATE= [display_template temperature_color] param_cool_temp: 22 param_hot_temp: 100 param_sensor: 'heater_bed' param_brightness: 1.0 param_gradient: [ (0.04,0.04,1.00,0.00), (0.04,0.04,1.00,0.00), (0.04,0.04,1.00,0.00), (0.04,0.04,1.00,0.00), (0.04,0.04,1.00,0.00), (0.05,0.04,1.00,0.00), (0.05,0.05,1.00,0.00), (0.06,0.06,1.00,0.00), (0.07,0.07,1.00,0.00), (0.08,0.08,1.00,0.00), (0.09,0.10,1.00,0.00), (0.11,0.12,1.00,0.00), (0.13,0.13,1.00,0.00), (0.15,0.15,1.00,0.00), (0.16,0.17,0.99,0.00), (0.18,0.19,0.99,0.00), (0.20,0.21,0.99,0.00), (0.23,0.23,0.99,0.00), (0.25,0.25,0.98,0.00), (0.27,0.27,0.98,0.00), (0.29,0.31,0.98,0.00), (0.31,0.42,0.96,0.00), (0.31,0.50,0.94,0.00), (0.31,0.57,0.92,0.00), (0.31,0.63,0.89,0.00), (0.31,0.69,0.86,0.00), (0.31,0.74,0.84,0.00), (0.30,0.78,0.80,0.00), (0.29,0.82,0.76,0.00), (0.27,0.86,0.72,0.00), (0.25,0.89,0.66,0.00), (0.23,0.93,0.58,0.00), (0.20,0.96,0.50,0.00), (0.16,0.98,0.41,0.00), (0.13,0.99,0.33,0.00), (0.09,1.00,0.25,0.00), (0.07,1.00,0.14,0.00), (0.08,1.00,0.20,0.00), (0.07,1.00,0.24,0.00), (0.08,1.00,0.25,0.00), (0.11,1.00,0.23,0.00), (0.10,1.00,0.18,0.00), (0.09,1.00,0.14,0.00), (0.18,1.00,0.22,0.00), (0.27,0.99,0.25,0.00), (0.36,0.98,0.28,0.00), (0.45,0.97,0.29,0.00), (0.53,0.96,0.29,0.00), (0.62,0.94,0.27,0.00), (0.71,0.92,0.23,0.00), (0.79,0.90,0.16,0.00), (0.86,0.88,0.10,0.00), (0.91,0.86,0.20,0.00), (0.95,0.84,0.25,0.00), (0.98,0.82,0.27,0.00), (0.98,0.82,0.27,0.00), (0.98,0.82,0.24,0.00), (0.99,0.82,0.16,0.00), (1.00,0.82,0.15,0.00), (1.00,0.82,0.13,0.00), (1.00,0.82,0.10,0.00), (1.00,0.83,0.06,0.00), (1.00,0.83,0.03,0.00), (1.00,0.82,0.09,0.00), (1.00,0.81,0.12,0.00), (1.00,0.80,0.14,0.00), (1.00,0.80,0.16,0.00), (1.00,0.78,0.17,0.00), (1.00,0.77,0.18,0.00), (1.00,0.76,0.18,0.00), (1.00,0.75,0.19,0.00), (1.00,0.74,0.19,0.00), (1.00,0.72,0.20,0.00), (1.00,0.71,0.20,0.00), (1.00,0.69,0.20,0.00), (1.00,0.68,0.20,0.00), (1.00,0.66,0.20,0.00), (1.00,0.64,0.20,0.00), (1.00,0.62,0.19,0.00), (1.00,0.60,0.18,0.00), (1.00,0.57,0.16,0.00), (1.00,0.54,0.15,0.00), (1.00,0.51,0.14,0.00), (1.00,0.47,0.13,0.00), (1.00,0.43,0.11,0.00), (1.00,0.39,0.10,0.00), (1.00,0.37,0.08,0.00), (1.00,0.36,0.06,0.00), (1.00,0.33,0.05,0.00), (1.00,0.31,0.04,0.00), (1.00,0.29,0.02,0.00), (1.00,0.27,0.02,0.00), (1.00,0.26,0.01,0.00), (1.00,0.24,0.01,0.00), (1.00,0.22,0.00,0.00), (1.00,0.20,0.00,0.00), (1.00,0.18,0.00,0.00), (1.00,0.16,0.00,0.00), (1.00,0.15,0.00,0.00), (1.00,0.13,0.00,0.00), (1.00,0.11,0.00,0.00), (1.00,0.09,0.00,0.00), (1.00,0.07,0.00,0.00), (1.00,0.05,0.00,0.00), (1.00,0.04,0.00,0.00), (1.00,0.02,0.00,0.00), (1.00,0.01,0.00,0.00), (1.00,0.00,0.00,0.00)] text: {% set temp = printer[param_sensor].temperature %} {% set steps = param_gradient|length %} {% set idx = (((temp - param_cool_temp) / (param_hot_temp - param_cool_temp)) * steps) | int %} {% if idx < 0 %} {% set idx = 0 %} {% elif idx > steps-1 %} {% set idx = steps-1 %} {% endif %} { param_gradient[idx][0] * param_brightness },{ param_gradient[idx][1] * param_brightness },{ param_gradient[idx][2] * param_brightness },{ param_gradient[idx][3] * param_brightness } Footer © 2023 GitHub, Inc. Footer navigation Terms Privacy Security Status Docs Contact GitHub Pricing API Training Blog About KlipperMacros/temperature_color.cfg at main · MapleLeafMakers/KlipperMacros · GitHub