Datasheet

On / Off Using STMPE GPIO
Another option is to just turn it on and off using the extra GPIO created by the touchscreen driver
Thanks to the raspberry Pi overlay system, this GPIO is already set up for you in a file called
/sys/class/backlight/soc:backlight/brightness
To turn the backlight off run
sudo sh -c 'echo "0" > /sys/class/backlight/soc\:backlight/brightness'
To turn it back on, run
sudo sh -c 'echo "1" > /sys/class/backlight/soc\:backlight/brightness'
For older versions of PiTFT Kernel
On older versions of the PiTFT kernel/overlay, the GPIO was not tied to the backlight device. Start by getting access to
the GPIO by making a device link
sudo sh -c "echo 508 > /sys/class/gpio/export"
ls -l /sys/class/gpio
For some
really
old versions, the GPIO pin was #252 not #508 so substitute that if you're running something from 2014
or earlier
Once you verify that you see GPIO #508, then you can set it to an output, this will turn off the display since it will output
0 by default
sudo sh -c "echo 'out' > /sys/class/gpio/gpio508/direction"
Then turn the display back on with
sudo sh -c "echo '1' > /sys/class/gpio/gpio508/value"
or back off
sudo sh -c "echo '0' > /sys/class/gpio/gpio508/value"
© Adafruit Industries
https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-
pi
Page 55 of 70