Blade ID not playing font ident when it switches. Should it?

I’ve set up a blade plug charger and used BladeID so the hilt can differentiate between charger and no blade/normal blade. I’ve set it to jump to the charge preset automatically when the charger plug is inserted.

But although it skips to the preset successfully, it doesn’t play the charge preset font ident wav.

My question is should it?

I’m sure when I’ve done it in the past, it has, but I think I was also using Blade Detect in those builds - whereas this current hilt uses just Blade ID (i.e. no extra wiring, just a 22k-ohm resistor in the blade plug charger telling the hilt it’s not a normal blade).

Just wondering if this is expected behaviour? The relevant bit of the config is below:

{ "FontStd2/Battery;Shared/Random;Shared/Function", "tracks/rey.wav",
//  Main Blade:
&style_charging,

//  Crystal Chamber:
&style_charging,

//  Plasma gate 1:
&style_charging,

//  Plasma gate 2:
&style_charging,

//  Emitter Back:
&style_charging,

//  5mm Red LED:
StylePtr<Layers<Layers<Rgb<180,180,180>,BlinkingL<Black,Int<750>,Int<500>>>,InOutHelperL<InOutFuncX<Int<300>,Int<800>>,Blinking<Black,Rgb<180,180,180>,2900,500>>>>(),

//  Proffie Micro LED:
StylePtr<Layers<Layers<Black,BlinkingL<Rgb<140,140,140>,Int<700>,Int<500>>>,InOutHelperL<InOutFuncX<Int<300>,Int<800>>,Blinking<Black,Rgb<140,140,140>,1500,500>>>>(),

//  Duel Strips:
&style_charging,
"battery"},

};

//  *************************

Preset charging[] = {

   { "FontStd2/Charger;Shared/Random;Shared/Function", "tracks/endtitle.wav",
//  Main Blade:
ChargingStylePtr<InOutHelper<Black,300,300,Pulsing<Black,Black,3000>>>(),

//  Crystal Chamber:
ChargingStylePtr<Blinking<Red,Blue,2600,500>>(),

//  Plasma gate 1:
ChargingStylePtr<Black>(),

//  Plasma gate 2:
ChargingStylePtr<Black>(),

//  Emitter Back:
ChargingStylePtr<Black>(),

//  5mm Red LED:
ChargingStylePtr<Black>(),

//  Proffie Micro LED:
ChargingStylePtr<Black>(),

//  Duel Strips:
ChargingStylePtr<Black>(),
"charging"},

};



//  *************************

template<int milliohms = 100000>
struct RedLED {
  static constexpr float MaxAmps = 0.02;
  static constexpr float MaxVolts = 2.1;
  static constexpr float P2Amps = 0.01;
  static constexpr float P2Volts = 1.8;
  static constexpr float R = milliohms / 1000.0;
  // LED color
  static const int Red = 255;
  static const int Green = 0;
  static const int Blue = 0;
};

//  3mm Blue
template<int milliohms = 47000>
struct BlueLED {
  static constexpr float MaxAmps = 0.02;
  static constexpr float MaxVolts = 3.1;
  static constexpr float P2Amps = 0.01;
  static constexpr float P2Volts = 3.05;
  static constexpr float R = milliohms / 1000.0;
  // LED color
  static const int Red = 255;
  static const int Green = 255;
  static const int Blue = 255;
};



//  *************************************************************************
//  KR V2 pixel strip blade lengths:
//	88cm = 132 pixels.
//  82cm = 122 pixels.
//  72cm = 108 pixels.


