Change colour of display backlight

While the display backlight colour of the SV08 can be changed interactively from settings dialog, I couldn’t find how to control colours through macros or better, through MQTT. Though macros can be called and executed from MQTT, passing parameters to macros is something else I haven’t figured out yet, therefore my preference for colour control through MQTT.
How is that done?

@sovol3d

Capture

This was a fun quest; thank you for asking @Bushmills :smile:
Had a few back and forth rounds with ChatGPT, but finally got it working :blush::robot::sparkles:

:art: How to add Neopixel Color Controls to your SV08 Neopixel display

  1. Open Mainsail

  2. Navigate to Machine on the left side navigation

  3. You should see Config listed at the top of the list, if not, select it from the dropdown

  4. Open your Macro.cfg file and find an empty line

  5. Paste in the following code:

[gcode_macro UPDATE_NEOPIXEL_VALUES]
description: "Store and update Neopixel color values dynamically"
gcode:
    {% set red = params.RED|default(printer.save_variables.variables.get("neopixel_red", 0.5)) %}
    {% set green = params.GREEN|default(printer.save_variables.variables.get("neopixel_green", 0.4)) %}
    {% set blue = params.BLUE|default(printer.save_variables.variables.get("neopixel_blue", 0.7)) %}
    SAVE_VARIABLE VARIABLE=neopixel_red VALUE={red}
    SAVE_VARIABLE VARIABLE=neopixel_green VALUE={green}
    SAVE_VARIABLE VARIABLE=neopixel_blue VALUE={blue}
    M117 Neopixel Updated: R={red} G={green} B={blue}
    APPLY_NEOPIXEL

[gcode_macro APPLY_NEOPIXEL]
description: "Apply stored Neopixel colors in real-time"
gcode:
    {% set red = printer.save_variables.variables.get("neopixel_red", 0.5) %}
    {% set green = printer.save_variables.variables.get("neopixel_green", 0.4) %}
    {% set blue = printer.save_variables.variables.get("neopixel_blue", 0.7) %}
    M117 Applying Neopixel: R={red}, G={green}, B={blue}
    SET_LED LED=Screen_Colour RED={red} GREEN={green} BLUE={blue}

[menu __main __neopixel]
type: list
name: "Neopixel Colors"

[menu __main __neopixel __red]
type: input
name: {"Red: %1.2f" % menu.input}
input: {printer.save_variables.variables.get("neopixel_red", 0.5)}
input_min: 0.00
input_max: 1.00
input_step: 0.05
gcode:
    {menu.exit()}
    UPDATE_NEOPIXEL_VALUES RED={menu.input}

[menu __main __neopixel __green]
type: input
name: {"Green: %1.2f" % menu.input}
input: {printer.save_variables.variables.get("neopixel_green", 0.4)}
input_min: 0.00
input_max: 1.00
input_step: 0.05
gcode:
    {menu.exit()}
    UPDATE_NEOPIXEL_VALUES GREEN={menu.input}

[menu __main __neopixel __blue]
type: input
name: {"Blue: %1.2f" % menu.input}
input: {printer.save_variables.variables.get("neopixel_blue", 0.7)}
input_min: 0.00
input_max: 1.00
input_step: 0.05
gcode:
    {menu.exit()}
    UPDATE_NEOPIXEL_VALUES BLUE={menu.input}

[menu __main __neopixel __turn_off]
type: command
name: "Turn Off"
gcode:
    {menu.exit()}
    UPDATE_NEOPIXEL_VALUES RED=0.0 GREEN=0.0 BLUE=0.0


[delayed_gcode _restore_neopixel]
initial_duration: 1.0
gcode:
    APPLY_NEOPIXEL

Note: For extra control, adjust the input_step values from 0.05 to 0.01

  1. Click Save & Restart

  2. Once your printer has done the reboot sequence, you should now have a control available at the bottom of the main menu for Neopixel Color

