Esempio n. 1
0
//触摸屏校准代码
//得到四个校准参数
void touch_adjust(void)
{
	u16 tempVal[4][2]={0};
	u16 adjPointX[4]={20,340,20,340};
	u16 adjPointY[4]={20,20,220,220};
	u8 i;
						 
	LCD_Clear(White);//清屏 
	LCD_SetBackColor(White);
	LCD_SetTextColor(Black);
	LCD_DisplayString(24,110,"点击屏幕上红点进行校准"); 
	DelayMS(1000);
	
	LCD_Clear(White);//清屏 
	LCD_SetTextColor(Red);
	penPoint.keyState=Up;
	
AG:	i=0;
	do
	{		
		LCD_DrawCircle(adjPointX[i],adjPointY[i],1);
		LCD_DrawCircle(adjPointX[i],adjPointY[i],2);
		LCD_DrawCircle(adjPointX[i],adjPointY[i],3);
		LCD_DrawCircle(adjPointX[i],adjPointY[i],4);

		if(penPoint.keyState==Down)
		{
			if(GetTouchValue())
			{
				tempVal[i][0]=penPoint.x;
				tempVal[i][1]=penPoint.y;
				LCD_Clear(White);//清屏
				DelayMS(100);	
				i++;
			}
		}
		penPoint.keyState=Up;		
	}while(i<4);

	if(IsOk(tempVal)==0)goto AG;

	penConfig.xfac=(float)(340-20)/(tempVal[1][0]-tempVal[0][0]);
	penConfig.yfac=(float)(220-20)/(tempVal[3][1]-tempVal[0][1]);
	penConfig.xoff=20-penConfig.xfac*tempVal[0][0];
	penConfig.yoff=20-penConfig.yfac*tempVal[0][1];
	
	LCD_Clear(White);//清屏
	LCD_DisplayString(24,110,"屏幕校准成功");
	save_adjdata();
	DelayMS(1000);
	LCD_Clear(White);//清屏	 	     
}
Esempio n. 2
0
void DemoVector(void)
{
	LCD_ClearScreen();
	LCD_SetFillColor(1);	
	LCD_DrawRect(110,20,120,60,1);
	LCD_DrawLine(0,0,127,0);
	LCD_DrawLine(0,0,127,16);
	LCD_DrawLine(0,0,127,32);
	LCD_DrawLine(0,0,127,48);
	LCD_DrawLine(0,0,127,63);
	LCD_SetPenColor(1);
	LCD_DrawCircle(63,31,31);
	LCD_DrawCircle(8,50,5);
	LCD_DrawEllipse(80,40, 30,10);
	LCD_SetFillColor(0);	
	LCD_DrawRect(12,20,40,40,3);
	LCD_SetFillColor(-1);	
	LCD_DrawRect(30,50,60,60,1);
}
Esempio n. 3
0
void DrawWalls(void)
{
	u32 i;
	static u32 lineIndexOld;

	if(lineIndex == 0) return;


	for(i = 0; i < lineIndexOld; i++)
	{
		LCD_DrawUniLine(120-lineBufOld[i].StartX/lidarScale,
						160+lineBufOld[i].StartY/lidarScale,
						120-lineBufOld[i].EndX/lidarScale,
						160+lineBufOld[i].EndY/lidarScale, BLACK);
		LCD_DrawCircle(120-lineBufOld[i].StartX/lidarScale,
						160+lineBufOld[i].StartY/lidarScale, 3, BLACK);
		LCD_DrawCircle(120-lineBufOld[i].EndX/lidarScale,
						160+lineBufOld[i].EndY/lidarScale, 3, BLACK);
	}

	for(i = 0; i < lineIndex; i++)
	{
//		line_t line2 = lineBuf[i], line;
//		TwoPointsLine_LSQF(line2.Start, line.End, &line);
//		// normalize line parameters
//		float norm = sqrtf(line.A * line.A + line.B * line.B);
//		line.A = line.A / norm;
//		line.B = line.B / norm;
//		line.C = line.C / norm;

		LCD_DrawUniLine(120-lineBuf[i].StartX/lidarScale,
						160+lineBuf[i].StartY/lidarScale,
						120-lineBuf[i].EndX/lidarScale,
						160+lineBuf[i].EndY/lidarScale, CYAN);
		LCD_DrawCircle(120-lineBuf[i].StartX/lidarScale,
						160+lineBuf[i].StartY/lidarScale, 3, MAGENTA);
		LCD_DrawCircle(120-lineBuf[i].EndX/lidarScale,
						160+lineBuf[i].EndY/lidarScale, 3, MAGENTA);

		lineBufOld[i] = lineBuf[i];
	}
	lineIndexOld = lineIndex;
}
//--------------------------------------------------------------
void LCD_DrawFullCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius, uint16_t color)
{
  int32_t  D;    /* Decision Variable */
  uint32_t  CurX;/* Current X Value */
  uint32_t  CurY;/* Current Y Value */

  D = 3 - (Radius << 1);

  CurX = 0;
  CurY = Radius;

  while (CurX <= CurY)
  {
    if(CurY > 0)
    {
      LCD_DrawLine(Xpos - CurX, Ypos - CurY, 2*CurY, LCD_DIR_VERTICAL, color);
      LCD_DrawLine(Xpos + CurX, Ypos - CurY, 2*CurY, LCD_DIR_VERTICAL, color);
    }

    if(CurX > 0)
    {
      LCD_DrawLine(Xpos - CurY, Ypos - CurX, 2*CurX, LCD_DIR_VERTICAL, color);
      LCD_DrawLine(Xpos + CurY, Ypos - CurX, 2*CurX, LCD_DIR_VERTICAL, color);
    }
    if (D < 0)
    {
      D += (CurX << 2) + 6;
    }
    else
    {
      D += ((CurX - CurY) << 2) + 10;
      CurY--;
    }
    CurX++;
  }

  LCD_DrawCircle(Xpos, Ypos, Radius, color);
}
Esempio n. 5
0
void DrawFunction(int FuncArray[] , int Length)
{
	int a,b,c;
	a = FuncArray[0];
	b = FuncArray[1];
	c = FuncArray[2];
	int Xpos,Ypos,math_x,math_y;
	Xpos = 10;
	Ypos = 10;
	math_x =0;
	math_y =0;

        for(math_x=0;math_x<100;math_x++)
	{

		math_y = a*math_x*math_x + b*math_x + c;
		LCD_DrawCircle(math_x+Xpos , math_y+Ypos , 1);
		
		
	}

	
}
void drawCenter(){
	LCD_SetTextColor(White);
	uint16_t radius = CENTER_RADIUS;
	while(radius != 0)
		LCD_DrawCircle(CENTER_X, CENTER_Y, radius--);
}
Esempio n. 7
0
int ts_test(void)
{
	calibration_t cal;
	tp_point_t point;
	int cal_fd;
	char cal_buffer[256];
	char *tsdevice = NULL;
	char *calfile = NULL;
	unsigned int i;

	int xtemp,ytemp;
	int x,y;

	/* Clear the LCD */ 
	LCD_Clear(Blue);
	get_sample (&cal, 0, 50,        50,        "Top left");

	get_sample (&cal, 1, XRES - 50, 50,        "Top right");

	get_sample (&cal, 2, XRES - 50, YRES - 50, "Bot right");

	get_sample (&cal, 3, 50,        YRES - 50, "Bot left");

	get_sample (&cal, 4, XRES / 2,  YRES / 2,  "Center");

	if (Tp_Calibration (&cal)) {
		printf ("Calibration constants: ");
		for (i = 0; i < 7; i++) 
			printf("%d ", cal.a [i]);
		printf("\n\r");
		sprintf (cal_buffer,"%d %d %d %d %d %d %d",
			 cal.a[0], cal.a[1], cal.a[2],
			 cal.a[3], cal.a[4], cal.a[5], cal.a[6]);
		printf ("%d %d %d %d %d %d %d",
			 cal.a[1], cal.a[2], cal.a[0],
			 cal.a[4], cal.a[5], cal.a[3], cal.a[6]);
        i = 0;
	} 
	else {
		printf("Calibration failed.\n\r");
		i = -1;
	}
	while(1)
	{
		while(1){		
			if (pen_flag){
				
				TpGetXY(&point);
				LCD_Clear(White);
				pen_flag = 0;
				break;
			}
		}
		cal.x[0] = point.x;
		cal.y[0] = point.y;
		printf("before Calibration x = %d y=%d\n\r",cal.x[0],cal.y[0]);
	   		xtemp = cal.x[0];
			ytemp = cal.y[0];
			x = 	(int)(( cal.a[0] +
					cal.a[1]*xtemp + 
					cal.a[2]*ytemp ) / cal.a[6]);
			y =		(int)(( cal.a[3] +
					cal.a[4]*xtemp +
					cal.a[5]*ytemp ) / cal.a[6]);
		printf("after Calibration x = %d y=%d\n\r",x,y);
		LCD_DrawCircle(x, y, 5, Red);
	}

//	close_framebuffer();
	return i;
}
Esempio n. 8
0
void GUI_Release(){  // create GUI 
  static int i, j;       //indexes

 //if z-index == 0 eq hide
 for(j = 1; j < MAX_Z_INDEX; j++ ){
  
    for(i = 0; i < MAX_OBJECTS_Q; i++){
     if(GUI_Objects[i].z_index == j){
       if(GUI_Objects[i].existance){
      LCD_SetColorPixel(GUI_Objects[i].color); // set the font, color of font and the color of line
        switch(GUI_Objects[i].type){
          case LINE_TYPE:
             LCD_DrawLine(GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2], GUI_Objects[i].params[3]);
                   break;
          case VERTICAL_LINE_TYPE:
                   break;    
          case HORIZONTAL_LINE_TYPE:
             DrawFastLineHorizontal(GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2]);   
                   break;  
          case POLYGON_TYPE:
                   break;
          case TEXT_STRING:
            LCD_InitParams(0, GUI_Objects[i].params[6], GUI_Objects[i].color, (sFONT*) GUI_Objects[i].params[5]);
            LCD_DisplayStringAt(GUI_Objects[i].params[0], GUI_Objects[i].params[1], (uint8_t*)GUI_Objects[i].params[2], (Text_AlignModeTypdef) GUI_Objects[i].params[3], (uint8_t)GUI_Objects[i].params[4]);
                   break; 
          case CIRCLE_TYPE:
            LCD_DrawCircle(GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2]);
                   break;
          case FILLED_CIRCLE_TYPE:
            LCD_DrawFullCircle(GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2]);
                   break;
          case FILLED_RECT_TYPE:
             LCD_FillRect(GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2], GUI_Objects[i].params[3]);     
                   break;
          case RECT_TYPE:
             LCD_DrawRect((uint16_t)GUI_Objects[i].params[0], (uint16_t)GUI_Objects[i].params[1], (uint16_t)GUI_Objects[i].params[2], (uint16_t)GUI_Objects[i].params[3]);     
                   break;         
          case IMAGE_FAST_FILL:
             LCD_Fill_Image((ImageInfo *)GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2]);
                   break;
          case IMAGE_WITH_TRANSP:
             LCD_Fill_ImageTRANSP((ImageInfo *)GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2]);
                   break;
          case FILLED_TRIANGLE:   
             LCD_FillTriangle(GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2], GUI_Objects[i].params[3], GUI_Objects[i].params[4], GUI_Objects[i].params[5]);
                   break;
          case FILLED_POLY: 
             LCD_FillPolygon((pPoint)GUI_Objects[i].params[0], (uint16_t)GUI_Objects[i].params[1]);
                   break;
          case POLY_TYPE: 
             LCD_DrawPolygon((pPoint)GUI_Objects[i].params[0], (uint16_t)GUI_Objects[i].params[1]);
                   break;  
           case ROTATING_FILLED_POLY_TYPE: 
             StorePoly((pPoint)(GUI_Objects[i].params[0]),(uint16_t)(GUI_Objects[i].params[1])); 
             RotatePoly((pPoint)(GUI_Objects[i].params[0]),  (uint16_t)(GUI_Objects[i].params[1]),(pPoint)GUI_Objects[i].params[2], GUI_Objects[i].params[3]);
             LCD_FillPolygon((pPoint)GUI_Objects[i].params[0], (uint16_t)GUI_Objects[i].params[1]); 
             RestorePoly((pPoint)(GUI_Objects[i].params[0]),(uint16_t)(GUI_Objects[i].params[1]));
              break;
        }
      } 
    }
   }
  }  
 }
