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?

goldilocks
  • 58,859
  • 17
  • 112
  • 227
lewiatan
  • 713
  • 2
  • 8
  • 15

1 Answers1

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.

lewiatan
  • 713
  • 2
  • 8
  • 15
  • This is perfect! I was looking for something like this for a Pi3.. – WreckeR Mar 08 '18 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 '19 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 04 '20 at 17:40
  • On my model 1 type B vcgencmd does nothing but tvservice works with buster. Pls. refer to https://forums.raspberrypi.com/viewtopic.php?t=257631 – user333869 Dec 04 '22 at 14:37
  • 1
    Works on Raspian Buster 32 bit on a Pi4 with a single monitor. – Earl Ruby Apr 15 '23 at 01:42