is it possible to replace the resistive 2,8" touch against a capacitive 2,8" Adafruit PiTFT in software just by changing the display type in the webinterface?
I think about the replacement because my resistive TFT from the kit has a bit uneven backlight with blurry areas and bright an dark spots. I have a unused spare capacitive one mentioned above.
Would be great if the replacement would be as easy as expected…
It should work without problem, although probably you will need to “tweak” some file to get working the “touch” surface. I think Adafruit have some good tutorial about it. If you do it, please, send feedback and i will include your configuration in the webconf tool.
As i remember, my resistive display has gone black when the Zynthian was shut down.
That doens’t seem to work with the capacitive touch anymore.
Is the backlight of the resistive TFT controlled by the Zynthian Software?
If yes, by the STMPE GPIO?
The capacitive touch doesn’t have this extra GPIO (because there is no such controller).
But there is an alternative pin that can be used. On RPi 1 this is GPIO18. As far as i see on the RPi2/3 this is GPIO1 which seems to be not connected at the Zynthian wiring.
So would it be possible to change this automatically if the capacitive touch is selected in the webconf display configuration?
You can check at the init script “/zynthian/zynthian-ui/zynthian.sh”:
function backlight_on() {
# Turn On Display Backlight
echo 0 > /sys/class/backlight/soc:backlight/bl_power
}
function backlight_off() {
# Turn Off Display Backlight
echo 1 > /sys/class/backlight/soc:backlight/bl_power
}
The same method is used in the systemd “backlight.service”.
As you can see, the resistive driver implements a software switch using the “sys” interface.
It would be nice if every display driver implements this “standard” mechanism, but if not, we can create a “backlight control script” with the different cases.
The /sys/class/backlight/soc:backlight/bl_power directory doesn’t exist when i am using the capacitive touch TFT.
What works is the following (if the #18 backlight solder bridge on the TFT is closed):
gpio -g mode 18 pwm
gpio -g pwm 18 0 -> Turns the BL off
gpio -g pwm 18 1023 -> Turns the BL on
or this:
gpio -g mode 18 out
gpio -g write 18 0 -> Turns the BL off
gpio -g write 18 1 -> Turns the BL on
#!/usr/bin/env python3
from time import sleep
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
backlight_pin = 18
pause_time = 0.02
pir_trigger = True
inactive_status = False
delay_timer = 100
GPIO.setup(pir_pin, GPIO.IN) # activate input
GPIO.setup(backlight_pin, GPIO.OUT)
backlight = GPIO.PWM(backlight_pin, 100)
backlight.start(100)
def fadeIn():
for i in range(0,101): # 101 because it stops when it finishes 100
backlight.ChangeDutyCycle(i)
sleep(pause_time)
def fadeOut():
for i in range(100,-1,-1): # from 100 to zero in steps of -1
backlight.ChangeDutyCycle(i)
sleep(pause_time)
fadeIn()