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

📄 some_test.c

📁 使用embest IDE开发工具开发的基于LPC2294 的触摸屏开发
💻 C
📖 第 1 页 / 共 2 页
字号:
						break;									
			case 4:		j=45678901;
						break;			
			case 5:		j=56789012;
						break;			
			case 6:		j=67890123;
						break;				
			case 7:		j=78901234;
						break;	
			case 8:		j=89012345;
						break;
			case 9:		j=90123456;
						break;	
			default:	break;							
		}
		i++;
		i=i%10;	
		display_88(j);
		
	    if(mytouch_moni_key())
		 break;
		
		time_dly(10);
      }
}      
/*******************************************************

*******************************************************/		
void AD_test(void)
{
	INT32U i,data;
	mycls(0xe0);	
	//输入字母	
	myposi_set(0,0);			//set display position	
	myposi_piexl_start(10,10);
    myLCD_fore_on(0);
    mycolor_set(0xe0,0x0);
	myLCD_printf("A/D test..");

    myposi_set(0,0);			//set display position	
    myLCD_fore_on(0);
    myposi_piexl_start(10,30);
    mycolor_set(0xe0,0x0);
	myLCD_printf("screw it...");
	
	myposi_set(0,0);			//set display position	
    myposi_piexl_start(10,50);
    myLCD_printf("Press anywhere to return!");
//CD_printf("Press any key!");
	while(1)
	{
	//	posi_set(3,0);	
		
//LCD_printf("AIN6: %d   ",data);
        myposi_set(0,0);	//set display position	
        myLCD_fore_on(0);
        myposi_piexl_start(10,70);
        mycolor_set(0xe0,0x0);
        AD_init(0,AIN6,0,0);
		data=AD_value();
    	myLCD_printf("AIN6: %d   ",data);
    	
	//	posi_set(4,0);		
			
    	myposi_set(0,0);	//set display position	
        myLCD_fore_on(0);
        mycolor_set(0xe0,0x0);
        myposi_piexl_start(10,90);
        AD_init(0,AIN7,0,0);
		data=AD_value();
    	myLCD_printf("AIN7: %d",data);
    	
    	
    	
    	
		if(mytouch_moni_key())
			break;
		time_dly(60);
	}
	AD_close();
	
	touch_data.x=0;
	touch_data.y=0;
}

/*******************************************************

*******************************************************/
void led_test(void)
{  
        mycls(0xe0);	
        myposi_set(0,0);	//set display position	
        myLCD_fore_on(0);
        myposi_piexl_start(10,10);
        mycolor_set(0xe0,0x0);
    	myLCD_printf("LED testing...");
    	
    	myposi_set(0,0);
    	myposi_piexl_start(10,30);
    	myLCD_printf("Press anywhere to return!");
//	LCD_printf("LED testing...\nPress any key!\n");
    	Init_lamp();	
	 while(1)
	{
		IO_lamp(0, 1);
		 time_dly(0x80);
		 IO_lamp(1, 0);
		 time_dly(0x80);
	   	 if(mytouch_moni_key())
			break;
	}
	IO_lamp(0, 0);	
	
	touch_data.x=0;
	touch_data.y=0;
}

/*******************************************************

*******************************************************/