BladeConfig blades[] = {
  { 84,
//  Main Blade:
    WS281XBladePtr<132, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3>>(),
//  Crystal Chamber:
    WS281XBladePtr<1, blade4Pin, Color8::RGB, PowerPINS<bladePowerPin4>>(),
//  Plasma gate 1:
    SubBlade (0, 0, WS281XBladePtr<3, blade3Pin, Color8::GRB, PowerPINS<bladePowerPin4>>()),
//  Plasma gate 2:
    SubBlade(1, 1, NULL), 
//  Emitter Back:
    SubBlade(2, 2, NULL), 
//  5mm Red LED:
    SimpleBladePtr<RedLED<100000>, NoLED, NoLED, NoLED, bladePowerPin6, -1, -1, -1>(), 
//  Proffie Micro LED:
    SimpleBladePtr<BlueLED<47000>, NoLED, NoLED, NoLED, bladePowerPin1, -1, -1, -1>(),
//  Duel Strips:
    SubBladeReverse (0, 3, WS281XBladePtr<4, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin5>>()),
CONFIGARRAY(presets) },


//  Use for blade plug charging.
//  Main blade must be data 1.
  { 53,
//  Main Blade:
    WS281XBladePtr<132, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3>>(),
//  Crystal Chamber:
    WS281XBladePtr<1, blade4Pin, Color8::RGB, PowerPINS<bladePowerPin4>>(),
//  Plasma gate 1:
    SubBlade (0, 0, WS281XBladePtr<3, blade3Pin, Color8::GRB, PowerPINS<bladePowerPin4>>()),
//  Plasma gate 2:
    SubBlade(1, 1, NULL), 
//  Emitter Back:
    SubBlade(2, 2, NULL), 
//  5mm Red LED:
    SimpleBladePtr<RedLED<100000>, NoLED, NoLED, NoLED, bladePowerPin6, -1, -1, -1>(), 
//  Proffie Micro LED:
    SimpleBladePtr<BlueLED<47000>, NoLED, NoLED, NoLED, bladePowerPin1, -1, -1, -1>(),
//  Duel Strips:
    SubBladeReverse (0, 3, WS281XBladePtr<4, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin5>>()),
CONFIGARRAY(charging) },


};
#endif

I think you need to specify a save directory for one or both of your blades[] entries.
Otherwise they are going to save the presets from one entry, and re-use it in the other, which is probably not what you want.
Also, make sure you’re using ProffieOS 7.13, since it has a bugfix for save directories.

Thanks Prof.

Yea, I was using 7.13, and have just added the save files - which all seems to work, but still no font ident when I insert the charge plug. :confused: It’s definitely switching to the correct preset/font though, because I added a unique OFF effect to the crystal to check it. Just seems odd to go to a font without playing the ident. But it’s not a deal breaker by any means. :slight_smile:

Post your updated config. (with save directories)

Unfortunately, the saved presets with say something like: “preset 1 4”, which refers to a preset in the preset array, so styles may switch even if font directories doesn’t. You need to use “pwd” in the serial monitor to see what font directory is actually in use.

All I did was add a save file to each side, then add empty folders to the SD card with corresponding names. Here’s the Blade Array:


BladeConfig blades[] = {
  { 84,
//  Main Blade:
    WS281XBladePtr<132, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3>>(),
//  Crystal Chamber:
    WS281XBladePtr<1, blade4Pin, Color8::RGB, PowerPINS<bladePowerPin4>>(),
//  Plasma gate 1:
    SubBlade (0, 0, WS281XBladePtr<3, blade3Pin, Color8::GRB, PowerPINS<bladePowerPin4>>()),
//  Plasma gate 2:
    SubBlade(1, 1, NULL), 
//  Emitter Back:
    SubBlade(2, 2, NULL), 
//  5mm Red LED:
    SimpleBladePtr<RedLED<100000>, NoLED, NoLED, NoLED, bladePowerPin6, -1, -1, -1>(), 
//  Proffie Micro LED:
    SimpleBladePtr<BlueLED<47000>, NoLED, NoLED, NoLED, bladePowerPin1, -1, -1, -1>(),
//  Duel Strips:
    SubBladeReverse (0, 3, WS281XBladePtr<4, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin5>>()),
CONFIGARRAY(presets), "bldesave"}  , 


//  Use for blade plug charging.
//  Main blade must be data 1.
  { 53,
//  Main Blade:
    WS281XBladePtr<132, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3>>(),
//  Crystal Chamber:
    WS281XBladePtr<1, blade4Pin, Color8::RGB, PowerPINS<bladePowerPin4>>(),
//  Plasma gate 1:
    SubBlade (0, 0, WS281XBladePtr<3, blade3Pin, Color8::GRB, PowerPINS<bladePowerPin4>>()),
//  Plasma gate 2:
    SubBlade(1, 1, NULL), 
//  Emitter Back:
    SubBlade(2, 2, NULL), 
//  5mm Red LED:
    SimpleBladePtr<RedLED<100000>, NoLED, NoLED, NoLED, bladePowerPin6, -1, -1, -1>(), 
//  Proffie Micro LED:
    SimpleBladePtr<BlueLED<47000>, NoLED, NoLED, NoLED, bladePowerPin1, -1, -1, -1>(),
//  Duel Strips:
    SubBladeReverse (0, 3, WS281XBladePtr<4, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin5>>()),
CONFIGARRAY(charging), "chgsave"}


};
#endif

