Threading and Phillips Hue

Updating the Phillips Hue was giving some performance issues, since it would pause the sketch until it sent its PUT HTTP request. Although this didn’t happen every time, when it did happen it would pause the visualisation for about half a second which took away from the immersive experience I was looking to create in the first place.

In order to solve this problem, I thought about placing the HTTP requests that I needed to make in to separate threads so that the requests can be sent in an asynchronous manner with regards to the visuals.

To do this I watched:

Here, threads in Processing are explained thoroughly, and I was able to incorporate threads in to my sketch which has improved the performance issue with the visuals no longer being paused.

I found that for it to work effectively, I had to use “if (frameCount % 10 == 0)”. If i took that statement out and put the thread just in draw() then it would lag and wouldn’t update the light for about one second. Not sure why.

Leave a comment

Design a site like this with WordPress.com
Get started