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

📄 main.c

📁 基于uCOS操作系统和LPC2292硬件平台的嵌入式系统程序
💻 C
📖 第 1 页 / 共 2 页
字号:
       	
	while (1)
	{   key = ZLG7290GetKey();  // 扫描键盘输入			        
		    
	    if(key&0x00FF)          // 如果有按键,则判断是否要发送按下消息
	    {   if(s_enter_sta == 0) // 按键单击	          	        
	        {   // 设置消息中的按键值
                s_event_input.sta = 0x82;
                s_event_input.key = (key-1)&0x000F;   // 原按键值为1-16,所以要减1变为0-15	          
	            OSMboxPost(TouchKeyMbox, (void *)&s_event_input);
	            
	            s_enter_sta = 1;  
	        }	        
	    }
	    else    // 如果是没有按键,则判断是否要发送放开消息	       
	    {   if(s_enter_sta != 0)  // 按键放开,则发送按键放开消息
	        {   s_event_input.sta = 0x02;
	            OSMboxPost(TouchKeyMbox, (void *)&s_event_input);             	            
	        }	
	        
	        s_enter_sta = 0;        
	    } // end of if(key&0x00FF)...else...
	    
		OSTimeDly(1);   
	}
}
/*void Task0	(void *pdata)
{   static uint8  s_enter_sta = 0;   // 输入设备状态字,对应位的值为1表示已按下,为0表示已放开。
                                     // d1用于指示按键,d0用于指示触摸屏。
    static TouchKey_Sta  s_event_input;
    uint16  key; 
    uint16  vx1, vy1;
    int     x1, y1;    
    
	pdata = pdata;		
	TargetInit();	
	if(TestTouch() == 0)            // 读取触摸屏校准参数,判断触摸屏是否已校准
	{   // 若触摸屏没有校准,则控制数码管显示"Error 01"
	    ZLG7290ShowChar(7, 0x0E);
        OSTimeDly(OS_TICKS_PER_SEC / 100);
        ZLG7290ShowChar(6, 0x18);
        OSTimeDly(OS_TICKS_PER_SEC / 100);
        ZLG7290ShowChar(5, 0x18);
        OSTimeDly(OS_TICKS_PER_SEC / 100);
        ZLG7290ShowChar(4, 0x15);
        OSTimeDly(OS_TICKS_PER_SEC / 100);
        ZLG7290ShowChar(3, 0x18);
        OSTimeDly(OS_TICKS_PER_SEC / 100);
        ZLG7290ShowChar(2, 0x1F);
        OSTimeDly(OS_TICKS_PER_SEC / 100);
        ZLG7290ShowChar(1, 0x00);
        OSTimeDly(OS_TICKS_PER_SEC / 100);
        ZLG7290ShowChar(0, 0x01);
        OSTimeDly(OS_TICKS_PER_SEC / 100);
	}
       	
	while (1)
	{   key = ZLG7290GetKey();  // 扫描键盘输入			        
		    
	    if(key&0x00FF)          // 如果有按键,则判断是否要发送按下消息
	    {   if((s_enter_sta&0x02) == 0) // 按键单击	          	        
	        {   // 设置消息中的按键值
                s_event_input.sta = 0x82;
                s_event_input.key = (key-1)&0x000F;   // 原按键值为1-16,所以要减1变为0-15	          
	            OSMboxPost(TouchKeyMbox, (void *)&s_event_input);
	            
	            s_enter_sta |= 0x02;  
	        }	        
	    }
	    else    // 如果是没有按键,则判断是否要发送放开消息	       
	    {   if((s_enter_sta&0x02) != 0)  // 按键放开,则发送按键放开消息
	        {   s_event_input.sta = 0x02;
	            OSMboxPost(TouchKeyMbox, (void *)&s_event_input);             	            
	        }	
	        
	        s_enter_sta &= 0xFD;        
	    }
	    
	    // 判断是否有触摸屏输入 
	    if(GetLCD_XY(&vx1, &vy1)==1)
	    {   // 触摸屏按下,转换坐标值(为了实现拖动,不对s_enter_sta进行判断)
            x1 = (vx1 - g_vx_min) * touch_wide / (g_vinx1 - g_vinx0);
            y1 = (vy1 - g_vy_min) * touch_high / (g_viny1 - g_viny0);
            if(x1<0) x1 = 0;
            if(y1<0) y1 = 0;        
            if(x1>319) x1 = 319;
            if(y1>239) y1 = 239;                        	    
              
            // 设置消息中的坐标值  
            s_event_input.sta = 0x81;
            s_event_input.x = x1;
            s_event_input.y = y1;
            OSMboxPost(TouchKeyMbox, (void *)&s_event_input);
                
            s_enter_sta |= 0x01;            	        
	    }   
	    else
	    {   if(vy1 == 0)
	        {   if((s_enter_sta&0x01) != 0)     // 若是松开触摸点,则发送放开消息
	            {   s_event_input.sta = 0x01;
	                OSMboxPost(TouchKeyMbox, (void *)&s_event_input);	            
	            }
	            s_enter_sta &= 0xFE;
	        } // end of if(vy1 == 0)...
	    } // end of if(GetLCD_XY(&vx1, &vy1)==1)...else...
	    
		OSTimeDly(1);   
	}
}
*/

