Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- LASTPWM=/dev/shm/lcd35
- PWMFILE=/sys/devices/platform/pwm-ctrl/duty0
- if [ -z "$1" ]; then
- echo "Usage $0 on|off|<0-100>"
- echo "Set the backlight of the LCD on/off or to a percent illumination"
- exit;
- fi
- if [ "$1" = "off" ]; then
- #save the current value
- cat $PWMFILE > $LASTPWM
- echo 0 > $PWMFILE
- echo "Turned off 3.5in LCD"
- exit;
- fi
- if [ "$1" = "on" ]; then
- #see if the old PWM value has been saved
- if [ -f "$LASTPWM" ]; then
- cat "$LASTPWM" > $PWMFILE
- else
- #no previous value, turn on full brightness
- echo 1023 > $PWMFILE
- fi
- echo "Turned on 3.5in LCD"
- exit;
- fi
- if [ "$1" -ge 0 -a "$1" -le 100 ]; then
- #set a percent of brightness
- value=$[1023*$1/100]
- echo $value > $PWMFILE
- echo "Set backlight to $1% ($value)"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement