global variable not updating in draw()
in
Programming Questions
•
1 year ago
Hi all,
My program has several functions. One of which is getData, it gets data from a server and puts it in a global variable called wind. Every second the getData function connects to the server to get the 10 most recent data points. If I print them in the getData function I get 10 different values in the wind variable.
My draw() function (no frameRate set) should use the wind variable to do its thing. But when I print the value of wind in draw() it only takes the last value of the 10 data points and doesn't update the wind variable value with every draw() execution.
Here's an example of the output:
The 10 different data point printed from getData look fine:
get wind225.0
get wind227.0
get wind238.0
get wind255.0
get wind281.0
get wind290.0
get wind290.0
get wind286.0
get wind280.0
get wind269.0
The wind variable as printed from draw(), only the final value is printed:
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
etc.
When the next 10 points become available again only the last one gets printed.
Does anyone know where I should look to solve this issue? Thanks very much in advance, d
My program has several functions. One of which is getData, it gets data from a server and puts it in a global variable called wind. Every second the getData function connects to the server to get the 10 most recent data points. If I print them in the getData function I get 10 different values in the wind variable.
My draw() function (no frameRate set) should use the wind variable to do its thing. But when I print the value of wind in draw() it only takes the last value of the 10 data points and doesn't update the wind variable value with every draw() execution.
Here's an example of the output:
The 10 different data point printed from getData look fine:
get wind225.0
get wind227.0
get wind238.0
get wind255.0
get wind281.0
get wind290.0
get wind290.0
get wind286.0
get wind280.0
get wind269.0
The wind variable as printed from draw(), only the final value is printed:
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
269.0
etc.
When the next 10 points become available again only the last one gets printed.
Does anyone know where I should look to solve this issue? Thanks very much in advance, d
1