Ok so if I don't call the ADC constructor in the loop, then the anomalous behaviour goes away. However the problem then is that I need to dynamically reconfigure the pins to read the touchscreen and I'm not entirely sure what the behaviour of calling ADC(pin) and retaining a reference and then reconfiguring the pin and resetting it, would do. It's possible that the ADC still works correctly after doing this which might mitigate the issues I'm seeing, I'm not sure yet. On the 2040, this doesn't cause any anomalies but it looks like the pin will change voltage if it's at a certain input voltage when you call the ADC constructor.
EDIT: No, it doesn't like you doing that i.e
ad = ADC(27)
ResetPin(27)
after that reading 'ad' doesn't work properly, it seems to latch up around 48500 and doesn't track the pot. Since the pin has to be reconfigured separately for reading X and Y (it needs to be an input and then an output) then every reconfiguration looks like for certain input voltages it will inject a spurious voltage pulse. Which is kind of a show-stopper.
EDIT: No, it doesn't like you doing that i.e
ad = ADC(27)
ResetPin(27)
after that reading 'ad' doesn't work properly, it seems to latch up around 48500 and doesn't track the pot. Since the pin has to be reconfigured separately for reading X and Y (it needs to be an input and then an output) then every reconfiguration looks like for certain input voltages it will inject a spurious voltage pulse. Which is kind of a show-stopper.
Statistics: Posted by ajay_m — Sat Aug 31, 2024 8:20 pm