0

PiTFT 2.4" Backlight Control
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Please be positive and constructive with your questions and comments.

PiTFT 2.4" Backlight Control

by PaulGr on Thu Oct 04, 2018 1:28 pm

I am having problems controlling the PiTFT backlight via GPIO 18. Control via STMPE GPIO as per p45 of the tutorial works fine. However, neither the gpio commands on p44 or manipulation using gpiozero in python have any effect. The backlight stays on all the time.

I connected a scope probe to GPIO18. The voltage never goes below 2.0V. If I make GPIO 18 a PWM output I can see the square wave on the scope. The levels are 3.3V and 2.0V. Other GPIO pins work as expected, switching between 3.3V and 0V.

I suspect the cause of the problem is that the STMPE610 is always driving its GPIO 2 pin. To allow GPIO 18 to take control, the STMPE pin needs to be configured as an input. Pull-up resistor R12 will then turn the FET on.

Has anyone else encountered this problem?

Has Adafruit tested the instructions on p44 of their tutorial?

Could Adafruit or someone else provide a fix?

I look forward to your help. This is a great little display module and my project has gone really well with it. I just need to sort out the backlight!

PaulGr
 
Posts: 7
Joined: Thu Oct 04, 2018 12:54 pm

Re: PiTFT 2.4" Backlight Control

by adafruit_support_carter on Thu Oct 04, 2018 1:40 pm


adafruit_support_carter
 
Posts: 11091
Joined: Tue Nov 29, 2016 2:45 pm

Re: PiTFT 2.4" Backlight Control

by PaulGr on Thu Oct 04, 2018 1:45 pm

No, I did not cut the solder jumper.

PaulGr
 
Posts: 7
Joined: Thu Oct 04, 2018 12:54 pm

Re: PiTFT 2.4" Backlight Control

by adafruit_support_carter on Thu Oct 04, 2018 1:46 pm

You need to cut the solder jumper, otherwise it is still connected to the STMPE GPIO.

adafruit_support_carter
 
Posts: 11091
Joined: Tue Nov 29, 2016 2:45 pm

Re: PiTFT 2.4" Backlight Control

by PaulGr on Thu Oct 04, 2018 2:13 pm

Your comment is incorrect. I suggest you refer to the schematic. The STMPE GPIO pin is always connected to the FET gate. Cutting the solder jumper isolates RasPi GPIO 18 from the FET gate.

PaulGr
 
Posts: 7
Joined: Thu Oct 04, 2018 12:54 pm

Re: PiTFT 2.4" Backlight Control

by adafruit_support_carter on Thu Oct 04, 2018 4:31 pm

You're right. For some reason skipped over the crucial 'not' in that guide page.

OK, so what seems to not be working is the software disabling of the STMPE GPIO to make sure it doesn't override GPIO 18. Did you run that command?
Code: Select all | TOGGLE FULL SIZE
sudo sh -c 'echo "1" > /sys/class/backlight/soc\:backlight/brightness'

adafruit_support_carter
 
Posts: 11091
Joined: Tue Nov 29, 2016 2:45 pm

Re: PiTFT 2.4" Backlight Control

by PaulGr on Thu Oct 04, 2018 4:58 pm

Yes I did run that command. It didn't have the desired effect.

I suspect the command is causing the STMPE GPIO pin to drive high rather than configuring it as an input. Unfortunately I'm not sure how to prove that. Is there a way to read the STMPE GPIO_DIR register? If so, that would answer the question.

PaulGr
 
Posts: 7
Joined: Thu Oct 04, 2018 12:54 pm

Re: PiTFT 2.4" Backlight Control

by adafruit_support_carter on Thu Oct 04, 2018 5:16 pm

You're right. It's driving the pin high. I don't think it needs to be an input, just set low instead. Try this as the precursor step for disabling the STMPE control:
Code: Select all | TOGGLE FULL SIZE
sudo sh -c 'echo "0" > /sys/class/backlight/soc\:backlight/brightness'

and then try the gpio commands:
Code: Select all | TOGGLE FULL SIZE
gpio -g mode 18 pwm
gpio pwmc 1000
gpio -g pwm 18 100
gpio -g pwm 18 1023
gpio -g pwm 18 0

adafruit_support_carter
 
Posts: 11091
Joined: Tue Nov 29, 2016 2:45 pm

Re: PiTFT 2.4" Backlight Control

by PaulGr on Thu Oct 04, 2018 5:28 pm

I tried your suggestion. It didn't work. The sudo echo command turned the backlight off (as expected). The gpio commands did not turn the backlight on. This is not surprising. Because of the diode D1, the RasPi GPIO 18 can only pull the FET gate low. It cannot drive the FET gate high.

I really think we need to configure STMPE GPIO 2 as an input.

PaulGr
 
Posts: 7
Joined: Thu Oct 04, 2018 12:54 pm

Re: PiTFT 2.4" Backlight Control

by adafruit_support_carter on Thu Oct 04, 2018 6:05 pm

