Blade Detect Fails Upon Color Change or Edit

As requested by @profezzorn I am opening this up as a topic.

I thought this had been resolved but it’s still happening on multiple hilts that have Blade Detect active. Of note this is not solely a specific manufacturer or installer-programer issue.

Steps taken to repeat the issue for testing:

Flash the board with original defines as well as updated defines, shown in the config below. Turn on kill-switch or remove kill-key if equipped. Install blade, verify bladein plays. Remove blade, verify bladeout plays. Install blade and tighten grub/blade screw. Make sure blade is properly installed. Ignite blade. Swing saber around, play with it for a bit and leave it on. Enter color change and scroll to a different blade color. Confirm blade color. Play with saber some more. Turn blade off. Remove blade. Verify bladeout does not play and instead a “beep” is heard. Cycle the kill-switch or kill-key to see if a power cycle will reset things. It does not. Pull SD Card, delete contents, re-format and reload files to stop the error and proceed with more testing. As video demonstrates it’s very repeatable. Multiple blade defines tried out and no full solution found yet.

Notes: Changing the blade defines to include nbsave does lessen the likelihood of this occurrence. If you change the initial steps above to:

DO NOT install blade. Turn on kill-switch or remove kill-key if equipped. WITH THE BLADE NOT INSTALLED ignite the saber to activate the No_Blade preset and verify saber is indeed on. (*This is where having a No_Blade font pack helps.) Swing the saber for a second and then turn it off. Repeat this two more times. Now after the third ignition and shut down install the blade. Verify bladein plays. Remove blade and verify bladeout plays. Install blade and tighten grub/blade screw. Make sure blade is properly installed. Ignite blade. Swing saber around, play with it for a bit and leave it on. Enter color change and scroll to a different blade color. Confirm blade color. Play with saber some more. Turn blade off. Remove blade. Verify bladeout plays. Engage kill-switch or kill-key to fully power board down (if equipped). Connect board and look at SD card contents. Verify the board wrote to the SD by finding the initial global.ini as well as nbsave folder with its related curestate files in there.

*The concern being why this last bit of steps is necessary to make sure that No Blade works? A common user may well immediately ignite the saber and go right into color change and not understand why the “beep” happens. Obviously nbsave is a step in the right direction because once the board sees no blade three times in a row as an initializer and writes the global and nbsave curestate files it stops, unless a user goes in and inadvertently removes the written files in favor of just the basics like common, fonts including a specific font pack for No Blade, tracks.

Video demonstrating the error.

Config example.

What does the serial monitor say at this point?

If you do not have an “nbsave” directory, then making any sort of modifications will create a “presets.ini” file based on your Survivor preset, and that preset will also be used for the “no blade” case, since they use the same save directory. It’s not weird that it doesn’t work without “nbsave”. I think it should work with nbsave though…

One more question: Are you using the config file exactly as written, or do you have more presets when you try this?

Serial Monitor says similar to what it said in the reports I sent previously, file not found. Same with other report copies. When the error happens they just say file not found.

There are more presets both I and others are using while testing this. I have updated the paste to reflect that. Just scroll to the second config listed.

link?

I’d like to know more than just the error message itself though.
I need to see the lines that lead up to that error.
Also, the output of the effect and pwd commands would be helpful.

I didn’t keep the data after I sent it. Let me get a fresh readout.

Note this also happens if a user does a blade length change before the global and nbsave files are written.

Here ya go.

Welcome to ProffieOS $Id: ce12a06a1e236b5101ec60c950530a9a4719a74d $
For available serial commands, see:
https://pod.hubbe.net/tools/serial-monitor-commands.html
EVENT: Select-On millis=15282
BLADE ID: 1007.00
Blade Detected
blade = 1
WS2811 Blade with 108 leds.
Simple Blade
Style RAM = 1164
Style RAM = 8
Scanning sound font: SurvivorBlue
 done
Scanning sound font: common
 done