I also tried hooking up serial monitor, and it does indeed seem to be switching font as well as preset. Here’s the output. You can also see the BladeID scans working, as well as the points at which I added the charge plug and then removed it again:

20:40:15.620 -> ID: 83.50
20:40:16.615 -> ID: 83.10
20:40:17.609 -> ID: 82.70
20:40:18.602 -> ID: 83.60
20:40:19.628 -> ID: 52.30
20:40:19.628 -> ID: 54.00
20:40:19.628 -> blade = 1
20:40:19.628 -> WS2811 Blade with 132 leds.
20:40:19.628 -> WS2811 Blade with 1 leds.
20:40:19.628 -> WS2811 Blade with 3 leds.
20:40:19.628 -> Simple Blade
20:40:19.628 -> Simple Blade
20:40:19.628 -> WS2811 Blade with 4 leds.
20:40:19.661 -> Style RAM = 8
20:40:19.661 -> Style RAM = 8
20:40:19.661 -> Style RAM = 8
20:40:19.661 -> Style RAM = 8
20:40:19.661 -> Style RAM = 8
20:40:19.661 -> Style RAM = 8
20:40:19.661 -> Style RAM = 8
20:40:19.661 -> Style RAM = 8
20:40:19.661 -> Scanning sound font: FontStd2/Charger done
20:40:19.661 -> Scanning sound font: Shared/Random done
20:40:19.694 -> Scanning sound font: Shared/Function done
20:40:19.694 -> Activating polyphonic font.
20:40:19.728 -> Activating SmoothSwing V2
20:40:19.728 -> Accent Swings Enabled.
20:40:19.728 -> Polyphonic swings: 2
20:40:19.728 -> Monophonic swings: 0
20:40:19.728 -> Accent Slashes NOT Detected: 
20:40:20.622 -> ID: 53.90
20:40:20.688 -> Unmounting SD Card.
20:40:21.615 -> ID: 54.10
20:40:22.608 -> ID: 53.60
20:40:23.602 -> ID: 53.90
20:40:24.628 -> ID: 53.90
20:40:25.621 -> ID: 53.80
20:40:26.581 -> Battery voltage: 0.22
20:40:26.614 -> ID: 53.90
20:40:27.607 -> ID: 53.80
20:40:28.634 -> ID: 53.90
20:40:29.627 -> ID: 53.90
20:40:30.619 -> ID: 53.70
20:40:31.612 -> ID: 53.80
20:40:32.638 -> ID: 53.40
20:40:33.631 -> ID: 53.90
20:40:33.963 -> FontStd2/Charger
20:40:33.963 -> Shared/Random
20:40:33.963 -> Shared/Function
20:40:34.625 -> ID: 53.70
20:40:35.634 -> ID: 53.80
20:40:36.630 -> ID: 53.90
20:40:37.645 -> ID: 53.90
20:40:38.640 -> ID: 53.80
20:40:39.653 -> ID: 83.30
20:40:39.653 -> ID: 83.70
20:40:39.653 -> blade = 0
20:40:39.653 -> WS2811 Blade with 132 leds.
20:40:39.653 -> WS2811 Blade with 1 leds.
20:40:39.653 -> WS2811 Blade with 3 leds.
20:40:39.653 -> Simple Blade
20:40:39.691 -> Simple Blade
20:40:39.691 -> WS2811 Blade with 4 leds.
20:40:39.691 -> Style RAM = 600
20:40:39.691 -> Style RAM = 528
20:40:39.691 -> Style RAM = 88
20:40:39.691 -> Style RAM = 196
20:40:39.691 -> Style RAM = 196
20:40:39.691 -> Style RAM = 44
20:40:39.691 -> Style RAM = 44
20:40:39.691 -> Style RAM = 312
20:40:39.691 -> Scanning sound font: FontPrem/FthrANH done
20:40:39.794 -> Scanning sound font: Shared/Vader done
20:40:39.831 -> Scanning sound font: Shared/Function done
20:40:39.870 -> Activating polyphonic font.
20:40:39.907 -> Activating SmoothSwing V2
20:40:39.907 -> Accent Swings Enabled.
20:40:39.907 -> Polyphonic swings: 16
20:40:39.907 -> Monophonic swings: 0
20:40:39.907 -> Accent Slashes NOT Detected: 
20:40:40.658 -> ID: 83.00
20:40:40.891 -> Unmounting SD Card.
20:40:41.647 -> ID: 83.40
20:40:42.657 -> ID: 83.30
20:40:43.657 -> ID: 83.00
20:40:44.657 -> ID: 79.60

