davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

change HDMI screen resolution manually during runtime?

Wed May 11, 2016 8:20 am

hi,
is it possible to change HDMI screen resolution manually during runtime?

Temporarily I am using a 1920x1080 HDMI TV screen for desktop programming, but than I have to switch to a 800x480 TFT for the mobile robot application to run,
so I want to unplug the full HD TV screen and change to the small TFT, and then vice versa, without intermediate rebooting.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: change HDMI screen resolution manually during runtime?

Wed May 11, 2016 7:36 pm

Have a look at the tvservice command. The source is available at https://github.com/raspberrypi/userland
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: change HDMI screen resolution manually during runtime?

Wed May 11, 2016 10:02 pm

tvservice? is that a subfolder or a program in a subfolder?
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: change HDMI screen resolution manually during runtime?

Thu May 12, 2016 8:20 pm

davenull wrote:tvservice? is that a subfolder or a program in a subfolder?
A program (already installed on RPF Raspbian images). Source is in the userland repo Dougie linked to (https://github.com/raspberrypi/userland ... /tvservice)

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 8:33 am

I see, tvservice is already installed -
how do I have to use that? Is there a description available?
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 1:32 pm

no idea which parameters I have to use for the pixel resolution settings to switch between
1920x1080 and 800x480 (both 16:9)
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
procount
Posts: 2209
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 1:40 pm

`tvservice` on its own will give you a list of parameters.
Use
`tvservice -s` to show your current status
`tvservice -m DMT` to show available modes (mostly for digital monitors?)
`tvservice -m CEA` to show available modes (mostly for TVs?)
`tvservice -e ......` to set your required mode
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 1:56 pm

yes, thank you, I saw that already entering tvservice in a terminal -

but I still don't see which parameters I have to use for the pixel resolution settings to switch between
1920x1080 and 800x480 (both 16:9)

required DMT modes might be 9 or 87 and 82.
but, e.g.:
tvservice -e mode 82
does not work

so what is correct?
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:02 pm

davenull wrote:does not work

so what is correct?
Do you actually read what you see on screen?

Code: Select all

-e, --explicit="GROUP MODE DRIVE" Power on HDMI with explicit GROUP (CEA, DMT, CEA_3D_SBS, CEA_3D_TB, CEA_3D_FP, CEA_3D_FS)
So you write group, mode and drive in quotes with the -e option.
Example:

Code: Select all

tvservice --explicit="CEA 16 HDMI"
See e.g. https://www.raspberrypi.org/documentati ... fig-txt.md for description of groups, modes and drive.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:04 pm

I honestly don't understand a single word.
What is group? what is drive? I only need the resolution!

couldn't you provide the complete commands, please?
no -e parameter?
`tvservice -e ......` to set your required mode
hell, that's awfully weird that stuff to me! :evil:
Last edited by davenull on Fri May 13, 2016 3:07 pm, edited 1 time in total.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

DirkS
Posts: 10347
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:06 pm

davenull wrote:I honestly don't understand a single word.
What is group? what is drive? I only need the resolution!

couldn't you provide the complete commands, please?
no -e parameter?
that's awfull weird that stuff to me! :evil:
Dif you follow the link I gave you?

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:07 pm

don't understand what they are writing - too many words, too many ambigouos and weird explanations - I don't get it.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
procount
Posts: 2209
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:18 pm

You have to be more precise in what parameters you type for tvservice,

There are 2 groups: CEA and DMT
You have to get the list of available modes for each group, so to get a list of CEA modes, type:

Code: Select all

tvservice -m CEA
and to get a list of DMT modes that your monitor supports, type:

Code: Select all

tvsservice -m DMT
Then choose the mode you want (e.g. 82) from the group you want (e.g. DMT) and whether you want HDMI or DVI output (e..g. HDMI), and type, (for example):

Code: Select all

tvservice -e "DMT 82 HDMI"
The last parameter (HDMI) is optional. You must include the quotes.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:20 pm

my old setting was 800x480 for my small TFT.
for it I had to add to /boot/config.txt

Code: Select all

hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0
 
start_file=start_x.elf
fixup_file=fixup_x.elf
#gpu_mem=128
Then I plugged a full HD screen instead.
It still showed the small resolution at start up (800x480).

I now tried
tvservice --explicit="DMT 82 HDMI"
but then the screen was black, nothing visible any more
(I had plugged a full HD screen, HDMI-to-DVI adapter in between).


Had to hot-unplug the Pi.

So what's the correct command?
Last edited by davenull on Fri May 13, 2016 3:26 pm, edited 2 times in total.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
procount
Posts: 2209
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:26 pm

It depends on what your monitor supports.

Make sure the mode number you use is appropriate for the CEA or DMT mode that your monitor said it supports.

Sometimes it goes blank because you need to set the framebuffer to match the new resolution.
When it goes black type:

Code: Select all

fbset -depth 8
fbset -depth 16
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:28 pm

ok - thanks - but now it's getting far too weird to me.

I have no idea about all those low level hardware stuff.
and how should I type anything if I don't see what I type?

IMO Linux should show the available screen resolutions just like Windows does, to choose by a menu

Is there no other way to adjust the resolution?
If not, then I have to abandon that stuff
:evil:
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:37 pm

writing all that into a bash script, it didn't change anything then nevertheless - all stayed as it was before at 800x480:

Code: Select all

tvservice --explicit="DMT 82 HDMI"
fbset -depth 8
fbset -depth 16
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
procount
Posts: 2209
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:46 pm

A bash script is a good idea.
Try some other mode numbers. or try CEA and appropriate numbers for that group as well.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:48 pm

82 is the only 1920X1080 mode, and it worked automatically for that resolution before I had to force the config.txt changes for the small TFT
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:52 pm

tvservice -m CEA

has 0 modes
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
procount
Posts: 2209
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:55 pm

Why don''t you just remove the config.txt changes for the TFT then and reboot?
Maybe keep 2 config.txt files, one for each screen that you attach and copy the one you want.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

User avatar
procount
Posts: 2209
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 3:56 pm

Also try

Code: Select all

tvservice -p
which will set the monitor to its preferred mode, which is normally the best one.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: change HDMI screen resolution manually during runtime?

Fri May 13, 2016 4:03 pm

preferred is currently mode 87for the small 800x480 TFT which I already forced to by

Code: Select all

hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0
 
start_file=start_x.elf
fixup_file=fixup_x.elf
#gpu_mem=128
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

Return to “Beginners”