AnalogReadResolution () on selected pins?

Hi guys, a bit of backround info on the project.
I am using a touch display in conjunction with an ESP32Uno board (native 12 bit resolution), and in order to get the touch screen working properly I have to change the analog resolution to 10 bit.

This particular project will also be using some analog sensors, so having analogRead() running on 12bit resolution would be very nice in order to make the readings more accurate, as they will be measuring over a large range (NTC thermistor -30 c to 150c for example).

So to my question. is it possible to change resolution on only on selected pins?
If so, how can I define which pins will be affected by AnalogReadResolution ()?


Yes, by wrapping a helper function around the resolution change,
something like:

int read12bit (byte pin)
  analogReadResolution (12) ;
  int result = analogRead (pin) ;
  analogReadResolution (10) ;
  return result ;

Then use this when you want 12 bits.

I will give it a try, thanks!

I cant seem to get it working, code doesnt compile.

Do you have any tips to get it working?