We're no longer updating This wiki!!

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
en:acc:vu8 [2016/12/22 11:49]
odroid [3. Backlight control with PWM.]
en:acc:vu8 [2017/01/19 14:18]
joy.cho [3. Backlight control with PWM.]
Line 58: Line 58:
  
 ==== 2. Backlight ON/OFF. ==== ==== 2. Backlight ON/OFF. ====
-Add the following ​line in "/​etc/​rc.local"​.\\+ 
 +=== [ Ubuntu ] === 
 +Add the following ​lines into "/​etc/​rc.local"​.\\
 **ODROID-C2** **ODROID-C2**
 <​code>​ <​code>​
Line 79: Line 81:
 echo 0 > $path/​gpio108/​value echo 0 > $path/​gpio108/​value
 </​code>​ </​code>​
 +
 +=== [ Android ] ===
 +In case of Android, please add the followings in "​init.odroid.board.rc"​.\\
 +First, make the filesystem writable.
 +<​code>​
 +shell@odroidc2:/​ $ su
 +root@odroidc2:/​ # mount -o rw,remount /
 +</​code>​
 +
 +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.
 +
 +<​code>​
 +# su
 +# chmod 755 /​system/​bin/​vu8c_backlight_c2_android.sh
 +</​code>​
 +
 +**ODROID-C2**
 +<file sh 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
 +</​file>​
 +
 +Now, you need to register the service to run this script automatically on boot time.\\
 +Add the following lines in the end of /​init.odroid.board.rc.\\
 +Don't forget the root filesystem should be writable as aforementioned.
 +<​code>​
 +# su
 +# vi /​init.odroid.board.rc
 +.....
 +.....
 +service vu8c_backlight /​system/​bin/​vu8c_backlight_c2_android.sh
 +    class main                                ​
 +    user root                                 
 +    group root                                ​
 +    oneshot ​      
 +</​code>​
 +
 +Then, reboot.
 +<​code>​
 +$ reboot
 +</​code>​
 +After reboot, you can confirm if the nodes are configured normally by checking "​gpio214"​ and "​gpio234"​.
 +<​code>​
 +$ ls /​sys/​class/​gpio/​
 +export
 +gpio214
 +gpio234
 +gpiochip122
 +gpiochip136
 +unexport
 +</​code>​
 +
 +**ODROID-C1**
 +<file sh 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
 +</​file>​
 +Now, you need to register the service to run this script automatically on boot time.\\
 +Add the following lines in the end of /​init.odroid.board.rc.\\
 +Don't forget the root filesystem should be writable as aforementioned.
 +
 +<​code>​
 +# su
 +# vi /​init.odroid.board.rc
 +.....
 +.....
 +service vu8c_backlight /​system/​bin/​vu8c_backlight_c2_android.sh
 +    class main                                ​
 +    user root                                 
 +    group root                                ​
 +    oneshot ​      
 +</​code>​
 +Then, reboot.
 +<​code>​
 +$ reboot
 +</​code>​
 +After reboot, you can confirm if the nodes are configured normally by checking "​gpio97"​ and "​gpio108"​.
 +<​code>​
 +$ ls /​sys/​class/​gpio/​
 +export
 +gpio97
 +gpio108
 +......
 +......
 +unexport
 +</​code>​
 +
 ==== 3. Backlight control with PWM. ==== ==== 3. Backlight control with PWM. ====
 +
 === GPIO configuration === === GPIO configuration ===
 == ODROID-C2 == == ODROID-C2 ==
-  ​cd /​sys/​class/​gpio +<​code>​ 
-  echo 214 | sudo tee export +cd /​sys/​class/​gpio 
-  echo out | sudo tee gpio214/​direction +echo 214 | sudo tee export 
-  echo 0 | sudo tee gpio214/​value +echo out | sudo tee gpio214/​direction 
-  echo 234 | sudo tee unexport+echo 0 | sudo tee gpio214/​value 
 +echo 234 | sudo tee unexport 
 +</​code>​
 == ODROID-C1+/​C1/​C0 == == ODROID-C1+/​C1/​C0 ==
