Read the statement by Michael Teeuw here.
Save performance when rotating screen e.g. on Raspberry Pi
-
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=900Drawbacks:
- 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.
-
@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.
-
-
@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
-
@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.txtanddisplay_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 needrotate(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. -
@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.
-
@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 ? -
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=900Works now.
Only need to modify the omxplayer lines to have those streams rotated too.
-
Didnt work that easy for me.
- You have to take the resolution of your display/monitor in the config.txt, not just 1600,900.
- I had to enable overscan, cause the picture was to big.
- 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.
-
Great hack!! I’m going to add this to my CSS 101 guide if that’s OK. I think this is incredibly useful.
-
@j-e-f-f thank you! Of course you can :)
-
Hello,
Iam struggeling on my PI3 to rotate by 90deg to right. Monitor has 1920x1080.
But I see only black screen at any other position than -90deg!!
As I need to change to 90deg or -270deg I got only black screen (also 180deg even) …So I changed config.txt to:
display_hdmi_rotate=0 framebuffer_width=1920 framebuffer_height=1080& custom.css to:
body { margin: 0; position: absolute; transform: rotate(90deg); transform-origin: top left; width: 100vh; height: 100vw; object-fit: cover; top: 100vh; visibility: visible; }What is missing?
Worse case I change physical mounting way, but not preferred :face_with_stuck-out_tongue_winking_eye:
-
transform: rotate(90deg); transform-origin: top right;works at least see have screen, but only half screen is used, so no option…
-
Warning! Extreme newbie here. This is only my second day playing with Magic Mirror css.
I changed my css file and boot/config.txt following @evroom’s instructions above and although I was able to rotate the screen with these instructions, like @Joern, the Magic Mirror modules only fill the bottom half of the screen.
My CSS file is as follows (sorry, I don’t know how to put this in a separate box):
body {
margin: 0px; If I omit “px”, Magic Mirror does not display correctly.
position: absolute;
transform: rotate(90deg);
transform-origin: top right;
width: 100vh;
height: 100vh; If I change this to “100vw”, Magic Mirror does not display correctly.
object-fit: cover;
top: 100vh;
visibility: visible;
background: #000;
color: #aaa;
font-family: “Roboto Condensed”, san-serif;
font-weight: 400;
font-size: 2em;
line-height: 1.5em;
-webkit-font-smoothing: antialiased;
}
.MMM-HTMLBox {
font-size: 18px;
line-height: 22px;
}
.MMM-RTSPStream header {
text-align: left;
}
.MMM-RTSPStream .innerWrapper {
border-style: none;
}…a few more entries after these ones.
My boot/config.txt contains the following entry:
display_hdmi_rotate=0
framebuffer_width=1600
framebuffer_height=900Any entries shown here that were not included in @evroom’s instructions, are from the original installation of Magic Mirror.
I’m running Magic Mirror latest software on a Pi4 with an Acer 24" monitor.
Any ideas as to what I should change in order for the modules to fill the entire screen?
Any help will be greatly appreciated.
-
@hdez said in Save performance when rotating screen e.g. on Raspberry Pi:
(sorry, I don’t know how to put this in a separate box
after you paste the text, select it, and then push the button above the editor that looks like </>
-
@sdetweil Thanks. Next time.
-
Never mind guys I was able to get it to work by following the instructions here
After all it wasn’t the css file that I needed to change, but the Pi autostart file in the /etc/xdg/lxsession/LXDE-pi/ folder. -
Thank you @ptrk95, that just came in handy while playing around with fullpageos and the magic mirror in my docker setup!
-
Hi there! thanks for the easy fix! Is there a way to reposition the modules on the mirror? when I rotate the screen 90 degrees the bottom module (the newsfeed) its completely cut out.
-
S sdetweil referenced this topic on
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login