Crazy idea of the day - Constant Blade ID monitoring

This was a PM, but putting it here for public input.

Disclaimer - totally off-the-cuff experimental and likely might take up resources, be a bad idea in general, etc… but is working in testing by adding/removing any blade,
even a NPXL PCB first (detects the change), then add a blade on top of that (2nd change detected)
(They’re wired in parallel)
No BLADE_ID resistors are installed anywhere.

If you have bladein.wav, it will play that when detected.

Used these defines:
#define ENABLE_POWER_FOR_ID PowerPINS<bladePowerPin2, bladePowerPin3>
#define BLADE_ID_CLASS SnapshotBladeID

Edited the prop’s void Loop() to start like this:

  void Loop() override {
        if (millis() - last_blade_id_ > 2000) {
          STDOUT << "BLADE ID: OLD =  "<< looped_blade_id_ << "\n";
          last_blade_id_ = millis();
          STDOUT << "BLADE ID: checked = "<< << "\n";
          if (looped_blade_id_ > + 100 || looped_blade_id_ < - 100) {
            STDOUT << "BLADE ID: DIFFERENT ***** do something here\n";
            // beeper.Beep(0.5, 1000);
          looped_blade_id_ =;
    Vec3 mss = fusor.mss();

and initialized these at the bottom

uint32_t last_blade_id_ = millis();
uint32_t looped_blade_id_ = 0;

Might need to be tweaked per setup:
ENABLE_POWER_FOR_ID’s bladePowerPins are your blade’s LED pads.

  • The id() +/- values.
  • The 2000 delay adjust to taste.
  • The detected values set in the BladeConfig.
    Use something reasonable based on what it shows in Serial Monitor for “BLADE ID: checked” for each state.
  • You can kill the beep if you use bladein.wav instead.


The reply:

I see. Yeah, it did work, nothing crapped out. Although I was not doing any effects, just inserting and removing things to make sure the right blade array was being chosen.

There may be caveats, but I think the key might be to do it before this line:

If I remember correctly, once IsReadyForEndFrame() is true, that particular PIN is not transmitting, which means that we can call FindBladeAgain() if we want to.

The tricky part is that this class might have been deleted once we return from FindBladeAgain(), which means there is some hoops to jump through to make sure that it works properly.

There is also a possibility that calling findblade all the time will count as to the neopixels and cause glitches on the blade, but one step at a time I guess…

For anyone reading this, the latest to test would be
where millis is the blade ID scan interval.
If the blade ID comes out the same as before, it will do nothing. If it comes out different, it will do FindBladeAgain(), which will basically initialize the saber from scratch and load the right settings for the new id().
It will only work with neopixel blades, and it probably requires
#define SHARED_POWER_PINS to work.

“The force works in mysterious ways.”

NICE! I know a youngling and three people not running EditMode that could stand to use this option. I can’t jump in w testing r/n but let me know when things are ready, what props (or all props?) it’ll work for.