首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在lcd上删除单个字符

在lcd上删除单个字符
EN

Stack Overflow用户
提问于 2014-01-16 22:06:37
回答 2查看 2.3K关注 0票数 0

虽然在这里的一些人的帮助下,我已经通过一个欺骗代码成功地清除了所有的液晶显示器(因为它没有真正清除显示)for (int i=0; i < 80; i++),但现在我需要删除液晶显示器上的单字符

注意:我正在使用与我的lcd模块串行通信。我仔细搜索互联网,但我找不到任何解决办法,有没有人有想法这样做?

EN

回答 2

Stack Overflow用户

发布于 2014-01-16 22:09:45

HD44870命令集没有删除字符的规定。您将需要读出显示上的所有字符,将它们写在适当的位置,然后在后面放置一个或多个空格。

票数 0
EN

Stack Overflow用户

发布于 2020-12-06 14:46:08

这里有一个用键盘输入密码并显示在LCD上的示例:

代码语言:javascript
复制
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;
   
}

删除你这里的一个字符..。

代码语言:javascript
复制
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(),中启用光标时,它在视觉上看起来就像是在删除一个字符,实际上您用空格替换了最后一个字符。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21173904

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档