• 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.

Save performance when rotating screen e.g. on Raspberry Pi

Scheduled Pinned Locked Moved Showcase
19 Posts 11 Posters 19.4k Views 14 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.
  • P Offline
    ptrk95 Module Developer
    last edited by ptrk95 Feb 8, 2019, 6:36 PM Feb 5, 2019, 4:32 PM

    Rotating the screen through custom css (saving performance)

    Hello guys,

    if you’re running on low end hardware e.g. Raspberry Pi and want to rotate the screen you can rotate it with a custom css file, thus saving precious performance!

    Copy paste this code to your custom.css file for a screen rotation of 90degrees:

     body {
            margin: 0;
    	position: absolute;
     	transform: rotate(90deg);
     	transform-origin: bottom left;
    	width: 100vh;
    	height: 100vw;
    	object-fit: cover;
    	top: -100vw;
            visibility: visible;
     }
    

    Copy paste this code to your custom.css file for a screen rotation of -90degrees:

     body {
    	margin: 0;
    	position: absolute;
     	transform: rotate(-90deg);
     	transform-origin: top left; 
    	width: 100vh;
    	height: 100vw;
    	object-fit: cover;
    	top: 100vh;
            visibility: visible;
     }
    

    Also note that you may have to switch back framebuffer_width and framebuffer_height in your /boot/config.txt file as stated by evroom here, e.g.:

    framebuffer_width=1600
    framebuffer_height=900
    

    Drawbacks:

    • since it only rotates the magic mirror app, external apps like omxplayer have to be rotated seperately
    • you may have to edit the css file of some modules as well

    This could be added to the wiki here.

    K J 2 Replies Last reply Feb 8, 2019, 4:15 AM Reply Quote 3
    • K Offline
      keyun21 @ptrk95
      last edited by Feb 8, 2019, 4:15 AM

      @ptrk95 Thanks for sharing your code, so if i understood correctly (newbie here with CSS) I can just copy your code and plug it in my CUSTOM.CSS file and I should good to go (I understand i need to change “90deg” or so based on my monitor setup. TIA.

      1 Reply Last reply Reply Quote 1
      • J Offline
        justjim1220 Module Developer @ptrk95
        last edited by Feb 8, 2019, 4:31 AM

        @ptrk95

        this code also works with a 42" TV!

        Thanks!!!
        :smiling_face:

        "Life's Too Short To Dance With Ugly People"
        Jim Hallock - 1995

        1 Reply Last reply Reply Quote 1
        • P Offline
          ptrk95 Module Developer
          last edited by Feb 8, 2019, 10:21 AM

          @keyun21 Correct, just give it a go and see what happens ;) Just delete the lines if something strange occours.

          @justjim1220 Thanks for sharing! :)

          Only disadvantage here is that you may have to change the styles of other modules, for example the Snow module doesn’t work right of the bat I think.

          Also note that there might be a better way to code it, since I just googled how to rotate with CSS :D

          1 Reply Last reply Reply Quote 0
          • E Offline
            evroom
            last edited by evroom Feb 8, 2019, 11:50 AM Feb 8, 2019, 11:50 AM

            @ptrk95 said in Save performance when rotating screen e.g. on Raspberry Pi:

            and want to rotate the screen you can rotate

            Did you counter clockwise rotated you screen ?
            And therefore did ``transform: rotate(90deg);```??

            I originally rotated my screen clock wise (so the top now is on the right hand side) using /boot/config.txt and display_hdmi_rotate=3.
            This works fine.

            When I use your css example and take out the /boot/config.txt line, it does not work right.
            I figured I need rotate(270deg), but then I do not see anything.

            Besides that, the omxplayer modules need to be adjusted too (–orientation parameter), so I reverted back to my old method.

            My question: can you setup your screen so that it rotates this way that you see everything upside down (to simulate a clockwise rotation in your case) ??
            And then share the css code.

            MagicMirror version: 2.30.0
            Raspberry Pi 4 Model B Rev 1.5 (8 GB RAM)
            Raspbian GNU/Linux 12 (bookworm)

            Test environment:
            MagicMirror version: v2.30.0
            Raspberry Pi 3 Model B Plus Rev 1.3 (1 GB RAM)
            Raspbian GNU/Linux 12 (bookworm)

            P 1 Reply Last reply Feb 8, 2019, 2:27 PM Reply Quote 0
            • P Offline
              ptrk95 Module Developer @evroom
              last edited by Feb 8, 2019, 2:27 PM

              @evroom Yes, I did rotate it counter clockwise.

              I found a solution that worked for my setup, rotating the screen 270:

               body {
              	margin: 0;
              	position: absolute;
               	transform: rotate(-90deg);
               	transform-origin: top left; 
              	width: 100vh;
              	height: 100vw;
              	
              	object-fit: cover;
              	top: 100vh;
                      visibility: visible;
               }
              

              Tell me if that worked for you. Then I`ll update the post :)

              Adjusting the omxplayer orientation is one of the drawbacks.

              1 Reply Last reply Reply Quote 0
              • E Offline
                evroom
                last edited by evroom Feb 8, 2019, 3:19 PM Feb 8, 2019, 2:48 PM

                @ptrk95 said in Save performance when rotating screen e.g. on Raspberry Pi:

                Tell me if that worked for you.

                Almost, but not quite.
                It does rotate clock wise, but it is centered.
                In Excel analogy: vertical alignment: center.
                I would need ‘top’.

                This is my custom.css, probably the other settings interfere:

                body {
                  margin: 0;
                  position: absolute;
                  transform: rotate(-90deg);
                  transform-origin: top left;
                  width: 100vh;
                  height: 100vw;
                
                  object-fit: cover;
                  top: 100vh;
                        visibility: visible;
                 }
                
                .region.top.left {
                  width: 60%;
                }
                
                .region.middle.center {
                  width: 60%;
                }
                
                .region.bottom.left {
                  width: 60%;
                }
                
                .MMM-HTMLBox {
                  font-size: 18px;
                  line-height: 22px;
                }
                .MMM-RTSPStream header {
                
                  text-align: left;
                }
                
                .MMM-RTSPStream .innerWrapper {
                  border-style: none;
                  //border: 1px solid red;
                }
                

                I want the left side modules to occupy 60% and the right side modules 40%.
                Maybe I have to interpret top, middle and bottom different now ?

                MagicMirror version: 2.30.0
                Raspberry Pi 4 Model B Rev 1.5 (8 GB RAM)
                Raspbian GNU/Linux 12 (bookworm)

                Test environment:
                MagicMirror version: v2.30.0
                Raspberry Pi 3 Model B Plus Rev 1.3 (1 GB RAM)
                Raspbian GNU/Linux 12 (bookworm)

                1 Reply Last reply Reply Quote 0
                • E Offline
                  evroom
                  last edited by Feb 8, 2019, 3:28 PM

                  Okay, found it.

                  In my /boot/config.txt I had the width and height set to 900 and 1600 and this has to be now 1600 and 900.
                  This is working:

                  display_hdmi_rotate=0
                  framebuffer_width=1600
                  framebuffer_height=900
                  

                  Works now.

                  Only need to modify the omxplayer lines to have those streams rotated too.

                  MagicMirror version: 2.30.0
                  Raspberry Pi 4 Model B Rev 1.5 (8 GB RAM)
                  Raspbian GNU/Linux 12 (bookworm)

                  Test environment:
                  MagicMirror version: v2.30.0
                  Raspberry Pi 3 Model B Plus Rev 1.3 (1 GB RAM)
                  Raspbian GNU/Linux 12 (bookworm)

                  1 Reply Last reply Reply Quote 1
                  • T Offline
                    thedk
                    last edited by thedk Feb 14, 2019, 6:00 PM Feb 14, 2019, 6:00 PM

                    Didnt work that easy for me.

                    1. You have to take the resolution of your display/monitor in the config.txt, not just 1600,900.
                    2. I had to enable overscan, cause the picture was to big.
                    3. If you’re using the MMM-Remote_Control the picture is rotated when you have a look at your MagicMirror.

                    I switched back to the fake KMS driver.

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      j.e.f.f Project Sponsor Module Developer
                      last edited by Feb 16, 2019, 10:53 AM

                      Great hack!! I’m going to add this to my CSS 101 guide if that’s OK. I think this is incredibly useful.

                      P 1 Reply Last reply Feb 17, 2019, 3:58 PM Reply Quote 1
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        1/19
                        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