Exemplo n.º 1
0
void main(void)
{
    TFT_Initial();
    CLR_Screen(Black);
    init_timer(); 
    
    while(1);
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: qhw2015/aio
//================================================================================================
//	函数名称:	主函数
//	实现功能:	控制TFT实现汉字,字符显示.
//	参数:		无
//	返回值:	无
//================================================================================================
main()
{
//        unsigned char  run_computer,direction_index_computer;
		unsigned int x,y,z,di;
		float total,angle;
		
		Device_code=0x9320;                //TFT控制IC型号
		
		TFT_Initial();                     //初始化LCD
	   
		PCON=0x80;		 //设置波特率及串口中断
		SCON=0x50;
		TMOD=0x20;		 //T0方式1
		TH1=0xF3;
		TL1=0xF3;
		IT0=1;
		IT1=1;
		TR1=1;
		EX1=1;
		EX0=1;
		ES=1;
		EA=1;	
		
		direction=1;
		Show_RGB(0,240,0,320,Blue);
		LCD_PutString(0,16,"        中 国 科 学 院        ",White,Blue);
		LCD_PutString(0,40,"    安徽光学精密机械研究所    ",White,Blue);
		LCD_PutString(0,72,"当前角度 ",White,Blue);
		LCD_PutString(110,72,"度",White,Blue);
		LCD_PutString(0,88,"当前值",White,Blue);
		LCD_PutString(0,120,"方向",White,Blue);
		LCD_PutString(0,152,"模式",White,Blue);
		LCD_PutString(0,184,"状态",White,Blue);
		LCD_PutString(0,304,"version 1,aiofm,hfcas",White,Blue);
		while(1)                                
		{	   
			LCD_PutChar(70,88,rec_line[11],White,Blue);
			LCD_PutChar(78,88,rec_line[12],White,Blue);
			LCD_PutChar(86,88,rec_line[13],White,Blue);
			LCD_PutChar(94,88,rec_line[14],White,Blue);		 

			total=(float)(((int)num[0])*1000+((int)num[1])*100+num[2]*10+((int)num[3])); //显示当前读数
			angle=total/4095.0*360.0;
			x=((int)angle)/100;
			y=((int)angle)/10%10;
			z=((int)angle)%10;
			di=((int)(angle*10))%10;	  
				 
			LCD_PutChar(70,72,display1[x],White,Blue);		  //显示当前角度
			LCD_PutChar(78,72,display1[y],White,Blue);
			LCD_PutChar(86,72,display1[z],White,Blue);
			LCD_PutChar(94,72,'.',White,Blue);
			LCD_PutChar(102,72,display1[di],White,Blue);
			if(boardorcomputer==1)
				{			
						if(run==0)
						{	
							LCD_PutString(40,184,"运行",White,Blue);	
							TH0 = (8192 - 200)/32	;  //给计数器装初值
							TL0 = (8192 - 200)%32	;	 
							ET0=1;
							TR0=1;
						}
						else
						{
							LCD_PutString(40,184,"停止",White,Blue);
							ET0 = 0;       
							TR0 = 0;
							motor=0;
						}
						if(direction_index==1)
						{
							LCD_PutString(40,120,"逆时针",White,Blue);
							direction=0;
						}
						else
						{
							LCD_PutString(40,120,"顺时针",White,Blue);
							direction=1;
						}
						if(modekey==1)
						{
							LCD_PutString(40,152,"常规",White,Blue);
						}
						else
						{
							LCD_PutString(40,152,"微调",White,Blue);
						}	
			
				}
				else
				{
					switch(computer_char)
					{
					   case 0xff:
					   {
							LCD_PutString(40,184,"运行",White,Blue);	
							TH0 = (8192 - 200)/32	;  //给计数器装初值
							TL0 = (8192 - 200)%32	;	 
							ET0=1;
							TR0=1;
					   		break;
					   }
					   case 0x00:
					   {
					   		LCD_PutString(40,184,"停止",White,Blue);
							ET0 = 0;       
							TR0 = 0;
							motor=0;
							break;
						}
						case 0xf0:
						{
							LCD_PutString(40,120,"逆时针",White,Blue);
							direction=0;
							break;
						}
						case 0x0f:
						{
							LCD_PutString(40,120,"顺时针",White,Blue);
							direction=1;
							break;
						}
						case 0x30:
						{
							computermode=0;
							LCD_PutString(40,152,"常规",White,Blue);
							break;
						}
						case 0x03:
						{
							computermode=1;
							LCD_PutString(40,152,"微调",White,Blue);
							break;
						}
					   defult:break;
					}
				}
		}
}
Exemplo n.º 3
0
void main()
{  
    unsigned int x1, x2;
    unsigned int y1, y2;
    unsigned int color = White;
    
    TFT_Initial();
    CLR_Screen(Black); 
    
    for(x1 = 0; x1 < 40; x1 ++)
        for(y1 = 0; y1 < 40; y1 ++)
            Put_pixel(x1, y1, Blue);
    
    for(x1 = 0; x1 < 40; x1 ++)
        for(y1 = 40; y1 < 80; y1 ++)
            Put_pixel(x1, y1, White);
    
    for(x1 = 0; x1 < 40; x1 ++)
        for(y1 = 80; y1 < 120; y1 ++)
            Put_pixel(x1, y1, Red);
    
    for(x1 = 0; x1 < 40; x1 ++)
        for(y1 = 120; y1 < 160; y1 ++)
            Put_pixel(x1, y1, Magenta);
            
    for(x1 = 0; x1 < 40; x1 ++)
        for(y1 = 160; y1 < 200; y1 ++)
            Put_pixel(x1, y1, Green);
    
    for(x1 = 0; x1 < 40; x1 ++)
        for(y1 = 200; y1 < 240; y1 ++)
            Put_pixel(x1, y1, Cyan);
    
    for(x1 = 0; x1 < 40; x1 ++)
        for(y1 = 240; y1 < 280; y1 ++)
            Put_pixel(x1, y1, Yellow);
            
    for(y1 = 0; y1<320; y1 ++) {
        Put_pixel(42, y1, 0x0FF2);
        Put_pixel(43, y1, 0xD621);
    }
     
    while(1) {
        if(!Penirq) {
            x1 = get_X();
            x2 = get_X();
            
            y1 = get_Y();
            y2 = get_Y();
            
            if(abs(x1-x2)<2 && abs(y1-y2)<2) {
                x1 = (x1+x2)/2;
                y1 = (y1+y2)/2;
                
                y1 = 320 - y1;
                
                if(x1 < 41) {
                    if(y1<41)
                        color = Blue;
                    else if(y1<81)
                        color = White;
                    else if(y1<121)
                        color = Red;
                    else if(y1<161)
                        color = Magenta;
                    else if(y1<201)
                        color = Green;
                    else if(y1<241)
                        color = Cyan;
                    else if(y1<281)
                        color = Yellow;
                    else {
                        LCD_SetPos(44, 240, 0, 320); 
                        for (y1 = 0; y1 < 320; y1 ++) {
                            for (x1 = 44; x1 < 240; x1 ++)
                                Write_Data_U16(Black);
                        }
                    }  
                } else {
                    Put_pixel(x1, y1, color);
                }
            }
        }
    }
}
Exemplo n.º 4
0
void main()
{
	//Device_code = 0x9328;
	TFT_Initial();
	CLR_Screen(Black);
	//srand(1);
    for(k = 0; k < 6; k ++) {
        for(i = 20, j = 40; i > 12; i --, j --) {
            Put_mych(i+k*32, j, 32, 35, AHUTC[k], color, Black);
            color += 40;
        }
        Put_mych(i+k*32, j, 32, 35, AHUTC[k], Green, Black);
        color = Yellow+1200;
    }
    
    
//        for(i = 20, j = 40; i > 12; i --, j --) {
//            for(k = 0; k < 6; k ++) {
//                Put_mych(i+k*32, j, 32, 35, AHUTC[k], color, Black);
//            }
//            color += 40;
//        }
//        for(k = 0; k < 6; k ++) {
//            Put_mych(i+k*32, j, 32, 35, AHUTC[k], Green, Black);
//        }
//        color = Yellow+1200;
//    }
    
//    for(k = 0; k < 3; k ++) {
//        for(i = 20, j = 140; i > 12; i --, j --) {
//            Put_mych(i+k*16, j, 16, 15, computer[k], color, Black);
//            color += 40;
//        }
//        Put_mych(i+k*16, j, 16, 15, computer[k], Green, Black);
//        color = Yellow+1200;
//    }
    
    //for(k = 0; k < 3; k ++) {
//        for(i = 20, j = 140; i > 12; i --, j --) {
//            
//            for(k = 0; k < 3; k ++) {
//                Put_mych(i+k*16, j, 16, 15, computer[k], color, Black);
//            }
//            color += 40;
//           // Put_mych(i+k*16, j, 16, 15, computer[k], Green, Black); 
//        }

//       for(k = 0; k < 3; k ++) {
//            Put_mych(i+k*16, j, 16, 15, computer[k], Green, Black);
//       }
//        color = Yellow+1200;
//   // }
   
//	for(i = 320; i > 0; i --) {
//        //Put_mych(j, 280, 32, 35, AHUTC[i], color, Blue);
//		//GUI_VLine(120, i, 10, White);
//        //if(color & 0xF) 
//        GUI_HLine(0, i, 240, color);
//        color |= (extra&0x001F);
//        color |= ((extra<<5)&0x07E0);
//        extra += 1;
//		//delayms(20);
//		//GUI_VLine(120, i, i+10, Blue);
//	}
    
    
	
//	for(i = 250; i < 280; i += 2) {
//		GUI_VLine(100, i, i+6, Yellow);
//		delayms(20);
//		GUI_VLine(100, i, i+6, Blue);
//	}
	
	//srand(1);
	//while(1);
//	while(1) {
//		x = rand()%360;
//		y = rand()%360;
//		
//		line_length = rand()%30;
//		
//		color_num = rand()%6;
//		
//		Put_pixel(120 + line_length*cos((x)*PI/180), 
//						100 + line_length*sin((y)*PI/180), color[color_num]);
//	}
    while(1);
}
Exemplo n.º 5
0
main()
{
    unsigned int i, j;
    Device_code=0x9328;                
    TFT_Initial();                     	 
  	//while(1)                                
    //{
	 	//LCD_PutChar(123, 89, 'A', Blue, Cyan);
		//Show_RGB(0, 240, 0, 64, Cyan);
		//Put_mych(34, 34, my, Cyan, Red);
		CLR_Screen(Black);
		for(i = 120; i < 188; i ++)			
		{
			Put_pixel(i, 170 - sqrt(10000 - pow(i - 120, 2)), White);
			Put_pixel(i, sqrt(10000 - pow(i - 120, 2)) + 150, White);
			Put_pixel(240 - i, 170 - sqrt(10000 - pow(i - 120, 2)), White);
			Put_pixel(240 - i, sqrt(10000 - pow(i - 120, 2)) + 150, White);
		}
		for(i = 160; i < 228; i ++)
		{
			Put_pixel(sqrt(10000 - pow(i - 160, 2)) + 110, i, White);
			Put_pixel(130 - sqrt(10000 - pow(i - 160, 2)), i,White);
			Put_pixel(sqrt(10000 - pow(i - 160, 2)) + 110, 320 - i,White);
			Put_pixel(130 - sqrt(10000 - pow(i - 160, 2)), 320 - i,White);
		}
		//circle(120, 160, 40);
		//delayms(200000);	 	 
    //}

	//for(i = 0; i < 90; i ++)
	//{
	//	Put_pixel(cos(i*PI/180) + 120, sin(i*PI/180) + 160, White);	
	//}
	/*for(j = 90; j >= 0; j -= 5)
	{
		for(i = 0; i < 60; i ++)
		{
			Put_pixel(cos(j*PI/180) * i + 120, sin(j*PI/180) * i, White);
		}
		delayms(120);
		for(i = 0; i < 60; i ++)
		{
			Put_pixel(cos(240 - j*PI/180) * i, 320 - sin(j*PI/180) * i, Black);
		}	
	}*/

	for(j = 0; j <= 360; j = j + 6)
	{
		for(i = 0; i < 60; i ++)
		{
			Put_pixel(120 + cos((360-j)*PI/180) * i, 160 - sin((360 - j)*PI/180) * i, Yellow);
		}
		delayms(20);
		for(i = 0; i < 60; i ++)
		{
			Put_pixel(120 + cos((360 - j)*PI/180) * i, 160 - sin((360 - j)*PI/180) * i, Black);
		}	
	}

	for(j = 0; j <= 360; j ++)
	{
		Put_pixel(100 + cos((360-j)*PI/180) * 20, 200 + sin((360 - j)*PI/180) * 20, Yellow);
	}
	while(1);
}