问题描述
我正在从机器人的9个不同传感器中读取数据,我需要在同一窗口中稳定地显示所有数据,以便我可以比较这些值并查看是否有任何读数不正确.
I'm reading data from 9 different sensors for my robot and I need to display them all steadily, in the same window so I can compare the values and see if any of the readings is off.
Serial.print和lcd.print的问题在于值一直在移动,并且在移动机器人时我无法真正看清它们.
The problem I'm having with both Serial.print and lcd.print is that the values are constantly moving and I can't really have a good look at them while moving the robot.
我本来想在显示其他任何内容之前先调用Serial.clear()之类的东西,那样只会使事情稳定并在一处,仅更改值.
I was thinking to call something like Serial.clear() before displaying anything else and that would just keep things steady and in one place, changing only the values.
到目前为止,我发现不再支持Serial.print(17,BYTE)(调用ESC键).
From what I found so far, Serial.print(17,BYTE) for instance is no longer supported (Calling the ESC key).
那么...对于那些有更多Arduino经验的人...什么是正确的方法呢?
So...for those with a bit more Arduino experience...what is the proper way to do this?
推荐答案
Arduino串行监视器不是常规终端,因此无法使用标准终端命令清除屏幕.我建议使用实际的终端模拟器,例如腻子.
The Arduino serial monitor isn't a regular terminal so its not possible to clear the screen using standard terminal commands. I suggest using an actual terminal emulator, like Putty.
清除终端屏幕的命令是ESC [2J
The command for clearing a terminal screen is ESC[2J
要在Arduino代码中完成:
To accomplish in Arduino code:
Serial.write(27); // ESC command
Serial.print("[2J"); // clear screen command
Serial.write(27);
Serial.print("[H"); // cursor to home command
这篇关于清除终端屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!