upsd3300_lcd.lst

来自「增强型8位单片机upsd33xx系列芯片PWM结合ADC例程」· LST 代码 · 共 1,169 行 · 第 1/4 页

LST
1,169 行
字号
                                              dot_buffer[i] = ~pic[i-1];
                                                      
                                      }
                              
                               }
                              else
                              {
                                      if(i%2==0)
                                      {
                                      dot_buffer[i] = pic[i+1];
                                                      
                                      }
                                      if(i%2==1)
                                      {
                                              dot_buffer[i] = pic[i-1];
                                      
                                      }
                      
                              }
                      }
              }
              
              void disp_one_asc3(unsigned char width,unsigned char length,unsigned char *pic)
              {
                      unsigned long  i;
                      for (i=0;i<width*length;i++)
                      {
                              if(mode) 
                              {
                                      if(i%3==0)
                                      {
                                              dot_buffer[i] = ~pic[i+2];
                                                      
                                      }
                                      if(i%3==1)
                                      {
                                              dot_buffer[i] = ~pic[i];
                                                      
                                      }
                                      if(i%3==2)
                                      {
                                              dot_buffer[i] = ~pic[i-2];
                                                      
                                      }               
                               }
                              else
                              {
                                      if(i%3==0)
                                      {
                                              dot_buffer[i] = pic[i+2];
                                                      
                                      }
                                      if(i%3==1)
                                      {
C51 COMPILER V7.50   UPSD3300_LCD                                                          07/11/2005 15:30:33 PAGE 11  

                                              dot_buffer[i] = pic[i];
                                                      
                                      }
                                      if(i%3==2)
                                      {
                                              dot_buffer[i] = pic[i-2];
                                                      
                                      }
                              }
                      }
              }
              
              void disp_one_asc4(unsigned char width, unsigned char *pic)
              {
                      unsigned long  i;
                      for (i=0;i<width*4;i++)
                      {
                              if(mode) 
                              {
                                      if(i%4==0)
                                      {
                                              dot_buffer[i] = ~pic[i+3];
                                                      
                                      }
                                      if(i%4==1)
                                      {
                                              dot_buffer[i] = ~pic[i+1];
                                                      
                                      }
                                      if(i%4==2)
                                      {
                                              dot_buffer[i] = ~pic[i-1];                              
                                      }       
                                      if(i%4==3)
                                      {
                                              dot_buffer[i] = ~pic[i-3];
                                      }               
                      }
                              else
                              {
                                      if(i%4==0)
                                      {
                                              dot_buffer[i] = *(pic+i+3);
                                      }
                                      if(i%4==1)
                                      {
                                              dot_buffer[i] = *(pic+i+1);
                                                      
                                      }
                                      if(i%4==2)
                                      {
                                              dot_buffer[i] = *(pic+i-1);                             
                                      }       
                                      if(i%4==3)
                                      {
                                              dot_buffer[i] = *(pic+i-3);
                                      }               
                              }
                      }
              }
              
              
