清除终端屏幕? [英] Clearing the terminal screen?

查看:24
本文介绍了清除终端屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的机器人读取来自 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 串行监视器不是常规终端,因此无法使用标准终端命令清除屏幕.我建议使用实际的终端模拟器,例如 Putty.

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

来源:
http://www.instructables.com/id/A-Wireless-Controlled-Arduino-Powered-Message-B/step6/Useful-Code-Explained-Clearing-a-Serial-Terminal/

这篇关于清除终端屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