void Paint(u32 X,u32 Y)
{
   extern u8 Page;
   if(Y<30)
   {
      if((X<50)&&(painted)){painted=0;Paint_Init();}
      else if(X<100)PenColor=1;
      else if(X<150)PenColor=2;
      else if(X<200)PenColor=3;
      else if(X<250)PenColor=4;
      else if(X<300)PenColor=5;
      else PenColor=6;
   }
   else if(X<50)
   {
      if(Y<100){shape=0;}
      else if(Y<150){shape=4;}
      else if(Y<200){shape=1;}
      else{shape=2;}
   }
   else if((X>60)&&(Y>55)&&(X<290)&&(Y<195))
   {  painted++;
      if(shape==0){TFT_Set_Pen(colors[PenColor],10);TFT_Circle(X,Y,1);}
      else if(shape==1){TFT_Set_Pen(colors[PenColor],3);TFT_Circle(X,Y,20);}
      else if(shape==2){TFT_Set_Pen(colors[PenColor],3); TFT_Rectangle(X,Y,X+20,Y+20);}
      else  {TFT_Set_Pen(colors[PenColor],20);TFT_Circle(X,Y,1);}
   }
   else if(Y>210 && X>270)
       {
          Page=0;
          Menu_Init();
       }
}
Пример #2
0
int main(void)
{
	SPI_Initialize();				//Initialize SPI peripheral
	TFT_Initialize();
	I2C_Initialize(CAP1203ADDR);
	
    CAP1203_Initialize();
	
	unsigned char button = 0x00;
	
	#ifdef __DEBUG__
		int id = CAP1203_ReadID();							//Read ID of Capacitive touch controller 
		printf("Chip ID: 0x%04X. \r\n",id);
	#endif
	
	TFT_Background(WHITE);
	TFT_Circle(80,35,20,RED);
	TFT_Circle(80,80,20,GREEN);
	TFT_Circle(80,125,20,BLUE);
	  
	while(1)
	{
		button = CAP1203_ReadPressedButton();
			switch(button)
			{
				case 1:
					TFT_Disk(80,125,10,BLUE);
					printf("Button B1 pressed.\r\n");
					break;
				case 2:
					TFT_Disk(80,80,10,GREEN);
					printf("Button B2 pressed.\r\n");
					break;					
				case 3:
					TFT_Disk(80,35,10,RED);
					printf("Button B3 pressed.\r\n");
					break;				
				default:
					TFT_Circle(80,35,20,RED);				//Paint two circles for an annular ring
					TFT_Circle(80,80,20,GREEN);
					TFT_Circle(80,125,20,BLUE);	
					TFT_Circle(80,35,19,RED);
					TFT_Circle(80,80,19,GREEN);
					TFT_Circle(80,125,19,BLUE);
					
					TFT_Disk(80,35,10,WHITE);				//Clear interior
					TFT_Disk(80,80,10,WHITE);
					TFT_Disk(80,125,10,WHITE);
					break;
			}	
		delay_ms(100);		
    }
    return 0;
}
void Paint_Init(void)
{
    TFT_Fill_Screen(colors[14]);
    TFT_Set_Pen(colors[14],20);
    TFT_Rectangle(0,0,20,20);
    TFT_Write_Text("Clear",2,8);
    TFT_Set_Pen(colors[1],20);
    TFT_Rectangle(50,0,70,20);
    TFT_Set_Pen(colors[2],20);
    TFT_Rectangle(100,0,120,20);
    TFT_Set_Pen(colors[3],20);
    TFT_Rectangle(150,0,170,20);
    TFT_Set_Pen(colors[4],20);
    TFT_Rectangle(200,0,220,20);
    TFT_Set_Pen(colors[5],20);
    TFT_Rectangle(250,0,270,20);
    TFT_Set_Pen(colors[6],20);
    TFT_Rectangle(300,0,320,20);
    ///////////////////////////////////////////
    TFT_Set_Pen(colors[2],1);
    TFT_Rectangle(5,50,45,90);
    TFT_Set_Pen(colors[1],10);
    TFT_Circle(25,70,1);
    TFT_Set_Pen(colors[2],1);
    TFT_Rectangle(5,100,45,140);
    TFT_Set_Pen(colors[1],20);
    TFT_Circle(25,120,1);
    TFT_Set_Pen(colors[2],1);
    TFT_Rectangle(5,150,45,190);
    TFT_Set_Pen(colors[1],3);
    TFT_Circle(25,170,15);
    TFT_Set_Pen(colors[2],1);
    TFT_Rectangle(5,200,45,240);
    TFT_Set_Pen(colors[1],3);
    TFT_Rectangle(10,210,40,230);
    TFT_Set_Pen(colors[1],1);
    TFT_Rectangle(50,45,310,215);
    ////////////////////////////////////////////
    TFT_Write_Text("Back->",270,220);
}
void DrawRadioButton(TRadioButton *ARadioButton) {
  int circleOffset = 0;
  if (ARadioButton->Visible == 1) {
  circleOffset = ARadioButton->Height / 5;
    TFT_Set_Pen(ARadioButton->Pen_Color, ARadioButton->Pen_Width);
    if (ARadioButton->TextAlign == _taLeft) {
             TFT_Set_Brush(ARadioButton->Transparent,ARadioButton->Background_Color,0,0,0,0);
             TFT_Circle(ARadioButton->Left + ARadioButton->Height / 2, ARadioButton->Top + ARadioButton->Height / 2, ARadioButton->Height / 2);
             if (ARadioButton->Checked == 1) {
                 if (object_pressed == 1) {
                    object_pressed = 0;
                    TFT_Set_Brush(ARadioButton->Transparent, ARadioButton->Press_Color, ARadioButton->Gradient, ARadioButton->Gradient_Orientation, ARadioButton->Gradient_End_Color, ARadioButton->Gradient_Start_Color);
                 }
                 else 
                   TFT_Set_Brush(ARadioButton->Transparent, ARadioButton->Color, ARadioButton->Gradient, ARadioButton->Gradient_Orientation, ARadioButton->Gradient_Start_Color, ARadioButton->Gradient_End_Color);
               TFT_Circle(ARadioButton->Left + ARadioButton->Height / 2 , ARadioButton->Top + ARadioButton->Height / 2, ARadioButton->Height / 2 - circleOffset);
             }
             TFT_Set_Ext_Font(ARadioButton->FontName, ARadioButton->Font_Color, FO_HORIZONTAL);
             TFT_Write_Text_Return_Pos(ARadioButton->Caption, ARadioButton->Left + ARadioButton->Height + 4, ARadioButton->Top);
             TFT_Write_Text(ARadioButton->Caption, ARadioButton->Left + ARadioButton->Height + 4, (ARadioButton->Top + ((ARadioButton->Height - caption_height) / 2)));
    }
    else if (ARadioButton->TextAlign == _taRight) {
             TFT_Set_Brush(ARadioButton->Transparent,ARadioButton->Background_Color,0,0,0,0);
             TFT_Circle(ARadioButton->Left  + ARadioButton->Width - ARadioButton->Height / 2, ARadioButton->Top + ARadioButton->Height / 2, ARadioButton->Height / 2);
             if (ARadioButton->Checked == 1) {
                 if (object_pressed == 1) {
                    object_pressed = 0;
                    TFT_Set_Brush(ARadioButton->Transparent, ARadioButton->Press_Color, ARadioButton->Gradient, ARadioButton->Gradient_Orientation, ARadioButton->Gradient_End_Color, ARadioButton->Gradient_Start_Color);
                 }
                 else 
                   TFT_Set_Brush(ARadioButton->Transparent, ARadioButton->Color, ARadioButton->Gradient, ARadioButton->Gradient_Orientation, ARadioButton->Gradient_Start_Color, ARadioButton->Gradient_End_Color);
                 TFT_Circle(ARadioButton->Left  + ARadioButton->Width - ARadioButton->Height / 2, ARadioButton->Top + ARadioButton->Height / 2, ARadioButton->Height / 2 - circleOffset);
             }
             TFT_Set_Ext_Font(ARadioButton->FontName, ARadioButton->Font_Color, FO_HORIZONTAL);
             TFT_Write_Text_Return_Pos(ARadioButton->Caption, ARadioButton->Left + 3, ARadioButton->Top);
             TFT_Write_Text(ARadioButton->Caption, ARadioButton->Left + 3, ARadioButton->Top + (ARadioButton->Height - caption_height) / 2);
    }
 }
}