How to poweroff LCD display ?

Started by jk553, January 05, 2017, 11:01:51 AM

Previous topic - Next topic

jk553

Hello!
How can I power off LCD display on A20 ?
I see some LCD_PWR pin connected to CPU C4, but don't know how to control this C4 pin ?
I'm using Debian 8 image.

jk553

Do far, I've found this C code working:


int fd = open("/dev/disp", O_RDWR);
tmp = 0;
ret = ioctl(fd, 321, &tmp );

Unfortunately almost the same code in Python doesn't work:

buff = array.array( 'h',
  • )
    fd = open("/dev/disp", "wb")
    ioctl(fd, 321, buff, 1 )
    fd.close()

    ...
    IOError: [Errno 1] Operation not permitted

dlombardo

If you need control aka Standby from the userspace - you can use PWM.

We are using gradient power off using PWM, current consumptions goes of, but I think the monitor is not shut down. The wakeup is also smooth.


dlombardo

Simple PWM code:


COUNT=$(cat /sys/class/pwm-sunxi/pwm0/duty_percent)
while [ $COUNT -gt 20 ]; do
COUNT=$(($COUNT - 5))
echo $COUNT > /sys/class/pwm-sunxi/pwm0/duty_percent
sleep 0.1
done
if [ $COUNT -ne 1 ]; then
Log "Shutting down LCD duty=$COUNT -> 1"
echo 1 > /sys/class/pwm-sunxi/pwm0/duty_percent
fi


I think

echo 0 > /sys/class/pwm-sunxi/pwm0/duty_percent

gives some issues, have to check.

dlombardo

#4
Regarding controlling the PWR_EN pin on the LCD connector.

Indeed it is the C4 - PH08

From script.fex it is defined as:

lcd_power = port:PH08<1><0><default><1>


You can try defining it like an I/O output and setting the value.

Add in script.fex (take it from running script.bin) to

...
[gpio_para]
gpio_used = 1
gpio_num = 66
...
gpio_pin_66 = port:PH08<1><default><default><0>
...
[gpio_init]
...
pin_66 = port:PH08<1><default><default><0>


SET gpio_num to a value for your file - so +1 to the existing value!

Add gpio lines for the I/O output.
TRY using default startup state as <0> or <1> (the last parameter in the definition and init lines) as only one of them might work (or neither) to not disturb the normal startup of the LCD.

Pack .fex back to .bin and this should initialize the pin and allow you to map the GPIO in linux for control from user space (shell, python, C).

Please, report back your results or ask for further help if needed.

dlombardo

Hi, did you manage to turn LCD off?

For full reference, I am using default state <1> in script.fex(bin).

Then on boot I initialize the gpio:


# LCD brightness control
chown :dialout /sys/class/pwm-sunxi/pwm0/duty_percent
chmod 666 /sys/class/pwm-sunxi/pwm0/duty_percent
# LCD power enable
echo 66 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio66_ph8/direction
echo 1 > /sys/class/gpio/gpio66_ph8/value


To turn OFF:

echo 0 > /sys/class/gpio/gpio66_ph8/value


To turn ON:

echo 1 > /sys/class/gpio/gpio66_ph8/value