C51 COMPILER V7.50   UPSD3300_LCD                                                          07/11/2005 15:30:33 PAGE 12  

              void DrawPic ( unsigned char x0,unsigned char y0,unsigned char width,unsigned char length,unsigned char *b
             -mp)
              {
                      unsigned char x, address;
                      unsigned char * dat;
              
                      unsigned char m;                
                      unsigned long i=0;
                      unsigned char page =0; // if layer = 0;page = 0,so it will disply the first line Chinese word
                      
                      bit window = 0;  //display on master LCD
                              unsigned char orig_buscon;
                         orig_buscon = BUSCON;   // Save buscon value
                         BUSCON |= 0x3C;           // Set Xdata Read/Write to max wait states
              
              
                      if(length%8==0)
                      m = length/8;
                      else
                      m = length/8 + 1;
              
                      if(m==2)
                      disp_one_asc2(width, length, bmp);
                      if(m==3)
                      disp_one_asc3(width, length, bmp);
                      if(m==4)
                      disp_one_asc4(width, bmp);
              
                  dat = dot_buffer;
              
                      OutMasterCom( 0X00 ); //display column address  
                      OutMasterCom ( 0XC0|y0 );//display start line   
              
                      OutSlaveCom ( 0X00 );
                      OutSlaveCom ( 0XC0|y0);
              
                      for(x=x0;x<x0+width;x++)
                      {
                              if(x>121)
                                       return;  //the column exceeded 121 will be ignored
                              if (x>60)       
                              { 
                                      window =1; //disply on slave LCD
                                      address = x%61;
                              }
                              else 
                              address = x;  //display on master LCD
              
                              SetPage (page,page);      //disply the upper part of a Chinese word
                              SetAddress(address,address);
              
                              if (window) 
                                      PutChar0(dat[i]);
                              else 
                                      PutChar1(dat[i]);
                                              i+=1; 
              
                              if(m>=2)
                              {
                                      SetPage (page+1,page+1);  //disply the lower part of a Chinese word
                                      SetAddress(address,address);
              
C51 COMPILER V7.50   UPSD3300_LCD                                                          07/11/2005 15:30:33 PAGE 13  

                                      if (window) 
                                              PutChar0(dat[i]);
                                      else 
                                              PutChar1(dat[i]);
                                              i+=1; 
                               }
              
                               if(m>=3)
                              {
                                      SetPage (page+2,page+2);  //disply the lower part of a Chinese word
                                      SetAddress(address,address);
              
                                      if (window) 
                                              PutChar0(dat[i]);
                                      else 
                                              PutChar1(dat[i]);
                                              i+=1; 
                               }
              
                               if(m>=4)
                              {
                                      SetPage (page+3,page+3);  //disply the lower part of a Chinese word
                                      SetAddress(address,address);
              
                                      if (window) 
                                              PutChar0(dat[i]);
                                      else 
                                              PutChar1(dat[i]);
                                              i+=1; 
                               }
                      }
                      BUSCON = orig_buscon;  // Restore buscon value
              }
              
              
              /*---------------------------------------------------------------------------------------
              Function:
                      this function is used to display a Chinese word. 
              Parameters:
                      x0:             start column address.
                  layer:      if layer = 0,display the first line Chinese word,otherwise display the second line.
                      width:  the number of column of a Chinese word dot matrix.
                      bmp:    the pointer of the  dot matrix data.
              Note:
                      the LCD can only display two line Chinese word,so page 0 and 1 is to display the first line,page2
                  and page 3 is to display the second line.
              
              ----------------------------------------------------------------------------------------*/
              
              void disp_one_ch(unsigned char col,unsigned char layer,unsigned int ch_code,unsigned char mode)
              {
                      unsigned char i,j,c2,c1;
                      extern PSD_REGS PSD_reg;
                      unsigned char xdata *ptr;
                      
                      j = PSD_reg.PAGE ; //reserve page number first
                      PSD_reg.PAGE = CHINESE_FONT_PAGE;
              
                      c2 = (unsigned char)((ch_code&0xff00)>>8);  
                      c1 = (unsigned char)(ch_code&0x00ff);
              
              
C51 COMPILER V7.50   UPSD3300_LCD                                                          07/11/2005 15:30:33 PAGE 14  

                      for(i=0;i<159;i++)  //check index table to get the specific location
                      {
                              if ((c2 == index[i])&&(c1 == index[i+1]))
                              {
                                      ptr = (unsigned char xdata *)((index[i+2])*32);
                                      break;
                               }
                      }
              
                      for(i=0;i<32;i++)
                      {
                              dot_buffer[i] = *(FONT_BASE_ADDRESS+ptr+i);  //fetch font data from internal flash directly
                      }
              
                      if (mode)
                      {
                              for(i=0;i<32;i++)
                              {       
                                      dot_buffer[i] = ~ dot_buffer[i];
                              }
                      }
                              DrawBmp(col,layer,16,dot_buffer);//display the Chinese word after get the data from flash
                              PSD_reg.PAGE = j;  //restore page number
              }
              #endif
 811          /*---------------------------------------------------------------------------------------
 812          Function:
 813                  this function is used to converts low nibble of unsigned byte.
 814          Parameters:
 815                  byte: this unsigned byte is ready to converting.
 816          Note:
 817                  none
 818          
 819          ----------------------------------------------------------------------------------------*/
 820          char htoa_lo(unsigned char byte)         
 821                                                   // (0-F hex) to ascii   
 822          {
 823   1              {
 824   2              byte = byte & 0x0F;     // keep lower nibble only   
 825   2              if (byte <= 0x09)
 826   2                      return(byte + 0x30);
 827   2              else
 828   2                      return (byte + 0x37);
 829   2              }
 830   1      }

⌨️ 快捷键说明

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