Found myself a real stumper here...
For reference here's my program: https://youtu.be/QUfW7tNNWTI
Everything has been pretty snappy and working pretty well so far. I'm just at the point now where I can do a lot of debugging because I can start hooking up real inputs etc and checking to see if the data is being processed and displayed correctly. I got my input capture unit for KR working and also the AVR internal temperature graph working, then I moved on to the main battery voltage...
So I had initially made a mistake by assigning my main battery voltage to A9 on the mega. The physical wiring I did had it going to A11 through a voltage divider, to drop the voltage from 30 down to 5 and then using math internally to compensate and display 30 (or whatever voltage comes in). So bear in mind that up until I noticed this mistake, everything was working fine.
So I go into the code and check pin assignments. I realize that ADCs don't need to be set up so then I search for any instances of code reading that pin and I find just 1 which is part of my update routine. I change it from
BATT = analogRead(A9)
BATT = analogRead(A11)
and shit hits the fan. Not only does my KR ICP no longer work (reports a 0 instead of a 2 because I was sending it a 2) but more importantly the interface was suffering some ungodly lag. I mean bad lag, like waiting 15 seconds for my finger to register on the touch screen.
Now this only seemed to happen on screens where the battery information was present. If nothing battery related was on that screen it didn't lag but I'm wondering why the heck is it lagging at all? It reported the correct voltage so the ADC is polling, and even with the wrong pin assignment it was still polling but just giving a 1023 instead.
I guess, has anybody ever had this experience before where a program just froze up horribly because of an ADC input re-assignment? I don't even have a working hypothesis so I'm not sure what to look at first. I'm going to try changing the code back to the incorrect pin to see if that fixes the problem but that's all I can think to do now.