Ugh. Sorry again. I'm just adding confusion to confusion here. That worked for me - but on a different version of the display and a different tie in to the backlight. The tie in with the version you are using is different.

I don't have the specific model you're working with handy for testing. Let me ask here.

adafruit_support_carter
 
Posts: 11091
Joined: Tue Nov 29, 2016 2:45 pm

Re: PiTFT 2.4" Backlight Control

by adafruit2 on Thu Oct 04, 2018 11:20 pm

yeah this design was from back when we could change the stmpe GPIO direction. and i think that the device tree overlay has changed enough that might not be possible:
https://github.com/notro/fbtft/blob/mas ... y.dts#L104

do you see any other files in "/sys/class/backlight/soc\:backlight/" other than 'brightness'? if you ls -l and paste what you ahve, maybe there's a hint. the other option is to just compile a new DTO that doesnt have the STMPE backlight control pin enabled but thats a little tougher

adafruit2
Site Admin
 
Posts: 18327
Joined: Fri Mar 11, 2005 7:36 pm

Re: PiTFT 2.4" Backlight Control

by PaulGr on Fri Oct 05, 2018 6:35 am

I have two PiTFT systems. Here are their directory listings as requested:
System 1 has a Raspberry PI Zero and a usb WiFi dongle. It is running a Jessie kernel as per your Mini Kit guide dated 21 Oct 2016.

pi@RasPi3:/sys/class/backlight/soc:backlight $ ls -l
total 0
-r--r--r-- 1 root root 4096 Oct 5 11:18 actual_brightness
-rw-r--r-- 1 root root 4096 Oct 5 11:18 bl_power
-rw-r--r-- 1 root root 4096 Oct 5 11:15 brightness
lrwxrwxrwx 1 root root 0 Oct 5 11:18 device -> ../../../soc:backlight
-r--r--r-- 1 root root 4096 Oct 4 10:14 max_brightness
drwxr-xr-x 2 root root 0 Oct 5 11:18 power
lrwxrwxrwx 1 root root 0 Oct 4 10:14 subsystem -> ../../../../../../class/backlight
-r--r--r-- 1 root root 4096 Oct 4 10:14 type
-rw-r--r-- 1 root root 4096 Oct 4 10:14 uevent
pi@RasPi3:/sys/class/backlight/soc:backlight $

System 2 has a Raspberry Pi Zero W. It is running a Stretch kernel dated 13 Mar 2018 and was built using your guide dated 26 Jun 2018.

pi@RasPi5:/sys/class/backlight/soc:backlight $ ls -l
total 0
-r--r--r-- 1 root root 4096 Oct 5 11:20 actual_brightness
-rw-r--r-- 1 root root 4096 Oct 5 11:20 bl_power
-rw-r--r-- 1 root root 4096 Oct 4 23:23 brightness
lrwxrwxrwx 1 root root 0 Oct 5 11:20 device -> ../../../soc:backlight
-r--r--r-- 1 root root 4096 Oct 4 23:23 max_brightness
drwxr-xr-x 2 root root 0 Oct 5 11:20 power
lrwxrwxrwx 1 root root 0 Oct 4 23:23 subsystem -> ../../../../../../class/backlight
-r--r--r-- 1 root root 4096 Oct 4 23:23 type
-rw-r--r-- 1 root root 4096 Oct 4 23:23 uevent
pi@RasPi5:/sys/class/backlight/soc:backlight $

Both systems exhibit the problem.

PaulGr
 
Posts: 7
Joined: Thu Oct 04, 2018 12:54 pm

Re: PiTFT 2.4" Backlight Control

by hide0707 on Sun Feb 17, 2019 6:28 am

Hi, I'm facing same problem.
(I can't control brightness with "PWM Backlight Control with GPIO 18" method)

I have two PiTFT 2.4 units which I bought about 2 years ago.

I was able to control backlight with "For older versions of PiTFT Kernel" method in Raspbian Jessie before,
but now I can't control with "PWM Backlight Control with GPIO 18" method in Raspbian Stretch.

Any progress?
Or, new model can control brightness and old model can't ?

hide0707
 
Posts: 1
Joined: Sun Feb 17, 2019 6:18 am

Re: PiTFT 2.4" Backlight Control

by adafruit_support_carter on Mon Feb 18, 2019 3:08 pm

@hide0707 Please start a new thread for your issue.

adafruit_support_carter
 
Posts: 11091
Joined: Tue Nov 29, 2016 2:45 pm

Re: PiTFT 2.4" Backlight Control

by PaulGr on Tue Feb 19, 2019 7:15 am

Just to let everyone know, I gave up on dimming and implemented a simple screen blanker instead using the sudo echo ... commands wrapped up in shell scripts. This worked well. I don't blame Adafruit for not fixing it, after all they only have limited resources. However, they could have put a note in the tutorial to warn prospective customers about the issue.

PaulGr
 
Posts: 7
Joined: Thu Oct 04, 2018 12:54 pm

Please be positive and constructive with your questions and comments.