We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am writing an interface for an arduino project in Processing. The problem I have encountered is that the application works normally for sometime and then produces stray lines in the window.
I have attached a picture as to how it looks. I am updating the values using serialEvent() and not draw(). Also I have used GUI toolkit of the G4P library. Not able to understand what is causing the stray lines.
Answers
Well, neither do I, to be honest. I don't know how you wrote your code. :|
If you could either place your code in a comment, or give a link to download, that would be your next step to having anyone here helping you. ;)
Sure, but the code is a little long, owing to my bad programming skills...I'll attach the code anyways.
And this is a file with generated code, generated by GUI toolkit (G4P) with initializations and declarations:
Also, please realize that my comment is not an answer.
Pretty straightforward. If it doesn't answer the question, don't mark it as answered. It will only act as a detour for people that aren't helping you, thinking the question was answered.
As for the actual answer, I'll put that in a separate comment, once I get the code fixed.
I'll be asking some question along the way as well.
The difference between your sketch and mine is that yours has values in the "Plotted Points" textbox, and mine doesn't. What do you generally do after you launch the sketch? What has to happen before I can get to the point you're at?
Sometimes as a debugging aid changing the stroke and fill to other settings, section by section, can help narrow down when/where the problem is occurring. If the extra line occurs when the fill is yellow you at least have an idea where to concentrate.
Pretty primitive approach, but then so in sprinkling println() though the code. Both effective alternatives to staring at code with the error in ones blindspot.
Also the line looks to be two lines, or a really skinny ellipse, originating/ending off screen, which may be a clue. Click offscreen while app still has focus. Maybe ignore mouse events off grid/canvas.
@MenteCode, Actually, when a serial (USB) device is connected, once the device starts sending data and the sketch starts receiving the data through serialEvent(), this begins to happen, sometimes almost immediately and sometimes after a long time...Can't actually specify what triggers the event. I am using an Arduino Uno to generate the data, with matching Baud rates.
What is also perplexing is that I downloaded a similar code from some other project,
http://www.grook.net/how-to-make-radar-using-arduino-uno
from that link, specifically, look for processing-code with the link...That sketch too spit out the same result...A few stray lines here and there...
Seems like you need to sanitize coordinates. Check whether they're all confined within the grid!
@GoToLoop, yeah, i've done that...
Hmm... Did it work? What about the offset variables? :-/
Tough problem. Only grid lines and the range checked ellipse in the code. So the only other drawn components are the g4p_controls. Maybe a binary search of the components will kind the culprit. Eliminate 1/2 the components and see if the problem persists. Try the eliminated 1/2. Or just eliminate them one at a time.
It could be a combination of component interactions, though the scroll bar seems to be the only user interaction component, and the only animated component. So I'd pick that as the best possibility.
It might no even be the g4p. Then it is a real mystery.
@GoToLoop : I am not sure if that worked...btw, the offset variables are to offset the plot coordinates by an amount equal to the position of the origin of the grid. I didn't use translate because that would mess up the coordinates of the GUI components too...
@jas0501 : Will try that out...But in the link that I gave in one of the above comments, the processing code that he gives doesn't have a GUI and still encounters the same problem...Now I am inclined to think that something is messed up in my comp...So, i'll try it out on another computer and let you know how it goes...
EDIT: No luck, same result on other systems too...This is driving me crazy...:P
Problem Solved!!!...I just did this;
Anyway, thanks people for all the help!...Good Day!