Exemple #1
0
//////////////////////////与LCD显示相关的函数//////////////////////////////////
//画粗线
//x1,y1:起点坐标
//x2,y2:终点坐标  
void LCD_DrawDLine(u16 x1, u16 y1, u16 x2, u16 y2)
{
	u16 t; 
	int xerr=0,yerr=0,delta_x,delta_y,distance; 
	int incx,incy,uRow,uCol; 

	delta_x=x2-x1; //计算坐标增量 
	delta_y=y2-y1; 
	uRow=x1; 
	uCol=y1; 
	if(delta_x>0)incx=1; //设置单步方向 
	else if(delta_x==0)incx=0;//垂直线 
	else {incx=-1;delta_x=-delta_x;} 
	if(delta_y>0)incy=1; 
	else if(delta_y==0)incy=0;//水平线 
	else{incy=-1;delta_y=-delta_y;} 
	if( delta_x>delta_y)distance=delta_x; //选取基本增量坐标轴 
	else distance=delta_y; 
	for(t=0;t<=distance+1;t++ )//画线输出 
	{  
		Draw_Big_Point(uRow,uCol);//画点 
		xerr+=delta_x ; 
		yerr+=delta_y ; 
		if(xerr>distance) 
		{ 
			xerr-=distance; 
			uRow+=incx; 
		} 
		if(yerr>distance) 
		{ 
			yerr-=distance; 
			uCol+=incy; 
		} 
	}  
} 	 
Exemple #2
0
 int main(void)
 {
	u8 key;
	u8 i=0;	
	SystemInit();
	delay_init(72);	     //延时初始化
	NVIC_Configuration();
 	uart_init(9600);
 	LED_Init();
 	KEY_Init();
	LCD_Init();

	POINT_COLOR=RED;//设置字体为蓝色	   
	LCD_ShowString(60,50,"Mini STM32");	
	LCD_ShowString(60,70,"TOUCH TEST");	
	LCD_ShowString(60,90,"ATOM@ALIENTEK");
	LCD_ShowString(60,110,"2011/1/1");	
	LCD_ShowString(60,130,"Press KEY0 to Adjust");	
	Touch_Init();
	delay_ms(1500);
	Load_Drow_Dialog();	  
	while(1)
	{	
	 	key=KEY_Scan();
		if(Pen_Point.Key_Sta==Key_Down)//触摸屏被按下
		{
			Pen_Int_Set(0);//关闭中断
			do
			{
				Convert_Pos();
				Pen_Point.Key_Sta=Key_Up;
				if(Pen_Point.X0>216&&Pen_Point.Y0<16)Load_Drow_Dialog();//清除
				else 
				{
					Draw_Big_Point(Pen_Point.X0,Pen_Point.Y0);//画图	    
					GPIOC->ODR|=1<<1;    //PC1 上拉	   
				}
			}while(PEN==0);//如果PEN一直有效,则一直执行
			Pen_Int_Set(1);//开启中断
		}else delay_ms(10);
		if(key==1)//KEY0按下,则执行校准程序
		{
			LCD_Clear(WHITE);//清屏
		    Touch_Adjust();  //屏幕校准 
			Save_Adjdata();	 
			Load_Drow_Dialog();
		}
		i++;
		if(i==20)
		{
			i=0;
			LED0=!LED0;
		}
	};	   
 }
Exemple #3
0
//任务5
//触摸画笔
 void TaskTouch(void *pdata)
 {  LCD_ShowString(10,160,"Touch Panel");
 	while(1)
	{  	GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource1); //触摸中断线映射	  
		if(Pen_Point.Key_Sta==Key_Down)//触摸屏被按下
		{
			Pen_Int_Set(0);//关闭中断
			Convert_Pos();
			Pen_Point.Key_Sta=Key_Up;
			if(Pen_Point.X0>216&&Pen_Point.Y0>304)Load_Drow_Dialog();//清除
			else if(Pen_Point.Y0>180)
			{
				Draw_Big_Point(Pen_Point.X0,Pen_Point.Y0);//画图	    
				GPIO_SetBits(GPIOC,GPIO_Pin_1);   
			}		 
			Pen_Int_Set(1);//开启中断	
		}
		 OSTimeDlyHMSM(0,0,0,2);
	};		
 }
