The Story Of Lost Code

Some days you really gotta wonder what the hell were you thinking and where did you leave that? Before I had decided to design the board the micro is on, I had pretty much written the code and had it all working, come time to upload the code and finishing things off, i cant for the life of me find the code anywhere on my computer.

Screws me where the hell it is and the best I could find was an early backup that would have been more work to fix than actually starting from scratch. So, starting from scratch it was going to be. Start with getting the 2 rotary encoders working followed from the 6 push buttons, then the SI5351A and finally the LCD screen. All seems simple enough, well it was going swimmingly till I started on the buttons.

So this is my cheats way of doing key debounce, it works well and does a great job of debouncing the button so you only register one key press. But for whatever reason having 3 or more buttons functions called like that from the main loop, causes them all to fail and I have no idea why, other than for some bizarre reason it was getting locking in the while statement of the 3rd function.

I honestly have no idea why its doing that, or why it should be entering the while loop at all on the 3rd function. So I needed to find a fix, and fix it I did by writing an actual debounce library to use on buttons.

Now the button code looks a little cleaner, the read class is essentially a modification of digitalRead to use the millis timer to debounce, which is much nicer as its non blocking, unlike the delay call i was using. The difference is now I still get the odd double key, rather than always getting one per push.

So now the doing my head in is over, I can actually move on to writing the code to make each function work and do its thing, other than being a placeholder than does nothing than print to the serial monitor.

Code huh, it can be a pain in the arse.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.