13

I'm running the Qt5 application on my raspberry pi and I would like to introduce some kind of a power-saving feature.

I don't use x11 or wayland, because I don't need it, but I use gles2 (OpenGL for Embedded Systems).

I want to use tvservice --off and tvservice --preferred to toggle between turned off / turned on screen.

My problem is that when I call tvservice --preferred the display turns on but the screen is black (no application output is shown).

Question:
How can I turn it on and see the application that was running previously?

Tested:
When I restart the Qt5 application - it's being displayed correctly.

Changing foreground virtual terminal with chvt (as suggested here) does not help.

Changing framebuffer depth to different and back again with fbset -depth 16 ; fbset -depth 32 (I've seen it on some forum, cannot find which) also does not help.

Any ideas?

1 Answer 1

30

tvservice is not the best to turn off and on the screen.

Much better way to do this (found after a day of searching) is using vcgencmd command (more on this here).

vcgencmd display_power 0 turns off the screen

vcgencmd display_power 1 turns on the screen

This allows the Qt application to be visible on the screen after turning it off and back on.

5
  • This is perfect! I was looking for something like this for a Pi3..
    – WreckeR
    Mar 8, 2018 at 18:27
  • 2
    Thanks, @lewiatan - I had been using tvservice with Raspian Stretch but it had the problems described in the original question when I switched to Buster. vcgencmd works as hoped.
    – Eric Smith
    Dec 20, 2019 at 16:16
  • 1
    I searched for ages with this problem, thanks for posting this. Like @EricSmith, I'm also using Raspian Buster and found that tvservice just wouldn't work. Thanks again!
    – dariom
    Mar 4, 2020 at 17:40
  • On my model 1 type B vcgencmd does nothing but tvservice works with buster. Pls. refer to forums.raspberrypi.com/viewtopic.php?t=257631
    – user333869
    Dec 4, 2022 at 14:37
  • Works on Raspian Buster 32 bit on a Pi4 with a single monitor.
    – Earl Ruby
    Apr 15 at 1:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.