Re: [Interest] QTimer at 30Hz interval?
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" > To: "interestqt-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.33...) > > 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. > > Cheers, > Ola > ___ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QTimer at 30Hz interval?
On 04/04/18 09:52, Daniel Engelke wrote: What about QElapsedTimer you can get nanoseconds out of it. Yeah, but it doesn't have signals to fire on a timeout... QElapsedTimer's major purpose is measuring time, not sending (repeated) signals. So it's more like QTime, not like QTimer. Cheers, René ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QTimer at 30Hz interval?
> > one at 30 ms, and one at 31 ms > I meant 33 and 34 ms, but you get the idea. ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QTimer at 30Hz interval?
Hi, Just an idea: I believe by default QTimer doesn't have that fidelity, however you can check if your platform supports Qt::PreciseTimer and stagger two of them, one at 30 ms, and one at 31 ms. Both would go to one handler, where you check if the timeout has expired and trigger the needed slot on demand. On Wed, Apr 4, 2018 at 10:33 AM, Ola Røer Thorsen wrote: > 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.33...) > > 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. > > Cheers, > Ola > > > > > ___ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > > ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QTimer at 30Hz interval?
What about QElapsedTimer you can get nanoseconds out of it. Br Daniel From: René Reucher To: Sent: 4/4/2018 9:42 AM Subject: Re: [Interest] QTimer at 30Hz interval? On 04/04/18 09:33, Ola Røer Thorsen wrote: > 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.33...) > > 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. Not sure (and I haven't tried it myself), but maybe this class can help: https://github.com/rsmz/qnanotimer HTH, René ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] QTimer at 30Hz interval?
On 04/04/18 09:33, Ola Røer Thorsen wrote: 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.33...) 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. Not sure (and I haven't tried it myself), but maybe this class can help: https://github.com/rsmz/qnanotimer HTH, René ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
[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.33...) 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. Cheers, Ola ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest