Macro lighting control

I’m interested in creating a macro for changing the rail lights. Ideally, I would assign a button on the SLB E-Stop. The purpose would be to toggle through the light settings.

I would think the default operation of the rail is “automatic” so pressing the button once would turn on all lights white, press again, then a final press would be back to auto.

I’m trying to find macro references to see if this is possible to do and if even makes sense.

Unfortunately I can’t answer your question but I have some of my own.

What are the rail lights? Is this something specific to the SLB or the MK2? I did a quick search but didn’t find the answer.

EDIT: Never mind I found the answer here.

Correct. This is a new SLB feature. I’m trying to combine the new E-Stop programmable buttons to control the new rail lighting. If you’re on Facebook, I posted my lighting video proof of concept in the LongMill group

1 Like

Hey Jim,

Chatting with the team, we don’t have the ability to ‘toggle through’ the light settings, but that may be something we could look into add in the future. You can control the lights with the Action Buttons on the Estop, but you can’t cycle through settings at this time.

Cheers,
Stephen

Yeah probably the best way to do this for now would be using macro buttons in gSender but we could definitely look into it in the future :+1:

I figured macros were the best at least for now. I wasn’t sure if it was possible to write a macro to store a state variable and then read that on the next button press (macro run).

Does anyone have example macros I could plagiarize? Just looking for examples to maintain the same style references. I’ll dig through GitHub and cobble something together

If you’re using gSender macros (not the e-stop button firmware macros) with a keybind, something like this should work:

%nextLight = global.lightState || 0
M356 P0 Q[nextLight % 3]
%global.lightState = Number(nextLight) + 1

It either retrieves the current lightState or sets it to 0 if it’s undefined, sets the light to the current state modulus 3 (so the value will never go above 2) and then stores the next state sequence.

Any variables stored in global persist until the application is closed.

From a cursory glance it seems to be working as expected to cycle between auto, white, and off.

image

3 Likes

That’s exactly how I was thinking, I just wasn’t sure of valid syntax or formatting rules. I was originally thinking the e-stop button but when I went back and re-read the manual, I missed the part where it was the macros were specified in the firmware and not the regular macros. (This is what I get for skimming documentation)

@hamanjam Jim, this is a bit off topic, but you can enter macro text for the 3 buttons on the e-stop. I have done it by entering macro text in $450-452. We are limited to 127 characters. I believe that @KGN point was that we could not assign his macro to those buttons.

This is from the documentation:
“The buttons are customized in the SLBs EEPROM settings, using the Firmware section of either gSender or ioSender. Look for settings $450-452 to select one of the actions from the premade list, or select the first “Macro” option and type in your own g-code string to execute in settings $450-452.
Each macro can hold up to 127 characters, can run multiple lines using ‘|’ for a line break, and runs any vanilla g-code but no math operations.”

1 Like

I tried out a few macros in firmware and they do work for a single state. I didn’t want to dedicate multiple buttons to the lighting which was why I was trying to work out the cycling script but options are nice to have. I expect over time, the workflow would determine how I will use it. Most likely a joystick shortcut is a good compromise. (I did find out while testing yesterday that I technically Q3 was valid to turn all lights on green)

@hamanjam I use an android tablet to control gSender so I can simply map @KGN macro to a key press on the tablet. I have yet to buy the led strip. Would you mind telling me what leds you are using and what power supply? Tks, Jim.

Yeah, Q3 is all green, anything higher just turns the lights off.

I took a peek at the RGB plugin and it should be relatively straight forward to add an option to cycle. Time permitting/no promises I’ll probably try to put together a pull request adding that option some time within the next few firmware releases.

@KGN And here I thought that I was completely lost before. :grinning: :grinning:

1 Like

Wow! Quick response, that would be awesome to have this added but obviously it’s an enhancement and no rush. Thanks!

Not really a product endorsement but here’s the notes I took. I bought these simply because I could get them overnight from Amazon. Anything with similar specs should work. Many LED strips have an additional red/white wires if they are longer for a power boost, and I can’t speak to if/how that is used. I didn’t need the extra power since my strip is only a single run.

SLB_Rail_LEDs.pdf

3 Likes

@hamanjam Tks much, Jim. g

One more option is to use one of the two aux switch output in series with the red wire going to ring connector or the power wire for the rail connector. Then set that aux output to mist enable and button action to mist.

Then that button with toggle power on/off to that set of LEDs. When power toggled back on the LEDs will not come back on until first movement of the axis

1 Like

To add to the discussion, since Kevin made a really cool macro I had to add it to the gSender macro docs for future reference because I think it does a great job demoing how to work with macros in gSender. Also the tweak to the plugin I’m sure we could make since it may be handy to have available