-  ​cd /​sys/​class/​gpio +<​code>​ 
-  echo 97 | sudo tee export +cd /​sys/​class/​gpio 
-  echo out | sudo tee gpio97/​direction +echo 97 | sudo tee export 
-  echo 0 | sudo tee gpio97/​value +echo out | sudo tee gpio97/​direction 
-  echo 108 | sudo tee unexport+echo 0 | sudo tee gpio97/​value 
 +echo 108 | sudo tee unexport 
 +</​code>​
 === PWM configuration === === PWM configuration ===
 +
 +== [Ubuntu] ==
 Load PWM driver modules. Load PWM driver modules.
-  ​sudo modprobe pwm-meson +<​code>​ 
-  sudo modprobe pwm-ctrl+sudo modprobe pwm-meson 
 +sudo modprobe pwm-ctrl 
 +</​code>​ 
 +Ignore warning message of "​pwm-ctrl pwm-ctrl: cannot export to PWM-1 : modprobe pwm-meson npwm=2"​ \\ 
 +Enable PWM via sysfs. \\ 
 +<​code>​ 
 +echo 100000 | sudo tee /​sys/​devices/​platform/​pwm-ctrl/​freq0 
 +echo 1 | sudo tee /​sys/​devices/​platform/​pwm-ctrl/​enable0 
 +</​code>​ 
 +Set duty ratio (value can be 0 to 1023. Lower is brighter) 
 +<​code>​ 
 +echo 1023 | sudo tee /​sys/​devices/​platform/​pwm-ctrl/​duty0 
 +</​code>​ 
 + 
 +== [Android] == 
 +Load PWM driver modules. 
 +<​code>​ 
 +root@odroidc2:/​ # insmod /​system/​lib/​modules/​pwm-meson.ko npwm="​1"​ 
 +root@odroidc2:/​ # insmod /​system/​lib/​modules/​pwm-ctrl.ko 
 +</​code>​ 
 Enable PWM via sysfs. Enable PWM via sysfs.
-  ​cd /​sys/​devices/​platform/pwm-ctrl + 
-  echo 100000 | sudo tee freq0 +<​code>​ 
-  echo 1 | sudo tee enable0 +root@odroidc2:/​ # cd /​sys/​devices/​pwm-ctrl.43/​ 
-Set duty cycle +root@odroidc2:/​sys/​devices/pwm-ctrl.43 # ls 
-  echo [0-1023] | sudo tee duty0+driver 
 +duty0 
 +enable0 
 +freq0 
 +modalias 
 +power 
 +subsystem 
 +uevent 
 +root@odroidc2:/​sys/​devices/​pwm-ctrl.43 # cat enable0 ​                         
 +PWM_0 : off 
 +root@odroidc2:/​sys/​devices/​pwm-ctrl.43 # echo 1 enable0 ​                      
 +root@odroidc2:/​sys/​devices/​pwm-ctrl.43 # cat enable0 ​                           
 +PWM_0 : on 
 +</​code>​ 
 +Set default frequency. 
 +<​code>​ 
 +root@odroidc2:/​sys/​devices/​pwm-ctrl.43 # echo 100000 > freq0 
 +</​code>​ 
 +Set duty ratio.\\ 
 +Value can be to 1023 and lower value means brighter. 
 +<​code>​ 
 +root@odroidc2:/​sys/​devices/​pwm-ctrl.43 # cat duty0                            
 +
 +root@odroidc2:/​sys/​devices/​pwm-ctrl.43 #echo 160 > duty0 
 +root@odroidc2:/​sys/​devices/​pwm-ctrl.43 # cat duty0                              
 +160 
 +</​code>​ 
 + 
 +==== 4.  How to Set Auto Backlight On/Off by Monitor Status ==== 
 +Please refer to the following wiki page if you want to run auto backlight on/off control that is triggered by monitor on/off status. \\ 
 +http://​odroid.com/​dokuwiki/​doku.php?​id=en:​vu8c_backlightcontrol 
  
 ===== Hardware assembling ===== ===== Hardware assembling =====
en/acc/vu8.txt · Last modified: 2017/05/22 09:09 by odroid
CC Attribution-Share Alike 3.0 Unported
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0