Activating polyphonic font.
Activating SmoothSwing V2
Accent Swings Enabled.
Polyphonic swings: 16
Monophonic swings: 0
Accent Slashes NOT Detected: 
unit = 0 vol = 0.50, Playing SurvivorBlue/bladein.wav
channels: 1 rate: 44100 bits: 16
Amplifier off.
EVENT: Select-Off millis=16628
BLADE ID: 657.00
NO Blade Detected
blade = 0
WS2811 Blade with 108 leds.
Simple Blade
Style RAM = 8
Style RAM = 8
Scanning sound font: No_Blade
 done
Scanning sound font: common
 done
Activating polyphonic font.
unit = 0 vol = 0.50, Playing No_Blade/bladeout.wav
channels: 1 rate: 44100 bits: 16
Amplifier off.
EVENT: Select-On millis=17991
BLADE ID: 971.00
Blade Detected
blade = 1
WS2811 Blade with 108 leds.
Simple Blade
Style RAM = 1164
Style RAM = 8
Scanning sound font: SurvivorBlue
 done
Scanning sound font: common
 done
Activating polyphonic font.
Activating SmoothSwing V2
Accent Swings Enabled.
Polyphonic swings: 16
Monophonic swings: 0
Accent Slashes NOT Detected: 
unit = 0 vol = 0.50, Playing SurvivorBlue/bladein.wav
channels: 1 rate: 44100 bits: 16
Amplifier off.
Battery voltage: 4.04
Unmounting SD Card.
EVENT: Power-Pressed#1 millis=21829
EVENT: Power-Pressed millis=21829
EVENT: Power-Released#1 millis=22032
EVENT: Power-Released millis=22032
EVENT: Power-Shortclick#1 millis=22032
EVENT: Power-Shortclick millis=22032
Ignition.
unit = 0 vol = 0.00, Playing SurvivorBlue/hum.wav
channels: 1 rate: 44100 bits: 16
unit = 1 vol = 0.50, Playing SurvivorBlue/out/out2.wav
channels: 1 rate: 44100 bits: 16
humstart: 1700
unit = 2 vol = 0.00, Playing SurvivorBlue/swingl/swingl1.wav
channels: 1 rate: 44100 bits: 16
unit = 3 vol = 0.00, Playing SurvivorBlue/swingh/swingh1.wav
channels: 1 rate: 44100 bits: 16
EVENT: Aux-Pressed#1 ON millis=25074
EVENT: Aux-Pressed ON millis=25074
EVENT: Aux-Held#1 ON millis=25376
EVENT: Aux-Held ON millis=25376
EVENT: Power-Pressed#1 mods Aux ON millis=25440
EVENT: Power-Pressed mods Aux ON millis=25441
EVENT: Power-Released#1 mods PowerAux ON millis=25607
EVENT: Power-Released mods PowerAux ON millis=25607
EVENT: Power-Shortclick#1 mods Aux ON millis=25607
EVENT: Power-Shortclick mods Aux ON millis=25607
Style RAM = 1164
Style RAM = 8
Style RAM = 1164
Style RAM = 1164
unit = 1 vol = 0.50, Playing SurvivorBlue/ccbegin.wav
channels: 1 rate: 44100 bits: 16
EVENT: Aux-Released#1 ON millis=25669
EVENT: Aux-Released ON millis=25669
EVENT: ?48 ON millis=26887
unit = 1 vol = 0.50, Playing SurvivorBlue/ccchange.wav
channels: 1 rate: 44100 bits: 16
EVENT MENU TURN LEFT
EVENT: Power-Pressed#1 ON millis=27521
EVENT: Power-Pressed ON millis=27521
Playing mzoom.wav, channels: 1 rate: 44100 bits: 16
EVENT: Power-Released#1 ON millis=27720
EVENT: Power-Released ON millis=27721
unit = 4 vol = 0.50, Playing SurvivorBlue/ccend.wav
channels: 1 rate: 44100 bits: 16
NewColor(1,1)
Style RAM = 1164
Style RAM = 1164
Style RAM = 1164
Style RAM = 8
Style RAM = 8
Style RAM = 8
Creating file presets.tmp iteration = 2
Style RAM = 1164
Style RAM = 8
Audio underflows: 4746
Playing SurvivorBlue/swingl/swingl1.wav
channels: 1 rate: 44100 bits: 16
Playing SurvivorBlue/swingh/swingh1.wav
channels: 1 rate: 44100 bits: 16
EVENT: Aux-Pressed#1 ON millis=29844
EVENT: Aux-Pressed ON millis=29845
EVENT: Aux-Released#1 ON millis=29976
EVENT: Aux-Released ON millis=29976
EVENT: Aux-Shortclick#1 ON millis=29976
EVENT: Aux-Shortclick ON millis=29976
unit = 4 vol = 0.50, Playing SurvivorBlue/blst/blst6.wav
channels: 1 rate: 44100 bits: 16
EVENT: Power-Pressed#1 ON millis=31043
EVENT: Power-Pressed ON millis=31043
EVENT: Power-Released#1 ON millis=31184
EVENT: Power-Released ON millis=31184
EVENT: Power-Shortclick#1 ON millis=31184
unit = 1 vol = 0.50, Playing SurvivorBlue/in/in1.wav
channels: 1 rate: 44100 bits: 16
No sounds found: pstoff
Amplifier off.
Unmounting SD Card.
EVENT: Select-Off millis=33743
BLADE ID: 625.00
NO Blade Detected
blade = 0
WS2811 Blade with 108 leds.
Simple Blade
Scanning sound font: 
 NOT FOUND!