/*********************************************************************************************************
**                            Task1 任务1
** 键盘驱动任务。读取触摸屏的触摸输入,然后把键值发送到TouchKeyMbox邮箱。
** 由MiniGUI的"comm" IAL输入引擎接收TouchKeyMbox邮箱的消息,然后进行相应的处理。
********************************************************************************************************/
void  Task1(void *pdata)
{   static uint8  s_enter_sta = 0;   
    static TouchKey_Sta  s_event_input;
    uint16  vx1, vy1;
    int     x1, y1;    
    
	pdata = pdata;			
    /************************************************************/
    OSTaskCreate (TaskGPS,(void *)0, &TaskStkGPS[TaskStkGPSLengh - 1], 14);
     /************************************************************/
   	
	while (1)
	{   // 判断是否有触摸屏输入 
	    if(GetLCD_XY(&vx1, &vy1)==1)
	    {   // 触摸屏按下,转换坐标值(为了实现拖动,不对s_enter_sta进行判断)
            x1 = (vx1 - g_vx_min) * touch_wide / (g_vinx1 - g_vinx0);
            y1 = (vy1 - g_vy_min) * touch_high / (g_viny1 - g_viny0);
            if(x1<0) x1 = 0;
            if(y1<0) y1 = 0;        
            if(x1>319) x1 = 319;
            if(y1>239) y1 = 239;                        	    
              
            // 设置消息中的坐标值  
            s_event_input.sta = 0x81;
            s_event_input.x = x1;
            s_event_input.y = y1;
            OSMboxPost(TouchKeyMbox, (void *)&s_event_input);
                
            s_enter_sta = 1;            	        
	    }   
	    else
	    {   if(vy1 == 0)
	        {   if(s_enter_sta != 0)     // 若是松开触摸点,则发送放开消息
	            {   s_event_input.sta = 0x01;
	                OSMboxPost(TouchKeyMbox, (void *)&s_event_input);	            
	            }
	            s_enter_sta = 0;
	        } // end of if(vy1 == 0)...
	    } // end of if(GetLCD_XY(&vx1, &vy1)==1)...else...
	    
		OSTimeDly(5);   
	}
}
/************************************************************/
char tempchar[2];
		void TaskGPS	(void *pdata)
{
	extern const char hello_str_time[];
	extern const char hello_str_date[];
	extern const char hello_str_lat[];
	extern const char hello_str_lon[];
	extern const char hello_str_att[];
	extern char hello_str1[30];
	extern char hello_str2[30];
	extern char hello_str3[50];
	extern char hello_str4[50];
	extern char hello_str5[30];
	extern void POSTMSG(void);
	pdata = pdata;
	
	ZLG_GPS_Initial();
	ZLG_GPS_START_Command();
	ZLG_GPS_Send_AAC_Command();
	
	OSTimeDly(OS_TICKS_PER_SEC*10);
	
	while(1)
	{
		tempchar[1]=0;
		OSTimeDly(OS_TICKS_PER_SEC);
		OS_ENTER_CRITICAL();		
		memset(hello_str1,0,30);
		memset(hello_str2,0,30);
		memset(hello_str3,0,50);
		memset(hello_str4,0,50);
		memset(hello_str5,0,30);
		_sprintf(hello_str1,hello_str_date,GPS_DATA.Time.Year,GPS_DATA.Time.Mon,GPS_DATA.Time.Day);
		_sprintf(hello_str2,hello_str_time,GPS_DATA.Time.Hour,GPS_DATA.Time.Min,GPS_DATA.Time.Sec,GPS_DATA.Time.ms);
		tempchar[0]=GPS_DATA.Latitude.Indicator;
		_sprintf(hello_str3,hello_str_lat,tempchar,(uint8)GPS_DATA.Latitude.dd,(uint8)GPS_DATA.Latitude.mm,(uint16)GPS_DATA.Latitude.mmmm);
		tempchar[0]=GPS_DATA.Longtitude.Indicator;
		_sprintf(hello_str4,hello_str_lon,tempchar,(uint16)GPS_DATA.Longtitude.ddd,(uint8)GPS_DATA.Longtitude.mm,(uint16)GPS_DATA.Longtitude.mmmm);
		_sprintf(hello_str5,hello_str_att,(((short)GPS_DATA.Altitude)/10),abs(((short)GPS_DATA.Altitude)%10));
		OS_EXIT_CRITICAL();
		POSTMSG();
	}

}
/************************************************************/


   
/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

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