I am trying to detect if a PiTFT screen is connected.
Is there some kind of GPIO pin I can probe and detect it to some extent?
Old question, answering for someone else who might need it... Full disclaimer - this is what I collected in the last couple of days researching a different topic - there are might be better ways. That said, it seems there are at least a few possibilities for detecting a TFT screen. For one, you can query the device tree as described here:
$ cat /proc/device-tree/hat/product PiTFT 2.2inch without Touchscreen (ILI9340)
You can also see if the backlight device is registered (found here):
$ sudo find /sys/ -type f -iname '*brightness*' | grep 'led' /sys/devices/platform/soc/soc:leds/leds/led0/brightness /sys/devices/platform/soc/soc:leds/leds/led0/max_brightness
Or read the status of the backlight led directly (will be 0 if off):
$ gpio read 18 1
You can also check if there is more than one framebuffer (TFT runs on fb1 unless you have more than one monitor):
$ ls /sys/class/graphics/ fb0 fb1 fbcon
You can probably also talk directly to the TFT controller, but the options above seem simpler.