Activating polyphonic font.
Amplifier off.
Unmounting SD Card.
``

For comparative purposes here’s when the board has been allowed to recognize no blade and has had time to create the global.ini and nbsave folder with the curestate.ini and curestate.tmp in it.

Welcome to ProffieOS $Id: ce12a06a1e236b5101ec60c950530a9a4719a74d $
For available serial commands, see:
https://pod.hubbe.net/tools/serial-monitor-commands.html
EVENT: ?48 millis=3267
EVENT MENU TURN LEFT
EVENT: Aux-Pressed#1 millis=3658
EVENT: Aux-Pressed millis=3658
EVENT: Aux-Released#1 millis=3769
EVENT: Aux-Released millis=3769
EVENT: Aux-Shortclick#1 millis=3769
EVENT: Aux-Shortclick millis=3769
Saving Current Preset
Style RAM = 8
Style RAM = 8
Scanning sound font: No_Blade
 done
Scanning sound font: common
 done
Activating polyphonic font.
DISPLAY: no blade
unit = 0 vol = 0.50, Playing No_Blade/font.wav
channels: 1 rate: 44100 bits: 16
Amplifier off.
EVENT: Power-Pressed#1 millis=5094
EVENT: Power-Pressed millis=5094
EVENT: Power-Released#1 millis=5284
EVENT: Power-Released millis=5284
EVENT: Power-Shortclick#1 millis=5284
EVENT: Power-Shortclick millis=5284
Unmounting SD Card.
EVENT: Power-Pressed#1 millis=8098
EVENT: Power-Pressed millis=8098
EVENT: Power-Released#1 millis=8281
EVENT: Power-Released millis=8281
EVENT: Power-Shortclick#1 millis=8281
EVENT: Power-Shortclick millis=8281
EVENT: Power-Pressed#1 millis=9976
EVENT: Power-Pressed millis=9976
EVENT: Power-Released#1 millis=10190
EVENT: Power-Released millis=10190
EVENT: Power-Shortclick#1 millis=10190
EVENT: Power-Shortclick millis=10190
EVENT: Aux-Pressed#1 millis=11652
EVENT: Aux-Pressed millis=11652
EVENT: Aux-Released#1 millis=11828
EVENT: Aux-Released millis=11828
EVENT: Aux-Shortclick#1 millis=11828
EVENT: Aux-Shortclick millis=11828
Saving Current Preset
Style RAM = 8
Style RAM = 8
Scanning sound font: No_Blade
 done
