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

📄 kb.c

📁 自己编写的
💻 C
📖 第 1 页 / 共 2 页
字号:
#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"
#include "..\inc\Smlogo.h"

#include "..\inc\character.h"
#include "..\inc\page.h"



//#include"..\inc\plmm.h"

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

/*
//create a control file.
//return the file name.
//writed  by liangweidong.
void Createcontrolfile(unsigned int filelongth, struct Controlpoint *filename)
{
unsigned int i;
struct Controlpoint *p, *l;
filename = (struct Controlpoint *)malloc(sizeof(struct Controlpoint)); //create a control file
p = filename;
p->mark = 1; //set the first node's make as 1
for (i = 0; i < filelongth; i ++)
	{
	p = (struct Controlpoint *) malloc(sizeof(struct Controlpoint));
	p->sequence = i+1;
	p->mark = 0;
	p->thickness = 0x0f;
	l = p;
	p = l->next_point ;
	}
l->mark = 1; //set the last node's make as 1
l->next_point = NULL;
}



//delete a control file.
//writed  by liangweidong.
void Deletecontrolfile(struct Controlpoint *filename)
{
struct Controlpoint *p;
p = filename->next_point;

while (filename->next_point != NULL)
	{
	p = filename->next_point;
	free(filename);
	filename = p;
	}
}


//evaluate a value to the control file's node.
//writed  by liangweidong.
void Evaluatecontrolpoint(unsigned int currentpoint, unsigned int thicknessvalue, struct Controlpoint *filename)
{
struct Controlpoint *p, *l, *front_node, *next_node, *current_node;
unsigned char i =0, front_sequence = 0, current_sequence = 0, next_sequence = 0;
//set the value to current node.
p = filename->next_point;
for (i = 0; i < currentpoint ; i ++)
	{
	l = p->next_point;
	p = l;
	}
current_node = p;
current_sequence = p->sequence; //save the current node's sequence
p->thickness = thicknessvalue;
p->mark = 1;
//search the front mark node from frist node. 
l = p = filename->next_point;
while((p->next_point != NULL)|(p->sequence != currentpoint))
	{
	p = l ->next_point;
	if((l ->mark == 1)&&((l->sequence) < (current_node->sequence)))
	front_sequence = l ->sequence;
	if((l->sequence) == (current_node->sequence))
		break;
	l = p;
	}
//after the front mark node and befor the current mark node, be evaluated suitability volue.
p = l = front_node;
do
	{
	p->thickness = front_node->thickness 
		+ (current_node->thickness - front_node->thickness)*(p->sequence-front_node->sequence)
			/(current_node->sequence - front_node->sequence);//calculate the thickness value
	p = l->next_point;
	}
	while(p->sequence == current_sequence);
//display the thickness
for(i = 0; i < (current_sequence - front_node->sequence); i++)
	{
//	DrawHorizontalLine((1323+), (current_sequence*10 ));
	}
	
//search the next mark node from current node. 
while((p->mark != 1)|(p->next_point !=NULL))
	{
	p = l ->next_point;
	l = p;
	}
next_sequence = p->sequence;
current_node = p;
//after the current mark node and befor the next mark node, be evaluated suitability volue.
p = l = current_node;
do
	{
	p->thickness = current_node->thickness 
		+ (next_node->thickness - current_node->thickness)*(p->sequence-current_node->sequence)
			/(next_node->sequence - current_node->sequence);//calculate the thickness value
	p = l->next_point;
	}
	while(p->sequence == next_sequence);
//display the thickness
//for(i = 0; i < (current_sequence - front_node->sequence); i++)
//	{
//	DrawHorizontalLine((1323+), (current_sequence*10 ));
//	}
	
}
//end 2005-07-14
*/


//added by liangweidong 2005-8-1
extern fileparameter  *file_parameter;
extern flagsetting  *flag_setting;

//create a control file.
void Createcontrolfile(unsigned int filelongth, char *filename)
{
	unsigned int i;
	file_parameter->totalpointnumber = filelongth;
//	file_parameter = ( fileparameter *)malloc(sizeof( fileparameter));  //create a control file
	strcpy((file_parameter->name), filename);
	file_parameter->totalpointnumber = filelongth;

	//initilizate the control file data
//	f = p->file[0];
	clear_alarm_flag(0);	//file_parameter->file[0].alarmflag = 0;
	set_trun_flag(0);		//file_parameter->file[0].turnflag = 1;
	write_file_data(100, 0);	//file_parameter->file[0].data = 100;
	
	for (i = 1; i < filelongth; i ++)
	{
//		f = p->file[i];
		clear_alarm_flag(i);
		clear_trun_flag(i);
		write_file_data(100, i);
	}
//	f = p->file[filelongth];
		clear_alarm_flag(filelongth);
		set_trun_flag(filelongth);
		write_file_data(100, filelongth);
}

//evaluate a value to the control file's node.
void Evaluatecontrolpoint(unsigned short int currentpoint, unsigned short int thicknessvalue)//, struct fileparameter *filename)
{
	unsigned short int i, frontpoint, nextpoint, nextdata, frontdata, currentdata, temp;
	

	//set the value to current node.
//	f = p.file[currentpoint];
	write_file_data(thicknessvalue, currentpoint);//file_parameter->file[currentpoint].data = thicknessvalue;

	//search the front inflexional node from current node. 
	frontpoint = currentpoint;
	do
		{
			frontpoint--; 
//			f = p.file[frontpoint];
		}
		while( seek_trun_flag(frontpoint));  //file_parameter->file[frontpoint].turnflag);
	frontdata = read_file_data(frontpoint);	//frontdata = file_parameter->file[frontpoint].data;
		
	//after the front inflexional node and befor the current inflexional node, be evaluated suitability volue.
	i = frontpoint;
	do
		{
//		
//		file_parameter->file[i++].data = (thicknessvalue -file_parameter->file[frontpoint].data)
//			*((i - frontpoint)/((currentpoint - frontpoint))
//				+file_parameter->file[frontpoint].data);

			temp = (thicknessvalue -frontdata)
				*((i - frontpoint)/((currentpoint - frontpoint))
					+ frontdata);
			write_file_data(temp, i);
			i++;
		
		}while(i == currentpoint);
		
	//display the thickness
	//for(i = 0; i < (current_sequence - front_node->sequence); i++)
	//	{
	//	DrawHorizontalLine((1323+), (current_sequence*10 ));
	//	}
		
	//search the next inflexional node from current node. 
	nextpoint = currentpoint;
	do
		{
//			f = p.file[nextpoint];
			nextpoint++; 
		}
		while( seek_trun_flag(nextpoint));//(file_parameter->file[nextpoint].turnflag);

	//after the current mark node and befor the next mark node, be evaluated suitability volue.
	i = currentpoint;
	do
		{
//			f = p.file[i++];
			
//			file_parameter->file[i++].data = (file_parameter->file[currentpoint].data - file_parameter->file[nextpoint].data)
//			*((i - nextpoint)/(currentpoint - nextpoint))
//				+file_parameter->file[nextpoint].data;
			currentdata = read_file_data(currentpoint);
			temp = (currentdata - nextdata)*((i - nextpoint)/(currentpoint - nextpoint)) + nextdata;
			write_file_data(temp, i);
			i++;
		}
		while(i == nextpoint);
		
}


/*
// set a mark in current point
void Setalarmflag(unsigned int currentpoint,  fileparameter filename)
{
//	struct filedata f;
	filename.file[currentpoint].alarmflag = 1;
//	f.alarmflag = 1;
}

//clear a mark in current point
void Clearalarmflag(unsigned int currentpoint,  fileparameter filename)
{
//	struct filedata f;
	filename.file[currentpoint].alarmflag = 0;
//	f.alarmflag = 0;
}
*/


//end 2005-07-14



//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;
    }
}

//test end

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, 16);                            // 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, 16);                            // 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, 16);                            // 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, 16);                            // 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 );

⌨️ 快捷键说明

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