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?
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.
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:
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!
Life got busy and I wasn’t able to finish my saber for a while, but now I have another question on this thread. Triggering Blade ID with a button press is working, but it cuts off whatever sound I have going as well. If I tie it to the same button press that changes the preset, it only plays part of the font announcement sound thingy (idk what to call that), and if I try it with turning the blade off, it cuts off the retraction sound. Is there any possible work around for this, or some way I can delay it so that it plays the full sound and then checks for blade ID?
Also, should I be using a blade ID class besides the default? I do not have an external pull-up resistor and I haven’t bridged anything, which is all the POD site mentions (unless I’m missing something…), but I’ve seen some people using snapshot blade ID? I 'm having trouble finding information on what that is and when it should be used.
Oops, I didn’t realize SnapshotBladeID WAS the default. That’s… a helpful clarification lol.
I found the POD page for blade ID constant monitoring! I downloaded the OS7 alpha and did everything you said, and used the default prop file so it doesn’t check for blade ID with button presses anymore. Sound works correctly now, but it doesn’t seem to be switching to my “no blade” array, even when I toggle the kill switch. (Now that I think about it, I think this was happening before too, I just assumed something was wrong with the blade styles I made and not that it wasn’t switching arrays).
I haven’t checked the ID with the serial monitor yet (chassis has 2 segments that are held together in the hilt, but needs to be out to connect to computer, so its kind of tricky), so in the blade config my kr blade has a value of 0 and the “no blade” ID is 200000. Could that be why it isn’t switching, or is something potentially wrong?