虽然在这里的一些人的帮助下,我已经通过一个欺骗代码成功地清除了所有的液晶显示器(因为它没有真正清除显示)for (int i=0; i < 80; i++),但现在我需要删除液晶显示器上的单字符。
注意:我正在使用与我的lcd模块串行通信。我仔细搜索互联网,但我找不到任何解决办法,有没有人有想法这样做?
发布于 2014-01-16 22:09:45
HD44870命令集没有删除字符的规定。您将需要读出显示上的所有字符,将它们写在适当的位置,然后在后面放置一个或多个空格。
发布于 2020-12-06 14:46:08
这里有一个用键盘输入密码并显示在LCD上的示例:
bool enterPassword(char currentPassword[], byte lenghtMaxPassword)
{
byte nextChar = 0;
char changePassKeyPressed;
while(nextChar <= lenghtMaxPassword)
{
changePassKeyPressed = keyboard.getKey();
if(nextChar != lenghtMaxPassword)
{
if(!changePassKeyPressed)
{
continue;
}
else if(changePassKeyPressed=='#')
{
return false; // stop entering the password
}
else if(changePassKeyPressed=='*')
{
if(nextChar != 0) // Don't try delete char, which is not exists.
{
nextChar--;
lcd.setCursor(4 + nextChar,1);
lcd.print(" ");
lcd.setCursor(4 + nextChar,1);
}
}
else
{
lcd.print(changePassKeyPressed);
currentPassword[nextChar] = changePassKeyPressed;
nextChar++;
}
}
else
{
if(changePassKeyPressed == 'D')
{
break;
}
if(changePassKeyPressed == '#')
{
return false;
}
if(changePassKeyPressed == '*')
{
nextChar--;
}
}
}
return true;
}删除你这里的一个字符..。
else if(changePassKeyPressed=='*')
{
if(nextChar != 0) // Don't try delete char, which is not exists.
{
nextChar--;
lcd.setCursor(4 + nextChar,1);
lcd.print(" ");
lcd.setCursor(4 + nextChar,1);
}
}当您在液晶显示lcd.__blink(),中启用光标时,它在视觉上看起来就像是在删除一个字符,实际上您用空格替换了最后一个字符。
https://stackoverflow.com/questions/21173904
复制相似问题