⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd.lst

📁 单片机51环境下的字库代码122*32点阵的液晶显示
💻 LST
📖 第 1 页 / 共 3 页
字号:
 134                          
 135                          LCDSetPage2(page);
 136                          LCDSetCol2(col1-MAXCOL);
 137                          for(i=MAXCOL;i<=col2-MAXCOL;i++)
 138                                  *(pdat++)=LCDReadDat2();        
 139                  }
 140          }
 141          */
 142          void LCDDrawRect(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,char color)
 143          {
 144   1              unsigned char i,j,page0,page1,width,temp,ym,dtemp,mask;
 145   1              if(x0>x1)xchg(&x0,&x1);
 146   1              if(y0>y1)xchg(&y0,&y1);
 147   1              page0=y0>>3;
 148   1              page1=y1>>3;
 149   1              width=x1-x0+1;
 150   1              ym=y0%8;
 151   1      
 152   1              for(j=page0;j<=page1;j++)
 153   1              {
 154   2                      if(j>3)break;
 155   2                      LCDSetPage1(j);
 156   2                      LCDSetPage2(j);
 157   2      
 158   2                      if(x0<MAXCOL&&x1<MAXCOL)
 159   2                              LCDWriteCom1(x0);       
 160   2                      else if(x0<MAXCOL)
 161   2                      {       
 162   3                              LCDWriteCom1(x0);
 163   3                              LCDWriteCom2(0);
C51 COMPILER V7.07   LCD                                                                   08/17/2004 16:30:50 PAGE 5   

 164   3                      }
 165   2                      else if(x0>=MAXCOL)
 166   2                              LCDWriteCom2(x0-MAXCOL);
 167   2      
 168   2                      LCDSetModifyWriteON1();
 169   2                      LCDSetModifyWriteON2();
 170   2      
 171   2                      for(i=x0;i<=x1;i++)
 172   2                      {
 173   3                              if(i>MAXCOL*2)break;
 174   3                              if(i<MAXCOL)dtemp=LCDReadDat1();
 175   3                              else dtemp=LCDReadDat2();
 176   3                      
 177   3                              if(j==page0)
 178   3                              {
 179   4                                      mask=0xff<<ym;
 180   4                              }
 181   3                              else if(j!=page0)
 182   3                              {
 183   4                                      mask=0xff;
 184   4                              }
 185   3                              if(j==page1)
 186   3                              {
 187   4                                      mask=mask&(0xff>>(7-y1%8));
 188   4                              }
 189   3                              temp=mask;
 190   3      
 191   3                              if(color==0)temp=dtemp&(~mask);
 192   3                              else temp=dtemp|mask;
 193   3                              if(i<MAXCOL)LCDWriteDat1(temp);
 194   3                              else if(i<2*MAXCOL) LCDWriteDat2(temp);
 195   3                              else break;
 196   3                      }       
 197   2                      LCDSetModifyWriteOFF1();
 198   2                      LCDSetModifyWriteOFF2();
 199   2                      if(j>3)break;
 200   2              }
 201   1      }
 202          
 203          void LCDDrawChar10(unsigned char x0,unsigned char y0,unsigned char *pic,char mode)
 204          {
 205   1              unsigned char i,j,page0,page1,temp,ym,dtemp,mask;
 206   1      
 207   1              page0=y0>>3;
 208   1              page1=y0+10>>3;
 209   1              ym=y0%8;
 210   1      
 211   1              for(j=page0;j<=page1;j++)
 212   1              {
 213   2                      if(j>3)break;
 214   2                      LCDSetPage1(j);
 215   2                      LCDSetPage2(j);
 216   2      
 217   2                      if(x0<MAXCOL&&(x0+11)<MAXCOL)
 218   2                              LCDWriteCom1(x0);       
 219   2                      else if(x0<MAXCOL)
 220   2                      {       
 221   3                              LCDWriteCom1(x0);
 222   3                              LCDWriteCom2(0);
 223   3                      }
 224   2                      else if(x0>=MAXCOL)
 225   2                              LCDWriteCom2(x0-MAXCOL);
C51 COMPILER V7.07   LCD                                                                   08/17/2004 16:30:50 PAGE 6   

 226   2      
 227   2                      LCDSetModifyWriteON1();
 228   2                      LCDSetModifyWriteON2();
 229   2      
 230   2                      for(i=x0;i<=x0+10;i++)
 231   2                      {
 232   3                              unsigned char d0,d1;
 233   3                              if(i>MAXCOL*2)break;
 234   3                              if(i<MAXCOL)dtemp=LCDReadDat1();
 235   3                              else dtemp=LCDReadDat2();
 236   3                              if(i==x0+10)
 237   3                              {
 238   4                                      d0=0;
 239   4                                      d1=0;           
 240   4                              }
 241   3                              else
 242   3                              {
 243   4                                      d0=*(pic+i-x0);
 244   4                                      if(i==x0)d1=pic[10]&0x3;
 245   4                                      else if(i==x0+1)d1=(pic[10]>>2)&0x3;
 246   4                                      else if(i==x0+2)d1=(pic[10]>>4)&0x3;
 247   4                                      else if(i==x0+3)d1=(pic[10]>>6)&0x3;
 248   4                                      else if(i==x0+4)d1=pic[11]&0x3;
 249   4                                      else if(i==x0+5)d1=(pic[11]>>2)&0x3;
 250   4                                      else if(i==x0+6)d1=(pic[11]>>4)&0x3;
 251   4                                      else if(i==x0+7)d1=(pic[11]>>6)&0x3;
 252   4                                      else if(i==x0+8)d1=pic[12]&0x3;
 253   4                                      else if(i==x0+9)d1=(pic[12]>>2)&0x3;
 254   4                              }
 255   3      
 256   3                              if(j==page0)
 257   3                              {
 258   4                                      temp=d0<<ym;
 259   4                                      mask=0xff<<ym;
 260   4                              }
 261   3                              else if(j!=page0)
 262   3                              {
 263   4                                      temp=(d0>>(8-ym))|(d1<<ym);
 264   4                                      mask=0xff;
 265   4                              }
 266   3                              if(j==page1)
 267   3                              {
 268   4                                      temp=temp&(0xff>>(7-(y0+10)%8));
 269   4                                      mask=mask&(0xff>>(7-(y0+10)%8));
 270   4                              }
 271   3      
 272   3                              if(mode==DrawType_Normal)temp=(dtemp&(~mask))|(temp&mask);
 273   3                              else if(mode==DrawType_NotNormal)temp=(dtemp&(~mask))|((~temp)&mask);
 274   3                              else if(mode==DrawType_Mask)temp=(dtemp&(~mask))|((dtemp|temp)&mask);
 275   3                              else if(mode==DrawType_NotMask)temp=(dtemp&(~mask))|((dtemp|(~temp))&mask);
 276   3                              else if(mode==DrawType_And)temp=(dtemp&(~mask))|((dtemp&temp)&mask);
 277   3                              else if(mode==DrawType_Or)temp=(dtemp&(~mask))|((temp|dtemp)&mask);
 278   3                      
 279   3                              //else if(mode==DrawType_Not)temp=(dtemp&(~mask))&((~temp)&mask);
 280   3                      //      else if(mode==DrawType_MaskNot)temp=(dtemp&(~mask))|((~temp)&mask);
 281   3      
 282   3                              if(i<MAXCOL)LCDWriteDat1(temp);
 283   3                              else if(i<2*MAXCOL) LCDWriteDat2(temp);
 284   3                              else break;
 285   3                      }
 286   2      
 287   2                      LCDSetModifyWriteOFF1();
C51 COMPILER V7.07   LCD                                                                   08/17/2004 16:30:50 PAGE 7   

 288   2                      LCDSetModifyWriteOFF2();
 289   2                      if(j>3)break;
 290   2              }
 291   1      }
 292          
 293          void LCDDrawText10(unsigned char x0,unsigned char y0,unsigned char size,unsigned int *dat,char mode)
 294          {
 295   1              unsigned char i;
 296   1              for (i=0;i<size;i++)
 297   1              {
 298   2                      LCDDrawChar10(x0,y0,CharTable10+(*(dat+i))*13,mode);
 299   2                      x0+=11; 
 300   2              }
 301   1      }
 302          
 303          
 304          void LCDDrawImg(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,unsigned char *pic,cha
             -r mode)
 305          {
 306   1              unsigned char i,j,page0,page1,width,temp,ym,dtemp,mask;
 307   1              if(x0>x1)xchg(&x0,&x1);
 308   1              if(y0>y1)xchg(&y0,&y1);
 309   1              page0=y0>>3;
 310   1              page1=y1>>3;
 311   1              width=x1-x0+1;
 312   1              ym=y0%8;
 313   1              
 314   1              for(j=page0;j<=page1;j++)
 315   1              {
 316   2                      if(j>3)break;
 317   2                      LCDSetPage1(j);
 318   2                      LCDSetPage2(j);
 319   2      
 320   2                      if(x0<MAXCOL&&x1<MAXCOL)
 321   2                              LCDWriteCom1(x0);       
 322   2                      else if(x0<MAXCOL)
 323   2                      {       
 324   3                              LCDWriteCom1(x0);
 325   3                              LCDWriteCom2(0);
 326   3                      }
 327   2                      else if(x0>=MAXCOL)
 328   2                              LCDWriteCom2(x0-MAXCOL);
 329   2      
 330   2                      LCDSetModifyWriteON1();
 331   2                      LCDSetModifyWriteON2();
 332   2      
 333   2                      for(i=x0;i<=x1;i++)
 334   2                      {
 335   3                              if(i>MAXCOL*2)break;
 336   3                              if(i<MAXCOL)dtemp=LCDReadDat1();
 337   3                              else dtemp=LCDReadDat2();
 338   3                      
 339   3                              if(j==page0)
 340   3                              {
 341   4                                      temp=(*(pic+(i-x0)))<<ym;
 342   4                                      mask=0xff<<ym;
 343   4                              }
 344   3                              else if(j!=page0)
 345   3                              {
 346   4                                      temp=((*(pic+(j-page0-1)*width+(i-x0)))>>(8-ym))
 347   4                                                      |((*(pic+(j-page0)*width+(i-x0)))<<ym);
 348   4                                      mask=0xff;
C51 COMPILER V7.07   LCD                                                                   08/17/2004 16:30:50 PAGE 8   

 349   4                              }
 350   3                              if(j==page1)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -