[Interest] QTimer at 30Hz interval?
jhihn at gmx.com
Wed Apr 4 13:50:26 CEST 2018
Easy! You can't! But you can come very close. Remember on a multitasking OS, you're dealing with a time division multiplexing, and a scheduler, so getting scheduled at 30hz is impossible. But there are a few things you can do.
On linux you (a process) can set your priority and even scheduling method. This will get your jitter down. If you can always the kernel you can change the time size
The best thing is to use a hardware interrupt, which you may not be able to do.
At this point I have to ask why 30Hz? 30 FPS Video is really 29.77. not many things are actually 30.0 hz. And not-vomiting VR takes at least 60fps.
One trick I've done to get better resolution is, if you can work with jitter, is to set a low timer internal and check if the accumulated interval has accumilated work for you. Because the timer timout waits *at least* that many milliseconds, being called sooner and checking for work might work better than always overshooting. (I actually came up with a way to saturate a CPU with encryption while having a UI progress bar update smoothly by letting the timer interval adjust itself.) You can use 1 or 0ms. With 0, your slot will be called by the event loop when is empty as fast as it can be called.
> Sent: Wednesday, April 04, 2018 at 9:33 AM
> From: "Ola Røer Thorsen" <ola at silentwings.no>
> To: "interestqt-project.org" <interest at qt-project.org>
> Subject: [Interest] QTimer at 30Hz interval?
> is there some nice trick to make a QTimer trigger at 30 Hz? This interval
> can't be expressed properly in milliseconds (1000/30 = 33.333333...)
> My use case is for Linux only so I'd be happy with some Linux-specific way
> of triggering a signal at 30 Hz too. It won't have to be very precise for
> each trigger as long as the average frequency is 30 Hz.
> Interest mailing list
> Interest at qt-project.org
More information about the Interest