Exemplo n.º 1
0
/*********************************************************************************************************
** Function name:       
** Descriptions:   
** input parameters:    N Sec
** output parameters:  
** Returned value:      
*********************************************************************************************************/
void LongDelay(unsigned int CNT)
{
  unsigned char  i = 0;
  for(i=0;i<CNT;i++)
  {
    DelayTime(50000);DelayTime(50000);DelayTime(50000);DelayTime(50000);DelayTime(50000);
  }
}
Exemplo n.º 2
0
void GD_FP_FD650_Stop()
{
    GD_FP_FD650_Clear(FD650DataHandle);
    DelayTime(5);
    GD_FP_FD650_Set(FD650ClockHandle);
    DelayTime(1);
    GD_FP_FD650_Set(FD650DataHandle);
}
Exemplo n.º 3
0
/********************************************************
*	水平栅条特效
*********************************************************/
void EffectDisplay::HRasterDisplay(CDC* pDC, CDC* pMemDC)
{
	//扫描高度
	int nHeight = min(s_nPicHeight, s_nCDCHeight);
	//扫描宽度
	int nWidth = min(s_nPicWidth, s_nCDCWidth);

	int nScanLine = 16;

	for (int i = 0; i <= nWidth + s_nOffsetX; i++)
	{
		for (int j = 0; j <= nHeight; j += 2 * nScanLine)
		{
			pDC->BitBlt(0, j + s_nOffsetY, i, nScanLine, pMemDC,
				nWidth + s_nOffsetX - i, j + s_nOffsetY, SRCCOPY);

			int k = j + nScanLine;

			pDC->BitBlt(nWidth + s_nOffsetX - i, k + s_nOffsetY,
				i + s_nOffsetX, nScanLine, pMemDC, 0,
				k + s_nOffsetY, SRCCOPY);
		}
		DelayTime(1);
	}
}
Exemplo n.º 4
0
/*************************************************************************************************
Name            :   HR_PT6964_Send_Data
Function        :   以二进制的形式发送数据,b0在前,b7在后,通过IO发出去
Parameters  :   In  :   data(要写的数值)
                Out :   NONE
Return Values   :   NONE
Note            :   数据在上升沿写入
*************************************************************************************************/
void HR_PT6964_Send_Data(U8 sdata)
{
    U8 i;
    for(i=0;i<8;i++)
    {
        
        //准备数据
        if((sdata>>i)&0x01>0)//取低一位
            HRPio_Set(PT6964DataHandle);
        else
            HRPio_Clear(PT6964DataHandle);
        //把数据送出去
        HRPio_Clear(PT6964ClockHandle);
        DelayTime(5);
        HRPio_Set(PT6964ClockHandle);
        DelayTime(5);
    }
Exemplo n.º 5
0
void GD_FP_FD650_Send_Data(U8 sdata)
{
    int i;

    for(i=7; i>=0; --i)
    {
        //×¼±¸Êý¾Ý
        if((sdata>>i)&0x01>0)//È¡µÍһλ
            GD_FP_FD650_Set(FD650DataHandle);
        else
            GD_FP_FD650_Clear(FD650DataHandle);
        //°ÑÊý¾ÝËͳö
        DelayTime(1);
        GD_FP_FD650_Set(FD650ClockHandle);
        DelayTime(5);
        GD_FP_FD650_Clear(FD650ClockHandle);
        DelayTime(5);
    }
Exemplo n.º 6
0
Arquivo: periph.c Projeto: mrugala/pm
uint8_t Tickms(__IO uint32_t t)
{
	if(DelayTime() >= (1000 * t))
	{
		DelaySetTime(0);
		return 1;
	}
	else
	{
		return 0;
	}
}
Exemplo n.º 7
0
unsigned long int GetUltrasonicDistance(void){
  unsigned int range, first_edge, second_edge;
  unsigned long int distance, count;
  PinDirection = 0; // Output to start sending ultrasonic sound 
  TRISC2 = 0;
  TriggerAndEchoPin = 0;
  DelayTime(TenMicroSecond);
  TriggerAndEchoPin = 1; // Generate a pulse
  DelayTime(TenMicroSecond); // Minimum pulse width
  TriggerAndEchoPin = 0; // Turn off the pulse to start sending sound
  PinDirection = 1; // Switch to input to receive echo
  TRISC2 = 1;
  CCP1IF = 0;
  CCP1CON = 0b00000101; // Input capture on every rising edge
  // Wait for rising edge
  while(CCP1IF==0){}
  first_edge = CCPR1H;
  first_edge = first_edge<<8;
  first_edge = first_edge + CCPR1L;
  CCP1IF = 0;
  CCP1CON = 0b00000100; //Input capture on every falling edge
  //DelayTime(TenMicroSecond); /minimum pulse width
  while(CCP1IF==0){} //waiting for falling edge
  second_edge = CCPR1H;
  second_edge = second_edge<<8;
  second_edge = second_edge+CCPR1L;
  CCP1IF = 0;
  if(first_edge < second_edge)
    count = second_edge-first_edge;
   else {
    count = -first_edge;
    count = count+second_edge;
   }
   distance = count * Timer1ClockPeriod;
   distance = distance>>1;
   distance = distance * SpeedOfSound;
   distance = distance>>10; //in centimeters
   return distance;
}
Exemplo n.º 8
0
/**********************************************************
*	作用:向右移动特效
***********************************************************/
void EffectDisplay::MoveRightDisplay(CDC* pDC, CDC* pMemDC)
{
	//扫描高度
	int nHeight = min(s_nPicHeight, s_nCDCHeight);

	for (int i = 0; i <= s_nCDCWidth - s_nOffsetX; i += 2)
	{
		pDC->BitBlt(0, s_nOffsetY, i, nHeight, pMemDC,
			s_nCDCWidth - s_nOffsetX - i, s_nOffsetY, SRCCOPY);
		DelayTime(1);
	}
	//修正图像位置
	pDC->BitBlt(0, s_nOffsetY, s_nCDCWidth - s_nOffsetX, nHeight,
		pMemDC, 0, s_nOffsetY, SRCCOPY);
}
Exemplo n.º 9
0
/******************************************************
*	作用:向下扫描特效
*******************************************************/
void EffectDisplay::ScanDownDisplay(CDC* pDC, CDC* pMemDC)
{
	//扫描高度
	int nHeight = min(s_nPicHeight, s_nCDCHeight);

	//扫描宽度
	int nWidth = min(s_nPicWidth, s_nCDCWidth);

	for (int i = 0; i < nHeight; i += 1)
	{
		pDC->BitBlt(s_nOffsetX, i + s_nOffsetY, nWidth, 1,
			pMemDC, s_nOffsetX, i + s_nOffsetY, SRCCOPY);
		DelayTime(1);
	}
}
Exemplo n.º 10
0
//这里定时服务到时这返回
void TimerSrv(unsigned int Delay)
{
  if(Delay)
    timera_start(TimCH0,Delay);//启动定时器
  while(TimerCnt0&&RxFlag)
  	DelayTime(1000);//如果接收成功RxFlag=0,TimerCnt0 数据接收超时控制
    timera_stop(TimCH0);//关闭定时器
  if(TimerCnt0)
  TimerCnt0 = 1;// rxd ok
  else
  {
  	TimerCnt0 = 0;  //rxd timeout
	RxFlag = 0;
  }
}
Exemplo n.º 11
0
/****************************************************
*	作用:雨滴特效
*****************************************************/
void EffectDisplay::RaindropDisplay(CDC* pDC, CDC* pMemDC)
{
	//扫描高度
	int nHeight = min(s_nPicHeight, s_nCDCHeight);
	//扫描宽度
	int nWidth = min(s_nPicWidth, s_nCDCWidth);

	for (int i = 0; i <= nHeight + s_nOffsetY; i++)
	{
		for (int j = 0; j <= nHeight + s_nOffsetY - i; j++)
		{
			pDC->BitBlt(s_nOffsetX, j, nWidth, 1, pMemDC, s_nOffsetX,
				nHeight + s_nOffsetY - i, SRCCOPY);
		}
		DelayTime(1);
	}
}
Exemplo n.º 12
0
/***************************************************
*	作用:垂直双重扫描特效
****************************************************/
void EffectDisplay::VSScanDisplay(CDC* pDC, CDC* pMemDC)
{
	//扫描高度
	int nHeight = min(s_nPicHeight, s_nCDCHeight);
	//扫描宽度
	int nWidth = min(s_nPicWidth, s_nCDCWidth);

	for (int i = 0; i <= nHeight / 2; i += 1)
	{
		//上面部分
		pDC->BitBlt(s_nOffsetX, i + s_nOffsetY, nWidth, 1,
			pMemDC, s_nOffsetX, i + s_nOffsetY, SRCCOPY);
		//下面部分
		pDC->BitBlt(s_nOffsetX, nHeight - i - 1 + s_nOffsetY, nWidth, 1,
			pMemDC, s_nOffsetX, nHeight - i - 1 + s_nOffsetY, SRCCOPY);
		DelayTime(2);
	}
}
Exemplo n.º 13
0
/***************************************************
*	作用:水平百叶窗特效
****************************************************/
void EffectDisplay::HBlindDisplay(CDC* pDC, CDC* pMemDC)
{
	//扫描高度
	int nHeight = min(s_nPicHeight, s_nCDCHeight);
	//扫描宽度
	int nWidth = min(s_nPicWidth, s_nCDCWidth);

	//百叶窗宽度
	int nScanLine = 8;
	for (int i = 0; i < nScanLine; i += 1)
	{
		for (int j = 0; j < nHeight; j += nScanLine)
		{
			pDC->BitBlt(s_nOffsetX, j + i + s_nOffsetY, nWidth, 1,
				pMemDC, s_nOffsetX, j + i + s_nOffsetY, SRCCOPY);
		}
		DelayTime(50);
	}
}
Exemplo n.º 14
0
/*********************************************************************************************
* name:		TS_init
* func:		initialize TouchScreen
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void TS_init(void)
{
    /* enable interrupt */
	rINTMOD=0x0;
	rINTCON=0x1;
    rI_ISPC |= BIT_EINT2;            // clear pending_bit
	
	// TSPX(GPE4_Q4(-)) TSPY(GPE5_Q3(-)) TSMY(GPE6_Q2(-)) TSMX(GPE7_Q1(+)) 
	//          1               1                0                 1
    rPUPE  = 0x0;	                 // Pull up
    rPDATE = 0xb8;                   // should be enabled	
    DelayTime(100); 
    
    rEXTINT |= 0x200;                // falling edge trigger
    pISR_EINT2=(int)user_irq1;       // set interrupt handler
    
    rCLKCON = 0x7ff8;                // enable clock
    rADCPSR = 0x1;//0x4;             // A/D prescaler
    rINTMSK =~(BIT_GLOBAL|BIT_EINT2);

}
Exemplo n.º 15
0
/*************************************************************
*	作用:水平双重移动特效
**************************************************************/
void EffectDisplay::HSMoveDisplay(CDC* pDC, CDC* pMemDC)
{
	//扫描高度
	int nHeight = min(s_nPicHeight, s_nCDCHeight);
	//扫描宽度
	int nWidth = min(s_nPicWidth, s_nCDCWidth);

	for (int i = 0; i < s_nCDCWidth / 2; i += 2)
	{
		//左面部分
		pDC->BitBlt(0, s_nOffsetY, i, nHeight, pMemDC,
			nWidth / 2 - i + s_nOffsetX, s_nOffsetY, SRCCOPY);
		//右面部分
		pDC->BitBlt(s_nCDCWidth - i, s_nOffsetY, i, nHeight, pMemDC,
			nWidth / 2 + s_nOffsetX, s_nOffsetY, SRCCOPY);
		DelayTime(1);
	}
	//修正图像位置
	pDC->BitBlt(0, s_nOffsetY, s_nCDCWidth - s_nOffsetX, nHeight,
		pMemDC, 0, s_nOffsetY, SRCCOPY);
}
Exemplo n.º 16
0
/*********************************************************************************************
* name:		TSInt
* func:		TouchScreen interrupt handler function
* para:		none
* ret:		none
* modify:
* comment:		
********************************************************************************************/
void TSInt(void)
{
    int   i;
    char fail = 0;
    ULONG tmp;
    ULONG Pt[6];

	// <X-Position Read>
	// TSPX(GPE4_Q4(+)) TSPY(GPE5_Q3(-)) TSMY(GPE6_Q2(+)) TSMX(GPE7_Q1(-))
    //       0               1                 1                0
	rPDATE=0x68;
	rADCCON=0x1<<2;			// AIN1
	
	DelayTime(1000);                // delay to set up the next channel
	for( i=0; i<5; i++ )
	{
		rADCCON |= 0x1;				// Start X-position A/D conversion
	    while( rADCCON & 0x1 );		// Check if Enable_start is low
    	while( !(rADCCON & 0x40) );	// Check ECFLG
	    Pt[i] = (0x3ff&rADCDAT);
	}
	// read X-position average value
	Pt[5] = (Pt[0]+Pt[1]+Pt[2]+Pt[3]+Pt[4])/5;
	
	tmp = Pt[5];	
	
    // <Y-Position Read>
	// TSPX(GPE4_Q4(-)) TSPY(GPE5_Q3(+)) TSMY(GPE6_Q2(-)) TSMX(GPE7_Q1(+))
    //       1               0                 0                1
	rPDATE=0x98;
	rADCCON=0x0<<2;		        	// AIN0
	
	DelayTime(1000);                // delay to set up the next channel
	for( i=0; i<5; i++ )
	{
    	rADCCON |= 0x1;             // Start Y-position conversion
	    while( rADCCON & 0x1 );     // Check if Enable_start is low
    	while( !(rADCCON & 0x40) ); // Check ECFLG
	    Pt[i] = (0x3ff&rADCDAT);
	}
	// read Y-position average value
	Pt[5] = (Pt[0]+Pt[1]+Pt[2]+Pt[3]+Pt[4])/5;
     
	if(!(CheckTSP|(tmp < Xmin)|(tmp > Xmax)|(Pt[5] < Ymin)|(Pt[5] > Ymax)))   // Is valid value?
	  {
		tmp = 320*(tmp - Xmin)/(Xmax - Xmin);   // X - position
		Uart_Printf("X-Posion[AIN1] is %04d   ", tmp);
			
		Pt[5] = 240*(Pt[5] - Xmin)/(Ymax - Ymin);
		Uart_Printf("  Y-Posion[AIN0] is %04d\n", Pt[5]);
      }

    if(CheckTSP)
 	/*----------- check to ensure Xmax Ymax Xmin Ymin ------------*/
 	    DesignREC(tmp,Pt[5]);

	rPDATE = 0xb8;                  // should be enabled	
	DelayTime(3000);                // delay to set up the next channel	

    rI_ISPC = BIT_EINT2;            // clear pending_bit
	
}
Exemplo n.º 17
0
/***********************************************************
*	作用:马赛克特效
************************************************************/
void EffectDisplay::MosaicDisplay(CDC* pDC, CDC* pMemDC)
{
    #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }

	int nTileSize = 24;	//马赛克小方块大小
	int nRw = 0;
	int nRh = 0;

	if (s_nPicWidth % nTileSize != 0)
		nRw = 1;
	if (s_nPicHeight % nTileSize != 0)
		nRh = 1;

	//计算小方块的个数
	int nTileCount = (s_nPicWidth / nTileSize + nRw)*
		(s_nPicHeight / nTileSize + nRh);

	CPtrArray points;	//保存所有小方块的左上坐标
	long lx = 0;
	long ly = 0;

	for (int k = 0; k < nTileCount; k++)
	{
		CPoint* point = new CPoint;
		point->x = lx;
		point->y = ly;
		lx = lx + nTileSize;
		if (lx >= s_nPicWidth)
		{
			lx = 0;
			ly = ly + nTileSize;
		}
		points.Add(point);
	}

	//根据图像大小确定时间间隔
	int nDelayTime = 2;
	if (s_nPicHeight * s_nPicWidth > 600 * 500)
		nDelayTime = 1;

	LARGE_INTEGER seed;
	QueryPerformanceFrequency(&seed);
	QueryPerformanceCounter(&seed);

	//初始化一个以微秒为单位的时间种子
	srand((int)seed.QuadPart);

	for (int i = nTileCount - 1; i >= 0; i--)
	{
		int n = rand() % (i + 1);
		CPoint* point = (CPoint*)points[n];

		lx = point->x;
		ly = point->y;

		pDC->BitBlt(lx + s_nOffsetX, ly + s_nOffsetY, nTileSize, nTileSize,
			pMemDC, lx + s_nOffsetX, ly + s_nOffsetY, SRCCOPY);

		SAFE_DELETE(point);
		points.RemoveAt(n);

		DelayTime(nDelayTime);
	}
}