Scanning sound font: common
 done
Activating polyphonic font.
DISPLAY: no blade
unit = 0 vol = 0.50, Playing No_Blade/font.wav
channels: 1 rate: 44100 bits: 16
EVENT: Power-Pressed#1 millis=12490
EVENT: Power-Pressed millis=12490
EVENT: Power-Released#1 millis=12780
EVENT: Power-Released millis=12780
EVENT: Power-Shortclick#1 millis=12780
EVENT: Power-Shortclick millis=12781
Amplifier off.
Unmounting SD Card.
EVENT: Select-On millis=15173
BLADE ID: 1008.00
Blade Detected
blade = 1
WS2811 Blade with 108 leds.
Simple Blade
Style RAM = 1164
Style RAM = 8
Scanning sound font: SurvivorBlue
 done
Scanning sound font: common
 done
Activating polyphonic font.
Activating SmoothSwing V2
Accent Swings Enabled.
Polyphonic swings: 16
Monophonic swings: 0
Accent Slashes NOT Detected: 
unit = 0 vol = 0.50, Playing SurvivorBlue/bladein.wav
channels: 1 rate: 44100 bits: 16
EVENT: Select-Off millis=16289
BLADE ID: 740.00
NO Blade Detected
blade = 0
WS2811 Blade with 108 leds.
Simple Blade
Style RAM = 8
Style RAM = 8
Scanning sound font: No_Blade
 done
Scanning sound font: common
 done
Activating polyphonic font.
unit = 0 vol = 0.50, Playing No_Blade/bladeout.wav
channels: 1 rate: 44100 bits: 16
Audio underflows: 7
Amplifier off.
EVENT: Select-On millis=17191
BLADE ID: 967.00
Blade Detected
blade = 1
WS2811 Blade with 108 leds.
Simple Blade
Style RAM = 1164
Style RAM = 8
Scanning sound font: SurvivorBlue
 done
Scanning sound font: common
 done
