Check My Thinking - Blade Detect, Array A versus Array B Music Track?

So I have an install where I’m using Blade Detect as chassis detect, and I’ve set it up with the same number of fonts for chassis in and chassis out. But for the chassis in I want it to play one music track and for chassis out I want it to play a different music track.

Since the font ident line is repeated in the config for each state, I assumed it was simply a question of pointing the Proffie to a different track on each respective side, like this:

Preset chassisin[] = {
{ "/LS6Cave;Shared/Luke;Shared/Function;Shared/oled", "tracks/luke_music.wav",
blade style etc.

[...]

Preset chassisout[] = {
{ "/LS6Cave;Shared/Luke;Shared/Function;Shared/oled", "tracks/different_music.wav",
blade style etc.

Except it doesn’t seem to work. In both states, it plays the first version of music specified above.

I know BD is working because I get the confirmation sound and I can see that all the internal accent LEDs switch over to the opposite animation that I’ve I’ve programmed.

So my question is, is the track thing expected behaviour or is there something else I need to do to make it work?

As always, it’s not a biggie if it can’t be done, I just kind of assumed it would work.

Thoughts welcome as always and thanks in advance. :slight_smile:

Hold on - I think I’ve sorted it…

Turns out what I have as chassisin and chassisout in the extract above matters. I thought as long as the name at the top of each preset bank matched the name in the brackets in each blade array at the bottom, then it didn’t matter what you actually called them. But it turns out ProffieOS prefers the names blade and blade_in. Now inserted and now sorted.

Sorry for the false alert. :slight_smile:

It’s possible I missed something but I was fairly confident that was exactly how that worked… what do your two (prior non working and current working) blade arrays look like?

I suppose it’s also possible there’s a miscommunication here.

@profezzorn Could you comment on this?

Chassisin and chassisout were just illustrative - I actually used the words hilt and chassis.
So this was the non-working version:

//  Mode 1 - Chassis Loose:
BladeConfig blades[] = {
{ NO_BLADE,
//  Shtok Connector 1:
    SubBladeWithStride (0, 14, 2, WS281XBladePtr<16, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3>>()),
//  Shtok Connector 2:
    SubBladeWithStride (1, 15, 2, NULL),	
//  Crystal Chamber:
 	WS281XBladePtr<1, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin4>>(),
//  Accent Strips, Short, Front:
 	SubBladeReverse (0, 4, WS281XBladePtr<5, blade3Pin, Color8::GRB, PowerPINS<bladePowerPin5>>()),
//  Accent Strips, Long, Rear:	
 	WS281XBladePtr<9, blade4Pin, Color8::GRB, PowerPINS<bladePowerPin4>>(),
//  Motor:  
    SimpleBladePtr<Accessory, NoLED, NoLED, NoLED, bladePowerPin6, -1, -1, -1>(),
CONFIGARRAY(chassis) },


//  Mode 2 - Chassis Fitted in Hilt, with or without normal KR blade:
{ 0,
//  Main Blade:
 	WS281XBladePtr<122, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3>>(),
//  Dummy Blade:
    SimpleBladePtr<Accessory, NoLED, NoLED, NoLED, bladePowerPin1, -1, -1, -1>(),
//  Crystal Chamber:
 	WS281XBladePtr<1, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin4>>(),
//  Accent Strips, Short, Front:
 	SubBladeReverse (0, 4, WS281XBladePtr<5, blade3Pin, Color8::GRB, PowerPINS<bladePowerPin5>>()),
//  Accent Strips, Long, Rear:	
 	WS281XBladePtr<9, blade4Pin, Color8::GRB, PowerPINS<bladePowerPin4>>(),
//  Motor:  
    SimpleBladePtr<Accessory, NoLED, NoLED, NoLED, bladePowerPin6, -1, -1, -1>(),
CONFIGARRAY(hilt) },

};

and this is the working version:

//  Mode 1 - Chassis Loose:
BladeConfig blades[] = {
{ NO_BLADE,
//  Shtok Connector 1:
    SubBladeWithStride (0, 14, 2, WS281XBladePtr<16, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3>>()),
//  Shtok Connector 2:
    SubBladeWithStride (1, 15, 2, NULL),	
//  Crystal Chamber:
 	WS281XBladePtr<1, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin4>>(),
//  Accent Strips, Short, Front:
 	SubBladeReverse (0, 4, WS281XBladePtr<5, blade3Pin, Color8::GRB, PowerPINS<bladePowerPin5>>()),
//  Accent Strips, Long, Rear:	
 	WS281XBladePtr<9, blade4Pin, Color8::GRB, PowerPINS<bladePowerPin4>>(),
//  Motor:  
    SimpleBladePtr<Accessory, NoLED, NoLED, NoLED, bladePowerPin6, -1, -1, -1>(),
CONFIGARRAY(no_blade) },


//  Mode 2 - Chassis Fitted in Hilt, with or without normal KR blade:
{ 0,
//  Main Blade:
 	WS281XBladePtr<122, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3>>(),
//  Dummy Blade:
    SimpleBladePtr<Accessory, NoLED, NoLED, NoLED, bladePowerPin1, -1, -1, -1>(),
//  Crystal Chamber:
 	WS281XBladePtr<1, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin4>>(),
//  Accent Strips, Short, Front:
 	SubBladeReverse (0, 4, WS281XBladePtr<5, blade3Pin, Color8::GRB, PowerPINS<bladePowerPin5>>()),
//  Accent Strips, Long, Rear:	
 	WS281XBladePtr<9, blade4Pin, Color8::GRB, PowerPINS<bladePowerPin4>>(),
//  Motor:  
    SimpleBladePtr<Accessory, NoLED, NoLED, NoLED, bladePowerPin6, -1, -1, -1>(),
CONFIGARRAY(blade) },

};

And what about your Preset arrays?

This is correct. Whatever name you give the Preset[] array is what will be called with CONFIGARRAY(). Should work as expected.

Also the alternate music track should also work as you had it.

I have yet to see a situation require something different than simply repeating the same BladeConfig blades setup. If a blade doesn’t exist but you declare one, (like because you removed the chassis and now there’s actually no main blade, but you leave main blade in there) it won’t matter.

In the config that didn’t work, it was:
Preset chassis = {

and
Preset hilt = {

In the config that worked, it was:
Preset no_blade = {

and
Preset blade = {

Either should work fine provided you have the exact same array name in CONFIGARRAY in the BladeConfig.

This will stop working if you use edit mode or the ProffieOS Workbench, because it will create a presets.ini file and use that, regardless if you have blade or no-blade presets. The solution is to specify a save directory in the blades array for at least one of the two entries so that they use separate save files. That also means that edit mode changes done with the blade in will not affect what happens when the blade is not inserted of course…

The save directory goes after the CONFIGARRAY, more information here:

Interesting.
It’s a 3.9 board and OS7.14 if that makes a difference, and it uses a modified SA22C button prop. I don’t use Edit Mode, but I do generally upload with Serial + WebUSB and I have SAVE_STATE in the defines. Under this system, I’ve observed that ProffieOS will generate a global.ini save file and a curstate.ini and curstate.tmp file, but it doesn’t usually generate a preset file. The last preset is stored in curstate.

I deliberately avoided different save files for each array because I want it to work such that whatever preset you’re on with chassis out, it will stay on that preset with chassis in.

I just tried using WebUSB with this hilt and it didn’t make a preset file when I made a change.

I guess all I can tell you is that using blade/no_blade to describe the arrays works as intended, but changing those names to hilt/chassis made it switch blade styles but not font files.

If it helps, here’s the working config. (It’s a long one! 67 fonts, times two! LOL!). The only difference between this and the one that didn’t switch font folders was the array names, i.e. four words of code in total.

It will if you use the “edit” button and change something in the workbench.

1 Like