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

📄 kb.c

📁 epson1147 是 240*320 黑白(16级灰度)的液晶配合sw44b0综合测试程序(附送液晶字模提取小程序)
💻 C
字号:
#include <string.h>
#include "..\inc\def.h"
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\kb.h"
#include "..\inc\option.h"
#include "..\inc\def.h"
#include "..\inc\lcd.h"
#include "..\inc\lcdlib.h"
#include "..\inc\44blcd.h"
#include "..\inc\myplmm.h"
#include "..\inc\plmm1.h"
#include "..\inc\plmm2.h"
#include "..\inc\plmm3.h"
#include "..\inc\plmm4.h"

 //#define LOOP 1
#define XTOTAL 256
#define YTOTAL 320
#define EVERYX 32
#define HIGHB 32

 void clr_pf(char onebit);
void setb_pf(char onebit);
void displaylcd(char num);
void displaylcd32(char x, char y, char num);
void clear(void);
void Lcd_kb_MonoInit_one(void);
void kb_displaylcd(unsigned short int type);
extern void  Lcd_MonoInit(void);
extern void clrscreen(void);
//void __irq keyboard(void);

/*void __irq keyboard(void)
{
    char x=0,y=0,yrecord;
    rINTMSK=(BIT_GLOBAL|BIT_EINT3);
    Delay(200);
    Uart_Printf("come in,   \n");	 
    if((rPDATE&0xf0)==0xf0)
       {
    	      rPDATF=0X1f;
             rINTMSK=~(BIT_GLOBAL|BIT_EINT3);
	      rI_ISPC = BIT_EINT3;
	      return;
       	}
    else
    {  
       for (x=5; x<9; x++)
        {
         rPDATF=0X1ff;
         clr_pf(x);
         if ((rPDATE&0xf0) !=0xf0)
            {
             yrecord=(~((rPDATE&0xf0)>>4))&0xf;
	      for (y=0;  yrecord!=0; y++)  
		  { 
		   yrecord=(yrecord>>1);
		   }
	      setb_pf(x);
	      Uart_Printf("the key is %d  \n", (y+(x-5)*4-1));
	      Delay(100);
             switch(y+(x-5)*4-1)
	      {
	        case 0:
                            displaylcd32(250, 176, y+(x-5)*4-1);
			        break;
		default: 
			       displaylcd32(250, 176, y+(x-5)*4-1);
                             break;
	     }
	      rPDATF=0X1F;
	      rINTMSK=~(BIT_GLOBAL|BIT_EINT3);
	      rI_ISPC = BIT_EINT3;
	      return;
	      }
         setb_pf(x);
	  }
	  rPDATF=0X1F;
	  rINTMSK=~(BIT_GLOBAL|BIT_EINT3);
         rI_ISPC = BIT_EINT3;
  	  return;
    }
}
*/
void Test_Kb(void)
{
    U8 which_key;
    unsigned short int type=0, i=0,j=0;
    rPCONG=0x00ff;	//EINT7~0
    rPUPG=0x0;		//pull up enable    
    Lcd_kb_MonoInit_one();
    clear();
    Uart_Printf("\n now let's start, enter a key please,you can see a picture in lcd \n");
    Uart_Printf("	press any key return\n");
    while(!Uart_GetKey())  
             {
    	         while((rPDATG & 0xf0)==0xf0 && type==0)
    	         	{
                          for (i=7; i<12; i++)
                                { 
                                  displaylcd32(j, 228, 15);                            // clear the last one bmp
                                  j=(i-7)*16;
	                           displaylcd32(j, 228, i);
					if ((rPDATG & 0xf0) !=0xf0)
						{ break ;}
                                   Delay(2200);
	                           }
                         for (i=12; i<17; i++)
                               { 
                                 displaylcd32(j, 228, 15);                            // clear the last one bmp
                                 j=(i-7)*16;
	                          displaylcd32(j, 228, i-5);
					if ((rPDATG & 0xf0) !=0xf0)
						{ break ;}
                                 Delay(2200);
	                        }
                         for (i=17; i<22; i++)
                              { 
                                 displaylcd32(j, 228, 15);                            // clear the last one bmp
                                 j=(i-7)*16;
	                         displaylcd32(j, 228, i-10);
					if ((rPDATG & 0xf0) !=0xf0)
						{ break ;}
                                 Delay(2200);
	                        }
                        for (i=22; i<24; i++)
                             { 
                               displaylcd32(j, 228, 15);                            // clear the last one bmp
                               j=(i-7)*16;
	                       displaylcd32(j, 228, i-15);
					if ((rPDATG & 0xf0) !=0xf0)
						{ break ;}
                              Delay(2200);
	                       }
                      }
    	         which_key=rPDATG&0xf0;
		  if (which_key >0 && type ==0)
		  	{
		  	  Lcd_MonoInit();
			  type=1;
		  	}
                switch(which_key)
                          {
    	                     case 0xe0:  kb_displaylcd(0x1);
    	                                      break;
    	                     case 0xd0:
    	                                      kb_displaylcd(0x2);
    	                                      break;
    	                     case 0xb0:
    	                                      kb_displaylcd(0x3);
    	                                      break;
    	                     case 0x70:
    	                                      kb_displaylcd(0x4);
    	                                      break;
    	                     default :
    	                                       break;
        	              }
     	}
}

/*********************************************************/
void Lcd_kb_MonoInit_one(void)
{
    //160x240 1bit/1pixel LCD
     #define MVAL_USED 0
     if((U32)frameBuffer1==0)
	{
	    if (( frameBuffer1=(unsigned int (*)[SCR_XSIZE/32])malloc(256/8*SCR_YSIZE))==NULL)
	    {
	      Uart_Printf("ERROR !!!!!! NO MEMERY !!!!!!!!! \n");
	    }
	}
   
	rLCDCON1=(0)|(1<<5)|(0<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_MONO<<12);
	    // disable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
	rLCDCON2=(LINEVAL)|(256/4-1<<10)|(10<<21);  
	    //LINEBLANK=10 (without any calculation) 
	rLCDSADDR1= (0x0<<27) | ( ((U32)frameBuffer1>>22)<<21 ) | M5D((U32)frameBuffer1>>1);
	    // monochrome, LCDBANK, LCDBASEU
	rLCDSADDR2= M5D( (((U32)frameBuffer1+(256*LCD_YSIZE/8))>>1) ) | (MVAL<<21);
	rLCDSADDR3= (256/16) | ( ((SCR_XSIZE-LCD_XSIZE)/16)<<9 );

	rLCDCON1=(1)|(1<<5)|(0<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_MONO<<12);
	    // enable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
    
}
void displaylcd32(char x, char y, char num)
{
    unsigned int *pbuffer,temp_data;
    unsigned int i=0, j=0, m=0;
    //clrscreen();
    pbuffer =(U32*) frameBuffer1;
    for(m=0; m<HIGHB; m++)
     {
       i = (y+m)*XTOTAL/EVERYX+x/EVERYX;
	//Uart_Printf("the i is : %x   \n", i);
       temp_data = (Bitmap32[num][m*4] << 24) + (Bitmap32[num][m*4+1] << 16) + (Bitmap32[num][m*4+2] << 8) +(Bitmap32[num][m*4+3]);
       j=(pbuffer[i]>>(EVERYX- x%EVERYX))<<(EVERYX-x%EVERYX);
	pbuffer[i]=j|(temp_data>>(x%EVERYX));
	//Uart_Printf("pbuffer[%d]= %x   \n", i, pbuffer[i]);   
	j=(pbuffer[i+1]<<(x%EVERYX))>>(x%EVERYX);
	pbuffer[i+1] = j|(temp_data<<(EVERYX-x%EVERYX));       // ~temp_data;  
       // Uart_Printf("pbuffer[%d]= %x   \n", i+1, pbuffer[i+1]);  
      }
}

void clear(void)
{ 
     unsigned int *pbuffer;
     int i;
     
    pbuffer =(U32*) frameBuffer1;
    for(i = 0; i< (9600/4) ;i++)
    {
        pbuffer[i] = 0;
 }

}

void kb_displaylcd(unsigned short int type)
{
   unsigned int *pbuffer,temp_data;
     int i,j=0;
    pbuffer =(U32*) frameBuffer16;
    clrscreen();
  if (type==1)
  {  
    for(i = 0; i< (38400/4) ;i++)
         {
            temp_data = (plmmBitmap1[i*4] << 24) + (plmmBitmap1[i*4+1] << 16) + (plmmBitmap1[i*4+2] << 8) +(plmmBitmap1[i*4+3]);
            pbuffer[i] = temp_data;
          }
   }
  if (type==2) 
  {  
    for(i = 0; i< (38400/4) ;i++)
         {
            temp_data = (plmmBitmap2[i*4] << 24) + (plmmBitmap2[i*4+1] << 16) + (plmmBitmap2[i*4+2] << 8) +(plmmBitmap2[i*4+3]);
            pbuffer[i] = temp_data;
          }
   }
  if (type==3)
  {  
    for(i = 0; i< (38400/4) ;i++)
         {
            temp_data = (plmmBitmap3[i*4] << 24) + (plmmBitmap3[i*4+1] << 16) + (plmmBitmap3[i*4+2] << 8) +(plmmBitmap3[i*4+3]);
            pbuffer[i] = temp_data;
          }
   }
  if (type==4)
  {  
    for(i = 0; i< (38400/4) ;i++)
         {
            temp_data = (plmmBitmap4[i*4] << 24) + (plmmBitmap4[i*4+1] << 16) + (plmmBitmap4[i*4+2] << 8) +(plmmBitmap4[i*4+3]);
            pbuffer[i] = temp_data;
          }
   }
}






⌨️ 快捷键说明

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