K
K
Klaxons2018-08-11 15:16:18
infographics
Klaxons, 2018-08-11 15:16:18

How to correctly draw a graph of data from a com port in Swift?

There is a device that sends data via a serial port (type uint8), data transfer rate is 115200 baud, data is sent every 20 microseconds.
I began to draw in nsview, the data is added to an array, where the index is the x value, and the array element itself is the y value. I draw in the context of the nsview itself. If I draw test data (a predefined array) through a timer (with a frequency of 0.01s) then everything is OK when I draw from the port. The program freezes and starts drawing in pieces, and then it hangs altogether (there is a memory leak). It is worth noting that each new datum redraws the entire graph. Bezier didn't improve the situation either.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question