Set the :red_square: Red, :green_square: Green or :blue_square: Blue values between 0.00-1.00 for each until you find your desired color. The code above will also store the values and ensure that your color scheme appears after a reboot sequence. :sunglasses:


:art: Neopixel RGB Value Guide for Popular Colors

Here is a list of pre-set RGB values (0.00 - 1.00 scale) to quickly achieve specific colors for your Neopixel setup.


:fire: Primary Colors

Color Red (R) Green (G) Blue (B)
Red 1.00 0.00 0.00
Green 0.00 1.00 0.00
Blue 0.00 0.00 1.00

:rainbow: Secondary Colors (Mixed)

Color Red (R) Green (G) Blue (B)
Yellow 1.00 1.00 0.00
Cyan 0.00 1.00 1.00
Magenta 1.00 0.00 1.00

:art: Common Warm Colors

Color Red (R) Green (G) Blue (B)
Orange 1.00 0.50 0.00
Amber 1.00 0.30 0.00
Gold 1.00 0.75 0.00

:blue_heart: Common Cool Colors

Color Red (R) Green (G) Blue (B)
Sky Blue 0.30 0.60 1.00
Turquoise 0.25 0.88 0.82
Teal 0.00 0.50 0.50

:purple_heart: Purples & Pinks

Color Red (R) Green (G) Blue (B)
Lavender 0.75 0.50 1.00
Violet 0.50 0.00 1.00
Hot Pink 1.00 0.00 0.50
Rose Pink 1.00 0.40 0.70

:black_circle: Shades of Gray & White

Color Red (R) Green (G) Blue (B)
White 1.00 1.00 1.00
Cool White 0.85 0.90 1.00
Warm White 1.00 0.85 0.70
Light Gray 0.75 0.75 0.75
Dark Gray 0.30 0.30 0.30
Black (Off) 0.00 0.00 0.00

:green_heart: Fun & Unique Colors

Color Red (R) Green (G) Blue (B)
Mint Green 0.60 1.00 0.60
Lime Green 0.75 1.00 0.00
Dark Green 0.00 0.50 0.00
Indigo 0.30 0.00 1.00
Deep Purple 0.50 0.00 0.75
Neon Pink 1.00 0.20 0.80

If you’d like to see any updates or changes to how this works, please let me know.
Feel free to contact me anytime if you have any questions.
I’m here to help! :smile:

2 Likes

Good work! I used it as a starting point to integrate SV08 display colours with a Node-RED flow. That way can I keep the changes to the printer configuration to a minimum: all it then needs is a single macro which is called from and receives its arguments from a Node-RED flow, while the actual parametrization and event response can be delegated to the Node-RED flow. This allows, for example, controlling printer light from any machine able to send an MQTT message, which is picked up by that Node-RED flow, then relayed to the printer.
As far can I only set display to pre-set colours, not to any numeric value for each colour channel, contrary to main LED brightness, which I can now control that way (for example, by a slider on the dashboard page, or by printer system load or whatever parameter Node-RED can receive - printer shares vital parameters over MQTT, which is how Node-RED can obtain them). But getting the same control with display colours should now only by a small step. What I yet need to deal with is the fact that I don’t have only one single brightness parameter which can be send through a single message channel, but three of them, one for each colour - sending them combined in one message works as far, individual color channel control not yet.
I’ll publish my setup and changes to it in a wiki page related to SV08 on github. Page for remote controlling the SV08 exist already, but only a few screen shots published as far, which may need more elaboration.
wiki page is @ main_led · Bushmills/Sovol-SV08 Wiki · GitHub
The printer sharing vital operation parameters through MQTT hasn’t been described there yet, and I feel I should add a chapter on that too, especially as the setup to achieve that is relatively simple. Makes me think whether the procedure to move the gcodes directory to external storage device may also be worthwhile to store there.
Thank you for your efforts, I’m confident that many users will appreciate that.

1 Like