Afin d’afficher plus lisiblement le résultat de la console :
User interface is through a VT100, VT220, VT320, or « ANSI » style terminal program using UTF-8 characters.
* Please note that the « Serial Monitor » built into the Arduino’s development
* software cannot be used to communicate with this example program. You must
* use terminal software capable of talking to a serial port. For Windows XP
* you can try the built-in HyperTerminal. For Linux and Windows you can
* use PuTTY (http://www.chiark.greenend.org.uk/~sgtatham/putty/) with
* « Connection type » set to « Serial ». On Linux, I have used GtkTerm and PuTTY.
* The best option for MacOS X is probably ZTerm (http://www.dalverson.com/zterm/).
* http://en.wikipedia.org/wiki/List_of_terminal_emulators gives a list of
* terminal software, however, many of these programs cannot access a serial port.
* Terminal settings:
* Emulation: VT100, VT220, VT320, ANSI, or similar
* Character set: UTF-8 (if available)
* Baud (BPS): 9600
* Data bits: 8
* Parity: No
* Stop bits: 1
* ATTENTION: You must either quit the terminal software or get it to release
* the Arduino’s serial port whenever you want to reprogram the Arduino.
*
//control chars and sequences
#define ESC_CHAR ‘\x1B’
#define CSI_CHAR ‘\x9B’ //single char version of CSI
#define CSI « \x1B[ » //two char version of CSI
#define HOME CSI »H »
#define POSX(x) CSI #x « G »
#define POS(x,y) CSI #y « ; » #x « H »
#define EL CSI « K » //erase to end of line
#define ERASE_TO_END_OF_SCREEN CSI « J »
#define BOLD CSI « 1m »
#define REVERSE CSI « 7m »
#define NORMAL CSI « m »
#define HIDE_CURSOR CSI « ?25l »
#define printp(name, str) static const char PROGMEM name[]=str; printpstr(name)
//print flash ROM (program memory) string to serial port.
void printpstr(const char *pstr){
char ch; //char from str
//read next char
while(ch = pgm_read_byte(pstr++)){
//write non-null char
Serial.write(ch);
}
}
Utilisation :
Serial.write(i+’0′);
printp(colon, « : « );
http://forum.arduino.cc/index.php/topic,172618.0.html
// function clearAndHome()
// clear the terminal screen and send the cursor home
void clearAndHome()
{
Serial.print(27, BYTE); // ESC
Serial.print(« [2J »); // clear screen
Serial.print(27, BYTE); // ESC
Serial.print(« [H »); // cursor to home
}
Votre commentaire