• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Adjust brightness of the screen in the night

Scheduled Pinned Locked Moved Troubleshooting
8 Posts 4 Posters 10.7k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    Keromida
    last edited by Aug 18, 2016, 9:52 PM

    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

    1 Reply Last reply Reply Quote 0
    • K Offline
      Keromida
      last edited by Aug 19, 2016, 11:28 PM

      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.

      R 1 Reply Last reply Aug 20, 2016, 5:25 AM Reply Quote 0
      • R Offline
        RedNax Module Developer @Keromida
        last edited by Aug 20, 2016, 5:25 AM

        @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…

        1 Reply Last reply Reply Quote 0
        • C Offline
          Cato Module Developer
          last edited by Aug 20, 2016, 8:21 AM

          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;
          }
          
          S 1 Reply Last reply Aug 20, 2016, 8:33 AM Reply Quote 0
          • S Offline
            strawberry 3.141 Project Sponsor Module Developer @Cato
            last edited by Aug 20, 2016, 8:33 AM

            @Cato this will prevent touchscreen ability for Those with Touch screen

            I would go for a Filter like

            body {
            -webkit-filter: brigthness(50%);
            }

            Please create a github issue if you need help, so I can keep track

            C 1 Reply Last reply Aug 20, 2016, 8:57 AM Reply Quote 0
            • C Offline
              Cato Module Developer @strawberry 3.141
              last edited by Aug 20, 2016, 8:57 AM

              @strawberry-3.141 Yes, that seems like a much better idea! I tried to think simple, but it was not simple enough… :-)

              1 Reply Last reply Reply Quote 0
              • K Offline
                Keromida
                last edited by Keromida Aug 20, 2016, 10:30 AM Aug 20, 2016, 10:29 AM

                @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 :(

                R 1 Reply Last reply Aug 21, 2016, 5:35 AM Reply Quote 0
                • R Offline
                  RedNax Module Developer @Keromida
                  last edited by Aug 21, 2016, 5:35 AM

                  @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!

                  1 Reply Last reply Reply Quote 1
                  • 1 / 1
                  1 / 1
                  • First post
                    5/8
                    Last post
                  Enjoying MagicMirror? Please consider a donation!
                  MagicMirror created by Michael Teeuw.
                  Forum managed by Sam, technical setup by Karsten.
                  This forum is using NodeBB as its core | Contributors
                  Contact | Privacy Policy