[fpc-pascal] USB Human Interface Devices

Stefan V. Pantazi svpantazi at gmail.com
Mon Aug 19 03:32:12 CEST 2019


>> My guess is that it would be better to leave the time sensitive read
>> thread to do the fast reads and immediate calculations and leave writing
>> to the device screen in a separate thread (even main thread), with a
>> lower update frequency!
> 
> Yes, that was what I was attempting to describe.. but I can't write to the usb device if the read thread happens to be in the middle of a read... so how do I pause the read thread at the correct time so it's not partially in the middle of reading a packet, and I can't read again until I'm done writing.  I figure I can just check for some period of time of idle handwheel input before I stop the read thread and do the write then start the read thread again, because only the handwheel produces such a large stream of data.. but still I’m not sure how to make sure I stop it at the correct time.

I do not get why should you stop the read thread, when that is the 
actual advantage of having multiple threads. While the read thread is 
busily reading input in a buffer/queue/what have you, you are free 
within limits) to do whatever you need to do (e.g., output to LCD 
display, do calculations) in the other threads, including the main 
thread, after which, you can get back to consuming and processing the 
(hopefully only slightly larger now) data from the read thread 
buffer/queue. After you figured writing to the LCD screen you could try 
writing random data to it while reading and processing handwheel and 
button input *at the same time*. Hope this makes sense.



_______________________________________________________


More information about the fpc-pascal mailing list