Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rainbow BARF LED Toolhead Support for StealthBurner #164

Closed
M3HNGRY opened this issue Apr 26, 2023 · 10 comments
Closed

Rainbow BARF LED Toolhead Support for StealthBurner #164

M3HNGRY opened this issue Apr 26, 2023 · 10 comments
Labels
done Issue is done but not merged on main enhancement New feature or request next version This thing is already done or is planned in the next version in preparation tracking This issue is tracked and work will be done

Comments

@M3HNGRY
Copy link

M3HNGRY commented Apr 26, 2023

Would like to request support for this if possible.

# Macros for setting the status leds on the Voron StealthBurner toolhead (or for any neopixel-type leds).
#
# You will need to configure a neopixel (or other addressable led, such as dotstar). See
# https://www.klipper3d.org/Config_Reference.html#neopixel for configuration details.


#####################################
#           INSTRUCTIONS            #
#####################################
# How to use all this stuff:
#
#     1.  Copy this .cfg file into your Klipper config directory and then add [include stealthburner_leds.cfg]
#         to the top of your printer.cfg in order for register the LEDs and macros with Klipper.
#     2.  Define your LEDs by editing [neopixel sb_leds] below and entering the data pin from your control board
#         as well as the color order.
#
#           Note: RGB and RGBW are different and must be defined explicitly.  RGB and RGBW are also not able to 
#                 be mix-and-matched in the same chain. A separate data line would be needed for proper functioning.
#
#                 RGBW LEDs will have a visible yellow-ish phosphor section to the chip.  If your LEDs do not have
#                 this yellow portion, you have RGB LEDs.
#
#     3.  Save your config and restart Klipper.
#
#           Note: We set RED and BLUE to 1.0 to make it easier for users and supporters to detect 
#                 misconfigurations or miswiring. The default color format is for Neopixels with a dedicated 
#                 white LED. On startup, all three SB LEDs should light up.
#
#                 If you get random colors across your LEDs, change the color_order to GRB and restart. Then
#                 omit the W for each suggested color_order in the next paragraph.
#
#                 If you get MAGENTA, your  color order is correct. If you get CYAN, you need to use RGBW. If
#                 you get YELLOW, you need to use BRGW (note that BRG is only supported in the latest Klipper
#                 version).
#
#     4.  Once you have confirmed that the LEDs are set up correctly, you must now decide where you want 
#         these macros called up...which means adding them to your existing gcode macros.  NOTHING will happen
#         unless you add the STATUS_????? macros to your existing gcode macros.  
#
#           Example: add STATUS_LEVELING to the beginning of your QGL gcode macro, and then add STATUS_READY 
#                    to the end of it to set the logo LED and nozzle LEDs back to the `ready` state.
#
#           Example: add STATUS_CLEANING to the beginning of your nozzle-cleaning macro, and then STATUS_READY
#                    to the end of it to return the LEDs back to `ready` state.
#
#     5.  Feel free to change colors of each macro, create new ones if you have a need to.  The macros provided below
#         are just an example of what is possible.  If you want to try some more complex animations, you will most
#         likely have to use WLED with Moonraker and a small micro-controller (please see the LED thread for help inside
#         of the stealthburner_beta channel on Discord).
#
#####################################
#       END INSTRUCTRUCTIONS        #
#####################################


[neopixel sb_leds]
pin: PB0
#   The pin connected to the neopixel. This parameter must be provided.
chain_count: 10
#   The number of Neopixel chips that are "daisy chained" to the
#   provided pin. The default is 1 (which indicates only a single
#   Neopixel is connected to the pin).
color_order: GRB, GRB, GRB, GRB, GRB, GRB, GRB, GRB, GRBW,  GRBW
#   Set the pixel order required by the LED hardware. Options are GRB,
#   RGB, GRBW, or RGBW. The default is GRB.
initial_RED: 1.0
initial_GREEN: 0.0
initial_BLUE: 1.0
initial_WHITE: 0.0
#   Sets the initial LED color of the Neopixel. Each value should be
#   between 0.0 and 1.0. The WHITE option is only available on RGBW
#   LEDs. The default for each color is 0.#


##########################
# LED Effects Animations #
##########################

##################
## logo effects ##
##################

[led_effect sb_logo_busy]
autostart:              false
frame_rate:             24
leds:
    neopixel:sb_leds (1-8)
layers:
    breathing  3 1 top (1,0,0)

[led_effect sb_logo_cleaning]
autostart:              false
frame_rate:             24
leds:
    neopixel:sb_leds (1-8)
layers:
    breathing  3 1 top (0.0, 0.02, 0.5)

[led_effect sb_logo_calibrating_z]
autostart:              false
frame_rate:             24
leds:
    neopixel:sb_leds (1-8)
layers:
        breathing  3 1 top (0.0, 0.0, 0.35)

[led_effect sb_logo_heating]
leds:
    neopixel:sb_leds (1,3,7,8,6,2)
autostart:                          false
frame_rate:                         24
layers:
    comet  0.3  0 add (1, 0.18, 0)

[led_effect sb_logo_cooling]
leds:
    neopixel:sb_leds (1,3,7,8,6,2)
autostart:                          false
frame_rate:                         24
layers:
    comet  0.3  0 add (0, 0, 1)

[led_effect sb_logo_homing]
autostart:              false
frame_rate:             24
leds:
    neopixel:sb_leds (1-8)
layers:
        breathing  3 1 top (0.0, 0.6, 0.2)

[led_effect sb_logo_leveling]
autostart:              false
frame_rate:             24
leds:
    neopixel:sb_leds (1-8)
layers:
        breathing  3 1 top (0.5, 0.1, 0.4)

[led_effect sb_logo_meshing]
autostart:              false
frame_rate:             24
leds:
    neopixel:sb_leds (1-8)
layers:
        breathing  3 1 top (0.2, 1.0, 0.0)

[led_effect sb_logo_printing]
autostart:              false
frame_rate:             24
leds:
    neopixel:sb_leds (1-8)
layers:
    gradient  0.3  1 add (0.3, 0.0, 0.0),(0.3, 0.3, 0.0),(0.3, 0.1, 0.0)

[led_effect sb_logo_standby]
autostart:              false
frame_rate:             24
leds:
    neopixel:sb_leds (1-8)
layers:
        breathing  3 1 top (0.01, 0.01, 0.01)

[led_effect sb_logo_part_ready]
autostart:              false
frame_rate:             24
leds:
    neopixel:sb_leds (1-8)
layers:
        breathing  3 1 top (0.0, 1.0, 0.0)

####################
## nozzle effects ##
####################

[led_effect sb_nozzle_heating]
autostart:              false
frame_rate:             24
leds:
    neopixel:sb_leds (9,10)
layers:
        breathing  3 1 top (1.0, 0.18, 0.0, 0.0)

[led_effect sb_nozzle_cooling]
autostart:              false
frame_rate:             24
leds:
    neopixel:sb_leds (9,10)
layers:
        breathing  3 1 top (0.0, 0.0, 1.0, 0.1)

[led_effect sb_nozzle_standby]
autostart:              false
frame_rate:             24
leds:
    neopixel:sb_leds (9,10)
layers:
        breathing  3 1 top (0.6, 0.0, 0.0, 0.0)

[led_effect sb_nozzle_part_ready]
autostart:              false
frame_rate:             24
leds:
    neopixel:sb_leds (9,10)
layers:
        breathing  3 1 top (0.6, 1.0, 0.0, 0.1)


#####################
## all led effects ##
#####################

[led_effect sb_critical_error]
leds:
    neopixel:sb_leds
layers:
    strobe         1  1.5   add        (1.0,  1.0, 1.0)
    breathing      2  0     difference (0.95, 0.0, 0.0)
    static         1  0     top        (1.0,  0.0, 0.0)
autostart:                             false
frame_rate:                            24
run_on_error:                          true


[led_effect rainbow]
leds:
    neopixel:sb_leds
autostart:                          true
frame_rate:                         24
layers:
    gradient  0.3  1 add (0.3, 0.0, 0.0),(0.0, 0.3, 0.0),(0.0, 0.0, 0.3)


#######################
# LED Effects Statics #
#######################

[led_effect set_nozzle_leds]
leds:
    neopixel:sb_leds (9,10)
   #neopixel:caselight
autostart:                          false
frame_rate:                         24
layers:
    static         0  0     top        (0.0,  0.0, 0.0, 1.0)

[led_effect set_logo_leds]
leds:
    neopixel:sb_leds (1,2,3,4,5,6,7,8)
   #neopixel:caselight
