Sometimes automatic switching between Presets, using Blade ID or Blade Detection and SAVE_STATE define, doesn’t work properly

I noticed it long time ago but writing only now about this issue:

so I have define SAVE_STATE in my config and it works perfectly for some time after first code upload, but as I use the saber more, switching presets, changing volume, colors, changing Presets by using Blade ID or Blade Detection etc., at some moment it gets messed up and doesn’t switch to a proper Preset anymore when I insert the blade or remove it. Deleting the saved temporary files from SD card root solves it, it resets to the default state and works as normal. So looks like something with the SAVE_STATE thing.

So it sounds like disconnecting/reconnecting power doesn’t help, right?
Which file(s) do you actually delete to fix it?
What’s actually in that file when it doesn’t work?

Correct, rebooting the board by power reconnecting doesn’t help, only deleting the temporary save files from SD:


deleting just the “presets.ini” and “presets.tmp” fixes it.

also looks like volume change doesn’t save after board power reboot… color change saves.

Some changes (like volume) don’t save until the blade is retracted and all sound has stopped.
This is because saving while things are on can cause minor audio glitches. Is that what you mean by “doesn’t save”, or is it something else?

When your saber is exhibiting these problems, could you just attach all the ini and tmp files to this thread so I can check what’s in them?

1 Like

So volume level doesn’t save if I’m using automatic presets switching by Blade Detection or Blade ID. I set the volume to 3000, turn the blade OFF, remove the battery, insert the battery again, turn the saber ON and volume is back to its default 500…
Blade styles of my “NO_BLADE” config array stop working when I’m changing the color wheel in my other “BLADE” config array presets and the temporary “presets” files are created on SD. Deleting those temporary files solves the issue.

global.ini (48 Bytes)
curstate.ini (46 Bytes)
presets.ini (2.9 KB)

.tmp files are not supported for upload here…

I’ve added .tmp files to the set of supported upload extensions.
I’ll look into the preset switching by blade detect, maybe there is a trysave missing in there somewhere.
What version of ProffieOS are you using? Do you have any modified files?

I’m using 5.7. Yes, I modified battery_monitor.h to adjust better voltage indication for the OLED display, and I also changed something you told me to change when I had issues with motion activation timeout in my config not working.

Could you attach the tmp files too? (should work now)

I looked at the ini files that you attached earlier, and I didn’t see anything wrong with them. Was the saber really having a problem with starting up properly with these files?

Everything works until I change colors with the blade attached, and then “presets.ini” is created on SD. After that when I remove the blade and it switches to the NO_BLADE Preset, non of the blade styles work, nothing lights up, but sound plays.

Can you post your config file?

When I’m adding .tmp files it uploads same .ini file.

Here is a video describing the issue:

Config file:
jedikiller_proffie_config.h (19.6 KB)

Since you have multiple different preset arrays, you need to set up separate save directories for them. Basically, create two directories on your sd card: blade and noblade then in your config, add the save directory after the CONFIGARRAY(), like this:

 { 700,
     WS281XBladePtr<133, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),
     WS281XBladePtr<5, blade4Pin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >(),                  
     WS281XBladePtr<1, blade2Pin, Color8::GRB, PowerPINS<bladePowerPin4> >(),
     WS281XBladePtr<1, blade3Pin, Color8::GRB, PowerPINS<bladePowerPin5> >(), 
     CONFIGARRAY(blade), "blade" },

By doing this, it will use different preset.ini files for the “blade” and “noblade” cases, which should hopefully make things work better.

1 Like

Hmm, looks like my Arduino doesn’t compile anything at all and not even giving any error descriptions…

Weird. Hope a reboot or something fixes it.

Ok, works now, had to restart my PC lol. That works now properly, nice! But volume changing still doesn’t save…

Maybe if you insert



(May be a different line number in your prop_base.h)

1 Like

Did anybody try this?
Did it work?

That change for the volume isn’t needed, all works as it should now, no idea why it didn’t recently…

Thanks for testing, let me know if it starts happening again.

1 Like