notro / fbtft

Linux Framebuffer drivers for small TFT LCD display modules. Development has moved to https://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/tree/drivers/staging/fbtft?h=staging-testing
1.86k stars 494 forks source link

How to turn off backlight completely after certain minutes and wakeup with any key press #210

Closed zwccai closed 9 years ago

zwccai commented 9 years ago

I got the Adafruit 2.8" PiTFT Capacitive Touch setup working from this guide: https://learn.adafruit.com/adafruit-2-8-pitft-capacitive-touch/capacitive-touchscreen

The display turn off after 30 minutes, but the back light still on. Is there a way to configure it so that the back light turn off completely after certain minutes and wakeup with any key press?

notro commented 9 years ago

First you have to do this: https://learn.adafruit.com/adafruit-2-8-pitft-capacitive-touch?view=all#backlight-control

Then enable FBTFT backlight support by setting the 'led' gpio:

options fbtft_device name=adafruitct28 rotate=90 frequency=32000000 gpios=dc:25,led=18

X windows can't turn off the backlight because fb_blank() is not supported in FBTFT. This is a workaround: https://github.com/notro/fbtft-spindle/wiki/Appendix#x-windows-backlight-script

I don't have this display so this is not tested.

zwccai commented 9 years ago

I think I have an older version of the display, I don't see the #18 backlight jumper. (Please see the attachment). What I should I do? img_2456

notro commented 9 years ago

This is the resistive version of the display. Use led=252: https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi?view=all#controlling-the-backlight

zwccai commented 9 years ago

What if I am on the console, not running X? Is possible to create some custom kernel module for this?

notro commented 9 years ago

Didn't this work?

options fbtft_device name=adafruitct28 rotate=90 frequency=32000000 gpios=dc:25,led=252

This should give you an entry under /sys/class/backlight.

From SSH, you can change the console blanking timeout to speed up testing:

sudo sh -c "TERM=linux setterm -blank 1 >/dev/tty0"

More: https://github.com/notro/fbtft/wiki/Backlight

zwccai commented 9 years ago

I tried "options fbtft_device name=adafruitct28 rotate=90 frequency=32000000 gpios=dc:25,led=252", but the "/sys/class/backlight" is empty, "tee: /sys/class/backlight/*/bl_power: No such file or directory"

notro commented 9 years ago

Is backlight support enabled in the kernel?

$ zgrep BACKLIGHT /proc/config.gz
CONFIG_FB_BACKLIGHT=y
CONFIG_BACKLIGHT_LCD_SUPPORT=y
CONFIG_BACKLIGHT_CLASS_DEVICE=y
[...]
zwccai commented 9 years ago

$zgrep BACKLIGHT /proc/config.gz CONFIG_FB_BACKLIGHT=y CONFIG_BACKLIGHT_LCD_SUPPORT=y CONFIG_BACKLIGHT_CLASS_DEVICE=y

CONFIG_BACKLIGHT_GENERIC is not set

CONFIG_BACKLIGHT_PWM is not set

CONFIG_BACKLIGHT_ADP8860 is not set

CONFIG_BACKLIGHT_ADP8870 is not set

CONFIG_BACKLIGHT_LM3630 is not set

CONFIG_BACKLIGHT_LM3639 is not set

CONFIG_BACKLIGHT_LP855X is not set

CONFIG_BACKLIGHT_GPIO is not set

CONFIG_BACKLIGHT_LV5207LP is not set

CONFIG_BACKLIGHT_BD6107 is not set

CONFIG_HID_PICOLCD_BACKLIGHT is not set

CONFIG_LEDS_TRIGGER_BACKLIGHT=y

notro commented 9 years ago

Ok, let's turn on some debug output to see more of what's going on: add option debug=3 'led' should show up here:

$ dmesg | grep fbtft_request_gpios
zwccai commented 9 years ago

Tried "options fbtft_device name=adafruitct28 rotate=90 frequency=32000000 gpios=dc:25,led=252 debug=3" $ dmesg | grep fbtft_request_gpios No result

If I do "options fbtft_device name=adafruitct28 rotate=90 frequency=32000000 debug=3" $dmesg | grep fbtft_request_gpios [ 12.274670] fb_ili9340 spi0.0: fbtft_request_gpios: 'dc' = GPIO25

My kernel version: Linux rpi 3.12.26+ #7 PREEMPT Wed Sep 17 14:25:24 EDT 2014 armv6l GNU/Linux

notro commented 9 years ago

Oh, I'm sorry, it should be led:252 (colon not equal):

options fbtft_device name=adafruitct28 rotate=90 frequency=32000000 gpios=dc:25,led:252 
zwccai commented 9 years ago

Cool, now I am seeing the result. $ dmesg | grep fbtft_request_gpios [ 12.226363] fb_ili9340 spi0.0: fbtft_request_gpios: 'dc' = GPIO25 [ 12.319619] fb_ili9340 spi0.0: fbtft_request_gpios: 'led' = GPIO252

$ ls -la /sys/class/backlight/ fb_ili9340 -> ../../devices/platform/bcm2708_spi.0/spi_master/spi0/spi0.0/backlight/fb_ili9340

Thanks for your timely response!

notro commented 9 years ago

Closing issue since there has been no activity for more than 2 months. Reopen if needed.