autostart:                          false
frame_rate:                         24
layers:
    static         0  0     top        (1.0,  1.0, 1.0)

##############
# The Macros #
##############

[gcode_macro set_logo_leds_off]
gcode:
    SET_LED_EFFECT EFFECT=set_logo_leds STOP=1

[gcode_macro set_logo_leds_on]
gcode:
    SET_LED_EFFECT EFFECT=set_logo_leds

[gcode_macro set_nozzle_leds_on]
gcode:
    SET_LED_EFFECT EFFECT=set_nozzle_leds

[gcode_macro set_nozzle_leds_off]
gcode:
    SET_LED_EFFECT EFFECT=set_nozzle_leds STOP=1

[gcode_macro status_off]
gcode:
    STOP_LED_EFFECTS

[gcode_macro status_ready]
gcode:
    STOP_LED_EFFECTS
    SET_LED_EFFECT EFFECT=rainbow

[gcode_macro status_part_ready]
gcode:
    STOP_LED_EFFECTS
    SET_LED_EFFECT EFFECT=sb_nozzle_part_ready
    SET_LED_EFFECT EFFECT=sb_logo_part_ready

[gcode_macro status_busy]
gcode:
    STOP_LED_EFFECTS
    SET_LED_EFFECT EFFECT=sb_logo_busy
    set_nozzle_leds_on

[gcode_macro status_heating]
gcode:
    STOP_LED_EFFECTS
    SET_LED_EFFECT EFFECT=sb_logo_heating
    SET_LED_EFFECT EFFECT=sb_nozzle_heating

[gcode_macro status_cooling]
gcode:
    STOP_LED_EFFECTS
    SET_LED_EFFECT EFFECT=sb_logo_cooling
    SET_LED_EFFECT EFFECT=sb_nozzle_cooling


[gcode_macro status_leveling]
gcode:
    STOP_LED_EFFECTS
    SET_LED_EFFECT EFFECT=sb_logo_leveling
    set_nozzle_leds_on

[gcode_macro status_homing]
gcode:
    STOP_LED_EFFECTS
    SET_LED_EFFECT EFFECT=sb_logo_homing
    set_nozzle_leds_on

[gcode_macro status_cleaning]
gcode:
    STOP_LED_EFFECTS
    SET_LED_EFFECT EFFECT=sb_logo_cleaning
    set_nozzle_leds_on

[gcode_macro status_meshing]
gcode:
    STOP_LED_EFFECTS
    SET_LED_EFFECT EFFECT=sb_logo_meshing
    set_nozzle_leds_on

[gcode_macro status_calibrating_z]
gcode:
    STOP_LED_EFFECTS
    SET_LED_EFFECT EFFECT=sb_logo_calibrating_z
    set_nozzle_leds_on

[gcode_macro status_printing]
gcode:
    STOP_LED_EFFECTS
    SET_LED_EFFECT EFFECT=sb_logo_printing
    set_nozzle_leds_on
Footer
© 2023 GitHub, Inc.
Footer navigation
[Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
[Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
[Security](https://github.com/security)
[Status](https://www.githubstatus.com/)
[Docs](https://docs.github.com/)

V/R
Anthony

@Surion79
Copy link
Collaborator

Surion79 commented Apr 26, 2023

this is based on a different repo for led_effect. it is more an integration request for led effect instead or just a barf led?

@M3HNGRY
Copy link
Author

M3HNGRY commented Apr 26, 2023

Both it has the setting for the CENTER LOGO LED and coding for the effects. I was looking at the status_led and its similar.

@Surion79
Copy link
Collaborator

it seems that it possible to place it in the overrides.cfg for the time being, until it is clear when and how it is integrated.

@Frix-x Frix-x added enhancement New feature or request help wanted Extra attention is needed labels Apr 29, 2023
@LongDono
Copy link
Contributor

LongDono commented Aug 31, 2023

You can find this core code (an evolution of the current status_leds.cfg) in at least two variants (different default configurations):

General Stealthburner Configuration
https://github.com/VoronDesign/Voron-Stealthburner/blob/main/Firmware/stealthburner_leds.cfg

Rainbow Barf RGB Grid Configuration
https://github.com/tanaes/whopping_Voron_mods/blob/main/LEDs/Rainbow_Barf_Logo_LED/Code/stealthburner_led_effects_barf.cfg

@W141-ID
Copy link
Contributor

W141-ID commented Sep 6, 2023

Any updates here?

I have tinkered myself and found a solution. We can create if statements regarding the color state which will apply the effects. We only need to implement another user variable as a precondition to check if LED_EFFECTS is enabled by the user.

I've just done some manual testing and it will need some polishing, but seems to work

Here an example:

{% if color == 'homing' %}
	STOP_LED_EFFECTS
	 SET_LED_EFFECT EFFECT=sb_logo_homing
	 set_nozzle_leds_on
{% endif %}

@mrstone14
Copy link

@W141-ID could you elaborate where you are placing that example code to apply the led_effect?

@W141-ID
Copy link
Contributor

W141-ID commented Nov 3, 2023

@W141-ID could you elaborate where you are placing that example code to apply the led_effect?

I have added my costum status_leds config below. I uploaded it to the the config directory of my printes klippain folder (same folder as where the printer.cfg is stored) and included the file via the printer.cfg

If there is intrest behind this implementation I could work on a viable solution.

# This file is automatically included when status_leds hardware config file is included

# src : https://github.com/VoronDesign/Voron-Stealthburner/blob/main/Firmware/stealthburner_leds.cfg
# Contributed by Voron discord users wile.e, Tetsunosuke, and etherwalker
# Heavily modified by Frix-x to be more adapted for the generic config goal


# The following status macro is available:
#    STATUS_LEDS COLOR="xxxxx"

# With additional macros for basic control:
#    SET_NOZZLE_LEDS_ON
#    SET_LOGO_LEDS_OFF
#    SET_NOZZLE_LEDS_OFF

#-------------------------#
#    Rainbow neopixel     #
#-------------------------#

[gcode_macro _USER_VARIABLES]
variable_status_leds_logo_idx: '1,2,3,4,5,6,7,8'
variable_status_leds_nozzle_idx: '9,10'

[neopixel status_leds]
pin: toolhead:STATUS_NEOPIXEL
#   The pin connected to the neopixel. This parameter must be provided.
chain_count: 10
#   The number of Neopixel chips that are "daisy chained" to the
#   provided pin. The default is 1 (which indicates only a single
#   Neopixel is connected to the pin).
color_order: GRB, GRB, GRB, GRB, GRB, GRB, GRB, GRB, GRBW,  GRBW
#   Set the pixel order required by the LED hardware. Options are GRB,
#   RGB, GRBW, or RGBW. The default is GRB.
initial_RED: 1.0
initial_GREEN: 0.0
initial_BLUE: 1.0
initial_WHITE: 0.0
#   Sets the initial LED color of the Neopixel. Each value should be
#   between 0.0 and 1.0. The WHITE option is only available on RGBW
#   LEDs. The default for each color is 0.#


##########################
# LED Effects Animations #
##########################

##################
## logo effects ##
##################

[led_effect sb_logo_busy]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
    breathing  3 1 top (1,0,0)

[led_effect sb_logo_cleaning]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
    breathing  3 1 top (0.0, 0.02, 0.5)

[led_effect sb_logo_calibrating_z]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
        breathing  3 1 top (0.0, 0.0, 0.35)

[led_effect sb_logo_heating]
leds:
    neopixel:status_leds (1,3,7,8,6,2)
autostart:                          false
frame_rate:                         24
layers:
    comet  0.3  0 add (1, 0.18, 0)

[led_effect sb_logo_cooling]
leds:
    neopixel:status_leds (1,3,7,8,6,2)
autostart:                          false
frame_rate:                         24
layers:
    comet  0.3  0 add (0, 0, 1)

[led_effect sb_logo_homing]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
        breathing  3 1 top (0.0, 0.6, 0.2)

[led_effect sb_logo_leveling]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
        breathing  3 1 top (0.5, 0.1, 0.4)

[led_effect sb_logo_meshing]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
        breathing  3 1 top (0.2, 1.0, 0.0)

[led_effect sb_logo_printing]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
    gradient  0.3  1 add (0.3, 0.0, 0.0),(0.3, 0.3, 0.0),(0.3, 0.1, 0.0)

[led_effect sb_logo_standby]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
        breathing  3 1 top (0.01, 0.01, 0.01)

[led_effect sb_logo_part_ready]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
        breathing  3 1 top (0.0, 1.0, 0.0)

####################
## nozzle effects ##
####################

[led_effect sb_nozzle_heating]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (9,10)
layers:
        breathing  3 1 top (1.0, 0.18, 0.0, 0.0)

[led_effect sb_nozzle_cooling]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (9,10)
layers:
        breathing  3 1 top (0.0, 0.0, 1.0, 0.1)

[led_effect sb_nozzle_standby]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (9,10)
layers:
        breathing  3 1 top (0.6, 0.0, 0.0, 0.0)

[led_effect sb_nozzle_part_ready]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (9,10)
layers:
        breathing  3 1 top (0.6, 1.0, 0.0, 0.1)


#####################
## all led effects ##
#####################

[led_effect sb_critical_error]
leds:
    neopixel:status_leds
layers:
    strobe         1  1.5   add        (1.0,  1.0, 1.0)
    breathing      2  0     difference (0.95, 0.0, 0.0)
    static         1  0     top        (1.0,  0.0, 0.0)
autostart:                             false
frame_rate:                            24
run_on_error:                          true


[led_effect rainbow]
leds:
    neopixel:status_leds
autostart:                          true
frame_rate:                         24
layers:
    gradient  0.3  1 add (0.3, 0.0, 0.0),(0.0, 0.3, 0.0),(0.0, 0.0, 0.3)


#######################
# LED Effects Statics #
#######################

[led_effect set_nozzle_leds]
leds:
    neopixel:status_leds (9,10)
   #neopixel:caselight
autostart:                          false
frame_rate:                         24
layers:
    static         0  0     top        (0.0,  0.0, 0.0, 1.0)

[led_effect set_logo_leds]
leds:
    neopixel:status_leds (1,2,3,4,5,6,7,8)
   #neopixel:caselight
autostart:                          false
frame_rate:                         24
layers:
    static         0  0     top        (1.0,  1.0, 1.0)

[gcode_macro _SET_LEDS]
gcode:
    {% set red = params.RED|default(0)|float %}
    {% set green = params.GREEN|default(0)|float %}
    {% set blue = params.BLUE|default(0)|float %}
    {% set white = params.WHITE|default(0)|float %}
    {% set led = params.LED|string %}
    {% set idx = (params.IDX|string).split(',') %}
    {% set transmit_last = params.TRANSMIT|default(1) %}

    {% for led_index in idx %}
        {% set transmit=transmit_last if loop.last else 0 %}
        SET_LED LED={led} RED={red} GREEN={green} BLUE={blue} WHITE={white} INDEX={led_index} TRANSMIT={transmit}
    {% endfor %} 

[gcode_macro _SET_LEDS_BY_NAME]
# set color by led index
gcode:
    {% set leds_name = params.LEDS %}
    {% set color_name = params.COLOR %}
    {% set color = printer["gcode_macro _USER_VARIABLES"].status_leds_colors[leds_name][color_name] %}
    {% set led = printer["gcode_macro _USER_VARIABLES"]["status_leds_" + leds_name + "_led_name"] %}
    {% set idx = printer["gcode_macro _USER_VARIABLES"]["status_leds_" + leds_name + "_idx"] %}
    {% set transmit = params.TRANSMIT|default(1) %}

    _SET_LEDS LED={led} RED={color.r} GREEN={color.g} BLUE={color.b} WHITE={color.w} IDX="{idx}" TRANSMIT={transmit}

[gcode_macro _SET_ALLLEDS_BY_NAME]
# set same color for all leds
gcode:
    {% set leds_name = params.LEDS %}
    {% set color_name = params.COLOR %}
    {% set led = printer["gcode_macro _USER_VARIABLES"]["status_leds_" + leds_name + "_led_name"] %}
    {% set color = printer["gcode_macro _USER_VARIABLES"].status_leds_colors[leds_name][color_name] %}
    {% set transmit = params.TRANSMIT|default(1) %}

    SET_LED LED={led} RED={color.r} GREEN={color.g} BLUE={color.b} WHITE={color.w}  TRANSMIT={transmit}

[gcode_macro _SET_LOGO_LEDS]
gcode:
    {% set red = params.RED|default(0)|float %}
    {% set green = params.GREEN|default(0)|float %}
    {% set blue = params.BLUE|default(0)|float %}
    {% set white = params.WHITE|default(0)|float %}
    {% set led = printer["gcode_macro _USER_VARIABLES"].status_leds_logo_led_name %}
    {% set idx = printer["gcode_macro _USER_VARIABLES"].status_leds_logo_idx %}
    {% set transmit = params.TRANSMIT|default(1) %}

    _SET_LEDS LED={led} RED={red} green={green} BLUE={blue} WHITE={white} IDX="{idx}" TRANSMIT={transmit}

[gcode_macro _SET_NOZZLE_LEDS]
gcode:
    {% set red = params.RED|default(0)|float %}
    {% set green = params.GREEN|default(0)|float %}
    {% set blue = params.BLUE|default(0)|float %}
    {% set white = params.WHITE|default(0)|float %}
    {% set led = printer["gcode_macro _USER_VARIABLES"].status_leds_nozzle_led_name %}
    {% set idx = printer["gcode_macro _USER_VARIABLES"].status_leds_nozzle_idx %}
    {% set transmit = params.TRANSMIT|default(1) %}

    _SET_LEDS LED={led} RED={red} green={green} BLUE={blue} WHITE={white} IDX="{idx}" TRANSMIT={transmit}
    SET_LED_EFFECT EFFECT=set_logo_leds

[gcode_macro SET_LOGO_LEDS_OFF]
gcode:
    {% set transmit = params.TRANSMIT|default(1) %}

    _SET_LEDS_BY_NAME LEDS="logo" COLOR="off" TRANSMIT={transmit}
    SET_LED_EFFECT EFFECT=set_logo_leds STOP=1

[gcode_macro SET_NOZZLE_LEDS_ON]
gcode:
    {% set transmit = params.TRANSMIT|default(1) %}

    _SET_LEDS_BY_NAME LEDS="nozzle" COLOR="on" TRANSMIT={transmit}
    SET_LED_EFFECT EFFECT=set_nozzle_leds

[gcode_macro SET_NOZZLE_LEDS_OFF]
gcode:
    {% set transmit = params.TRANSMIT|default(1) %}

    _SET_LEDS_BY_NAME LEDS="nozzle" COLOR="off" TRANSMIT={transmit}
    SET_LED_EFFECT EFFECT=set_nozzle_leds STOP=1

[gcode_macro STATUS_LEDS]
gcode:
    {% set color = params.COLOR|default('off')|lower %}

    {% set status_color = {
        'ready': {
            'logo': 'standby',
            'nozzle': 'standby',
            'caselight': 'standby',
            'minidisplay': 'on'
        },
        'busy': {
            'logo': 'busy',
            'nozzle': 'on',
            'caselight': 'busy',
            'minidisplay': 'on'
        },
        'heating': {
            'logo': 'heating',
            'nozzle': 'heating',
            'caselight': 'heating',
            'minidisplay': 'on'
        },
        'leveling': {
            'logo': 'leveling',
            'nozzle': 'on',
            'caselight': 'leveling',
            'minidisplay': 'on'
        },
        'homing': {
            'logo': 'homing',
            'nozzle': 'on',
            'caselight': 'homing',
            'minidisplay': 'on'
        },
        'cleaning': {
            'logo': 'cleaning',
            'nozzle': 'on',
            'caselight': 'cleaning',
            'minidisplay': 'on'
        },
        'meshing': {
            'logo': 'meshing',
            'nozzle': 'on',
            'caselight': 'meshing',
            'minidisplay': 'on'
        },
        'calibrating_z': {
            'logo': 'calibrating_z',
            'nozzle': 'on',
            'caselight': 'calibrating_z',
            'minidisplay': 'on'
        },
        'printing': {
            'logo': 'printing',
            'nozzle': 'on',
            'caselight': 'printing',
            'minidisplay': 'on'
        },
        'off': {
            'logo': 'off',
            'nozzle': 'off',
            'caselight': 'off',
            'minidisplay': 'off'
        },
        'on': {
            'logo': 'on',
            'nozzle': 'on',
            'caselight': 'on',
            'minidisplay': 'on'
        },        
        'error': {
            'logo': 'error',
            'nozzle': 'error',
            'caselight': 'error',
            'minidisplay': 'error'
        }   
    } %}
    {% if color == 'ready' %}
        STOP_LED_EFFECTS
        SET_LED_EFFECT EFFECT=rainbow
    {% endif %}

    {% if color == 'busy' %}
        STOP_LED_EFFECTS
        SET_LED_EFFECT EFFECT=sb_logo_busy
        set_nozzle_leds_on
    {% endif %}

    {% if color == 'heating' %}
        STOP_LED_EFFECTS
        SET_LED_EFFECT EFFECT=sb_logo_heating
        SET_LED_EFFECT EFFECT=sb_nozzle_heating
    {% endif %}

    {% if color == 'leveling' %}
        STOP_LED_EFFECTS
        SET_LED_EFFECT EFFECT=sb_logo_leveling
        set_nozzle_leds_on
    {% endif %}

    {% if color == 'homing' %}
        STOP_LED_EFFECTS
        SET_LED_EFFECT EFFECT=sb_logo_homing
        set_nozzle_leds_on
    {% endif %}

    {% if color == 'cleaning' %}
        STOP_LED_EFFECTS
        SET_LED_EFFECT EFFECT=sb_logo_cleaning
        set_nozzle_leds_on
    {% endif %}

    {% if color == 'meshing' %}
        STOP_LED_EFFECTS
        SET_LED_EFFECT EFFECT=sb_logo_meshing
        set_nozzle_leds_on
    {% endif %}

    {% if color == 'calibrating_z' %}
        STOP_LED_EFFECTS
        SET_LED_EFFECT EFFECT=sb_logo_calibrating_z
        set_nozzle_leds_on
    {% endif %}

    {% if color == 'printing' %}
        STOP_LED_EFFECTS
        SET_LED_EFFECT EFFECT=sb_logo_printing
        set_nozzle_leds_on
    {% endif %}

    {% if color == 'off' %}
        STOP_LED_EFFECTS
    {% endif %}

    {% if color == 'on' %}
        set_nozzle_leds_on
    {% endif %}

    {% if color == 'error' %}
        STOP_LED_EFFECTS
        SET_LED_EFFECT EFFECT=sb_critical_error
        set_nozzle_leds_on
    {% endif %}

    {% if not (color in status_color) %}
        { action_raise_error("COLOR is not valid!") }
    {% endif %}

    {% if printer["gcode_macro _USER_VARIABLES"].status_leds_enabled %}
        _SET_LEDS_BY_NAME LEDS="logo" COLOR={status_color[color].logo} TRANSMIT=0
        _SET_LEDS_BY_NAME LEDS="nozzle" COLOR={status_color[color].nozzle} TRANSMIT=1
    {% endif %}

    {% if printer["gcode_macro _USER_VARIABLES"].status_leds_caselight_enabled %}
        _SET_ALLLEDS_BY_NAME LEDS="caselight" COLOR={status_color[color].caselight} TRANSMIT=1
    {% endif %}

    {% if printer["gcode_macro _USER_VARIABLES"].status_leds_minidisplay_enabled %}
        _SET_ALLLEDS_BY_NAME LEDS="minidisplay" COLOR={status_color[color].minidisplay} TRANSMIT=1
    {% endif %}

@Frix-x
Copy link
Owner

Frix-x commented Nov 14, 2023

This issue is highly linked to #142 (just for reference and to track it for a next version)

@Surion79 Surion79 added the stale Issue that appear to be inactive, mark for potenial closing if stale for longer time label Dec 7, 2023
@Surion79 Surion79 added tracking This issue is tracked and work will be done next version This thing is already done or is planned in the next version in preparation and removed help wanted Extra attention is needed stale Issue that appear to be inactive, mark for potenial closing if stale for longer time labels Dec 23, 2023
@thegutuproject
Copy link

thegutuproject commented Feb 19, 2024

id like to propose a variation to the above - I have not created a PR yet but I plan to in the coming days. Currently, testing some odd issues with incorrect LED effects being applied on boot, and LED effects pausing during certain actions (like homing). It seems like any movement of the steppers pause the LED effect.

Please note, this relies on led-effect being installed from https://github.com/julianschill/klipper-led_effect

printer_data/config/config/lights/neopixel_caselight_barf.cfg

[gcode_macro _USER_VARIABLES]
variable_status_leds_caselight_enabled = True
variable_status_leds_caselight_barf_enabled = True
variable_status_leds_caselight_barf_right_led_name: "caselight_right"
variable_status_leds_caselight_barf_left_led_name: "caselight_left"
gcode:

[neopixel caselight_right]
pin: LIGHT_RGB_RIGHT
#   The pin connected to the neopixel. This parameter must be provided.
chain_count: 18
#   The number of Neopixel chips that are "daisy chained" to the
#   provided pin. The default is 1 (which indicates only a single
#   Neopixel is connected to the pin).
color_order: GRB
#   Set the pixel order required by the LED hardware. Options are GRB,
#   RGB, GRBW, or RGBW. The default is GRB.
initial_RED: 0.0
initial_GREEN: 0.0
initial_BLUE: 0.0
initial_WHITE: 0.0
#   Sets the initial LED color of the Neopixel. Each value should be
#   between 0.0 and 1.0. The WHITE option is only available on RGBW
#   LEDs. The default for each color is 0.#

[neopixel caselight_left]
pin: LIGHT_RGB_LEFT
#   The pin connected to the neopixel. This parameter must be provided.
chain_count: 18
#   The number of Neopixel chips that are "daisy chained" to the
#   provided pin. The default is 1 (which indicates only a single
#   Neopixel is connected to the pin).
color_order: GRB
#   Set the pixel order required by the LED hardware. Options are GRB,
#   RGB, GRBW, or RGBW. The default is GRB.
initial_RED: 0.0
initial_GREEN: 0.0
initial_BLUE: 0.0
initial_WHITE: 0.0
#   Sets the initial LED color of the Neopixel. Each value should be
#   between 0.0 and 1.0. The WHITE option is only available on RGBW
#   LEDs. The default for each color is 0.#

### Sleep ###
[delayed_gcode led_sleep]
gcode:
    STOP_LED_EFFECTS ; turn off all LEDs
    UPDATE_DELAYED_GCODE ID=led_sleep DURATION=0

##########################
# LED Effects Animations #
##########################

#######################
## caselight effects ##
#######################

[led_effect caselight_busy]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart:              false
frame_rate:             24
layers:
    breathing 3 1 top (1,0,0)

### Off ###
[led_effect caselight_off]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart:               false
frame_rate:              24
layers:
  static 0 0 top (0,0,0)
       
[led_effect caselight_cleaning]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart: false
frame_rate: 24
layers:
    twinkle 4 0.05 add (0.0,0.02,0.5)
    twinkle 2 0.1 add (0.0,0.06,0.2)

[led_effect caselight_calibrating_z]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart: false
frame_rate: 24
layers:
    comet 0.3 6 add (0.8,0.0,0.35),(0.4,0.0,0.7)
    comet -0.3 6 add (0.8,0.0,0.35),(0.4,0.0,0.7)

[led_effect caselight_heating]
leds:
    neopixel:caselight_left
    neopixel:caselight_right
autostart: false
frame_rate: 24
heater: heater_bed
layers:
    breathing 3 1 top (1.0, 0.18, 0.0, 0.0)

[led_effect caselight_heating_ironbow]
leds:
    neopixel:caselight_left
    neopixel:caselight_right
autostart: false
frame_rate: 24
heater: heater_bed
layers:
    # FLIR Ironbow gradient
    static 0 0 subtract (0.5,0.5,0.5)
    heaterfire 20 1 top (0.97,0.99,0.59),(0.92,0.27,0.31),(0.98,0.71,0.00),(0.69,0.04,0.58),(0.08,0.02,0.35)
    heater 0 0 add  (0,0,0.5),(0.84,0.84,0)

[led_effect caselight_heating_rainbow]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart: false
frame_rate: 24
heater: heater_bed
layers:
    # FLIR Rainbow gradient
    static 0 0 subtract (0.5,0.5,0.5)
    heaterfire 20 1 top (1.00,0.79,0.71),(0.98,0.10,0.26),(0.74,0.83,0.04),(0.00,0.55,0.72),(0.01,0.13,0.45) 
    heater 0 0 add  (0,0,0.5),(0.84,0.84,0)

[led_effect caselight_heating_ironbow_right]
leds:
    neopixel:caselight_right
autostart: false
frame_rate: 24
heater: heater_bed
layers:
    # FLIR Ironbow gradient
    static 0 0 subtract (0.5,0.5,0.5)
    heaterfire 20 1 top (0.97,0.99,0.59),(0.92,0.27,0.31),(0.98,0.71,0.00),(0.69,0.04,0.58),(0.08,0.02,0.35)
    heater 0 0 add  (0,0,0.5),(0.84,0.84,0)

[led_effect caselight_heating_ironbow_left]
leds:
    neopixel:caselight_left
autostart: false
frame_rate: 24
heater: heater_bed
layers:
    # FLIR Ironbow gradient
    static 0 0 subtract (0.5,0.5,0.5)
    heaterfire 20 1 top (0.97,0.99,0.59),(0.92,0.27,0.31),(0.98,0.71,0.00),(0.69,0.04,0.58),(0.08,0.02,0.35)
    heater 0 0 add  (0,0,0.5),(0.84,0.84,0)

[led_effect caselight_heating_rainbow_right]
leds:
    neopixel:caselight_right
autostart: false
frame_rate: 24
heater: heater_bed
layers:
    # FLIR Rainbow gradient
    static 0 0 subtract (0.5,0.5,0.5)
    heaterfire 20 1 top (1.00,0.79,0.71),(0.98,0.10,0.26),(0.74,0.83,0.04),(0.00,0.55,0.72),(0.01,0.13,0.45) 
    heater 0 0 add  (0,0,0.5),(0.84,0.84,0)

[led_effect caselight_heating_rainbow_left]
leds:
    neopixel:caselight_left
autostart: false
frame_rate: 24
heater: heater_bed
layers:
    # FLIR Rainbow gradient
    static 0 0 subtract (0.5,0.5,0.5)
    heaterfire 20 1 top (1.00,0.79,0.71),(0.98,0.10,0.26),(0.74,0.83,0.04),(0.00,0.55,0.72),(0.01,0.13,0.45) 
    heater 0 0 add  (0,0,0.5),(0.84,0.84,0)

### Cooling ###
[led_effect caselight_cooling]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart: false
frame_rate: 24
layers:
    comet  0.3  0 add (0, 0, 1) 

### Homing ###
[led_effect caselight_homing]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart: false
frame_rate: 24
layers:
    chase 0.5 5 add (0.08,1.0,0.38),(0,0.35,0.11) 
    breathing 8 0 add (0,0.6,0.2),(0,0.46,0.15) 
    
### Quad Gantry Leveling ###
[led_effect caselight_leveling]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart: false
frame_rate: 24
layers:
    comet 0.75 3 add (0,0.5,0.75),(0,1.0,1.0) 
    comet -0.75 3 add (0,0.5,0.75),(0,1.0,1.0)

### Meshing ###
[led_effect caselight_meshing]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart: false
frame_rate: 24 
layers:
    chase 0.25 0.50 add (0.2,1.0,0.0),(0.75,0.79,0.00) 
    chase -0.2 0.50 add (0.2,1.0,0.0),(0.75,0.79,0.00) 
    
### Printing ###
[led_effect caselight_printing]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart: false
frame_rate: 24
layers:
    static 0 1 top (0.5,0.5,0.5)

[led_effect caselight_printing_progress]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart: false
frame_rate: 24
layers:
    progress 3 0 subtract (0.5,0,1.0),(0.30,0,0.58)
    static 0 1 top (0.5,0.5,0.5)


[led_effect caselight_printing_progress_left]
leds:
    neopixel:caselight_left
autostart: false
frame_rate: 24
layers:
    progress 3 0 subtract (0.5,0,1.0),(0.30,0,0.58)
    static 0 1 top (0.5,0.5,0.5)

[led_effect caselight_printing_progress_right]
leds:
    neopixel:caselight_right
autostart: false
frame_rate: 24
layers:
    progress 3 0 subtract (0.5,0,1.0),(0.30,0,0.58)
    static 0 1 top (0.5,0.5,0.5)
    
### Standby ###
[led_effect caselight_standby]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart:          true
frame_rate:         24
layers:
    breathing 12 1 add (0,0,1.0)
    static 0 0 add (0,0,0.05)

### Input Shaper ###
[led_effect caselight_input_shaper]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart: false
frame_rate: 1
layers:
    static 0 0 top (0.25,0.0,0.5)

### Loading ###
[led_effect caselight_loading]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart: false
frame_rate: 24
layers:
    chase 0.3 0.6 add (0.00,0.50,0.00),(0.18,1.00,1.00)

### Unloading ###
[led_effect caselight_unloading]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart: false
frame_rate: 24
layers:
    chase -0.3 0.5 add (1.0,0,0),(1.1,0.5,0) 

### Runout ###
[led_effect caselight_filament_runout]
leds: 
    neopixel:caselight_right
    neopixel:caselight_left
autostart: false
frame_rate: 24
layers:
    breathing 6 1 top (1.0,0.0,0.0,0.0)
    static 0 0 top (1.0,0,0,0)

#######################
##  all led effects  ##
#######################

[led_effect caselight_critical_error]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
layers:
    strobe         1  1.5   add        (1.0,  1.0, 1.0)
    breathing      2  0     difference (0.95, 0.0, 0.0)
    static         1  0     top        (1.0,  0.0, 0.0)
autostart:                             false
frame_rate:                            24
run_on_error:                          true

[led_effect caselight_rainbow]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
layers:
    gradient  0.3  1 add (0.3, 0.0, 0.0),(0.0, 0.3, 0.0),(0.0, 0.0, 0.3)
autostart:                              true
frame_rate:                             24

[led_effect caselight_party_time]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart:                              false
frame_rate:                             24
layers:
    twinkle 30 0.2 add (0,0,1.0),(0,1.0,0),(1.0,0,0) 
    gradient 1 2 add (1.0,0,0),(0,1.0,0),(0,0,1.0) 

#######################
# LED Effects Statics #
#######################

[led_effect set_logo_leds]
leds:
    neopixel:caselight_right
    neopixel:caselight_left
autostart:                          false
frame_rate:                         24
layers:
    static         0  0     top        (1.0,  1.0, 1.0)

##############
# The Macros #
##############

[gcode_macro caselight_status_off]
gcode:
    SET_LED_EFFECT EFFECT=caselight_off REPLACE=1

[gcode_macro caselight_status_part_ready]
gcode:
    SET_LED_EFFECT EFFECT=caselight_party_time REPLACE=1

[gcode_macro caselight_status_busy]
gcode:
    SET_LED_EFFECT EFFECT=caselight_busy REPLACE=1

[gcode_macro caselight_status_heating]
gcode:
    SET_LED_EFFECT EFFECT=caselight_heating REPLACE=1

[gcode_macro caselight_status_heating_ironbow]
gcode:
    SET_LED_EFFECT EFFECT=caselight_heating_ironbow REPLACE=1

[gcode_macro caselight_status_heating_rainbow]
gcode:
    SET_LED_EFFECT EFFECT=caselight_heating_rainbow REPLACE=1

[gcode_macro caselight_status_cooling]
gcode:
    SET_LED_EFFECT EFFECT=caselight_cooling REPLACE=1

[gcode_macro caselight_status_leveling]
gcode:
    SET_LED_EFFECT EFFECT=caselight_leveling REPLACE=1

[gcode_macro caselight_status_homing]
gcode:
    SET_LED_EFFECT EFFECT=caselight_homing REPLACE=1

[gcode_macro caselight_status_cleaning]
gcode:
    SET_LED_EFFECT EFFECT=caselight_cleaning REPLACE=1

[gcode_macro caselight_status_meshing]
gcode:
    SET_LED_EFFECT EFFECT=caselight_meshing REPLACE=1

[gcode_macro caselight_status_calibrating_z]
gcode:
    SET_LED_EFFECT EFFECT=caselight_calibrating_z REPLACE=1

[gcode_macro caselight_status_printing]
gcode:
    SET_LED_EFFECT EFFECT=caselight_printing_progress REPLACE=1

[gcode_macro caselight_status_critical]
gcode:
    SET_LED_EFFECT EFFECT=caselight_critical_error REPLACE=1

[gcode_macro caselight_status_input_shaper]
gcode:
    SET_LED_EFFECT EFFECT=caselight_input_shaper REPLACE=1

[gcode_macro caselight_status_loading]
gcode:
    SET_LED_EFFECT EFFECT=caselight_loading REPLACE=1

[gcode_macro caselight_status_unloading]
gcode:
    SET_LED_EFFECT EFFECT=caselight_unloading REPLACE=1

[gcode_macro caselight_status_party_time]
gcode:
    SET_LED_EFFECT EFFECT=caselight_party_time REPLACE=1
    UPDATE_DELAYED_GCODE ID=led_sleep DURATION=7200                      ; Set to turn off LEDs after 2 hours of inactivity

[gcode_macro caselight_status_standby]
gcode:
    SET_LED_EFFECT EFFECT=caselight_rainbow REPLACE=1
    UPDATE_DELAYED_GCODE ID=led_sleep DURATION=7200                      ; Set to turn off LEDs after 2 hours of inactivity

[gcode_macro caselight_status_filament_runout]
gcode:
    SET_LED_EFFECT EFFECT=caselight_filament_runout REPLACE=1

printer_data/config/config/lights/neopixel_status_leds_barf.cfg

# Neopixel leds used on the toolhead (stealthburner style) (led-effects
[gcode_macro _USER_VARIABLES]
variable_status_leds_enabled: True
variable_status_leds_barf_enabled: True
variable_status_leds_barf_logo_led_name: "status_leds_barf"
variable_status_leds_barf_logo_idx: '1,2,3,4,5,6,7,8'
variable_status_leds_barf_nozzle_led_name: "status_leds_barf"
variable_status_leds_barf_nozzle_idx: '9,10'
gcode:

# Also include directly the leds control macros from here
[include ../macros/hardware_functions/status_leds.cfg]

[neopixel status_leds]
pin: STATUS_NEOPIXEL
#   The pin connected to the neopixel. This parameter must be provided.
chain_count: 10
#   The number of Neopixel chips that are "daisy chained" to the
#   provided pin. The default is 1 (which indicates only a single
#   Neopixel is connected to the pin).
color_order: GRB, GRB, GRB, GRB, GRB, GRB, GRB, GRB, GRBW, GRBW
#   Set the pixel order required by the LED hardware. Options are GRB,
#   RGB, GRBW, or RGBW. The default is GRB.
initial_RED: 0.0
initial_GREEN: 0.0
initial_BLUE: 0.0
initial_WHITE: 0.0
#   Sets the initial LED color of the Neopixel. Each value should be
#   between 0.0 and 1.0. The WHITE option is only available on RGBW
#   LEDs. The default for each color is 0.#

### Sleep ###
[delayed_gcode led_sleep]
gcode:
    led_off ; turn off all LEDs
    UPDATE_DELAYED_GCODE ID=led_sleep DURATION=0
    
##########################
# LED Effects Animations #
##########################

##################
## logo effects ##
##################

### Busy ###
[led_effect sb_logo_busy]
leds:
    neopixel:status_leds (1-8)
autostart:              false
frame_rate:             24
layers:
    breathing  3 1 top (1,0,0)

### Cleaning ###
[led_effect sb_logo_cleaning]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
    breathing  3 1 top (0.0, 0.02, 0.5)

### Cleaning - Twinkle ###
[led_effect sb_logo_cleaning_twinkle]
autostart:              false
frame_rate:             24
leds: 
	neopixel:status_leds (1-8)
layers:
    twinkle 2.0 0.05 add (0.00,0.12,0.50) 
    twinkle 0.5 0.10 add (0.00,0.06,1.00) 

### Calibrating Z (obsolete w/ Tap) ###
[led_effect sb_logo_calibrating_z_breathing]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
    breathing  3 1 top (0.0, 0.0, 0.35)

### Calibrating Z - Comet (obsolete w/ Tap) ###
[led_effect sb_logo_calibrating_z_comet]
autostart: false
frame_rate: 24
leds: 
	neopixel:status_leds (1-8)
layers:
	comet 0.3 1 add (0.8,0.0,0.35),(0.4,0.0,0.7) 
    comet -0.3 1 add (0.8,0.0,0.35),(0.4,0.0,0.7) 

### Heating ###
[led_effect sb_logo_heating]
leds:
    neopixel:status_leds (1,3,7,8,6,2)
autostart:                          false
frame_rate:                         24
layers:
    comet  0.3  0 add (1, 0.18, 0)

[led_effect sb_logo_heating_heaterfire]
leds: 
	neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
heater: extruder
layers:
	heaterfire 20 1 add (0,0,0.5),(0.5,0,1.0),(0.5,0,0),(1.0,0.5,0.25),(1.0,1.0,0) 

[led_effect sb_logo_heating_heater]
leds: 
	neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
heater: extruder
layers:
    heater 150 0 add (0,0,0.5),(0.5,0,1.0),(0.5,0,0),(1.0,0.5,0.25),(1.0,1.0,0)

[led_effect sb_logo_heating_ironbow]
leds: 
	neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
heater: extruder
layers:
    # FLIR Ironbow gradient
    static 0 0 subtract (0.5,0.5,0.5)
    heaterfire 20 1 add (0.97,0.99,0.59),(0.92,0.27,0.31),(0.98,0.71,0.00),(0.69,0.04,0.58),(0.08,0.02,0.35) 
    heater 150 0 add  (0,0,0.5),(0.84,0.84,0)

[led_effect sb_logo_heating_rainbow]
leds: 
	neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
heater: extruder
layers:
    # FLIR Rainbow gradient
    static 0 0 subtract (0.5,0.5,0.5)
    heaterfire 20 1 top (1.00,0.79,0.71),(0.98,0.10,0.26),(0.74,0.83,0.04),(0.00,0.55,0.72),(0.01,0.13,0.45) 
    heater 150 0 add (0,0,0.5),(0.84,0.84,0)

### Cooling ###
[led_effect sb_logo_cooling]
leds:
    neopixel:status_leds (1,3,7,8,6,2)
autostart:                          false
frame_rate:                         24
layers:
    comet  0.3  0 add (0, 0, 1)

### Homing ###
[led_effect sb_logo_homing]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
    breathing  3 1 top (0.0, 0.6, 0.2)

[led_effect sb_logo_homing_chase]
leds: 
	neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
endstops: x, y, z
layers:
    static 0 0 subtract (0.5,0.5,0.5)
    breathing 8 0 add (0,0.6,0.2),(0,0.46,0.15) 
	chase 0.25 0.25 add (0,0.6,0.2) 
    homing 4 0 top (0.75,0.75,1.0)

[led_effect sb_logo_leveling]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
    breathing  3 1 top (0.5, 0.1, 0.4)

### Meshing ###
[led_effect sb_logo_meshing]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
    breathing  3 1 top (0.2, 1.0, 0.0)

[led_effect sb_logo_meshing_static]
leds: 
	neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
endstops: z, probe
layers:
    static 0 0 subtract (0.5,0.5,0.5)
	chase -0.30 0.40 add (0.2,1.0,0.0),(0.75,0.79,0.00)
    homing 2.5 0 top (0.75,0.75,1.0)

### Printing ###
[led_effect sb_logo_printing]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
    gradient  0.3  1 add (0.3, 0.0, 0.0),(0.3, 0.3, 0.0),(0.3, 0.1, 0.0)

### Printing ###
[led_effect sb_logo_printing_static]
leds: 
	neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
layers:
	static 0 0 add (0.0,0.0,1.0,0.0)

### Standby ###
[led_effect sb_logo_standby]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
    breathing  3 1 top (0.01, 0.01, 0.01)

[led_effect sb_logo_standby_static]
leds: 
	neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
layers:
    breathing 12 1 add (0,0,1.0,0.0)
    static 0 0 add (0,0,0.05,0.0)

### Input Shaper ###
[led_effect logo_input_shaper]
leds: 
	neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
layers:
    static 0 0 top (0.25,0.0,0.5)

### Loading ###
[led_effect sb_logo_loading]
leds: 
	neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
layers:
    static 0 0 subtract (0.5,0.5,0.5)
    stepper 2 2 add (0.00,0.50,0.00),(0.18,1.00,1.00)

### Unloading ###
[led_effect sb_logo_unloading]
leds: 
	neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
layers:
    static 0 0 subtract (0.5,0.5,0.5)
    stepper 2 2 add (1.0,0,0),(1.0,0.5,0) 

### Part Ready ###
[led_effect sb_logo_part_ready]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (1-8)
layers:
    breathing  3 1 top (0.0, 1.0, 0.0)

### Party Time ###
[led_effect sb_logo_party_time]
leds:
    neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
layers:
    gradient 1 1 add (0.07,0,0),(0,0.07,0),(0,0,0.07) 

### Purge ###
[led_effect sb_logo_purge]
leds:
    neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
layers:
    linearfade 0.75 1.00 top (0.7,0,1.0),(0.25,0.00,0.44) 

### Runout ###
[led_effect sb_logo_filament_runout]
leds: 
	neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
layers:
    breathing 6 1 top (1.0,0.0,0.0,0.0)
    static 0 0 top (1.0,0,0,0)

### Leveling (Z_tilt_adjust) ###
[led_effect sb_logo_leveling]
leds: 
	neopixel:status_leds (1-8)
autostart: false
frame_rate: 24
endstops: z, probe
layers:
	comet -0.30 0.70 add (0.00,0.50,0.75),(0.00,1.00,1.00)
    homing 3 0 top (0.75,0.75,1.0)

####################
## nozzle effects ##
####################

### On ###
[led_effect sb_nozzle_on]
leds: 
	neopixel:status_leds (9,10)
autostart: false
frame_rate: 24
layers:
	static 0 0 add (0.8,0.8,0.8,1.0)

### Off ###
[led_effect sb_nozzle_off]
leds: 
	neopixel:status_leds (9,10)
autostart: false
frame_rate: 24
layers:
	static 0 0 add (0.0,0.0,0.0,0.0)

## Heating ##
[led_effect sb_nozzle_heating]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (9,10)
layers:
    breathing  3 1 top (1.0, 0.18, 0.0, 0.0)

[led_effect sb_nozzle_heating_static]
leds: 
	neopixel:status_leds (9,10)
autostart: false
frame_rate: 24
layers:
    static 0 0 top (0.8,0.35,0.0,0.0)

## Cooling ##
[led_effect sb_nozzle_cooling]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (9,10)
layers:
        breathing  3 1 top (0.0, 0.0, 1.0, 0.1)

### Standby ###
[led_effect sb_nozzle_standby]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (9,10)
layers:
        breathing  3 1 top (0.6, 0.0, 0.0, 0.0)

[led_effect sb_nozzle_standby_static]
leds: 
	neopixel:status_leds (9,10)
autostart: false
frame_rate: 24
layers:
    breathing 12 1 add (0,0,1.0,0.0)
    static 0 0 add (0,0,0.05,0.0)

[led_effect sb_nozzle_part_ready]
autostart:              false
frame_rate:             24
leds:
    neopixel:status_leds (9,10)
layers:
        breathing  3 1 top (0.6, 1.0, 0.0, 0.1)

### Homing ###
[led_effect sb_nozzle_homing]
leds: 
	neopixel:status_leds (9,10)
autostart: false
frame_rate: 24
endstops: x, y, z
layers:
    breathing 8 0 add (0,0.6,0.2),(0,0.46,0.15) 
    #homing 4 0 top (1.0,1.0,1.0)
    homing 4 0 top (0.75,0.75,1.0)
    
### Input Shaper ###
[led_effect sb_nozzle_input_shaper]
leds: 
	neopixel:status_leds (9,10)
autostart: false
frame_rate: 24
layers:
    static 0 0 top (0.25,0.0,0.5)

### Party Time ###
[led_effect sb_nozzle_party_time]
leds:
    neopixel:status_leds (9,10)
autostart: false
frame_rate: 24
layers:
    strobe 1.25 1.5 add (1.0,0,0,0),(1.0,1.0,0,0),(0,1.0,0,0),(1.0,0,1.0,0),(0,1.0,1.0,0),(0,0,1.0,0) 

#####################
## all led effects ##
#####################

### Critical Error ###
[led_effect sb_critical_error]
leds:
    neopixel:status_leds
layers:
    strobe 1 1.5 add (1.0, 1.0,1.0)
    breathing 2 0 difference (0.95,0.0,0.0)
    static 1 0 top (1.0,0.0,0.0)
autostart:                              false
frame_rate:                             24
run_on_error:                           true

[led_effect sb_rainbow]
leds:
    neopixel:status_leds
autostart:                          true
frame_rate:                         24
layers:
    gradient  0.3  1 add (0.3, 0.0, 0.0),(0.0, 0.3, 0.0),(0.0, 0.0, 0.3)

#######################
# LED Effects Statics #
#######################

[led_effect set_nozzle_leds]
leds:
    neopixel:status_leds (9,10)
autostart:                          false
frame_rate:                         24
layers:
    static         0  0     top        (0.0,  0.0, 0.0, 1.0)

[led_effect set_logo_leds]
leds:
    neopixel:status_leds (1,2,3,4,5,6,7,8)
autostart:                          false
frame_rate:                         24
layers:
    static         0  0     top        (1.0,  1.0, 1.0)

##############
# The Macros #
##############

# [gcode_macro set_logo_leds_off]
# gcode:
#     SET_LED_EFFECT EFFECT=set_logo_leds STOP=1

# [gcode_macro set_logo_leds_on]
# gcode:
#     SET_LED_EFFECT EFFECT=set_logo_leds

# [gcode_macro set_nozzle_leds_on]
# gcode:
#     SET_LED_EFFECT EFFECT=set_nozzle_leds

# [gcode_macro set_nozzle_leds_off]
# gcode:
#     SET_LED_EFFECT EFFECT=set_nozzle_leds STOP=1

[gcode_macro sb_status_off]
gcode:
    STOP_LED_EFFECTS LEDS="neopixel:status_leds"

[gcode_macro sb_status_ready]
gcode:
    sb_status_off
    SET_LED_EFFECT EFFECT=sb_rainbow

[gcode_macro sb_status_part_ready]
gcode:
    sb_status_off
    SET_LED_EFFECT EFFECT=sb_nozzle_part_ready
    SET_LED_EFFECT EFFECT=sb_logo_part_ready

[gcode_macro sb_status_busy]
gcode:
    sb_status_off
    SET_LED_EFFECT EFFECT=sb_logo_busy
    SET_NOZZLE_LEDS_ON

[gcode_macro sb_status_heating]
gcode:
    sb_status_off
    SET_LED_EFFECT EFFECT=sb_logo_heating
    SET_LED_EFFECT EFFECT=sb_nozzle_heating

[gcode_macro sb_status_cooling]
gcode:
    sb_status_off
    SET_LED_EFFECT EFFECT=sb_logo_cooling
    SET_LED_EFFECT EFFECT=sb_nozzle_cooling

[gcode_macro sb_status_leveling]
gcode:
    sb_status_off
    SET_LED_EFFECT EFFECT=sb_logo_leveling
    SET_NOZZLE_LEDS_ON

[gcode_macro sb_status_homing]
gcode:
    sb_status_off
    SET_LED_EFFECT EFFECT=sb_logo_homing
    SET_NOZZLE_LEDS_ON

[gcode_macro sb_status_cleaning]
gcode:
    sb_status_off
    SET_LED_EFFECT EFFECT=sb_logo_cleaning
    SET_NOZZLE_LEDS_ON

[gcode_macro sb_status_meshing]
gcode:
    sb_status_off
    SET_LED_EFFECT EFFECT=sb_logo_meshing
    SET_NOZZLE_LEDS_ON

[gcode_macro sb_status_calibrating_z]
gcode:
    sb_status_off
    SET_LED_EFFECT EFFECT=sb_logo_calibrating_z
    SET_NOZZLE_LEDS_ON

[gcode_macro sb_status_printing]
gcode:
    sb_status_off
    SET_LED_EFFECT EFFECT=sb_logo_printing
    SET_NOZZLE_LEDS_ON

[gcode_macro sb_status_critical]
gcode:
    sb_status_off
    SET_LED_EFFECT EFFECT=sb_critical_error
    SET_NOZZLE_LEDS_ON

printer_data/config/overrides.cfg

[gcode_macro SET_LOGO_LEDS_OFF]
gcode:
    {% set transmit = params.TRANSMIT|default(1) %}

    {% if printer["gcode_macro _USER_VARIABLES"].status_leds_barf_enabled == TRUE %}
        SET_LED_EFFECT EFFECT=set_logo_leds STOP=1
    {% elif printer["gcode_macro _USER_VARIABLES"].status_leds_enabled == TRUE %}
        _SET_LEDS_BY_NAME LEDS="logo" COLOR="off" TRANSMIT={transmit}
    {% endif %}

[gcode_macro SET_NOZZLE_LEDS_ON]
gcode:
    {% set transmit = params.TRANSMIT|default(1) %}
    
    {% if printer["gcode_macro _USER_VARIABLES"].status_leds_barf_enabled == TRUE %}
        SET_LED_EFFECT EFFECT=set_nozzle_leds
    {% elif printer["gcode_macro _USER_VARIABLES"].status_leds_enabled == TRUE %}
        _SET_LEDS_BY_NAME LEDS="nozzle" COLOR="on" TRANSMIT={transmit}
    {% endif %}

[gcode_macro SET_NOZZLE_LEDS_OFF]
gcode:
    {% set transmit = params.TRANSMIT|default(1) %}

    {% if printer["gcode_macro _USER_VARIABLES"].status_leds_barf_enabled == TRUE %}
        SET_LED_EFFECT EFFECT=set_nozzle_leds STOP=1
    {% elif printer["gcode_macro _USER_VARIABLES"].status_leds_enabled == TRUE %}
        _SET_LEDS_BY_NAME LEDS="nozzle" COLOR="off" TRANSMIT={transmit}
    {% endif %}

[gcode_macro STATUS_LEDS]
gcode:
    {% set color = params.COLOR|default('off')|lower %}
    {% set logo_leds_name = printer["gcode_macro _USER_VARIABLES"]["status_leds_logo_led_name"] %}
    {% set nozzle_leds_name = printer["gcode_macro _USER_VARIABLES"]["status_leds_nozzle_led_name"] %}
    {% set logo_transmit = 0 if (logo_leds_name == nozzle_leds_name) else 1 %}

    {% set status_color = {
        'ready': {
            'logo': 'standby',
            'nozzle': 'standby',
            'caselight': 'standby',
            'minidisplay': 'on'
        },
        'busy': {
            'logo': 'busy',
            'nozzle': 'on',
            'caselight': 'busy',
            'minidisplay': 'on'
        },
        'heating': {
            'logo': 'heating',
            'nozzle': 'heating',
            'caselight': 'heating',
            'minidisplay': 'on'
        },
        'leveling': {
            'logo': 'leveling',
            'nozzle': 'on',
            'caselight': 'leveling',
            'minidisplay': 'on'
        },
        'homing': {
            'logo': 'homing',
            'nozzle': 'on',
            'caselight': 'homing',
            'minidisplay': 'on'
        },
        'cleaning': {
            'logo': 'cleaning',
            'nozzle': 'on',
            'caselight': 'cleaning',
            'minidisplay': 'on'
        },
        'meshing': {
            'logo': 'meshing',
            'nozzle': 'on',
            'caselight': 'meshing',
            'minidisplay': 'on'
        },
        'calibrating_z': {
            'logo': 'calibrating_z',
            'nozzle': 'on',
            'caselight': 'calibrating_z',
            'minidisplay': 'on'
        },
        'printing': {
            'logo': 'printing',
            'nozzle': 'on',
            'caselight': 'printing',
            'minidisplay': 'on'
        },
        'off': {
            'logo': 'off',
            'nozzle': 'off',
            'caselight': 'off',
            'minidisplay': 'off'
        },
        'on': {
            'logo': 'on',
            'nozzle': 'on',
            'caselight': 'on',
            'minidisplay': 'on'
        },        
        'error': {
            'logo': 'error',
            'nozzle': 'error',
            'caselight': 'error',
            'minidisplay': 'error'
        }   
    } %}

    {% if not (color in status_color) %}
        { action_raise_error("COLOR is not valid!") }
    {% endif %}

    {% if printer["gcode_macro _USER_VARIABLES"].status_leds_enabled %}
        {% if printer["gcode_macro _USER_VARIABLES"].status_leds_barf_enabled %}
            {% set nozzle_status = status_color[color]['nozzle'] %}
            {% set logo_status = status_color[color]['logo'] %}

            {printer["gcode_macro _USER_VARIABLES"].status_leds_barf_status['logo'][logo_status]}
            {printer["gcode_macro _USER_VARIABLES"].status_leds_barf_status['nozzle'][nozzle_status]}
        {% else  %}
            _SET_LEDS_BY_NAME LEDS="logo" COLOR={status_color[color].logo} TRANSMIT={logo_transmit}
            _SET_LEDS_BY_NAME LEDS="nozzle" COLOR={status_color[color].nozzle} TRANSMIT=1
        {% endif %}
    {% endif %}

    {% if printer["gcode_macro _USER_VARIABLES"].status_leds_caselight_enabled %}
        {% if printer["gcode_macro _USER_VARIABLES"].status_leds_caselight_barf_enabled %}
            {% set caselight_status = status_color[color]['caselight'] %}

            {printer["gcode_macro _USER_VARIABLES"].status_leds_barf_status['caselight'][caselight_status]}
        {% else  %}
            _SET_ALLLEDS_BY_NAME LEDS="caselight_right" COLOR={status_color[color].caselight} TRANSMIT=1
            _SET_ALLLEDS_BY_NAME LEDS="caselight_left" COLOR={status_color[color].caselight} TRANSMIT=1
        {% endif %}
    {% endif %}

    {% if printer["gcode_macro _USER_VARIABLES"].status_leds_minidisplay_enabled %}
        _SET_ALLLEDS_BY_NAME LEDS="minidisplay" COLOR={status_color[color].minidisplay} TRANSMIT=1
    {% endif %}

[gcode_macro QUAD_GANTRY_LEVEL]
rename_existing: _BASE_QUAD_GANTRY_LEVEL
description: Conform a moving, twistable gantry to the shape of a stationary bed with klicky automount
gcode:
    {% set tilting_travel_accel = printer["gcode_macro _USER_VARIABLES"].tilting_travel_accel %}
    {% set verbose = printer["gcode_macro _USER_VARIABLES"].verbose %}

    {% if verbose %}
        { action_respond_info("Quad gantry leveling") }
    {% endif %}
    _CG28
    
    STATUS_LEDS COLOR="LEVELING"

    ACTIVATE_PROBE

    # Set the tilting acceleration prior to any movement
    {% set saved_accel = printer.toolhead.max_accel %}
    {% set saved_decel = printer.toolhead.max_accel_to_decel %}
    M204 S{tilting_travel_accel}
    
    _BASE_QUAD_GANTRY_LEVEL {% for p in params %}{'%s=%s ' % (p, params[p])}{% endfor %}
    
    # Reset acceleration values to what it was before
    SET_VELOCITY_LIMIT ACCEL={saved_accel} ACCEL_TO_DECEL={saved_decel}

    DEACTIVATE_PROBE

    STATUS_LEDS COLOR="READY"

printer_data/config/variables.cfg

variable_status_leds_barf_status: {
        'logo': {
            'busy': 'sb_status_busy',
            'cleaning': 'sb_status_cleaning',
            'calibrating_z': 'sb_status_calibrating_z',
            'heating': 'sb_status_heating',
            'homing': 'sb_status_homing',
            'leveling': 'sb_status_leveling',
            'meshing': 'sb_status_meshing',
            'on': 'set_logo_leds_on',
            'off': 'set_logo_leds_off',
            'printing': 'sb_status_printing',
            'standby': 'sb_status_ready',
            'error': 'sb_status_critical',
            'done': 'sb_logo_part_ready'
        },
        'nozzle': {
            'heating': 'sb_status_heating',
            'off': 'set_nozzle_leds_off',
            'on': 'set_nozzle_leds_on',
            'standby': 'sb_status_ready',
            'error': 'sb_status_critical',
        },
        'caselight': {
            'busy': 'caselight_status_busy',
            'cleaning': 'caselight_status_cleaning',
            'calibrating_z': 'caselight_status_calibrating_z',
            'heating': 'caselight_status_heating',
            'homing': 'caselight_status_homing',
            'leveling': 'caselight_status_leveling',
            'meshing': 'caselight_status_meshing',
            'on': 'caselight_status_standby',
            'off': 'caselight_status_off',
            'printing': 'caselight_status_printing',
            'standby': 'caselight_status_standby',
            'error': 'caselight_status_critical',
        },
        'minidisplay': {
            'on': {'r': 0.0, 'g': 0.2, 'b': 0.4, 'w':1.0},
            'off': {'r': 0.0, 'g': 0.0, 'b': 0.0, 'w': 0.0},
            'error': {'r': 0.4, 'g': 0.0, 'b': 0.0, 'w':0.0},
        },
        'thermal': {
            'hot': {'r': 1.0, 'g': 0.0, 'b': 0.0, 'w': 0.0},
            'cold': {'r': 0.3, 'g': 0.0, 'b': 0.3, 'w': 0.0}
        }
    }

Would be nice if I understood how to rename existing macros, for example the QUAD_GANTRY_LEVELING macro is overridden by klippain, but when I tried to overwrite it and store the klippain version in a variable using rename_existing, it wouldn't call the klippain version, only the original one (confirmed via M118 commands in the klippain version)

There is further testing to be done, but this is currently working

@Frix-x
Copy link
Owner

Frix-x commented Feb 22, 2024

Please check out the development branch, a lot of work was done on the LED system a few weeks ago and led_effect support is already there as well as barf support, etc. The release is hopefully planned for tomorrow :)

@Frix-x Frix-x added the done Issue is done but not merged on main label Feb 22, 2024
@Frix-x Frix-x closed this as completed Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done Issue is done but not merged on main enhancement New feature or request next version This thing is already done or is planned in the next version in preparation tracking This issue is tracked and work will be done
Projects
None yet
Development

No branches or pull requests

7 participants