Configuring BladeID, Blade Present and multple Blades simultaneously

Sorry to ask if this is a silly question, but I’m slowly implementing the full functionality. I have set up my saber with Shtok NPXL V3 (in a V4 config) plus Blade Present. Thus, I have the main blade, with Blade Detect, plus the Shtock PCB blade.
So, I basically have to implement multiple blades. Is this what I should add?

#define NUM_BLADES 2
#define SHARED_POWER_PINS
#define ENABLE_POWER_FOR_ID PowerPINS<bladePowerPin2, bladePowerPin3>
#define BLADE_DETECT_PIN 17


BladesConfig blades[] = {
  { 5000,
    WS281XBladePtr<121, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
    WS281XBladePtr<16, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
    CONFIGARRAY(p1)
  },
  { 10000,
    WS281XBladePtr<132, bladePin, Color8::GRBw, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
    WS281XBladePtr<16, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),    CONFIGARRAY(p2)
  },
  { NO_BLADE,
    WS281XBladePtr<16, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
    CONFIGARRAY(p3),
  }
};

With 5000 and 1000 the resistor values as measured by the specific board?

You might want to replace “17” with blade3Pin to make it more readable, but toher than that, this all looks quite reasonable to me.

1 Like

Thanks! Another one. In the Wiki you say that:

Alternatively, an external pull-up resistor can be used. This resistor should be in the 20k to 50k range and placed between the blade pin and 3.3v. Then you add this to the config file:

 #define BLADE_ID_CLASS ExternalPullupBladeID<bladeIdentifyPin, 22000>

(Replace 22000 with the value of your pullup resistor.) With this workaround, Blade ID should return values that are close to the Blade ID resistor values, which will make configuration easier.''

I just run a cable with a 22kR resistor between 3.3 and blade3Pin, add “#define BLADE_ID_CLASS ExternalPullupBladeID<blade3Pin, 22000>” to the config that’s it, I can write actual resistor values?

Yep, that is exactly it.

1 Like

One of those tiny 1/4W carbon resistors would do?

I’m not sure which resistor you’re talking about, but it doesn’t matter, because the answer is yes. None of these resistors should carry any major amount of current.

1 Like

I’m sorry to come back still with more questions. But I’ve been reading the manual on Blade Detect, and when it shows NOBLADE, then it still has the two neopixel blades:

BladeConfig blades[] = {
{ 0,
WS281XBladePtr<138, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
//Main Blade 138 pixels (“blade” #1)
WS281XBladePtr<5, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
//Connector 5 Pixels (“blade” #2)
CONFIGARRAY(blade) },
{ NO_BLADE,
WS281XBladePtr<138, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
//Main Blade (No Blade) (“blade” #1)
WS281XBladePtr<5, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
//Connector 5 Pixels (“blade” #2)
CONFIGARRAY(no_blade) },
};

What’s more, the sample code for presets still has two blades in the no_blade preset. Is this a printing mistake?

So, overall, I should just have:

  { 0,
    WS281XBladePtr<121, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
    WS281XBladePtr<16, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
    CONFIGARRAY(presetneopixelblade)
  },
  { 10000,
    WS281XBladePtr<132, bladePin, Color8::GRBw, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
    WS281XBladePtr<16, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),    CONFIGARRAY(presetneopixelblade)
  },
  { NO_BLADE,
    WS281XBladePtr<16, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
    CONFIGARRAY(presetnoblade),
  }
};```

And then:

```Preset presetneopixelblade[] = {
   { "TeensySF", "tracks/venus.wav",
    StyleNormalPtr<CYAN, WHITE, 300, 800>(),
    StyleNormalPtr<CYAN, WHITE, 300, 800>(), "cyan"},
   { "SmthJedi", "tracks/mars.wav",
    StylePtr<InOutSparkTip<EASYBLADE(BLUE, WHITE), 300, 800> >(),
    StyleNormalPtr<RED, YELLOW, 300, 800>(), "blue"},
    { "SmthJedi", "tracks/mars.wav",
    &style_charging,
    StyleNormalPtr<CYAN, WHITE, 300, 800>(),
   "Battery\nLevel"}
};