Exemple #4
0
//触摸画板功能演示函数   
void Touch_Play(void)
{				  	
	u8 i;		 
	u8 key;
	u8 M_STA=0;
	u16 temp_color;
	LCD_Clear(WHITE);	    
	Load_Gui_Show("重画","颜色","返回");//加载界面  
	POINT_COLOR=RED;  
	while(1)
	{
 		key=AI_Read_TP(20);//得到触点的状态
		if(key)//触摸屏被按下						  
		{	
			Pen_Point.Key_Reg|=0x80;//标记按下了按键

			if(Pen_Point.Y<296&&M_STA==0)//在画图区域内,并且颜色框没有弹出来
			{
				Draw_Big_Point(Pen_Point.X,Pen_Point.Y);//画点	      
			}      
		}else if(Pen_Point.Key_Reg&0X80)//按键松开了 
		{
			if(Pen_Point.Key_Reg&0x02)//点动按下
			{
				if(M_STA)//菜单已经弹出来了
				{
					if(Pen_Point.X>88&&Pen_Point.X<153&&Pen_Point.Y>268)//在颜色框内
					{
						temp_color=LCD_ReadPoint(Pen_Point.X,Pen_Point.Y);//读取该点的颜色
						if(temp_color!=FRAME2)//不是按在边框上
						{
							Reshow_Temp_Color(88,268,65,29);//恢复之前的颜色
							POINT_COLOR=temp_color;//修改画笔颜色	    
							M_STA=0;	   
						}   
					}else 
					{
						Reshow_Temp_Color(88,268,65,29);//恢复之前的颜色
						M_STA=0;
					}
				}
				if(Is_In_Area(5,300,32,16))//清除按钮按下了
				{
					LCD_Fill(0,0,239,296,WHITE);//清屏
				}else if(Is_In_Area(104,300,32,16))//颜色按钮按下了
				{
					Read_Temp_Color(88,268,65,29);//先读出之前的颜色值
					Draw_Color_Table(88,268); 
					M_STA=1;//标记颜色框已经显示出来了 
				}else if(Is_In_Area(203,300,32,16))//返回按钮按下了
				{
					Pen_Point.Key_Reg=0;//清除笔状态			   
					return;
				}   
			}
			Pen_Point.Key_Reg=0;//清除笔状态	  	 
		}else delay_ms(1);
		i++;
		if(i==200)
		{
			i=0;
			LED0=!LED0;
		}	
	} 		   
}
Exemple #5
0
//触摸画板功能演示函数   
void Wireless_Play(void)
{				  	
	u8 err=0,i;		 
	u8 key;	 
	u8 mode;//24L01的模式设置
	u8 tmp_buf[5];//低4个字节,传递坐标值,最高一个字节:0,正常画图,1清除;2,退出;  
	  
	mode=Wireless_Mode_Set();
	if(mode==0)
	{
		SPIx_Init();//设置回原来的				 
		SPIx_SetSpeed(SPI_SPEED_4);//18Mhz 
		return;//24L01检测失败,直接退出
	}	 			
	if(mode==2)
	{			    
		Load_Gui_Show("清除","发送","返回");//加载界面 
		TX_Mode();//发送模式
	}else
	{
		Load_Gui_Show("清除","接收","返回");//加载界面 
		RX_Mode();//接收模式
	}
	LCD_Fill(0,0,240,296,LGRAY);//填充灰色 
	POINT_COLOR=BLUE;//设置字体为蓝色  	 
	while(1)
	{	  		   				 
		key=AI_Read_TP(20);//得到触点的状态
		if(mode==1)//接收模式
		{
			if(NRF24L01_RxPacket(tmp_buf)==0)//一旦接收到信息,则显示出来.
			{
				Pen_Point.X=tmp_buf[0];
				Pen_Point.X=(Pen_Point.X<<8)+tmp_buf[1];
 				Pen_Point.Y=tmp_buf[2];
				Pen_Point.Y=(Pen_Point.Y<<8)+tmp_buf[3];
				switch(tmp_buf[4])
				{
					case 0://正常画点
						Draw_Big_Point(Pen_Point.X,Pen_Point.Y);//画点
						break;
					case 1://清除
						LCD_Fill(0,0,240,296,LGRAY);//填充灰色
						break;
					case 2://退出
						Pen_Point.Key_Reg=0;//清除笔状态
						SPIx_Init();//设置回原来的				 
						SPIx_SetSpeed(SPI_SPEED_4);//18Mhz 
						return; 
				}	  
			}
		}
		if(key)//触摸屏被按下						  
		{	
			Pen_Point.Key_Reg|=0x80;//标记按下了按键    
			if(Pen_Point.Y<296&&mode==2)//在画图区域内,且为发送模式
			{
				tmp_buf[0]=Pen_Point.X>>8;
				tmp_buf[1]=Pen_Point.X&0xFF;
				tmp_buf[2]=Pen_Point.Y>>8;	 
				tmp_buf[3]=Pen_Point.Y&0xFF; 
				tmp_buf[4]=0;//功能为0,正常画图  
				Draw_Big_Point(Pen_Point.X,Pen_Point.Y);//画点
				err=0;	      
				while(NRF24L01_TxPacket(tmp_buf)!=TX_OK)//等待发送完成
				{
					err++;
					if(err>10)return;//连续超过10次错误,则返回
				}
			}      
		}else if(Pen_Point.Key_Reg&0X80)//按键松开了 
Exemple #6
0
int main(void)
{
    ///////////////////////////////////////////
    uint8_t Key;
    int i;
    ////////////////////////////////////////////////

    brightness = 0x40;//亮度
    contrast   = 0x70;//对比度
    saturation = 0x40;//饱和度
    memset(outbuf,0,64);


    SystemInit();
    //GPIOInit();

    //chumo改版加入
    //Touch_Initializtion();

    Init_NVIC();				//中断向量表注册函数 	
    Init_LED();					//LED初始化
    Init_KEY();					//按键初始化
    Init_IIC();					//24LC02初始化
    Init_TOUCH();				// 触摸屏配置
    //Touch_Initializtion();


    //////////

    UART3_Init(115200);
    PrintStr("=========12345========\r\n");

    //ADC_Init_Ex();
    //Tim3_ETR_Init();
    //Tim4_Init();
    //CAN1_Init(250);

    //	USB_Init();

    //	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);

    /* Configure FSMC Bank1 NOR/SRAM3 */
    //FSMC_SRAM_Init();
    DelayMs(300);
    //InitSSD1963();
    //LcdInitTest();
    LcdInit();

    LcdClear(GRAY0);
    DispButton(button2);
    DisplayButtonUp(2,  2,400,25);   	
    LcdPrintStr("版权所有(C)mmmmmmmmmmmmmmmmmmmm",4,4,BLUE,GRAY0);
    DisplayButtonUp(402,2,478,25);
    LcdPrintf(410,4,BLACK,GRAY0,"%02d:%02d:%02d",12,12,12);
    DisplayButtonDownColor(200, 410, 290, 470, RED);
    DisplayButtonDownColor(412, 410, 502, 470, GREEN);
    LcdPrintStr("删除",230,432,WHITE,RED);
    LcdPrintStr("确认",442,432,BLACK,GREEN);
    LcdFillRec(200,100,502,190,DGREEN);
    DisplayButtonUp(190,90,512,475);
    DelayMs(1000);
    LcdFillRec(190,90,512,475,RED);
    DelayMs(1000);
    LcdFillRec(190,90,512,475,GRAY0);
    DispButton(button2);
    DisplayButtonDownColor(200, 410, 290, 470, RED);
    DisplayButtonDownColor(412, 410, 502, 470, GREEN);
    LcdPrintStr("删除",230,432,WHITE,RED);
    LcdPrintStr("确认",442,432,BLACK,GREEN);
    LcdFillRec(200,100,502,190,DGREEN);
    DisplayButtonUp(190,90,512,475);
    //	Pen_Point.Key_Sta==Key_Up;


    //LcdPrint16bitBmp(gImage, 16, 16, 490, 368 );
    while(1)
    {
        //	if(Pen_Point.Key_Sta==Key_Down)
        //	{
        //		LcdPrintf( 16,16,BLUE,WHITE,"%d",ADS_Read_AD(CMD_RDX));
        //		LcdPrintf( 16,32,BLUE,WHITE,"%d",ADS_Read_AD(CMD_RDY));
        //	}
        //LcdPrintf( 16,32,BLUE,WHITE,"%d",Touch_GetPhyY());
        //LcdPrintf( 16,16,BLUE,WHITE,"%d",Touch_GetPhyX());

        //	DelayMs(200);
        //	LED1 = ~LED1;


        //LED1=~LED1;
        //DelayMs(50);
        ////////////////////////////////////////
        Key=KEY_Scan();
        if(Pen_Point.Key_Sta==Key_Down)//触摸屏被按下
        {
            Pen_Int_Set(0);				//关闭中断
            do
            {
                LcdPrintf( 16,16,BLUE,WHITE,"%d",ADS_Read_AD(CMD_RDX));
                LcdPrintf( 16,32,BLUE,WHITE,"%d",ADS_Read_AD(CMD_RDY));

                Convert_Pos();
                Pen_Point.Key_Sta=Key_Up;
                //GPIOC->ODR|=1<<5;//临时添加
                //	LcdPrintf(16,16,BLUE,BLACK,"%d\n",Pen_Point.X);
                //	LcdPrintf(16,32,BLUE,BLACK,"%d\n",Pen_Point.Y);
                if(Pen_Point.X0>216&&Pen_Point.Y0<48)LcdClear(RED);//清除
                else 
                {
                    Draw_Big_Point(Pen_Point.X0,Pen_Point.Y0);//画图	    
                    GPIOC->ODR|=1<<5;    //PC5 上拉	   
                }  

            }while(PEN==0);//如果PEN一直有效,则一直执行
            Pen_Int_Set(1);//开启中断
        }
        else DelayMs(1);
        if(Key==USER)//USER按下,则执行校准程序
        {
            LcdClear(BlackColor);//清屏
            Touch_Adjust();  //屏幕校准 
            Save_Adjdata();	 
            LcdClear(RED);
        } 
        i++;  
        if(i==1)
        {
            i=0;
            LED1=~LED1;
        }
    }
    ///////////////////////////////////

    /*
       if(_SEC_)
       {
       _SEC_ = 0;

       GPIO_WriteBit(GPIOC, GPIO_Pin_6, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOC, GPIO_Pin_6)));

       LcdPrintf(300,460,BLACK,GRAY0,"%03d",i);
    //i += 10;
    SetSensors();

    for(u8 i=1; i<=16; i++)
    Printf("No.%d=%d,",i,GetSensorVoltage(i));
    PrintStr("\r\n");
    }
    UART1_SendByte(0x55);
    DelayMs(1);	
    }				  */
}