Activating polyphonic font.
Activating SmoothSwing V2
Accent Swings Enabled.
Polyphonic swings: 16
Monophonic swings: 0
Accent Slashes NOT Detected: 
unit = 0 vol = 0.50, Playing SurvivorBlue/bladein.wav
channels: 1 rate: 44100 bits: 16
Amplifier off.
Unmounting SD Card.
EVENT: Power-Pressed#1 millis=19671
EVENT: Power-Pressed millis=19671
EVENT: Power-Released#1 millis=19881
EVENT: Power-Released millis=19881
EVENT: Power-Shortclick#1 millis=19881
EVENT: Power-Shortclick millis=19881
Ignition.
unit = 0 vol = 0.00, Playing SurvivorBlue/hum.wav
channels: 1 rate: 44100 bits: 16
unit = 1 vol = 0.50, Playing SurvivorBlue/out/out4.wav
channels: 1 rate: 44100 bits: 16
humstart: 1700
unit = 2 vol = 0.00, Playing SurvivorBlue/swingl/swingl1.wav
channels: 1 rate: 44100 bits: 16
unit = 3 vol = 0.00, Playing SurvivorBlue/swingh/swingh1.wav
channels: 1 rate: 44100 bits: 16
Battery voltage: 4.00
EVENT: Aux-Pressed#1 ON millis=21582
EVENT: Aux-Pressed ON millis=21582
EVENT: Power-Pressed#1 mods Aux ON millis=21851
EVENT: Power-Pressed mods Aux ON millis=21852
EVENT: Aux-Held#1 mods PowerAux ON millis=21884
EVENT: Aux-Held mods PowerAux ON millis=21884
EVENT: Power-Released#1 mods PowerAux ON millis=22033
EVENT: Power-Released mods PowerAux ON millis=22033
EVENT: Power-Shortclick#1 mods Aux ON millis=22033
EVENT: Power-Shortclick mods Aux ON millis=22033
Style RAM = 1164
Style RAM = 8
Style RAM = 1164
Style RAM = 1164
unit = 1 vol = 0.50, Playing SurvivorBlue/ccbegin.wav
channels: 1 rate: 44100 bits: 16
EVENT: Aux-Released#1 ON millis=22048
EVENT: Aux-Released ON millis=22048
EVENT: ?48 ON millis=22923
unit = 1 vol = 0.50, Playing SurvivorBlue/ccchange.wav
channels: 1 rate: 44100 bits: 16
EVENT MENU TURN LEFT
EVENT: Power-Pressed#1 ON millis=23325
EVENT: Power-Pressed ON millis=23325
Playing mzoom.wav, channels: 1 rate: 44100 bits: 16
EVENT: Power-Released#1 ON millis=23494
EVENT: Power-Released ON millis=23494
unit = 4 vol = 0.50, Playing SurvivorBlue/ccend.wav
channels: 1 rate: 44100 bits: 16
NewColor(1,1)
Style RAM = 1164
Style RAM = 1164
Style RAM = 1164
Style RAM = 8
Style RAM = 8
Style RAM = 8
Creating file presets.tmp iteration = 2
Style RAM = 1164
Style RAM = 8
Audio underflows: 4834
EVENT: Aux-Pressed#1 ON millis=25593
EVENT: Aux-Pressed ON millis=25593
EVENT: Aux-Released#1 ON millis=25755
EVENT: Aux-Released ON millis=25755
EVENT: Aux-Shortclick#1 ON millis=25755
EVENT: Aux-Shortclick ON millis=25755
unit = 4 vol = 0.50, Playing SurvivorBlue/blst/blst4.wav
channels: 1 rate: 44100 bits: 16
EVENT: ?47 ON millis=26790
EVENT MENU TURN RIGHT
TWIST
EVENT: Twist ON millis=27047
unit = 1 vol = 0.50, Playing SurvivorBlue/in/in1.wav
channels: 1 rate: 44100 bits: 16
TWIST
EVENT: Twist millis=27193
No sounds found: pstoff
Amplifier off.
Unmounting SD Card.
EVENT: Select-Off millis=29273
BLADE ID: 565.00
NO Blade Detected
blade = 0
WS2811 Blade with 108 leds.
Simple Blade
Style RAM = 8
Style RAM = 8
Scanning sound font: No_Blade
 done
Scanning sound font: common
 done
Activating polyphonic font.
unit = 0 vol = 0.50, Playing No_Blade/bladeout.wav
channels: 1 rate: 44100 bits: 16
Amplifier off.
EVENT: Select-On millis=30658
BLADE ID: 967.00
Blade Detected
blade = 1
WS2811 Blade with 108 leds.
Simple Blade
Style RAM = 1164
Style RAM = 8
Scanning sound font: SurvivorBlue
 done
Scanning sound font: common
 done
Activating polyphonic font.
Activating SmoothSwing V2
Accent Swings Enabled.
Polyphonic swings: 16
Monophonic swings: 0
Accent Slashes NOT Detected: 
unit = 0 vol = 0.50, Playing SurvivorBlue/bladein.wav
channels: 1 rate: 44100 bits: 16
Amplifier off.
EVENT: Select-Off millis=31958
BLADE ID: 650.00
NO Blade Detected
blade = 0
WS2811 Blade with 108 leds.
Simple Blade
Style RAM = 8
Style RAM = 8
Scanning sound font: No_Blade
 done
Scanning sound font: common
 done
Activating polyphonic font.
unit = 0 vol = 0.50, Playing No_Blade/bladeout.wav
channels: 1 rate: 44100 bits: 16
Amplifier off.
Unmounting SD Card.

