Clarification about Blade ID

I’m currently working on my first neopixel lightsaber, second saber in general. I’ve been reading a lot about blade detect and blade ID and found a thread in which NoSloppy posted a config that appears to use blade ID with a very high resistor value as a no-blade option, instead of blade detect (if I’m understanding correctly. Again, I’m relatively new at this). It’s not something I’ve seen anywhere else, but seems very useful. Is that something that would make sense to do if I don’t have a free pin for blade detect? If so, is there anything special I would need to add to my config (or anywhere else) to make that work?

Here is the link to the post/reply that I saw:

First of all, I will refer you to the blade id / blade detect pages for more information:

Second, let me clarify a few things.
Blade Detect adds a billion to the blade detect value when no blade is present. In the config file, you use NO_BLADE, but the value of NO_BLADE is actually one billion.

Blade ID will also return a high value when no blade is connected. It depends a bit on what blade detect method is used, but it is often somewhere in the ~300000 range.

Using the blade ID instead of blade detect might not do what you want though, becaus blade ID only runs when triggered. Without blade detect, blade ID is only triggered when the saber is powered on. With blade detect, blade ID is triggered every time you connect or disconnect a blade, in addition to when the the saber is powered on.

That’s very helpful, thank you.
So blade ID is just triggered with blade detect, and when I flip the kill switch on?

That is correct.

Although it can be triggered at other times as well.
Some people set it to trigger blade id when you switch presets.
That requires making some changes in the code.

1 Like

I’m certainly open to the idea of making changes in code anywhere that’s needed, and want to learn, but I’m afraid I don’t really understand how/where to do that. I also saw another thread where you mentioned possibly triggering blade ID with a button press (not when changing presets), which is an intriguing option too.

Can you please help me understand how I would set it up to trigger with a button press or when the preset changes, or direct me to a resource that can help?

I haven’t decided exactly how I want to proceed yet- I might still end up just going with blade detect, but I want to understand all my options, especially the ones that involve less wires lol

Basically, you would need to modify the event2 function in the prop class.
That function is responsible for specifying what happens for any button press.
Essentially all you would need to do is to insert a call to the FindBladeAgain() method somewhere and that will re-do the blade ID.

There is a pod page about making your own prop that might be relevant here:

I’m not exactly knowledgeable about terminology… Like this? (and if so, anything/what else?)

        aux_on_ = true;
        return true;

^^^just using the default saber.h file

Maybe… it depends on how much state is saved. If the current preset isn’t saved, then FindBladeAgain will reset back to the first preset, and next_preset() will essentially stop working.

So do I just need to define SAVE_STATE or SAVE_PRESET? What do you mean by “how much?” I hadn’t been thinking of it as a quantity, but maybe I’m just reading too much into this.
Apologies if this stuff is obvious, modifying the prop file is all very new to me beyond just changing button functionality. I really appreciate all the help you’ve been giving.

Well, SAVE_STATE includes SAVE_PRESET, so either would work.
We could also add some code that keeps track of the preset before and after in memory.

Now where it gets really tricky is that each blade can have it’s own preset array, and those arrays can be different sizes. Going from preset 4 to preset 5 makes perfect sense if you’re in the same blade ID, but if you switch to a different blade ID, you might find yourself with only 1 preset, and then going to preset 5 makes very little sense. It shouldn’t crash or anything, but it might be weird…

Okay, I think I like SAVE_PRESET better because I don’t really want color change mode to save. I’m glad to know that works, but yeah I can see how it could be weird.
I have the same number of presets in both arrays, so I’m hoping it will be fine without extra code. Regardless its good to know it wouldn’t have any serious issues, just the potential to be annoying. Thanks for your help!