1602LCD显示器的使用
ursorPosition--;
}
}
void moveRightOneStep(void)
{
if(startAddress+cursorPosition==endAddress+1)
return;
if(cursorPosition==15)//表明要考虑是否进行翻页
{
if(startAddress+16 //表明 startAddress+15得到的是LCD最后一位对应express的地址 再加1表示长度 { startAddress++; endAddress=startAddress+15; displayExpress(); } else if(startAddress+16==expressLength)//表明当前已是最后一个字符 { startAddress++; endAddress=startAddress+14;//光标处应该是空 displayExpress(); } else//表明光标处并没有显示字符 { return; } } else//表明无需翻页 { if(cursorPosition==endAddress+1)//已到最后一个位置,光标不能再动了 { return; } cursorPosition++; endAddress=expressLength-1; setCursorPosition(cursorPosition); } } void moveLeft(void)//startAddress+cursorPosition是光标对应express中的地址 { if(startAddress+cursorPosition==0)//跳转到最后 { if(expressLength>15) { endAddress=expressLength-1; startAddress=endAddress-14; } cursorPosition=endAddress-startAddress+2; } if(startAddress+cursorPosition-1>=0&&express[startAddress+cursorPosition-1]==n)//tan,sin,ln { if(startAddress+cursorPosition-6>=0&&express[startAddress+cursorPosition-6]==a&&express[startAddress+cursorPosition-6+1]==r) //arctan,arcsin…… { moveLeftOneStep(); moveLeftOneStep(); moveLeftOneStep(); moveLeftOneStep(); moveLeftOneStep(); moveLeftOneStep(); } else if(express[startAddress+cursorPosition-2]==l)//表明为ln { moveLeftOneStep(); moveLeftOneStep(); } else //表明为sin或tan { moveLeftOneStep(); moveLeftOneStep(); moveLeftOneStep(); } } else if(startAddress+cursorPosition-1>=0&&startAddress+cursorPosition-1>=0&&express[startAddress+cursorPosition-1]==g)//lg { moveLeftOneStep(); moveLeftOneStep(); } else if(startAddress+cursorPosition-1>=0&&express[startAddress+cursorPosition-1]==s) { if(startAddress+cursorPosition-6>=0&&express[startAddress+cursorPosition-6]==a&&express[startAddress+cursorPosition-6+1]==r) //arctan,arcsin…… { moveLeftOneStep(); moveLeftOneStep(); moveLeftOneStep(); moveLeftOneStep(); moveLeftOneStep(); moveLeftOneStep(); } else { moveLeftOneStep(); moveLeftOneStep(); moveLeftOneStep(); } } else//表明为单个字符 { moveLeftOneStep(); } } void moveRight(void) { if(endAddress-startAddress+1==cursorPosition)//表明光标到了最后 { if(expressLength>15) { endAddress=15; startAddress=0; } cursorPosition=0; } else if(express[startAddress+cursorPosition]==s||express[startAddress+cursorPosition]==t||express[startAddress+cursorPosition]==c)//sin,tan { moveRightOneStep(); moveRightOneStep(); moveRightOneStep(); } else if(express[startAddress+cursorPosition]==a)//arctan,arcsin之类的 { moveRightOneStep(); moveRightOneStep(); moveRightOneStep(); moveRightOneStep(); moveRightOneStep(); moveRightOneStep(); } else if(express[startAddress+cursorPosition]==l)//lg,ln { moveRightOneStep(); moveRightOneStep(); } else//表明为单字符 moveRightOneStep(); } void displayExpress(void)//从startAddress显示到endAddress { char i; write_position(0x80);//从这里开始显示 for(i=startAddress;i<=endAddress;i++) { write_data(express[i]); } for(i=endAddress+1;i<16+startAddress;i++)//后面的写空格 { write_data( ); } } void insertOneAndDisplay(void) { expressLength++; if(cursorPosition>=0&&cursorPosition<15)//表明是在和前面当中插入的 { //查看当前显示状态 if(endAddress-startAddress==15)//表明当前已经满显了 { endAddress--; } else//表明未满显 { endAddress++; } cursorPosition++; } else if(cursorPosition==15)//表明光标在显示器第16个显示单元处 此时 startAddress得变 { if(endAddress-startAddress==15)//表明当前已经满显未满显的情况已在isModifyInput中处理 { startAddress++; endAddress++; } } } void deleteOneAndDisplay(void) { moveExpressForward(cursorPosition+startAddress,1); expressLength--; if(cursorPosition==0) { startAddress--; //确定endAddress的位置 if(expressLength-startAddress>=16)//表明显示满了 { endAddress=startAddress+15; } else//表明后面还有几个空要填满 { endA
1602LCD显示 相关文章:
- 1602LCD显示驱动程序(11-24)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)