## direct control of neopixel is not working on RPI
# [neopixel pixel]
# pin: rpi:gpio18
# chain_count: 4
# color_order: GRB
# initial_RED: 0.0
# initial_GREEN: 0.0
# initial_BLUE: 0.0
# # initial_WHITE: 0.0

# [gcode_macro NEOPIXEL]
# description: control neopixel
# gcode:
#   {% set R = params.R|default(0) %}
#   {% set G = params.G|default(0) %}
#   {% set B = params.B|default(0) %}
#   SET_LED LED=pixel RED={R} GREEN={G} BLUE={B}

## run script instead
[gcode_macro NEOPIXEL_ON]
description: turn neopixel on
gcode:
  {% set COLOR = params.COLOR|default("white") %}
  {% if COLOR == "white" %}
    RUN_SHELL_COMMAND CMD=neopixel_white
  {% elif COLOR == "red" %}
    RUN_SHELL_COMMAND CMD=neopixel_red
  {% elif COLOR == "green" %}
    RUN_SHELL_COMMAND CMD=neopixel_green
  {% elif COLOR == "blue" %}
    RUN_SHELL_COMMAND CMD=neopixel_blue
  {% endif %}

[gcode_macro NEOPIXEL_OFF]
description: turn neopixel off
gcode:
  RUN_SHELL_COMMAND CMD=neopixel_off

[gcode_shell_command neopixel_white]
command: sudo /home/pi/klipper_config/scripts/pixel.py 255
timeout: 3
verbose: False

[gcode_shell_command neopixel_red]
command: sudo /home/pi/klipper_config/scripts/pixel.py 255 0 0
timeout: 3
verbose: False

[gcode_shell_command neopixel_green]
command: sudo /home/pi/klipper_config/scripts/pixel.py 0 255 0
timeout: 3
verbose: False

[gcode_shell_command neopixel_blue]
command: sudo /home/pi/klipper_config/scripts/pixel.py 0 0 255
timeout: 3
verbose: False

[gcode_shell_command neopixel_off]
command: sudo /home/pi/klipper_config/scripts/pixel.py 0
timeout: 3
verbose: False