Read the statement by Michael Teeuw here.
Adjust brightness of the screen in the night
-
Hello everyone!
I was trying to write some code which is connected to the time. I would like to adjust the brightness of the screen from 10 PM to 6 AM from 100% to 50% brightness. I do know the code to adjust the screen brightness on the raspberry pi on command, but I have to restart the Pi to apply the adjustment and that’s something that I don’t like. I don’t want the Raspberry Pi to restart the whole time just to adjust the brightness.
I was thinking to adjust the clock module with the brightness adjustment or write a complete new module but my ecperience in programming isn’t that much. I started programming like 3 months ago with Visual Basic but I’m glad that I understand pretty much of the code of the MagicMirror². I would really appreciate any help.
Kind regards,
Keromida -
I would also appreciate if there is a way to turn off/on the screen. I could write a shellscript for that, but I don’t know how to tell my RPi 3 out of the clock module, that when the time reaches 10.00 PM that it should start the “Screen Turn Off”-Script and at 6 AM to start the “Screen Turn On”-Script. The script could be run without the LXTerminal, so there wouldn’t be any complications with the MagicMirror interface.
-
@Keromida You can easily use cron and tvservice to turn on/off at specific times…
tvservice -o turns off the display.
tvservice -p turns it back on.Just use cron (crontab -e) to schedule them…
-
Have you considered using a 50% transparent black DIV that is laying on top of everything?
The DIV has to be added to the DOM with absolute position, like this:
div.nightmode { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: Black; opacity: 0.5; }
-
@Cato this will prevent touchscreen ability for Those with Touch screen
I would go for a Filter like
body {
-webkit-filter: brigthness(50%);
} -
@strawberry-3.141 Yes, that seems like a much better idea! I tried to think simple, but it was not simple enough… :-)
-
@strawberry-3-141 That sound’s like a pretty good idea but now I have to connet that code to the time and that’s my actual problem. How could i integrate that? I would really like to use that option because that’s exactly what I want to use =)
@Cato Yeah, I was thinking the same but there was also my problem to write a code like that and then tell the code that it should just work between 10 PM and 6 AM (or better betweeen 22:00 and 6:00 for me in Germany) the time :(
@RedNax Yeah, these are the codes I know but there is still the problem to conect the code to the time :(
I’m really sorry when I’m not that good in programming like you all do but I started with VisualBasic just 3 months ago and I never programmed with anything else than VisualBasic :(
-
@Keromida The raspbian os is a linux derivative and includes cron which is used to schedule things.
You can tell it to do things through your crontab.When you log on to your pi issue the crontab -e command. The first time it will ask you which editor to use… chose the default if you’re not sure.
You’ll be greeted by something like this:
# # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command 00 23 * * * /usr/bin/tvservice -o 00 06 * * * /usr/bin/tvservice -p
You’ll have to add the two lines at the bottom which, in this example, will turn the mirror off at 2300 (11pm) and on again at 0600.
Save the file, and when asked yes you’re sure, and exit the editor… all done!