Well, I took a crack at this, but I’m stuck at the moment.
The primary goal is to increment the shots_fired_ during a lockup.
Secondarily, it would be ideal to count each shot based on the sound’s duration, but I don’t think we can get the length of the looped auto.wav during lockup, so might need to choose a fixed duration of each shot instead of incrementing after each actual shot sound plays.
But the way I have things coded currently, even using a set time for each shot, it’s getting stuck because we’re in a ‘while (auto_firing)’ loop and this causes all remaining shots to fire until empty even if the trigger is released.
So I guess the next thing is choose a different way to cause the shots_fired_ to increment while continuing to listen for button events.
This does not work.
All ProffieOS coding has to be done in a “non-blocking” style. That means that the code cannot wait, stop or loop until something happens. Instead it must return and then check if that something has happened next time the code is called.
Some of the ProffieOS code uses a trick using switch() which lets you jump out of the code, and then jump back next time. This ends up kind of like threads, but it’s not really. Such code will be inside a function that has BEGIN_STATE_MACHINE / END_STATE_MACHINE in it, and it’s possible to do loops, because each YIELD() call actually jumps out of the function, does other stuff and then comes back later.
Thanks Professor.
Some brain racking with that info and now this is working!
Very cool. Was stuck because I didn’t see there’s already a Loop in the prop, so it didn’t like a second one,
so I moved the new counting bit to Loop() inside a STATE_MACHINE.
Finally, figured out I needed to add StateMachine to the class
Wow thanx for the tip.
Do you think it might also be that when break cleaner evaporates it cools rapidly causing the internal stresses in extruded polycarbonate to be releaced?
Ooh! Self Destruct! That goes in the blade style code, right? Or in this case, blaster code. As soon as I try out the rapid fire bullet count fix, I might give that a go as well. I have another suggestion for the OLED display. Since we’re not at a place where we can decrease the font size for the bullet counter easily, can we instead make it so that the bullet count display goes away after, say, one second? The reticle animation then comes back on the OLED until the fire button gets activated again, displaying the bullet count once again. Do-able?