This is an old revision of the document!
Table of Contents
VU8C Backlight On/Off Control by Monitor Status
This wiki page describes the way how to control vu8c backlight on/off when monitor status is triggered by controlling the related GPIO ports.
[ Ubuntu ]
On Ubuntu, monitor standby time can be set using Power Management Preferences menu.
You can refer to the section, [Set standby time to enter monitor off using power management setting menu] in the following wiki page.
http://odroid.com/dokuwiki/doku.php?id=en:c2_turn_off_monitor
1. Set up Default Ports
Add the following lines into “/etc/rc.local”
(1) ODROID-C2
path="/sys/class/gpio" echo 234 > $path/export echo 214 > $path/export echo out > $path/gpio234/direction echo out > $path/gpio214/direction echo 0 > $path/gpio234/value echo 0 > $path/gpio214/value chown odroid $path/gpio234/value chown odroid $path/gpio214/value
(2) ODROID-C1/C1+
# vi /etc/rc.local path="/sys/class/gpio" echo 97 > $path/export echo 108 > $path/export echo out > $path/gpio97/direction echo out > $path/gpio108/direction echo 0 > $path/gpio97/value echo 0 > $path/gpio108/value chown odroid $path/gpio97/value chown odroid $path/gpio108/value
2. Configure VU8C control script
Now you need to add a startup task to run the shell script that controls vu8c backlight ports.
Download the shell script
First, download the script file in the path /usr/local/bin/.
And then set the mode as a+x.
(Download one of following shell script) # mv ~/Download/vu8c_backlight_c2.sh /usr/local/bin/ # chmod a+x /usr/local/bin/vu8c_backlight_c2.sh
(1) ODROID-C2
- vu8c_backlight_c2.sh
#!/bin/bash # VU8C backlight control path="/sys/class/gpio" cur_stat="On" while true do sleep 1 stat=$(xset -q|sed -ne 's/^[ ]*Monitor is //p') if [ "$stat" == "Off" -a "$cur_stat" == "On" ]; then echo "monitor goes to Off" # backlight off first echo 1 > $path/gpio214/value echo 1 > $path/gpio234/value cur_stat=$stat elif [ "$stat" == "On" -a "$cur_stat" == "Off" ]; then echo "monitor turns back On" echo 0 > $path/gpio234/value # backlight on later echo 0 > $path/gpio214/value cur_stat=$stat fi done
(2) ODROID-C1/C1+
- vu8c_backlight_c1.sh
#!/bin/bash # VU8C backlight control path="/sys/class/gpio" cur_stat="On" while true do sleep 1 stat=$(xset -q|sed -ne 's/^[ ]*Monitor is //p') if [ "$stat" == "Off" -a "$cur_stat" == "On" ]; then echo "monitor goes to Off" echo 1 > $path/gpio97/value echo 1 > $path/gpio108/value cur_stat=$stat elif [ "$stat" == "On" -a "$cur_stat" == "Off" ]; then echo "monitor turns back On" echo 0 > $path/gpio108/value echo 0 > $path/gpio97/value cur_stat=$stat fi done
Add a startup task
Because this script includes the X server utility, xset, you need to add it using Startup Application menu to run it automatically.
Open the application Startup Applications, under System → Preference → Personal.
Click Add button and find the script file in /usr/local/bin by entering Browse button.
And then complete with Add button as described the 3rd picture.
Reboot
After reboot, you can find the script in ps list.
odroid@odroid64:~$ sudo ps aux | grep vu8c odroid 1521 0.1 0.0 5836 1396 ? S 11:28 0:00 /bin/bash /usr/local/bin/vu8c_backlight_c2.sh odroid 1757 0.5 0.0 5564 904 ttyS0 S+ 11:28 0:00 grep --color=auto vu8c
[ Android ]
1. Download script
First, set the root filesystem writable using remount command.
# su # mount -o rw,remount /
Make or download the following shell script of the board model that you're using (C1 or C2)
and copy it in /system/bin/.
And make its permission executable
# su # chmod 755 /system/bin/vu8c_backlight_c2_android.sh
- ODROID-C2
- vu8c_backlight_c2_android.sh
#!/bin/sh path="/sys/class/gpio" echo 234 > $path/export echo 214 > $path/export echo out > $path/gpio234/direction echo out > $path/gpio214/direction echo 0 > $path/gpio234/value echo 0 > $path/gpio214/value chown system:system $path/gpio234/value chown system:system $path/gpio214/value cur_stat="On" while [ 1 ]; do sleep 1 screen_info=`dumpsys power | grep "Display Power"` if [[ $screen_info == *"OFF"* && $cur_stat == "On" ]]; then echo "monitor goes to Off" # backlight off first echo 1 > $path/gpio214/value echo 1 > $path/gpio234/value cur_stat="Off" elif [[ $screen_info == *"ON"* && $cur_stat == "Off" ]]; then echo "monitor turns back On" echo 0 > $path/gpio234/value # backlight on later echo 0 > $path/gpio214/value cur_stat="On" fi done
- ODROID-C1/C1+
- vu8c_backlight_c1_android.sh
#!/bin/sh path="/sys/class/gpio" echo 97 > $path/export echo 108 > $path/export echo out > $path/gpio97/direction echo out > $path/gpio108/direction echo 0 > $path/gpio97/value echo 0 > $path/gpio108/value chown system system $path/gpio97/value chown system system $path/gpio108/value cur_stat="On" while [ 1 ]; do sleep 1 screen_info=`dumpsys power | grep "mScreenOn"` if [[ $screen_info == *"false"* && $cur_stat == "On" ]]; then echo "monitor goes to Off" echo 1 > $path/gpio97/value echo 1 > $path/gpio108/value cur_stat="Off" elif [[ $screen_info == *"true"* && $cur_stat == "Off" ]]; then echo "monitor turns back On" echo 0 > $path/gpio108/value echo 0 > $path/gpio97/value cur_stat="On" fi done
2. Configure system init to run script on boot
Now, you need to register the service to run this script automatically on boot time.
Add the following lines in the end of /system/init.odroid.board.rc.
Don't forget the root filesystem should be writable as aforementioned.
- in case of C2
# su # vi /system/init.odroid.board.rc ..... ..... service vu8c_backlight /system/bin/vu8c_backlight_c2_android.sh class main user root group root oneshot
- in case of C1
# su # vi /system/init.odroid.board.rc ..... ..... service vu8c_backlight /system/bin/vu8c_backlight_c1_android.sh class main user root group root oneshot
And then, reboot the system.
# reboot