Exemplo n.º 1
0
/*******************************************************************************
* Function Name  : DrawCross
* Description    : ÔÚÖ¸¶¨×ù±ê»­Ê®×Ö×¼ÐÇ
* Input          : - Xpos: Row Coordinate
*                  - Ypos: Line Coordinate
* Output         : None
* Return         : None
* Attention		 : None
*******************************************************************************/
void DrawCross(uint16_t Xpos,uint16_t Ypos)
{
   	LCD_DrawUniLine(Xpos-12,Ypos,Xpos+13,Ypos);
  	LCD_DrawUniLine(Xpos,Ypos-12,Xpos,Ypos+13);
  	Pixel(Xpos+2,Ypos+2,BLUE);
  	Pixel(Xpos-2,Ypos+2,BLUE);
  	Pixel(Xpos+2,Ypos-2,BLUE);
  	Pixel(Xpos-2,Ypos-2,BLUE);
  	LCD_Circle(Xpos, Ypos, 6, 1, BLUE);

}	
void drawMinutes(uint8_t minutes, uint16_t color){
	float angle = (2 * M_PI / 60) * minutes;
	uint8_t x = MINUTE_HAND_LEN * cos(- M_PI/2 + angle) + CENTER_X;
	uint8_t y = MINUTE_HAND_LEN * sin(- M_PI/2 + angle) + CENTER_Y;
	LCD_SetTextColor(color);
	LCD_DrawUniLine(   	CENTER_X,
						CENTER_Y,
						x,
						y);
	LCD_DrawUniLine(   	CENTER_X+1,
						CENTER_Y+1,
						x + 1,
						y + 1);
}
Exemplo n.º 3
0
/**
* @brief  Display LCD
* @param  Pre-Set Argument
* @retval Null
*/
void DisplayLCD(void const *argument){
	char* s;
	int cnt, i = 0;
	  LCD_Clear(LCD_COLOR_WHITE);
	  LCD_SetFont(&Font8x8);
	  LCD_SetTextColor(LCD_COLOR_BLACK);
	  LCD_DisplayStringLine(1, (uint8_t*)"   NOW DISPLAYING TRAJECTORY     ");
	  LCD_DisplayStringLine(310, (uint8_t*)"         Y DISPLACEMENT     ");
		LCD_DisplayChar(90, 10, (uint8_t)'X');
    LCD_DisplayChar(110, 10, (uint8_t)'D');
		LCD_DisplayChar(120, 10, (uint8_t)'I');
		LCD_DisplayChar(130, 10, (uint8_t)'S');
		LCD_DisplayChar(140, 10, (uint8_t)'P');
		LCD_DisplayChar(150, 10, (uint8_t)'L');
		LCD_DisplayChar(160, 10, (uint8_t)'A');
		LCD_DisplayChar(170, 10, (uint8_t)'C');
		LCD_DisplayChar(180, 10, (uint8_t)'E');
		LCD_DisplayChar(190, 10, (uint8_t)'M');
		LCD_DisplayChar(200, 10, (uint8_t)'E');
		LCD_DisplayChar(210, 10, (uint8_t)'N');
		LCD_DisplayChar(220, 10, (uint8_t)'T');
     //setGrid();
	while(1){
		if((cnt > 1)&&(received[0] < 255)&&(received[1] < 255))
		{
			LCD_DrawUniLine((uint16_t)(120+received[0]*5), (uint16_t)(160-received[1]*5), plot[0], plot[1]);
		}
		plot[0] = (uint16_t)(120+received[0]*5); //0.862745
		plot[1] = (uint16_t)(160-received[1]*5);  //1.176
		cnt++;
		
		osDelay(200);
	}
}
Exemplo n.º 4
0
/**
  * @brief  tests the scaling and shifting operations
  * @param  input_data : the data to reverse
						length_of_array : size of input_data array
  * @retval None
  */
void test_scaling_and_shifting(uint16_t* input_array,uint8_t length_of_array){
	scale_data_to_screen(input_array,length_of_array);
	image_reverse_and_zero_offset(input_array,length_of_array);

	for (int i=0;i<=length_of_array-4;i+=2){
		LCD_DrawUniLine(input_array[i],input_array[i+1],input_array[i+2],input_array[i+3]);
	}
}
void drawHours(uint8_t hours, uint8_t minutes, uint16_t color){
	float angle = (2 * M_PI / 12) * hours + (2 * M_PI / (12*60)) * minutes;
	uint8_t x = HOUR_HAND_LEN * cos(- M_PI/2 + angle) + CENTER_X;
	uint8_t y = HOUR_HAND_LEN * sin(- M_PI/2 + angle) + CENTER_Y;
	LCD_SetTextColor(color);
	LCD_DrawUniLine(   	CENTER_X-1,
						CENTER_Y-1,
						x - 1,
						y - 1);
	LCD_DrawUniLine(   	CENTER_X,
						CENTER_Y,
						x,
						y);
	LCD_DrawUniLine(   	CENTER_X+1,
						CENTER_Y+1,
						x + 1,
						y + 1);
}
void drawSeconds(uint8_t seconds, uint16_t color){
	float angle = (2 * M_PI / 60) * seconds;
	uint8_t x = SECOND_HAND_LEN * cos(- M_PI/2 + angle) + CENTER_X;
	uint8_t y = SECOND_HAND_LEN * sin(- M_PI/2 + angle) + CENTER_Y;
	LCD_SetTextColor(color);
	LCD_DrawUniLine(   	CENTER_X,
						CENTER_Y,
						x,
						y);
}
void drawTenths(uint8_t tenths, uint16_t color){
	float angle = (2 * M_PI / 12) * tenths;
	uint8_t x = SECOND_HAND_LEN * cos(- M_PI/2 + angle) + CENTER_X;
	uint8_t y = SECOND_HAND_LEN * sin(- M_PI/2 + angle) + CENTER_Y;
	LCD_SetTextColor(color);
	LCD_DrawUniLine(   	CENTER_X,
						CENTER_Y,
						x,
						y);
}
Exemplo n.º 8
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;
}
Exemplo n.º 9
0
void DrawNeedle(uint16_t x,uint16_t y,uint16_t radius,float max,float min,float variable)
{
    float midpoint;
    float range;
    float angle;
    int16_t point2x;
    int16_t point2y;
    midpoint = (max + min)/2;
    range    = max - min;

    if (variable > midpoint)
    {
        angle = (variable - midpoint)/(range/2)*180;
    }
    else if (variable < midpoint)
    {
        angle = -(midpoint - variable)/(range/2)*180;
    }
    else if (variable > max && variable < min )
    {
        angle = 180;
    }
    else
    {
        angle = 0;
    }

    point2x = x + radius*sin(angle*3.14/180);
    point2y = y - radius*cos(angle*3.14/180);



    LCD_DrawUniLine(x-1,y-1,point2x-1,point2y-1);
    LCD_DrawUniLine(x,y,point2x,point2y);
    LCD_DrawUniLine(x+1,y+1,point2x+1,point2y+1);

}
Exemplo n.º 10
0
/**
 *	Draw an array of points on the screen, taking into account a scaling factor.
 *
 *	@author				Jacob Barnett
 *
 *	@param scale_x		scaling factor for the x direction
 *	@param scale_y		scaling factor for the y direction
 *	@param xs			list of x coordinates
 *	@param ys			list of y coordinates
 *	@param length		length of each of the lists of coordinates
 *
 *	@return void
 */
void draw_points(uint16_t scale_x, uint16_t scale_y, COORDINATE_TYPE* xs, COORDINATE_TYPE* ys, uint16_t length) {

	float prev_pixels_x = (float)xs[0] / scale_x;
	float prev_pixels_y = (float)ys[0] / scale_y;
	float pixels_x;
	float pixels_y;

	for (int i = 1; i < length; ++i) {
		pixels_x = (float)xs[i] / scale_x;
		pixels_y = (float)ys[i] / scale_y;

		LCD_DrawUniLine(prev_pixels_x, prev_pixels_y, pixels_x, pixels_y);

		prev_pixels_x = pixels_x;
		prev_pixels_y = pixels_y;
	}
}
Exemplo n.º 11
0
/**
  * @brief  Calibre l'écran tactile
  * @param  mode: le mode de calibration	(@ref TS_Calibration_mode_e)
  * @pre	Cette fonction doit être appelée en boucle jusqu'à ce qu'elle renvoit TRUE (calibration terminée).
  * @post	Lors de l'état INIT, l'appel à TS_Init() est réalisé.
  * @retval running_e END_OK si la calibration est terminée, IN_PROGRESS sinon.
  */
running_e TS_Calibration(bool_e ask_for_finish, TS_Calibration_mode_e mode)
{
	typedef enum{
		INIT=0,
		LEFT_CROSS_DISPLAY,
		WAIT_FIRST_PRESS,
		WAIT_FIRST_RELEASE,
		RIGHT_CROSS_DISPLAY,
		WAIT_SECOND_PRESS,
		WAIT_SECOND_RELEASE,
		COMPUTE,
		WAIT_PRESS_TO_EXIT,
		PLAY_TELECRAN,
		CLOSE
	}state_e;

	static state_e state = INIT;
	static TS_ADC first_cross_point, second_cross_point;
	static bool_e asked_for_finish = FALSE;
	TS_ADC trash;
	char* text[35];
	running_e ret;

	ret = IN_PROGRESS;
	if(ask_for_finish)
		asked_for_finish = TRUE;
	switch(state)
	{
		case INIT:
			asked_for_finish = FALSE;
			TS_Init();
			STM32f4_Discovery_LCD_Init();
			LCD_Clear(LCD_COLOR_WHITE);
			LCD_SetFont(&Font12x12);
			if(mode == CALIBRATION_MODE_NO_CALIBRATION)
				state = CLOSE;
			else
			{
				printf("Calibration of Touchscreen (for display DM-LCD25RT)\n");
				state = LEFT_CROSS_DISPLAY;
			}
			break;


		case LEFT_CROSS_DISPLAY:
			LCD_DrawUniLine(CROSS_MARGIN-CROSS_SIZE, 	CROSS_MARGIN, 			CROSS_MARGIN+CROSS_SIZE,CROSS_MARGIN, 			 LCD_COLOR_BLUE);
			LCD_DrawUniLine(CROSS_MARGIN-CROSS_SIZE, 	CROSS_MARGIN-1, 		CROSS_MARGIN+CROSS_SIZE,CROSS_MARGIN-1, 		 LCD_COLOR_BLUE);
			LCD_DrawUniLine(CROSS_MARGIN-CROSS_SIZE,	CROSS_MARGIN+1,			CROSS_MARGIN+CROSS_SIZE,CROSS_MARGIN+1, 		 LCD_COLOR_BLUE);
			LCD_DrawUniLine(CROSS_MARGIN,				CROSS_MARGIN-CROSS_SIZE,CROSS_MARGIN,			CROSS_MARGIN+CROSS_SIZE, LCD_COLOR_BLUE);
			LCD_DrawUniLine(CROSS_MARGIN-1,			 	CROSS_MARGIN-CROSS_SIZE,CROSS_MARGIN-1, 		CROSS_MARGIN+CROSS_SIZE, LCD_COLOR_BLUE);
			LCD_DrawUniLine(CROSS_MARGIN+1,				CROSS_MARGIN-CROSS_SIZE,CROSS_MARGIN+1,	 		CROSS_MARGIN+CROSS_SIZE, LCD_COLOR_BLUE);
			state = WAIT_FIRST_PRESS;
			break;


		case WAIT_FIRST_PRESS:
			if(!t)
			{
				t = 100;
				TS_Get_Filtered_Touch(&first_cross_point);
				if(first_cross_point.touch_detected)
					state = WAIT_FIRST_RELEASE;
			}
			if(asked_for_finish)
				state = CLOSE;
			break;

		case WAIT_FIRST_RELEASE:
			if(!t)
			{
				t = 100;
				if(!TS_Get_Filtered_Touch(&trash))
					state = RIGHT_CROSS_DISPLAY;
			}
			if(asked_for_finish)
				state = CLOSE;
			break;


		case RIGHT_CROSS_DISPLAY:
			LCD_Clear(LCD_COLOR_WHITE);
			LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN-CROSS_SIZE,	LCD_PIXEL_HEIGHT-CROSS_MARGIN, 				LCD_PIXEL_WIDTH-CROSS_MARGIN+CROSS_SIZE,  	LCD_PIXEL_HEIGHT-CROSS_MARGIN,				LCD_COLOR_BLUE);
			LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN-CROSS_SIZE,	LCD_PIXEL_HEIGHT-CROSS_MARGIN-1,			LCD_PIXEL_WIDTH-CROSS_MARGIN+CROSS_SIZE, 	LCD_PIXEL_HEIGHT-CROSS_MARGIN-1,			LCD_COLOR_BLUE);
			LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN-CROSS_SIZE,	LCD_PIXEL_HEIGHT-CROSS_MARGIN+1,			LCD_PIXEL_WIDTH-CROSS_MARGIN+CROSS_SIZE,  	LCD_PIXEL_HEIGHT-CROSS_MARGIN+1,			LCD_COLOR_BLUE);
			LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN,  				LCD_PIXEL_HEIGHT-CROSS_MARGIN-CROSS_SIZE,  	LCD_PIXEL_WIDTH-CROSS_MARGIN,  				LCD_PIXEL_HEIGHT-CROSS_MARGIN+CROSS_SIZE,	LCD_COLOR_BLUE);
			LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN-1,  			LCD_PIXEL_HEIGHT-CROSS_MARGIN-CROSS_SIZE,  	LCD_PIXEL_WIDTH-CROSS_MARGIN-1, 			LCD_PIXEL_HEIGHT-CROSS_MARGIN+CROSS_SIZE,	LCD_COLOR_BLUE);
			LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN+1,  			LCD_PIXEL_HEIGHT-CROSS_MARGIN-CROSS_SIZE,  	LCD_PIXEL_WIDTH-CROSS_MARGIN+1,  			LCD_PIXEL_HEIGHT-CROSS_MARGIN+CROSS_SIZE,	LCD_COLOR_BLUE);
			state = WAIT_SECOND_PRESS;
			break;

		case WAIT_SECOND_PRESS:
			if(!t)
			{
				t = 100;
				TS_Get_Filtered_Touch(&second_cross_point);
				if(second_cross_point.touch_detected)
					state = COMPUTE;
			}
			if(asked_for_finish)
				state = CLOSE;
			break;

		case COMPUTE:
			ts_coeff.scale_x = (float)((LCD_PIXEL_WIDTH-2*CROSS_MARGIN))	/	((float)second_cross_point.x-(float)first_cross_point.x);
			ts_coeff.scale_y = (float)((LCD_PIXEL_HEIGHT-2*CROSS_MARGIN))	/	((float)second_cross_point.y-(float)first_cross_point.y);

			ts_coeff.offset_x = (float)(CROSS_MARGIN-ts_coeff.scale_x*(float)first_cross_point.x);
			ts_coeff.offset_y = (float)(CROSS_MARGIN-ts_coeff.scale_y*(float)first_cross_point.y);

			if(mode >= CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE)
			{
				LCD_Clear(LCD_COLOR_WHITE);
				sprintf((char*)text,"First cross x = %d  ", first_cross_point.x);
				LCD_DisplayStringLine(LINE(3),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				sprintf((char*)text,"Second cross x = %d  ", second_cross_point.x);
				LCD_DisplayStringLine(LINE(5),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				sprintf((char*)text,"First cross y = %d  ", first_cross_point.y);
				LCD_DisplayStringLine(LINE(4),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				sprintf((char*)text,"Second cross y = %d  ", second_cross_point.y);
				LCD_DisplayStringLine(LINE(6),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);

				LCD_DisplayStringLine(LINE(8),COLUMN(0),(uint8_t *)"Toucher pour continuer !",LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);

				sprintf((char*)text,"Scale x = %f",ts_coeff.scale_x);	//%ld.%03ld  ", (int32_t)ts_coeff.scale_x,(int32_t)(ts_coeff.scale_x*1000)-(1000*(int32_t)ts_coeff.scale_x));
				LCD_DisplayStringLine(LINE(10),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				sprintf((char*)text,"Offset x = %f",ts_coeff.offset_x);	// = %ld.%03ld  ", (int32_t)ts_coeff.scale_x,(int32_t)(ts_coeff.offset_x*1000)-(1000*(int32_t)ts_coeff.offset_x));
				LCD_DisplayStringLine(LINE(11),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				sprintf((char*)text,"Scale y = %f",ts_coeff.scale_y);	// = %ld.%03ld  ", (int32_t)ts_coeff.scale_x,(int32_t)(ts_coeff.scale_y*1000)-(1000*(int32_t)ts_coeff.scale_y));
				LCD_DisplayStringLine(LINE(12),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				sprintf((char*)text,"Offset y = %f",ts_coeff.offset_y);	// = %ld.%03ld  ", (int32_t)ts_coeff.scale_x,(int32_t)(ts_coeff.offset_y*1000)-(1000*(int32_t)ts_coeff.offset_y));
				LCD_DisplayStringLine(LINE(13),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);

				if(mode == CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE_AND_PROVIDE_TELECRAN_GAME)
				{
					LCD_DisplayStringLine(LINE(15),COLUMN(0),(uint8_t *)"To quit the Telecran Game,",LCD_COLOR_RED, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
					LCD_DisplayStringLine(LINE(16),COLUMN(0),(uint8_t *)"Just press the blue button",LCD_COLOR_RED, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				}
			}
			state = WAIT_SECOND_RELEASE;
			break;

		case WAIT_SECOND_RELEASE:
			if(!t)
			{
				t = 100;
				if(!TS_Get_Filtered_Touch(&trash))
				{
					switch(mode)
					{
						case CALIBRATION_MODE_JUST_CALIBRATE:
							state = CLOSE;
							break;
						case CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE:
							state = WAIT_PRESS_TO_EXIT;
							break;
						case CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE_AND_PROVIDE_TELECRAN_GAME:
							state = WAIT_PRESS_TO_EXIT;
							break;
						default:
							state = CLOSE;
							break;
					}
				}
			}
			if(asked_for_finish)
				state = CLOSE;
			break;

		case WAIT_PRESS_TO_EXIT:
			if(!t)
			{
				t = 100;
				if(TS_Get_Filtered_Touch(&trash))
				{
					if(mode == CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE)
					{
						LCD_Clear(LCD_COLOR_WHITE);
						state = CLOSE;
					}
					else	//CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE_AND_PROVIDE_TELECRAN_GAME
					{
						LCD_Clear(LCD_COLOR_BLACK);
						state = PLAY_TELECRAN;
					}
				}
			}
			if(asked_for_finish)
				state = CLOSE;
			break;
		case PLAY_TELECRAN:{
			uint16_t x,y;
			char str[30];
			if(!t)
			{
				t = 15;
				if(TS_Get_Touch(&x,&y))
				{
					sprintf((char*)str,"x = %5d",x);
					LCD_DisplayStringLine(LINE(1),COLUMN(0),(uint8_t *)str, LCD_COLOR_WHITE, LCD_COLOR_BLACK,LCD_NO_DISPLAY_ON_UART);
					sprintf((char*)str,"y = %5d",y);
					LCD_DisplayStringLine(LINE(2),COLUMN(0),(uint8_t *)str, LCD_COLOR_WHITE, LCD_COLOR_BLACK,LCD_NO_DISPLAY_ON_UART);
					LCD_PutPixel(x, y, LCD_COLOR_YELLOW);
				}
			}
			if(asked_for_finish)
				state = CLOSE;
			break;}

		case CLOSE:
			LCD_Clear(LCD_COLOR_WHITE);
			state = INIT;
			ret = END_OK;
			break;
		default:
			break;
	}

	return ret;
}
Exemplo n.º 12
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32l1xx_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32l1xx.c file
     */
 
  uint32_t index = 0, tmp=0 ;
  
  /* Initialize the LCD */
  STM32L152D_LCD_Init(); 
  
  /* Clear the LCD */ 
  LCD_Clear(White);
  
  /* Set the LCD Back Color */
  LCD_SetBackColor(Blue);
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(White);
  
  /* Displays MESSAGE1 on line 1 */
  LCD_DisplayStringLine(LINE(0), (uint8_t *)MESSAGE1);
  
  /* Set the LCD Back Color */
  LCD_SetBackColor(Cyan);
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(Black);
  
  /* Draw lines */
  LCD_DrawUniLine(69, 121, 69,20);
  LCD_DrawUniLine(171, 121, 171, 20);
  
  /* Draw 4 lines  */
  LCD_DrawUniLine(70, 121, 120, 71);
  LCD_DrawUniLine(120, 71, 170,121);
  LCD_DrawUniLine(70, 20, 120, 70);
  LCD_DrawUniLine(120, 70, 170,20);
  
  /* Initailize the Display Picture */  
  for (index = 0; index < 100 ; index++)
  {
    if ((index % 2) ==0)
    {
      /* Set the LCD Text Color */
      LCD_SetTextColor(Blue);
      /* Draw Horizontal line */
      LCD_DrawLine(70 + (index/2) , 120 - (index/2)  , 101 - (index + 1) ,Horizontal);
      /* Set the LCD Text Color */
      LCD_SetTextColor(White);
      /* Draw Horizontal line */
      LCD_DrawLine(170 - (index/2) , 120 - (index/2)  , 101 - (index + 1) ,Horizontal);
    }
  }
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(Blue); 
  /* Set the LCD Back Color */
  LCD_SetBackColor(White);
  
  /* Display String on the LCD  */
  LCD_DisplayStringLine(LINE(3), " Set Timer:");
  LCD_DisplayStringLine(95,     "   01:00 ");  
  
  /* Initialize Timer to 60 seconds */
  SecondNumb = 60;
  
  /* Configure the external interrupt "LEFT", "RIGHT" , "DOWN" and "UP" buttons */
  STM_EVAL_PBInit(BUTTON_RIGHT, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_LEFT, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_UP, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_EXTI);
  
  /* Configure DOWN button in GPIO mode */  
   STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_GPIO);  
  
  /* Configure the RTC peripheral by selecting the clock source.*/
  RTC_Config();
 
  /* Configure RTC AlarmA register to generate 8 interrupts per 1 Second */
  RTC_AlarmConfig();
  
  /* Set Text and Back color and Text size */
  LCD_SetFont(&Font12x12);
  LCD_SetBackColor(Cyan);
  LCD_SetTextColor(Black);
  LCD_DisplayStringLine(LINE(18), (uint8_t *)MESSAGE2);
  
  /* Set the LCD Back Color */
  LCD_SetBackColor(Blue);
  LCD_SetTextColor(White);
  LCD_DisplayStringLine(LINE(19), (uint8_t *)MESSAGE3);
  LCD_SetFont(&Font16x24);

  while (1)
  {
    /* Check on the event 'start' */
    if(StartEvent == 8)
    {
      /* Check on the Alarm event counter */
      if(RTCAlarmCount != 0 ) 
      {
        tmp = (uint32_t) ((RTCAlarmCount * 100)/ (8 * SecondNumb)); 
        
        /* First */
        Delay((1000* SecondNumb));
        
        LCD_SetTextColor(Blue);
        LCD_DrawLine(120, 70, 2, Vertical);
        LCD_DrawLine(122, 68, 2, Vertical);
        LCD_DrawLine(122, 72, 2, Vertical);
        if(tmp <= 72)
        {  
          LCD_SetTextColor(White);
          LCD_DrawLine(130, 70, 2, Vertical);
          LCD_DrawLine(132, 68, 2, Vertical);
          LCD_DrawLine(132, 72, 2, Vertical);
        }
        LCD_SetTextColor(Blue);
        LCD_DrawLine(140, 70, 2, Vertical);
        LCD_DrawLine(142, 69, 2, Vertical);
        LCD_DrawLine(142, 72, 2, Vertical);
        
        /* Second */
        Delay((1000*SecondNumb));
        if(tmp <= 90)
        { 
          LCD_SetTextColor(White);
          LCD_DrawLine(120, 70, 2, Vertical);
          LCD_DrawLine(122, 68, 2, Vertical);
          LCD_DrawLine(122, 72, 2, Vertical);
        }
        LCD_SetTextColor(Blue);
        LCD_DrawLine(130, 70, 2, Vertical);
        LCD_DrawLine(132, 68, 2, Vertical);
        LCD_DrawLine(132, 72, 2, Vertical);
        if(tmp <= 52)
        { 
          LCD_SetTextColor(White);
          LCD_DrawLine(140, 70, 2, Vertical);
          LCD_DrawLine(142, 68, 2, Vertical);
          LCD_DrawLine(142, 72, 2, Vertical);
        }
      }
    }
    else if (StartEvent == 9)
    {
      LCD_SetTextColor(Blue);
      LCD_DrawLine(120, 70, 2, Vertical);
      LCD_DrawLine(122, 68, 2, Vertical);
      LCD_DrawLine(122, 72, 2, Vertical);
      
      LCD_DrawLine(130, 70, 2, Vertical);
      LCD_DrawLine(132, 68, 2, Vertical);
      LCD_DrawLine(132, 72, 2, Vertical);
      
      LCD_DrawLine(140, 70, 2, Vertical);
      LCD_DrawLine(142, 68, 2, Vertical);
      LCD_DrawLine(142, 72, 2, Vertical);
    }
    else
    {
      if(tmp <= 90)
      { 
        LCD_SetTextColor(White);
      }
      else
      {
        LCD_SetTextColor(Blue);
      }
      LCD_DrawLine(120, 70, 2, Vertical);
      LCD_DrawLine(122, 68, 2, Vertical);
      LCD_DrawLine(122, 72, 2, Vertical);
      
      if(tmp <= 72)
      { 
        LCD_SetTextColor(White);
      }
      else
      {
        LCD_SetTextColor(Blue);
      }
      LCD_DrawLine(130, 70, 2, Vertical);
      LCD_DrawLine(132, 68, 2, Vertical);
      LCD_DrawLine(132, 72, 2, Vertical);
      
      if(tmp <= 52)
      { 
        LCD_SetTextColor(White);
      }
      else
      {
        LCD_SetTextColor(Blue);
      }
      LCD_DrawLine(140, 70, 2, Vertical);
      LCD_DrawLine(142, 68, 2, Vertical);
      LCD_DrawLine(142, 72, 2, Vertical);
      
    }
  }
}
Exemplo n.º 13
0
void draw_s640k1(void)
{
  LCD_Clear(Black);
  LCD_str(267,0,"测试型号:S640K1",32,Blue,Black);
  
  
//  LCD_str(0,32,"换向手柄",32,Blue,Black);
  LCD_str(128,224,"后零前制",32,Blue,Black);
  LCD_str(0,256,"402(403)",32,Blue,Black);
  LCD_str(0,288,"404(405)",32,Blue,Black);
  LCD_str(0,320,"405(404)",32,Blue,Black);
  LCD_str(0,352,"407(407)",32,Blue,Black);
  LCD_str(0,384,"406(406)",32,Blue,Black);
  LCD_str(0,416,"409(410)",32,Blue,Black);
  LCD_str(0,447,"410(409)",32,Blue,Black); 
  
//  LCD_str(256,64,"401(401)",32,Blue,Black);
//  LCD_str(256,96,"401(401)",32,Blue,Black);
//  LCD_str(256,128,"401(401)",32,Blue,Black);
  LCD_str(256,352,"401(401)",32,Blue,Black); 
//  LCD_str(256,192,"401(401)",32,Blue,Black);
//  LCD_str(256,224,"401(401)",32,Blue,Black);
//  LCD_str(256,256,"401(401)",32,Blue,Black); 
  
  u8 n=0;
  for(n=0;n<7;n++)
  {
    LCD_DrawUniLine( 128,  (272+32*n),  256,  (272+32*n),  Cyan);
  }
  for(n=0;n<4;n++)
  {
    LCD_DrawUniLine( (144+32*n),  256,  (144+32*n),  479,  Cyan);
  }
  LCD_DrawUniLine( 256, 272,  256,  464,  Green);
  
  
//  LCD_str(384,64,"控制手柄",32,Blue,Black);
  LCD_str(176,32,"制动",32,Blue,Black);
  LCD_str(352,32,"零",32,Blue,Black);
  LCD_str(492,32,"牵引",32,Blue,Black);
  LCD_str(136,64,"1",32,Blue,Black);
  LCD_str(168,64,"3",32,Blue,Black);
  LCD_str(200,64,"6",32,Blue,Black);
  LCD_str(232,64,"9",32,Blue,Black);
  LCD_str(256,64,"12",32,Blue,Black);
  LCD_str(288,64,"15",32,Blue,Black);
  LCD_str(320,64,"17",32,Blue,Black);
  LCD_str(360,64,"0",32,Blue,Black);
  LCD_str(392,64,"*",32,Blue,Black);
  LCD_str(424,64,"3",32,Blue,Black);
  LCD_str(456,64,"6",32,Blue,Black);
  LCD_str(488,64,"9",32,Blue,Black);
  LCD_str(512,64,"12",32,Blue,Black);
  LCD_str(544,64,"15",32,Blue,Black);
  LCD_str(576,64,"17",32,Blue,Black);
  
  
  LCD_str(0,96,"422(415)",32,Blue,Black);
  LCD_str(0,160,"402(403)",32,Blue,Black);
  
  LCD_str(608,96,"414(416)",32,Blue,Black);
  LCD_str(608,144,"412(412)",32,Blue,Black); 
  LCD_str(608,192,"413(413)",32,Blue,Black);
  
  for(n=0;n<4;n++)
  {
    LCD_DrawUniLine( 128,  (112+32*n),  608,  (112+32*n),  Cyan);
  }
  for(n=0;n<15;n++)
  {
    LCD_DrawUniLine( (144+32*n),  96,  (144+32*n),  224,  Cyan);
  }
  LCD_DrawUniLine( 608, 144,  608,  176,  Green);
  LCD_DrawUniLine( 128, 144,  128,  272,  Green);
  
  for(n=0;n<43;n++)
  {
    LCD_DrawFullCircle( S640K1_POINTS[n][0],  S640K1_POINTS[n][1],  5,  Blue2,  1);
  }
  for(n=0;n<21;n++)
  {
    LCD_DrawFullRect( S640K1_TP[n][0],   S640K1_TP[n][1],   S640K1_TP[n][2],   S640K1_TP[n][3],  Blue2, 0);
  }
  //LCD_str(671,352,"保存结果",32,Blue2,Black);
  LCD_str(671,352,"自动模式",32,Blue2,Black);
  LCD_str(671,432,"退出实验",32,Red,Black);
  LCD_str(671,256,"级位电压",32,Blue,Black);
  
}
Exemplo n.º 14
0
/**
  * @brief  Lcd_Touch Calibration  test
  * @param  None
  * @retval None
  */
void Lcd_Touch_Calibration(void)
{
#define CURSOR_LEN    (10)
  uint8_t k,i;
  float ratio1,ratio2;
  Point_Struct left_upper_point,right_upper_point,left_down_point,right_down_point,tst_point;
  int tpx_sum = 0,tpy_sum = 0;

  /*Indicates whether Calibration is OK*/
  uint8_t adjust_OK_Falg = 0;
  TS_STATE *pstate = NULL;

  /* Clear the LCD */ 
  LCD_Clear(White);
  LCD_SetTextColor(Red); 
  delay(100);
  while (!adjust_OK_Falg) {
    tpx_sum = 0;
    tpy_sum = 0;
    /*wait for Calibration */
    for (k = 0;k < 4;k++) {
      LCD_DrawUniLine( point_Base[k].x - CURSOR_LEN,
                       point_Base[k].y,
                       point_Base[k].x + CURSOR_LEN,
                       point_Base[k].y);

      LCD_DrawUniLine( point_Base[k].x,
                       point_Base[k].y - CURSOR_LEN,
                       point_Base[k].x,
                       point_Base[k].y + CURSOR_LEN);
      do {
        pstate = IOE_TS_GetState();
      } while(!pstate->TouchDetected);
			delay(10);
      /*Read AD convert result*/
      for(i = 0; i < 16; i++) {
        tpx_sum += IOE_TS_Read_X();
        tpy_sum += IOE_TS_Read_Y();	
        delay(2);
      }
      tpx_sum >>= 4;
      tpy_sum >>= 4;

      switch (k) {
        case 0:
          left_upper_point.x = tpx_sum;
          left_upper_point.y = tpy_sum;
          break;

        case 1:
          right_upper_point.x = tpx_sum;
          right_upper_point.y = tpy_sum;
          break;

        case 2:
          left_down_point.x = tpx_sum;
          left_down_point.y = tpy_sum;
          break;

        case 3:
          right_down_point.x = tpx_sum;
          right_down_point.y = tpy_sum;
          break;

        default:
          break;
      }
      delay(200);
    }

    ratio1 = (float)((point_Base[1].x - point_Base[0].x) + (point_Base[3].x - point_Base[2].x)) / 2.0;
    ratio2 = (float)((right_upper_point.x - left_upper_point.x) + (right_down_point.x - left_down_point.x)) / 2.0;
    adjust_Para.xScale = ratio1 / ratio2;

    ratio1 = (float)((point_Base[2].y - point_Base[0].y) + 
             (point_Base[3].y - point_Base[1].y)) / 2.0;
    ratio2 = (float)((left_down_point.y - left_upper_point.y) + 
             (right_down_point.y - right_upper_point.y)) / 2.0;
    adjust_Para.yScale = ratio1 / ratio2;

    ratio1 = (((float)right_upper_point.x * adjust_Para.xScale - (float)point_Base[1].x)
             + ((float)left_upper_point.x * adjust_Para.xScale - (float)point_Base[0].x)) / 2.0;
    adjust_Para.xOffset = (int)ratio1;

    ratio1 = (((float)right_upper_point.y * adjust_Para.yScale - (float)point_Base[1].y)
             + ((float)left_upper_point.y * adjust_Para.yScale - (float)point_Base[0].y)) / 2.0;

    adjust_Para.yOffset = (int)ratio1; 

    /*Draw cross sign for calibration points*/
    LCD_DrawUniLine(point_Base[4].x - CURSOR_LEN,
                    point_Base[4].y,
                    point_Base[4].x + CURSOR_LEN,
                    point_Base[4].y);

    LCD_DrawUniLine(point_Base[4].x,
                    point_Base[4].y - CURSOR_LEN,
                    point_Base[4].x,
                    point_Base[4].y + CURSOR_LEN);

    do {
      pstate = IOE_TS_GetState();
    } while(!pstate->TouchDetected);
    delay(10);
    tpx_sum = 0;
    tpy_sum = 0;
    /*Read AD convert result*/
    for(i = 0; i < 16; i++) {
      tpx_sum += IOE_TS_Read_X();
      tpy_sum += IOE_TS_Read_Y();	
      delay(2);
    }
    tpx_sum >>= 4;
    tpy_sum >>= 4;

    tst_point.x = tpx_sum;
    tst_point.y = tpy_sum;
         
    tst_point.x = (int)(tst_point.x * adjust_Para.xScale - adjust_Para.xOffset); 
    tst_point.y = (int)(tst_point.y * adjust_Para.yScale - adjust_Para.yOffset); 

    if (tst_point.x > (point_Base[4].x + CALIBRATION_RANGE)
        || tst_point.x < (point_Base[4].x - CALIBRATION_RANGE)
        || tst_point.y > (point_Base[4].y + CALIBRATION_RANGE)
        || tst_point.y < (point_Base[4].y - CALIBRATION_RANGE)) {
      adjust_OK_Falg = 0;
      LCD_DisplayStringLine(LINE(8),"   Calibration Fail!    ");
      delay(200);
      LCD_Clear(White);
      delay(300);
    } else {
      adjust_OK_Falg = 1;
    }
  }
  LCD_DisplayStringLine(LINE(8),"   Calibration OK!    ");
  delay(200);
}
Exemplo n.º 15
0
/**
  * @brief  Display the value of calibration point
  * @param  None
  * @retval None
  */
void Calibration_Test_Dispose(void) 
{
  TS_STATE *pstate = NULL;
  uint8_t text[50];
  uint8_t b_flag = 1;

  /*Init Variables*/
  point_new.x = 0;
  point_new.y = 0;
  point_old.x = 0;
  point_old.y = 0;

  /*Display backgroup of LCD*/
  LCD_Clear(White);
  LCD_SetTextColor(Red);
  LCD_DisplayStringLine(LINE(9),"        please touch the screen          "); 
  while (1) {
    do {
      pstate = IOE_TS_GetState();
      delay(10);
    } while(!pstate->TouchDetected);
    point_new.x = pstate->X;
    point_new.y = pstate->Y;
		
    /* If AD result is abnormal, then LCD show nothing */
    if ((point_new.x > TOUCH_AD_VALUE_MAX) 
        || (point_new.x < TOUCH_AD_VALUE_MIN)
        || (point_new.y > TOUCH_AD_VALUE_MAX)
        || (point_new.y < TOUCH_AD_VALUE_MIN)) {
      continue;					
    }
    if (b_flag) {
      b_flag = 0;
      LCD_Clear(White);
    }
    LCD_SetTextColor(Blue);
    sprintf((char*)text,"   X_AD = %d ",point_new.x);
    LCD_DisplayStringLine(LINE(4),text);
    sprintf((char*)text,"   y_AD = %d ",point_new.y);
    LCD_DisplayStringLine(LINE(5),text);
    /*Calculate coordinates*/
    point_new.x = ((int)(point_new.x * adjust_Para.xScale - adjust_Para.xOffset));
    point_new.y = ((int)(point_new.y * adjust_Para.yScale - adjust_Para.yOffset));

    if (point_new.x >= LCD_PIXEL_WIDTH) {
      point_new.x = LCD_PIXEL_WIDTH -1;
    }
    if (point_new.y >= LCD_PIXEL_HEIGHT) {
      point_new.y = LCD_PIXEL_HEIGHT -1;
    }
    sprintf((char*)text,"   X_POS = %d ", point_new.x);
    LCD_DisplayStringLine(LINE(7),text);
    sprintf((char*)text,"   y_POS = %d ", point_new.y);
    LCD_DisplayStringLine(LINE(8),text);
    LCD_SetTextColor(Red); 
    /*Judge whether the inut point is the 1st point*/ 
    if ((point_old.x == 0) && (point_old.y == 0)) {
      point_old.x = point_new.x;
      point_old.y = point_new.y;			
    } else {
      LCD_DrawUniLine(point_old.x, point_old.y, point_new.x, point_new.y);
      point_old.x = point_new.x;
      point_old.y = point_new.y;	
    }
  }
}