We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello!
The formatting of the saved text is a bit garbled.
Processing code:
void draw() {
background(50);
textFont(t, 20);
fill(255);
readSerial();
drawBenchA();
}
void drawBenchA() {
}
void readSerial() {
if (mySerial.available ()>0 ) {
String myString = mySerial.readStringUntil('\n');
if (myString!=null) {
for (int i = 0; i<myString.length (); i++) {
Str1 [i] = myString.charAt(i);
}
}
mySerial.clear();
}
for (int i = 0; i < 15; i++)
{
output.print(Str1[i]);
}
textFont(t, 16);
fill(255);
}
void keyPressed() {
output.flush(); // Writes the remaining data to the file
output.close(); // Finishes the file
exit(); // Stops the program
}
Text file:
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Start
Bench A
velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-velope: 127546-Seconds
27546-Seconds
27546------
27546------
27546------
27546------
27546------
27546------
27546------
27546------
27546------
27546------
27546------
27546------
How it should appear:
Start
Bench A
Envelope 127546-2
5 Seconds
----------------------------
I think this can be fixed with serialEvent, but not sure how.
Answers
Sorry the formatting got all buggy. Can't seem to figure out exactly how the code wrap works.
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text
Thanks GoToLoop! Took me a second to realize that link was a tut on forum text formatting and not a solution to the serial data recording haha
Hi mgiara, try this
I sent for testing.....arduino
Just an observation: There's no need for testing for available() within serialEvent() callback.
Also setting up
bufferUntil(ENTER)
upon the Serial's instance makesreadStringUntil(ENTER)
redundant.1 more tip: Use noLoop() within setup() and redraw() at the end of serialEvent().