hello, back again.
I have successfully created a sketch, fnally, that graphs temperature during a coffee roast. I'm trying to make some upgrades to the displayed information to make it more useful.
The array is set for 20 minutes, and graphs each second until the roast is complete.
What I'm trying to do is display the average change/increase in temp over the last 15 seconds. Basically take the current temperature and subtract the value of the temp 15 seconds prior, then average the change/second.
Here is my array code:
Code:if ((currentPoint < numberOfGraphPoints)
&& (millis() - previousGrabTime >= timeStep)
&& (commPort.available() > 2)
&& (commPort.read() == 255)){
// if it's time to grab, the array is not full, AND the commport is available...
tempC = commPort.read();
tempB = commPort.read();
tempF = ((tempC * 9) / 5) + 32;
// converts tempC to Fahrenheit
tempEnvF = ((tempB*9)/5) + 32;
// converts tempB to Fahrenheit
//refresh the background to clear old data
// grab the values for A and B
// store them in the two float[] arrays
float x = map(currentPoint,0,graphPoints,30,530);
float y = map(tempF,minTemp,maxTemp,520,145);
float xa = map(currentPoint,0,graphPoints,30,530);
float ya = map(tempEnvF,minTemp,maxTemp,520,145);
tempValsA[currentPoint]=tempF; // plug the values into the arrays
tempValsB[currentPoint]=tempEnvF;
currentPoint++; // add 1 to the current point
previousGrabTime =millis(); // reset the wait time
println(currentPoint);
if (tempF >= minTemp && tempF <= maxTemp){
strokeWeight(3);
stroke(beanColor);
line (px,py,x,y);
px = x;
py = y;
strokeWeight(0);
}
if(tempEnvF >= minTemp && tempEnvF <= maxTemp){
strokeWeight (3);
stroke(envColor);
line (pxa,pya,xa,ya);
strokeWeight(0);
pxa=xa;
pya = ya;
}
}
the temp I want to average is tempF
starting at currentPoint >= 15 I need to subtract tempF at currentPoint 1 from the current tempF then divide it by fifteen. After each second get the currentPoint temp from 15 seconds previous to do the same calculation. Any ideas? Once I can get that value I can have it displayed on the sketch.
Thanks in advance guys.