void uart0_pc(void)
{
	
	bit_lcd=1;
	 while(1)
	{
	
	if(bit_lcd)
	{
	mycls(0xe0);									//clear screen  black blue
	draw_picture(50,10,270,40,50,17); 
	myLCD_printf("     start");
	draw_picture(50,50,270,80,50,57); 
	myLCD_printf("     return");
	
    	myposi_piexl_start(0,100);	//set display position	
	 
	    myposi_set(0,0);
        myLCD_fore_on(0);
        mycolor_set(0xe0,0x0);
    	myLCD_printf("   uart0 & PC!");
    	
    	myposi_piexl_start(0,120);
    	myposi_set(0,0);
        myLCD_printf("  set hyper_terminal..");	
    	
    	myposi_piexl_start(0,140);
    	myposi_set(0,0);
    	myLCD_printf("    57600 8 N 1 N");
    	
    bit_lcd=0;	
	}
	touch_data=mytouch_get_key();
	
	if(!(touch_data.x==0&&touch_data.y==0))
	{	
	lcd_pix=getDisplayPoint( touch_data );
	
	touch_data.x=0;
	touch_data.y=0;
	
	if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 10 && lcd_pix.y <= 40)
        case_value=1;
      else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 50 && lcd_pix.y <= 80)                    
	    case_value=2;
	 
	  else
	    case_value=3;
	      
	switch(case_value)
	 	{
	 	    case 1:	uart0_to_pc_testing();	 
	 					break;
	 		case 2: bit_lcd=1; 
	 		       	return;
	 										 	 						 						 						 					
	 		case 3: touch_errer();            
	 	//				time_dly(200);
	 					break;	 
//	        case 3:	    return;
	            //   	 time_dly(10);
		 		 
	   }
	   bit_lcd=1;
	  } 
	}
}	
//	LCD_printf("uart0 & PC!\n");
//	LCD_printf("set hyper_terminal..\n57600 8 N 1 N\n");
//	LCD_printf("any key start");
//	data=get_key();
	
//	cls();
//	LCD_printf("testing...\n");
//	LCD_printf("Press any key to quit!\n");
	


/*******************************************************/
void uart0_to_pc_testing(void)
{   
    	INT8U data;
    	mycls(0xe0);
    	myposi_set(0,0);	//set display position	
        myLCD_fore_on(0);
        mycolor_set(0xe0,0x0);
        myposi_piexl_start(10,10);
    	myLCD_printf("testing...");
    	
    	myposi_set(0,0);
    	myposi_piexl_start(10,30);
    	myLCD_printf("Press return key to quit!");

    uart0_init(57600); 			//set baudrate 			
		
	uart0_printf("\n\nwelcome,:)\n");
	uart0_printf("nothing impossible!\n");
	uart0_printf("we all are hero!\n\n"); 

	while(1)
	{
	data=uart0_getkey();
	if(data)
    	{	if(data=='\r')
			data='\n';	
		uart0_sendch(data);
    	}
    	
	if(mytouch_moni_key())
	 break;	
	}
	uart0_close();
	
	touch_data.x=0;
	touch_data.y=0;
		
}

/*******************************************************/
void uart0_uart1(void)
{
	INT8U i,data=0;
	mycls(0xe0);
    	myposi_set(0,0);	//set display position	
        myLCD_fore_on(0);
        mycolor_set(0xe0,0x0);
        
        myposi_piexl_start(0,0);
    	myLCD_printf("uart0 & uart1!");
    	
    	myposi_piexl_start(0,20);
    	myposi_set(0,0);
    	myLCD_printf("testing...");
//	LCD_printf("uart0 & uart1!");
//	LCD_printf("testing...\n");
	
    uart0_init(57600); 			//set uart0 baudrate 			
    uart1_init(57600); 			//set uart1 baudrate 
    			
	myposi_set(0,0);	//set display position	
        myLCD_fore_on(0);
        mycolor_set(0xe0,0x0);
        myposi_piexl_start(0,40);
	myLCD_printf("uart0 send A~Zuart1 receive");


    	myposi_piexl_start(0,60);
    	myposi_set(0,0);	
	for(i='A';i<'Z';i++)
	{
		uart0_sendch(i);
		time_dly(1);
		data=uart1_getkey();	
		if(data!=i)
		{
			myLCD_printf("error!");
			break;
		}
	}
	if(i=='Z')
	myposi_set(0,0);	//set display position	
        myLCD_fore_on(0);
        mycolor_set(0xe0,0x0);
        myposi_piexl_start(0,80);
	myLCD_printf("success!  any key quit!");
	
	while(1)
	{
//	touch_data=mytouch_get_key();
	
//	lcd_pix=getDisplayPoint( touch_data );
	
	if(mytouch_moni_key())
//	    com_test();
		break;
	}
	uart0_close();
	uart1_close();	
	
    touch_data.x=0;
	touch_data.y=0;
}
/*******************************************************

*******************************************************/