Preset presetnoblade[] = {
   { "TeensySF", "tracks/venus.wav",
     StyleNormalPtr<CYAN, WHITE, 300, 800>(), "cyan"},
   { "SmthJedi", "tracks/mars.wav",
    StylePtr<InOutSparkTip<EASYBLADE(BLUE, WHITE), 300, 800> >(), "blue"},
    { "SmthJedi", "tracks/mars.wav",
    &style_charging, "Battery\nLevel"}
};

Thus, the preset for a NO_BLADE has fewer blades?

All blade array entries must have the same number of blades.
The NO_BLADE entry doesn’t actually have one less blade, and it doesn’t really disable anything, it just lets you choose a different configuration. Most people just use it select different presets when the blade is not present. The blade definitions often stay exactly the same.

For the state of no blade inserted, I typically just make that blade’s style simply black as it’s unused.

   { "TeensySF", "tracks/venus.wav",
     StylePtr<Black>(),
     StyleNormalPtr<CYAN, WHITE, 300, 800>(), "cyan"},
   { "SmthJedi", "tracks/mars.wav",
     StylePtr<Black>(),
     StylePtr<InOutSparkTip<EASYBLADE(BLUE, WHITE), 300, 800> >(), "blue"},
    { "SmthJedi", "tracks/mars.wav",
     StylePtr<Black>(),
     &style_charging, "Battery\nLevel"}
};```
1 Like

Sorry to keep with this theme, but I only got hold of 20k resistors. Could not procure 22k. Did got 20k and 2.2k. Do I need to put them in series or 20k would be enough?

so 20k is fine by itself.

1 Like

This question is for a friend: he’s using an illuminated PCB. And the problem he has is that he only has a single Data Line, but his PCB pixels are GRB and his blade is GRBw. Can he use different definition of GRB/GRBw within a SubBlade?

Currently, there is no way to do that in ProffieOS.
It’s possible to make a hack that supports it though.
Unless you or your friend would like to write the code for it, I suggest filing an issue on the github bugtracker, and I will try to implement it when I have the time.

1 Like

Maybe a question is…really only 1 data line?

His install, not mine :man_shrugging:.
Now that I think of it. If you have GRB accents with GRBw blade with something like a Shtok ECO you physically can’t do squat about it.

I think I write a lot of questions but I don’t think enough. The BladeID resistor goes into the blade DATA line (Data1 in my case), NOT to the BladePresent pin (Data3, in my case). Right? :man_facepalming: :man_facepalming: :man_facepalming:

BladeID resistor goes across the data line for the blade to be measured and GND (or an LED neg usually )

That’s why I prefer to have the pogo-pin LEDs on it’s own data line.

The blade ID resistor goes in the blade, and it should be between the data line and GND.
However, if the blade PCB pixels are hooked up in series with the main blade, then blade ID cannot work and blade ID resistors are pointless.

I’m sorry I didn’t made myself clear: I meant the 20k resistor between 3.3V and BladeIDPin to be able to use straight resistor values on the blade PCB.
I’m doing so many things at the same time with this saber and using the same thread that I’m confusing everybody. The good thing is that I did a saber with charge port with killkey, BladeID, Blade Present, Illuminated PCB with separate data line, save_state and multiple presents, including the Battery Level. And it was my fourth install. I will have to redo two failed installs (one with the blown MOSFET and another where the wires are so thick that it won’t close).
Next project after finishing the two failed ones, will add dual buttons and OLED screen.
Then, if I can get hold of a BLE module, I will add that on top of that.
I assume by the time I’m done with all that I plan to do I assume I’ll be getting those sweets V3 so I can go straight to USB charge and save a lot of space and functionality.

Incidentally, It correctly detects the Blade with a 68k resistor, but the one without resistor it reads as a 100k! Any idea what could be happening there?