简体   繁体   English

ATMEGA USART处理箭头键

[英]ATMEGA USART handling arrow keys

I have a problem, I have to control a PWM of the ATMEGA 1280 with the USART pressing the keys on my computer. 我有一个问题,我必须用USART按下计算机上的键来控制ATMEGA 1280的PWM。 I can control that, using the ASCII keys and controlling the PWM. 我可以使用ASCII键并控制PWM来控制它。 The problem is that they're asking to use the arrow keys, now the thing is that arrow keys doesn't have ASCII values, and I don't have the ATMEGA 1280 right now at my disposal. 问题是他们要求使用箭头键,现在的问题是箭头键没有ASCII值,而且我现在没有ATMEGA 1280。 I don't know what value compare with the received value from the arrow key. 我不知道将哪个值与从箭头键接收到的值进行比较。 Somebody has an idea? 有人有主意吗?

You need to use terminal emulator like Putty or other terminal emulation software. 您需要使用终端仿真器(如Putty)或其他终端仿真软件。 If you need handle arrow keys use control escape sequences . 如果需要手柄箭头键,请使用控制转义序列

So if you need to handle UP arrow key and after UP key is pressed you will receive to UART ASCII sequence: "ESC 1 A". 因此,如果需要处理UP箭头键,并且在按下UP键后,您将收到UART ASCII序列:“ ESC 1 A”。 ESC is 0x1B in ASCII. ESC是ASCII中的0x1B。 Other chars just regular ASCII chars. 其他字符只是常规的ASCII字符。 You will find other sequences in page which I provided. 您会在我提供的页面中找到其他序列。 You need to parse sequences and you will get all keys. 您需要解析序列,您将获得所有键。

The cursor keys are not part of the standard ASCII character set, so they do not generate a character that can be sent over a UART... 光标键不是标准ASCII字符集的一部分,因此它们不会生成可以通过UART发送的字符...

Extended keys can be read via their scan code (Google "PC scan codes") you might be luck that your terminal program is sending the scan codes for non-ascii characters, but these are 2-byte sequences so you're probably ignoring them if you are getting them. 扩展密钥可以通过其扫描代码(Google“ PC扫描代码”)进行读取,您可能很幸运,您的终端程序正在发送非ASCII字符的扫描代码,但是这些都是2字节序列,因此您可能会忽略它们如果你得到他们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM