This might not be entirely on point but I wanted to share that I did some testing to decide if I wanted to poll my buttons or use interrupts. What I found was that an interrupt may trigger anywhere between 5 ms and 27 ms after a button press in my application. On average it triggered at 16 ms after the press. My main logic when the device is idle can run at almost 200 Hz right now, and if a button triggers more code I’m fortunate in that I don’t want more buttons to be registered until the previous routine is complete.
So ~16 ms with interrupts vs. ~ 5 ms without. IDK what else is at play but polling was the way to go for me. Gotta get that button info across a wireless link so I’m counting every ms. Easier to keep track of as well because I have less threads alive when debugging button stuffs.
Also that new string stuff. Make those static or cosnt. You are just asking for the garbage collector to get in there or even worse to run out of memory. In my experience the G30 is pretty nice about telling me that I ran out of memory if in a Try block and confusingly sometimes it is nice about it outside of Try, but without Try quiet failures happen often as well. So I always allocate significant memory inside Try.
Seems these strings can become significant memory usage depending on the size of Taba array, also if this whole code snippet can execute many times over its 20 ms slice and saveFlag is true then I suspect you are making lots of strings.
But maybe it isn’t a memory issue and just broken logic. I don’t know if the logic is correct for your application or not but I do know, and with all due respect, it is poorly written. The structure is poor. Even if this was the entire program aside from the setting of these flags it’s not immediately obvious what executes and when.
For example the for loop won’t execute for the second entry of taba until until saveFlag is true. It will just keep testing for fwdFlag and revFlag and running those blocks when they are true.Then what happens to saveFlag after it is true? – is it still true? Then for each entry of Taba you will just run the if (saveFlag) block until it’s false. You might want this, but good luck to anyone trying to make sense of why you want it.
Why is this meant to run the length of Taba anyway? it isn’t even used inside the block. Very mysterious to us without knowledge.
It’s the opposite of tight… it has the potential to never exit in many ways.