This is interesting, it’s clearly trying to load a blank preset here.
I’m going to add a few more printouts to find out exactly what’s going on. I’ll try to reproduce it on my side first, but if that doesn’t work, I’ll ask you to try it again and see what it says…

Sounds like a plan. Not that this helps but if nbsave would write immediately would it be less troublesome? That you have to go through those motions seems excessive to prevent the occurrence of the bladeout error. I know personally I can just adjust the volume, do a battery level read, and then cycle the No_Blade preset three times to get it to write quickly but…

Just thinking aloud here. Referencing old fuel-mapping and shift-point auto programming stuff.

*Remember I have holiday travel coming up so you may be getting feedback from all the way out in Batuu East. :wink:

Ok, so I added a few more PVLOG statements, looked over the code and tried to reproduce it. Still not sure what’s happening here. If you could try this again, with the latest code from github, and also add:

#define PROFFIEOS_LOG_LEVEL 1000

to your config file.
Then retry and post what it says in the serial monitor. Then we should be one step closer.

Here you go. Serial Monitor Report 12_3_23 - Pastebin.com

It’s in a paste because the site keeps kicking back

“An error occurred: Body is limited to 100000 characters; you entered 149998.”

*Although it did not happen this time I want to keep testing. Let me know.

Yeah, I need to see the output when it fails to learn something…

Got it to repeat. In the first case global and nbsave built themselves out.
These two other times they did not.
Second readout: Second Serial Monitor Report 12_3_23 - Pastebin.com
Third readout: Third Serial Monitor Report 12_3_23 - Pastebin.com

Shutting down for the night and will check back after 10a PST.

Thank you. This snippet:

SetPreset(0)
Scanning sound font: 
 NOT FOUND!

tells me two things:

  1. I was barking up the wrong tree. I thought for sure that the problem was somehow related to SetPreset being called with a number outside of the available presets. (Like SetPreset(5) when you only have one preset to choose from.) However, that does not seem to be the case.
  2. There is no CurrentPreset::Set() line here, which means that the empty font-string was somehow loaded from a file. Not sure yet if that means that the file actually contains a preset with an empty font string (If so, where did that come from?), or if it means that the loading code is buggy somehow…

Back to reading the code, there is a good chance that we’ll need to do this test again, but with even more printouts…

Ok, I think I found it. :slight_smile:
The preset code would remember which file it used last, but that knowledge isn’t valid anymore when using a different save directory than last time…

Please give the latest code from github a try. If it seems to be fixed, I will make a new ProffieOS release.

1 Like

I’ll head over to GitHub - profezzorn/ProffieOS: Lightsaber Controller Software and grab the update and let ya know shortly.

*Keep #define PROFFIEOS_LOG_LEVEL 1000 in the config for now?

Update: OK, without nbsave being written at all yet, I think that’s the fix. Again though I want to test this some more and will report back later today.

Here’s the printout if you need it. Fourth Serial Monitor Report 12_3_23 No Error This Time. - Pastebin.com

I don’t think it matters. I didn’t add any new log statements - if the fix works, then we don’t need it, and if the fix doesn’t work, I don’t think I’ll learn anything new from the serial monitor output unfortunately.

So far as to the error it’s gone across all the sample hilts.

That said, and in no way do I view this as a detractor, the No_Blade as a bladestyle preset does not have the hum play. Again in no way do I view this as a detractor because honestly as far as I see this needing to go, there’s no need for an alternate hum for this. It should only play four sounds. Bladein Bladeout Boot and Font for the user experience. No Blade means the machine won’t work, therefore there’s no hum without a blade or bladeplug (missing Kyber Crystal), right/ :wink:

Here’s the readout for that. Fifth Serial Monitor Report 12_3_23 Bladeout works No Hum Though - Pastebin.com

If you put a complete font in the No_Blade/ directory, it doesn’t play the hum when you turn on the saber? I’m fairly certain some people use the same fonts in the blade/No_Blade case, so that seems weird to me.