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
#define BLADE_ID_MONITORED
Edited the prop’s void Loop() to start like this:
BLADE_ID_CLASS_INTERNAL blade_id;
void Loop() override {
PropBase::Loop();
DetectTwist();
DetectShake();
#ifdef BLADE_ID_MONITORED
if (millis() - last_blade_id_ > 2000) {
STDOUT << "BLADE ID: OLD = "<< looped_blade_id_ << "\n";
blade_id.id();
last_blade_id_ = millis();
STDOUT << "BLADE ID: checked = "<< blade_id.id() << "\n";
if (looped_blade_id_ > blade_id.id() + 100 || looped_blade_id_ < blade_id.id() - 100) {
STDOUT << "BLADE ID: DIFFERENT ***** do something here\n";
// beeper.Beep(0.5, 1000);
FindBladeAgain();
SaberBase::DoBladeDetect(true);
}
looped_blade_id_ = blade_id.id();
}
#endif
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.
Terrible?