Hello
Debugging applications I often have to monitor many parameters at once. It's very hard with Arduino built in java terminal. Output is scrolling continuously, it's almost impossible to spot anything especially when monitoring changes in values.
It is possible to output values you need to specific places of the screen.
Like x,y position. All you need is terminal application capable of displaying "Xterm" command sequences. I'm using iTerm (http://iterm.sourceforge.net/) for MacOS X and for Windows you have free Putty app.
The only trade off is that you have to use external program instead of pressing nice shiny button in Arduino IDE. But it pays off in terms of visibility and ease of debugging.
All you have to do is to incorporate Xterm control sequences in your code like this
void setup() {
Serial.begin(9600);
Serial.print("\eSP F"); // tell to use 7-bit control codes
Serial.print("\e[?25l"); // hide cursor
Serial.print("\e[?12l"); // disable cursor highlighting
}
This is all needed to tell terminal application that you will use Xterm commands. An that you don't nee pesky bold cursor running like mad across the screen when values are updating.
Now how to output text on row; column coordinates
Serial.print("\e[1;1HTank hardware test console");
sens_fRng =analogRead(fRng);
Serial.print("\e[5;1HRangefinder: \e[5;16H");
Serial.print(sens_fRng);
Now what does "\e[1;1H" means?
\e[- This is so called escape sequence. It tells Xterm that next text will be command.
1;1 - row and column. Just put there cursor coordinates you desire. Text will be every time outputted there.
H - I think this is positioning command itself, but I don't care.
// I'm reading my sensor
sens_fRng =analogRead(fRng);
// I'm putting text "Rangefiders" at row 5, col 1. And moving cursor
// to column 16 to output next text there.
Serial.print("\e[5;1HRangefinder: \e[5;16H");
// Guess what? next text is my sensor reading value. It will be
// outputted where I told before.
Serial.print(sens_fRng);
So remember that you have to move cursor to position you need before outputting some text.
How to view it on computer
On MacOS X just open iTerm (http://iterm.sourceforge.net/) application and type there
screen /dev/name_of_your_arduino_port
My Arduino port is named tty.usbserial-A900ad3P. SO my command is screen /dev/tty.usbserial-A900ad3P
Conclusion
I'm sure there are many way to make this faster and more user friendly. For example Arduino Xterm library like Xterm.print("text",x,y)
And it should be possible to put and icon on your screen opening terminal application with all settings needed. I really hope this guide will be useful to some beginners struggling with lack of other means of debugging your running code as many-many variables output.