void IIC_test(void)
{
	INT8U data[16];
	INT8U i;
	
	IIC_init();
	mycls(0xe0);
	    myposi_piexl_start(10,10);
		myposi_set(0,0);	//set display position	
        myLCD_fore_on(0);
        mycolor_set(0xe0,0x0);
	myLCD_printf("IIC test...");
	
	 myposi_piexl_start(10,30);
	 myposi_set(0,0);
	myLCD_printf("Writing.. 0~f");	
	for(i=0;i<16;i++)
	Wr24C02(0xa0,i,i);
	
	 myposi_piexl_start(10,50);
	 myposi_set(0,0);
	myLCD_printf("Reading...");
	
	 myposi_piexl_start(0,70);
	 myposi_set(0,0);
	for(i=0;i<16;i++)
	{
		Rd24C02(0xa0,i,&data[i]);
		myLCD_printf(" %x",data[i]);
	}
	myposi_piexl_start(10,90);
	myposi_set(0,0);
	myLCD_printf("Press anywhere to return!");
	while(1)
	{
	
//	touch_data=mytouch_get_key();
	
//	lcd_pix=getDisplayPoint( touch_data );
	
	   	 if(mytouch_moni_key())
//	   	    com_test();
			break;	
	}
	
	touch_data.x=0;
	touch_data.y=0;	

}
//只有开始设置了IIC模式,没有结束IIC模式

/**************************************************
按一个按钮亮一个灯
SW18-LAMP1
SW19-LAMP2
***************************************************/
void switch_test(void)
{					 //sw18 and sw19 test
	 INT32U i;
	  Init_lamp();
	  mycls(0xe0);
		myposi_set(0,0);	//set display position	
        myLCD_fore_on(0);
        myposi_piexl_start(10,10);
        mycolor_set(0xe0,0x0);
	  myLCD_printf("sw18 and sw19");
	  
	  myposi_set(0,0);
	  myposi_piexl_start(10,30);
	  myLCD_printf("press it!");
	  
	  myposi_set(0,0);
	  myposi_piexl_start(10,50);
	  myLCD_printf(" press anywhere to quit!");
	  	  
	  i = PINSEL2;   //set p1.24 p1.25 to gpio
	  i &= 0xfffffff7;       //第四位为0
	  PINSEL2 = i;
	  
	  i = IODIR1;	//set to input
	  i &= 0xfcffffff;
	  IODIR1 = i;
	  
	  i =  IOSET1;	//set state as 1
	  i |= 0x03000000;
	  IOSET1 = i;
		  
	  while(1)
	  {
	  	if(!(IOPIN1 & 0x01000000))
	  		IO_lamp(0, 1);
	  	if(!(IOPIN1 & 0x02000000))
	  		IO_lamp(1, 0);
	  		
//	  	touch_data=mytouch_get_key();
	
 //      	lcd_pix=getDisplayPoint( touch_data );
	
	  	if(mytouch_moni_key())
//	  	    com_test();
	  		break;	  		  
	  }
	  IO_lamp(0, 0);
	  
	touch_data.x=0;
	touch_data.y=0;	  
	
}
/*******************************************************

*******************************************************/
void buzzer_test(void)
{
	INT32U i,data;
 	mycls(0xe0);
		myposi_set(0,0);	//set display position
			
        myLCD_fore_on(0);
        mycolor_set(0xe0,0x0);
        
        
	  myposi_piexl_start(10,10);
 	myLCD_printf("buzzer test");
 	
 	myposi_set(0,0);
	myposi_piexl_start(10,30);
 	myLCD_printf("screw AIN6...");
 	
 	myposi_set(0,0);
	myposi_piexl_start(10,50);
 	myLCD_printf("any key quit!");
 	
	i = IODIR2;			//open buzzer latch
	i |= (0x1<<21);     //用这1.21来控制buzzer的使能,但不知为什么不用设管脚连接模块
	IODIR2 = i;	
	
	i = IOCLR2;
	i |= (0x1<<21);
	IOCLR2 = i;
	
	pwm_init(0,pwm3,1);//init pwm3 to buzzer
  	pwm_set_f(10);		//set lowest frequency as 10Hz
  	pwm_single_edge(pwm3,10,0.5);
  	pwm_enable();		//pwm enable

	
	AD_init(0,AIN6,0,0);
	while(1)
	{
	data=AD_value();	//convert AD value to buzzer frequency
	data=(data/8)*50+10;  //???????????????????????????
	
	pwm_set_f(data);	
  	pwm_single_edge(pwm3,data,0.5);
  	
//  	touch_data=mytouch_get_key();
	
//    lcd_pix=getDisplayPoint( touch_data );
       	
  	if(mytouch_moni_key())
 // 	com_test();
  		break;
  	time_dly(50);
	}
	pwm_close();
	//close buzzer latch
	i = IOSET2;
	i |= (0x1<<21);
	IOSET2 = i;
	
	touch_data.x=0;
	touch_data.y=0;	
}


