Wow Peter, that’s some epic coding right there! It’s going to take me a bit to digest it all. If it works and it fits in the ATMega328P’s memory, then bravo!
There are lots of ways to condense code, but it gets more unreadable the more you condense it. A lot of the nifty efficient coding is beyond my level of knowledge, to be honest. To make things neater, you could use separate sketches for each function and call those like you would a library.
Here is a tutorial I found after a quick search (I haven’t followed it or looked at it in detail, but it seems to outline what I’m talking about). https://www.youtube.com/watch?v=2pxYEwaMtaI
Apologies for the late reply. I’m getting ready for a trade show at the moment, so I’m building boards, designing backdrops, packing kits and sorting insurance (who knew buying from China and selling to America was so uninsurable…).