Esempio n. 9
0
/**
 * @brief	The main task for the LCD
 * @param	pvParameters:
 * @retval	None
 */
void lcdTask(void *pvParameters)
{
    /* Initialize the hardware */
    prvHardwareInit();

    /* Display splash screen */
    prvSplashScreen();

    /* Make sure all channels have started up before we initialize the GUI */
    while (!prvAllChanneAreDoneInitializing())
    {
        vTaskDelay(1 / portTICK_PERIOD_MS);
    }

    /* Initialize the GUI elements */
    prvInitGuiElements();

    xLCDEventQueue = xQueueCreate(10, sizeof(LCDEventMessage));
    if (xLCDEventQueue == 0)
    {
        // Queue was not created and must not be used.
    }

    prvMainTextBoxRefreshTimer = xTimerCreate("MainTextBoxTimer", 10 / portTICK_PERIOD_MS, pdTRUE, 0, prvMainContainerRefreshTimerCallback);
    if (prvMainTextBoxRefreshTimer != NULL)
        xTimerStart(prvMainTextBoxRefreshTimer, portMAX_DELAY);

    LCDEventMessage receivedMessage;

//	GUITextBox_WriteString(GUITextBoxId_Clock, "14:15:12");

    /* The parameter in vTaskDelayUntil is the absolute time
     * in ticks at which you want to be woken calculated as
     * an increment from the time you were last woken. */
    TickType_t xNextWakeTime;
    /* Initialize xNextWakeTime - this only needs to be done once. */
    xNextWakeTime = xTaskGetTickCount();
    while (1)
    {
        /* Wait for a message to be received or the timeout to happen */
        if (xQueueReceive(xLCDEventQueue, &receivedMessage, 50) == pdTRUE)
        {
            /* Item successfully removed from the queue */
            switch (receivedMessage.event)
            {
            /* New touch data received */
            case LCDEvent_TouchEvent:
                if (receivedMessage.data[3] == FT5206Point_1)
                {
#if 0
                    /* DEBUG */
                    if (GUI_GetDisplayStateForTextBox(GUITextBoxId_Debug) == GUIDisplayState_NotHidden)
                    {
                        GUITextBox_SetWritePosition(GUITextBoxId_Debug, 5, 5);
                        GUITextBox_Clear(GUITextBoxId_Debug);
                        GUITextBox_WriteString(GUITextBoxId_Debug, "X:");
                        GUITextBox_WriteNumber(GUITextBoxId_Debug, receivedMessage.data[0]);
                        GUITextBox_WriteString(GUITextBoxId_Debug, ", Y:");
                        GUITextBox_WriteNumber(GUITextBoxId_Debug, receivedMessage.data[1]);
                        GUITextBox_WriteString(GUITextBoxId_Debug, ", EVENT:");
                        GUITextBox_WriteNumber(GUITextBoxId_Debug, receivedMessage.data[2]);
                    }
#endif

#if 0
                    /* Draw a dot on debug */
                    if (!prvDebugConsoleIsHidden)
                    {
                        LCD_SetForegroundColor(LCD_COLOR_GREEN);
                        LCD_DrawCircle(receivedMessage.data[0], receivedMessage.data[1], 2, 1);
                    }
#endif

                    GUITouchEvent touchEvent;
                    if (receivedMessage.data[2] == FT5206Event_PutUp)
                        touchEvent = GUITouchEvent_Up;
                    else if (receivedMessage.data[2] == FT5206Event_PutDown)
                        touchEvent = GUITouchEvent_Down;
                    /* Check all buttons */
                    GUIButton_CheckAllActiveForTouchEventAt(touchEvent, receivedMessage.data[0], receivedMessage.data[1]);
                    /* Check all text boxes */
                    GUITextBox_CheckAllActiveForTouchEventAt(touchEvent, receivedMessage.data[0], receivedMessage.data[1]);
                    /* Check all containers */
                    GUIContainer_CheckAllActiveForTouchEventAt(touchEvent, receivedMessage.data[0], receivedMessage.data[1]);
                }
                break;

            /* New temperature data received */
            case LCDEvent_TemperatureData:
                memcpy(&prvTemperature, receivedMessage.data, sizeof(float));
                int8_t currentTemp = (int8_t)prvTemperature - 11;
                GUITextBox_Draw(GUITextBoxId_Temperature);
                GUITextBox_SetWritePosition(GUITextBoxId_Temperature, 50, 3);
                GUITextBox_WriteNumber(GUITextBoxId_Temperature, (int32_t)currentTemp);
                GUITextBox_WriteString(GUITextBoxId_Temperature, " C");
                break;

            /* Debug message received */
            case LCDEvent_DebugMessage:
                GUITextBox_SetWritePosition(GUITextBoxId_Debug, 5, 5);
                GUITextBox_Clear(GUITextBoxId_Debug);
                GUITextBox_WriteNumber(GUITextBoxId_Debug, receivedMessage.data[0]);
                GUITextBox_WriteString(GUITextBoxId_Debug, " - ");
                GUITextBox_WriteString(GUITextBoxId_Debug, (uint8_t*)receivedMessage.data[1]);
                break;


            default:
                break;
            }
        }
        else
        {
            /* Timeout has occured i.e. no message available */
//			HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_2);
            /* Do something else */
        }
    }
}
Esempio n. 10
0
/*
*********************************************************************************************************
* Description: 	Main function
* Arguments  : 	None
* Returns    : 	None
*********************************************************************************************************
*/
int main (void)                       
{
  u8 key;
	
	u8 x0,y0,x1,y1,x2,y2;
	u8 r,a,b;
	unsigned char flag;
	tccolor=Blue;
  SystemInit();
	UART0_Init();
  LCD_Init   ();
	LPC_GPIO0->FIODIR |= 0x00002C0;  										//P0.6 0.7 0.9 Output
	LPC_GPIO2->FIODIR |= 0x00000FF;  										//P2.13 input P2.0...P2.7 Output	 
	Touch_Init();
	LCD_Color(0,0,239,239,White);
	Load_Drow_Dialog();
	LCD_Color(279,0,40,40,White);
	while(1)
	{
		if(len==8)
		{
				len=0;
				flag=data[6];
				switch(flag)
				{
							case 0x01:
								x0=data[0];y0=data[1];x1=data[2];y1=data[3];
								pencolor=colorchange(data[7]);
								LCD_Color(0,0,239,239,pencolor);
								LCD_DrawLine(x0,y0,x1,y1);
								break;
							case 0x02:
								x0=data[0];y0=data[1];x1=data[2];y1=data[3];x2=data[4];y2=data[5];
								pencolor=colorchange(data[7]);
								LCD_Color(0,0,239,239,pencolor);
								LCD_DrawTriangle(x0,y0,x1,y1,x2,y2);
								break;
							case 0x03:
								x0=data[0];y0=data[1];x1=data[2];y1=data[3];
								pencolor=colorchange(data[7]);
								LCD_Color(0,0,239,239,pencolor);
								LCD_DrawRectangle(x0,y0,x1,y1);
								break;
							case 0x04:
								x0=data[0];y0=data[1];r=data[2];
								pencolor=colorchange(data[7]);
								LCD_Color(0,0,239,239,pencolor);
								LCD_DrawCircle(x0,y0,r);
								break;
							case 0x05:
								x0=data[0];y0=data[1];a=data[2];b=data[3];
								pencolor=colorchange(data[7]);
								LCD_Color(0,0,239,239,pencolor);
								LCD_DrawEllipse(x0,y0,a,b);
			}
		}
		key =  KEY_Scan();
		if(Pen_Point.Key_Sta==Key_Down)										//Touch screen is pressed 
		{
			Pen_Int_Set(0);													//Closed interrupt
			do
			{
				Convert_Pos();
				Pen_Point.Key_Sta=Key_Up;
//				Draw_Big_Point(Pen_Point.X0,Pen_Point.Y0);				//Drawing	
				if(Pen_Point.Y0>=240)
				{
					Load_Drow_Dialog();
					switch(Pen_Point.X0/40)
					{
						case 0:LCD_Color(279,0,40,40,White);tccolor=Blue;break;
						case 1:LCD_Color(279,40,40,40,White);tccolor=Yellow;break;
						case 2:LCD_Color(279,80,40,40,White);tccolor=Green;break;
						case 3:LCD_Color(279,120,40,40,White);tccolor=Red;break;
						case 4:LCD_Color(279,160,40,40,White);tccolor=Purple;break;
						case 5:LCD_Color(279,200,40,40,White);tccolor=Cyan;break;
					}
				}
		/*		else
				{
						LCD_Color(0,0,239,239,tccolor);
				}*/
						
			}while(PEN==0);                                                  //While the Touch screen is pressing
			Pen_Int_Set(1);													 //Opene the interrupt
		}
		else
			delay1ms(1);
	}
}
Esempio n. 11
0
void StartLidarDemo(void)
{

	u32 i;
	u32 j;
	static u8 gridnum;
	lidarScale = 25;
	gridnum = 3;

	while(1)
	{
		fps_time = 0;

		//switch lidarScale
		if(Touch_pressed)
		{
			switch(lidarScale)//8916 874 07 98
			{
				case 13:
				{
					lidarScale = 25;
					gridnum = 3;
					break;
				}
				case 25:
				{
					lidarScale = 50;
					gridnum = 6;
					break;
				}
				case 50:
				{
					lidarScale = 13;
					gridnum = 1;
					break;
				}
			}
			LCD_Clear(BLACK);
			Delay_Ms(200);
		}
		//draw onscreen info
		LCD_DrawCircle(120,160,3,YELLOW);

		LCD_DisplayStringLine(2," # AN DIHN LIDAR DEMO");

		//lidar motor spinning rate in 1/10 of Hz
		sprintf(stringBuf," # SPIN %.2u", lidarSpeed);
		LCD_DisplayStringLine(220,stringBuf);



		//draw grid circles

		for(j=1;j<=gridnum;j++)
		{
			LCD_DrawCircle(120,160,j*1000/lidarScale,RGB(0x33,0x33,0x33));
		}

		//draw point cloud
		for(i=0;i<360;i++)
		{
			if((lidarBuf[i].dist != lidarBufOld[i].dist))
			{
				PutPixel(120-(lidarBufOld[i].x / lidarScale),160+(lidarBufOld[i].y / lidarScale),BLACK);
				//if(!lidarBuf[i].error)
				{

					if(!lidarBuf[i].warning)
					{
						PutPixel(120-(lidarBuf[i].x / lidarScale),160+(lidarBuf[i].y / lidarScale),GREEN);
					}
					else
					{
						PutPixel(120-(lidarBuf[i].x / lidarScale),160+(lidarBuf[i].y / lidarScale),YELLOW);
					}

					lidarBufOld[i].dist = lidarBuf[i].dist;
					lidarBufOld[i].x = lidarBuf[i].x;
					lidarBufOld[i].y = lidarBuf[i].y;
				}
			}
		}

		SearchWalls();
	//	DrawWalls();

		//display refresh rate, in frames per second
		if (fps_update > 20000)
		{
			sprintf(stringBuf, " # FPS %.3u", 100000/fps_time);
			LCD_DisplayStringLine(207, stringBuf);
			fps_update = 0;
		}
		//LCD_Clear(BLACK);
	}
}