void motor(INT8U type)
{
	INT8U mode=10;
//	mycls(0xe0);
//		myposi_set(50,50);	//set display position	
//        myLCD_fore_on(0);
//        mycolor_set(0xe0,0x0);
//	LCD_printf("Select motor type!\n");
//	LCD_printf("1:DC motor\n2:step motor\n");	
//	myLCD_printf("Select rotate mode!\n\n\n\n");
//	myLCD_printf("0:Deasil\n1:Contrarotate\n\n\n\n");
   bit_lcd=1;
   while(1)
   {
    if(bit_lcd)
    { 
    mycls(0xe0);
    myposi_set(0,0);
	myposi_piexl_start(10,10);
	myLCD_printf("any key quit");
  
	    draw_picture(50,90,270,120,50,127); 
    	myLCD_printf("     0:Deasil");
    	draw_picture(50,130,270,160,50,167); 
    	myLCD_printf("     1:Contrarotate");
        draw_picture(50,170,270,200,50,207);
    	myLCD_printf("     ruturn");
     bit_lcd=0;	
    }	
    
   	touch_data=mytouch_get_key();
	

	
	if(!(touch_data.x==0&&touch_data.y==0))
	 {
	lcd_pix=getDisplayPoint( touch_data );
	
	touch_data.x=0;
	touch_data.y=0;
	
	if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 90 && lcd_pix.y <= 120)
        mode=0;
      else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 130 && lcd_pix.y <= 160)                    
	    mode=1;
	  else if(lcd_pix.x >= 50 && lcd_pix.x <= 270 && lcd_pix.y >= 170 && lcd_pix.y <= 200)
	    mode=2;
	  else
	    mode=3;
	
		if(mode==0)
	    	{
			mycls(0x50);
			myposi_set(0,0);
	        myposi_piexl_start(10,10);
			myLCD_printf("Deasil rotating...");
		//	break;	
	    	}
	 	else
		if(mode==1)
	    	{
			mycls(0x60);
			myposi_set(0,0);
	        myposi_piexl_start(10,10);
			myLCD_printf("Contrarotating...");
		//	break;
	    	}
		else
		if(mode==3)
		    {
		    mycls(0x10);
		    myposi_set(0,0);
	        myposi_piexl_start(10,10);
		    myLCD_printf("press one of the keys!!");
		 //   break;
		    }
		else    
		if(mode==2)
			break;				
     
    	
//	myLCD_printf("any key quit!\n\n\n");
	motor_init();
    while(1)
     {
	motor_test(type,mode);
//	touch_data=mytouch_get_key();
//   	if(!(touch_data.x==0&&touch_data.y==0))
//	 {	
 //   lcd_pix=getDisplayPoint( touch_data );
//	  }
	if(mytouch_moni_key())
//	   motor_con();
		break;
	
	 }
	 bit_lcd=1;
	 
	motor_close();	
	
    touch_data.x=0;
	touch_data.y=0;
	 }
	}
	motor_close();	
	
    touch_data.x=0;
	touch_data.y=0;
}
/*
void LCD_logo(void)
{
	INT32U i;
	
	mycls(0x00);
	while(1)
	{	
		touch_data=mytouch_get_key();
	
    lcd_pix=getDisplayPoint( touch_data );
	
	if(inter_flag)
	   simple_test();
		break;
	}	

}
*/

⌨️ 快捷键说明

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