Hi All,
I'm quite new to processing. More used to working with xCode and Objective-C. I noticed my laptop Fan comes on and my CPU usage goes up to 69% or more everytime I run the following sketch:
To my mind this is quite a straight forward bit of script, yet my CPU usage is running around 69% compared to about 5% normally. I read this thread on a similar problem:
https://forum.processing.org/topic/absurd-java-cpu-usage-at-empty-sketch-with-draw
What I couldn't gather from this thread was if the high CPU usage would damage the machine? I'm guessing it's not good for it. Can anyone tell me? Also is there a way to manage CPU usage by the program from within the script?
Thanks!
I'm quite new to processing. More used to working with xCode and Objective-C. I noticed my laptop Fan comes on and my CPU usage goes up to 69% or more everytime I run the following sketch:
- //random drawing
import processing.serial.*;
Serial port;
float velocity;
float val;
float x;
float y;
int diameter = 10;
void setup()
{
size(1120, 800);
x = width/2;
y = height/2;
background(255,30,30);
String arduinoPort = Serial.list()[0];
port = new Serial(this, arduinoPort, 9600);
}
void draw()
{
smooth();
frameRate(30);
float value = brightness((int)random(255));
fill(value);
//If data is available...
if (port.available() >0)
{
//Read it and store it in the variable val...
val = port.read();
velocity = val/20;
// convert it to a value using the map function
}
x+= random(-velocity, velocity);
y+= random(-velocity, velocity);
x=constrain(x,0,width);
y=constrain(y,0,height);
ellipse(x,y,diameter,diameter);
}
To my mind this is quite a straight forward bit of script, yet my CPU usage is running around 69% compared to about 5% normally. I read this thread on a similar problem:
https://forum.processing.org/topic/absurd-java-cpu-usage-at-empty-sketch-with-draw
What I couldn't gather from this thread was if the high CPU usage would damage the machine? I'm guessing it's not good for it. Can anyone tell me? Also is there a way to manage CPU usage by the program from within the script?
Thanks!
1