It’s a “save file directory”, since you just said “save file”, I wasn’t sure what you did.

Anyways, that said, the blade in/out event will never play the “font” sound. (Although maybe it should fall back on that…) When you take the blade out it will play the “bladeout” effect, and when you put the blade in, it will play “bladein”, and if that doesn’t exist, it will play “boot”.

I’m guessing this refers to Blade Detect, not BladeID?
I’m only using BladeID, and although all of those files exist (bladein, bladeout, boot etc.) and are referred to in the preset, none of them of are playing when I fit or remove the charging plug.

Full config in case it helps:

Good point.
Ideally we want bladein/bladeout to work the same whether you use blade detect or blade id I think, although that is not how it works now.

My thinking is that we should:

  1. Make a define that specifies a range of blade ID values that means that no blade is present.
  2. Make the blade id class return NO_BLADE when a value is detected in that range.
  3. Make the blade ID polling code run the blade-in/out when going to/from NO_BLADE
  4. Make the blade ID polling code play the font sound when going from one entry to another, but NO_BLADE didn’t change

There is a pull request on github that does some of this already.

Aha, yes, just seen it.

Yes, I concur on all points, but at least I now know that the current behaviour is correct and isn’t going wrong due to something I’ve done.

I guess the only thing that occurs based on my very limited knowledge is that I’m not sure what values would be included in your proposed define. I ran BladeID to get the numbers needed for a normal blade, no blade and the charging plug and got around 84, 82 and 53 respectively. The numbers seem a bit arbitrary, although they do work.

I just had another thought which might be one to think about for a future OS perhaps - since the idea of BladeID is for the hilt to identify different types of blade, including blades of different lengths, it might be nice for each blade array to have its own wav file which it plays upon fitting the different blade. So you could make simple announcements saying, for example, “33 inch blade recognized.” And you could just specify the filename somewhere in the blade array - maybe the array name (no_blade, blade etc.) could double up as the wav filename, and if no file is specified, it reverts to playing bladein etc.

Just an idea - not trying to create mountains of work for anyone, but as I say, maybe one to think about for a future OS.
:slight_smile:

Isn’t this what bladein.wav is for?

If you turn on #define SPEAK_BLADE_ID it tells you the measured resistance.
As the owner, you would know which blade is which even if you need a cross reference cheat sheet.
Close enough?

1 Like

Yes it is, but it doesn’t differentiate between blade lengths.

My thinking is that you’d have, say, ten fonts/presets, then you would simply duplicate them in the config (almost no extra memory used), but have one side set for a short blade and the other for a long blade. If you left the default save file system, you could switch to, say, font four with your long blade, swap the blade for a short blade, and the Proffie would flip over to font four of the short blade array. Once programmed, it means stuff like tip drag would work correctly for either blade without needing to do anything but fit the blade, and the hilt would confirm which blade is fitted using your custom bladin.wav for that array.

As it is, you can either have the bladein.wav in your common folder, in which case it’s global, or you can have it per font. But either way, you can’t customize it to have a different announcement depending on which blade you’ve fitted, unless, I guess, you duplicate and rename all the font folders on the SD card too.

As I write this, I have a hunch you’re going to explain, a) why this is a bad idea, and b) provide a far simpler and more elegant solution that already exists to achieve the same thing. LOL! :smile:

LOL! Thanks Brian - yes, that is indeed pretty close!
I didn’t know about the speak blade ID define. So I’m guessing it simply reads the number in the blade array (in my case 84 or 53). Good to know. I’ll add it to this latest hilt and have a play. :slight_smile:

Sure you can. Just add a pre-font folder to the font search path for the different presets arrays, something like
{ "bladein32/font/common", .......
and stick your custom spoken length bladein.wav in there.

1 Like

It reads out the measured resistance, which is likely slightly off from the exact resistance as it varies a bit from read to read.
My other reply above is what you want to do.

1 Like

I knew you guys would have something super-simple to make this happen! That completely did not occur to me, but you’re right, of course! Great solution!

However the bad news is it takes us snakes and ladders style back to the original post which is that the bladein wav only seems to be triggered by blade detect, not blade id. :confused:

He giveth, and he taketh away. LOL! :sweat_smile:


:wink:

1 Like

That’s in the works on Github as we speak .

3 Likes