BlueWave Studio forum
Day/Night Brightness Control - Printable Version

+- BlueWave Studio forum (https://bluewavestudio.io/community)
+-- Forum: OpenAuto Pro (https://bluewavestudio.io/community/forum-86.html)
+--- Forum: User interface (https://bluewavestudio.io/community/forum-66.html)
+--- Thread: Day/Night Brightness Control (/thread-2839.html)



Day/Night Brightness Control - jimOAP - 08-01-2021

Hi all, I've combed through the config file and documentation on here, and can't find an existing answer to my query.

I'm looking for a way to set a screen brightness value for each Day and Night modes, so that when switching between the two the screen brightness changes along with the UI colours & background image.
When in night mode I'd like my screen brightness at its lowest value, and when in day mode have it at the brightest value.

Is this possible? If not I'd like to suggest it as a new feature.


Thanks,
Phil


RE: Day/Night Brightness Control - Daniel_BlueWave - 08-02-2021

You can start from here: https://www.bluewavestudio.io/community/showthread.php?tid=2042&pid=11925#pid11925


RE: Day/Night Brightness Control - Akshunhiro - 01-05-2022

I couldn't find anything for brightness control in the linked config thread. I mainly wanted to see whether brightness and night mode can be triggered from the same GPIO so when the headlights turn on both dark mode will be enabled AND the screen brightness will drop so a set level.


RE: Day/Night Brightness Control - Daniel_BlueWave - 01-05-2022

Check section [Day][Night]


RE: Day/Night Brightness Control - 765GHF - 01-06-2022

(08-01-2021, 08:55 PM)jimOAP Wrote: Hi all, I've combed through the config file and documentation on here, and can't find an existing answer to my query.

I'm looking for a way to set a screen brightness value for each Day and Night modes, so that when switching between the two the screen brightness changes along with the UI colours & background image.
When in night mode I'd like my screen brightness at its lowest value, and when in day mode have it at the brightest value.

Is this possible? If not I'd like to suggest it as a new feature.


Thanks,
Phil

If you are willing to install a TSL2561 light sensor then you can use an external script to control both the switching of day / night mode and screen brightness.

Example script mentioned in this post https://bluewavestudio.io/community/showthread.php?tid=2398 actual script located here - https://github.com/Grawa/brisensor/blob/master/BriSensor.py


RE: Day/Night Brightness Control - wkl3968 - 03-18-2022

I'm using HDMI kind of widescreen display. currently the display has its own remote control to adjust the brightness. I don't find it useful as the environment is changing dynamically and at times the brightness is too low in the day and brightness is too high at night.

So, at the moment, I have enable a CAN message to trigger the day and night perfectly. I also found that there is another CAN message that give the light level from the car.
Can I use the CAN message to trigger the brightness change here https://github.com/Grawa/brisensor/blob/...iSensor.py ?
can the RPI create different brightness signal for HDMI kind of display?


RE: Day/Night Brightness Control - GFunkbus76 - 03-18-2022

Check out PiShade on github - its a software solution which masks the desktop on command.

I tested it a bit with my setup on the bench but forget what I did as it was long ago. Had it functioning with both my screens however - not perfect, but a solution for the software side.

Would be cool if Bluewave added software brightness!


RE: Day/Night Brightness Control - burnsy180 - 08-21-2022

I know this is bit late, but i've found a solution for anyone reading this in the future.

This will change your screen brightness based on the high/low value of a GPIO.

For example, in my configuration, I have a GPIO wired to my car where the signal will go high when the headlights are turned on (night), and stay low when off (day).
You'll need to create 2 scripts for this, which can be done through SSH (i'm using PuTTY, but whatever works for you).

run these commands while connected to the pi in the terminal, or remotely via putty etc:

sudo nano /usr/local/bin/ButtonMonitor.py

this creates the 'ButtonMonitor.py' file and opens it for editing.

paste the below contents into the script in using (right-click is paste in Putty), then save
#!/usr/bin/python

import RPi.GPIO as GPIO
import time
import subprocess, os
import signal
GPIO.setmode(GPIO.BCM) # set to BCM if using GPIO numbering, use GPIO.BOARD if using board pin numbers
GPIO.setwarnings(False)
Brightness_Switch = 17 # Set GPIO number lights are connected to
GPIO.setup(Brightness_Switch, GPIO.IN)

print "  Press Ctrl & C to Quit"

try:

   while True :
        time.sleep(0.1)
        if GPIO.input(Brightness_Switch)==0: #if lights are off (daytime), set brightness MAX (255)
                print "Setting Brightness to 255"
                subprocess.call ("/usr/local/bin/backlight.sh 255", shell=True)
                while GPIO.input(Brightness_Switch)==0:
                        time.sleep(0.1)

        if GPIO.input(Brightness_Switch)==1: #if lights on (night) set brightness to MIN (20)
                print "Setting Brightness to 20"
                subprocess.call ("/usr/local/bin/backlight.sh 20", shell=True)
                while GPIO.input(Brightness_Switch)==1:
                        time.sleep(0.1)



except KeyboardInterrupt:
  print "  Quit"
  GPIO.cleanup()
Next do the same to create a 'backlight.sh' script. The backlight.sh script changes the brightness, the ButtonMonitor.py script checks for the GPIO input, and runs the backlight scripts appropriately.

Create the backlight.sh in the same directory using this:
sudo nano /usr/local/bin/backlight.sh
Paste this into the backlight.sh file:
#!/bin/bash

level=$1
#echo "level given is $level"

if [ $# != 1 ]; then
echo "USAGE: $0 brightness_level (0 to 255)"
exit 1
fi

if [[ $level -ge 0 && $level -le 255 ]]; then
#echo "level given is $level"
echo $level > /sys/class/backlight/rpi_backlight/brightness
echo "Screen brightness set to $level."
exit 0
else
echo "Brightness level $level is out of range! (0 to 255 only)"
exit 1
fi
You can test the backlight.sh works, by running this command, replacing the xxx with any value between 0 (screen off) and 255 (screen full bright).
/usr/local/bin/backlight.sh xxx
Next, make the ButtonMonitor.py script run at startup:
sudo nano /etc/rc.local
add this line at the bottom directly ABOVE the 'exit 0'
python3 /usr/local/bin/ButtonMonitor.py
The above scripts will change the brightness of your screen (i'm using the official Raspberry Pi 7" screen), to full brightness (255) when headlights are off, and low brightness (20) when headlights are on.
As the ButtonMonitor.py script runs on startup, it will be constantly monitoring the GPIO pin you set for high/low values, and when the headlights come on/off, the GPIO changes and it executes the backlight.sh to change the brightness.

I used Everlanders on YT for most of this info, hope it helps someone. It helped me!