Bikce
Posts: 2
Joined: Thu Oct 04, 2018 5:15 pm

Scheduled brightness on pi 3b+/RPi Display

Thu Oct 04, 2018 5:20 pm

Hello,
Is there any script that will change the brightness of the raspberry display during set hours. For example I want the screen to be full brightness until 4:00 PM. Then it stays around 40-50% percent brightness until 5:00 AM. Appreciate your answers :D

User avatar
DougieLawson
Posts: 34166
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Scheduled brightness on pi 3b+/RPi Display

Thu Oct 04, 2018 6:20 pm

I use sunwait to determine when daylight starts/ends and drive the RPF display brightness with a script when sunwait ends.

Code: Select all

45 4 * * * /usr/local/bin/sunwait civ up +0:00:00 51.2N 1.13W ; /usr/local/bin/sunny.sh light;
30 15 * * * /usr/local/bin/sunwait civ down -0:00:00 51.2N 1.13W ; /usr/local/bin/sunny.sh dark;

Code: Select all

#!/bin/bash

NOW=$(TZ=Europe/London date '+%T %d/%m')

if [ "$1" == "reboot" ]; then
  if [ ! -f /var/run/lightordark ];
  then
    echo $1' @ '$NOW > /var/run/lightordark
  fi
  else
  echo $1' @ '$NOW > /var/run/lightordark
fi


if [ "$1" == "light" ]; then
  /usr/local/bin/gpio -g pwm 18 0
  echo "128" > /sys/devices/platform/rpi_backlight/backlight

else
  /usr/local/bin/gpio -g pwm 18 1023
  echo "255" > /sys/devices/platform/rpi_backlight/backlight
fi
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

W. H. Heydt
Posts: 9216
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Scheduled brightness on pi 3b+/RPi Display

Fri Oct 05, 2018 1:19 am

I do it with set times on my "alarm colck", and like Mr. Lawson, use cron to control it:

Code: Select all

# Evening Dim Display
00 22 * * * echo 16 > /sys/class/backlight/rpi_backlight/brightness

# Normal weekday
40 05 * * 1-5 echo 250 > /sys/class/backlight/rpi_backlight/brightness

# No school weekday
# 20 07 * * 1-5 echo 250 > /sys/class/backlight/rpi_backlight/brightness

# Normal Saturday
50 07 * * 6 echo 250 > /sys/class/backlight/rpi_backlight/brightness

# Normal Sunday
50 06 * * 7 echo 250 > /sys/class/backlight/rpi_backlight/brightness
My alarm clock is a Pi2Bv1.1, but this sort of thing is generally independent of the model of Pi being used.

Bikce
Posts: 2
Joined: Thu Oct 04, 2018 5:15 pm

Re: Scheduled brightness on pi 3b+/RPi Display

Wed Oct 10, 2018 3:21 pm

W. H. Heydt wrote:
Fri Oct 05, 2018 1:19 am
I do it with set times on my "alarm colck", and like Mr. Lawson, use cron to control it:

Code: Select all

# Evening Dim Display
00 22 * * * echo 16 > /sys/class/backlight/rpi_backlight/brightness

# Normal weekday
40 05 * * 1-5 echo 250 > /sys/class/backlight/rpi_backlight/brightness

# No school weekday
# 20 07 * * 1-5 echo 250 > /sys/class/backlight/rpi_backlight/brightness

# Normal Saturday
50 07 * * 6 echo 250 > /sys/class/backlight/rpi_backlight/brightness

# Normal Sunday
50 06 * * 7 echo 250 > /sys/class/backlight/rpi_backlight/brightness
My alarm clock is a Pi2Bv1.1, but this sort of thing is generally independent of the model of Pi being used.
Thanks!
This was what I was looking for !! :D

Return to “Official Foundation Display”