Пример #1
0
char ProgressSpinner_Update(void * object, int newProgress) {
  ProgressSpinner * pspinner = (ProgressSpinner*)object;
  
  // Delete old one
  Draw_Circle(pspinner->x0+pspinner->size/2+pspinner->progressX, pspinner->y0+pspinner->size/2+pspinner->progressY, 
			 pspinner->size/5, 0);
  
  // Check for cancellation
  if (pspinner->cancelled == 1) return 1;
  
  // Update current progress of the spinner
  int r2 = pspinner->animRadius * pspinner->animRadius;
  
  if (pspinner->reverse == 0){
	pspinner->progressY = (int) (sqrt(r2 - pspinner->progressX*pspinner->progressX) + 0.5);
	
	pspinner->progressX += 2;
	if (pspinner->progressX >= pspinner->animRadius){
	  pspinner->reverse = 1;
	}
  }
  else{
	pspinner->progressY = (int) -(sqrt(r2 - pspinner->progressX*pspinner->progressX) + 0.5);
	
	pspinner->progressX -= 2;
	if (pspinner->progressX <= -pspinner->animRadius){
	  pspinner->reverse = 0;
	}
  }
  
  // Draw new one
  Draw_Circle(pspinner->x0+pspinner->size/2+pspinner->progressX, pspinner->y0+pspinner->size/2+pspinner->progressY,
			 pspinner->size/5, pspinner->borderColor);
  return 0;
}
Пример #2
0
PDGL_API int Draw_FillCircle(int ox, int oy, int ra, int r, int g, int b, int a)
{
	pdglDisableTexture2D();
	pdglColor4f(r/255.0, g/255.0, b/255.0, a/255.0);

	Draw_Circle(ox, oy, ra);
	return(0);
}
Пример #3
0
static
void Draw_Circle_Init(SDL_Surface *super,
                      Sint16 x0, Sint16 y0, Uint16 r,
                      Uint32 color)
{
  Draw_Init();
  Draw_Circle(super, x0, y0, r, color);
}
Пример #4
0
//////////////////////////////////////////////////
//与LCD部分有关的函数  
//画一个触摸点
//用来校准用的
void Drow_Touch_Point(u8 x,u16 y)
{
	LCD_DrawLine(x-12,y,x+13,y);//横线
	LCD_DrawLine(x,y-12,x,y+13);//竖线
	LCD_DrawPoint(x+1,y+1);
	LCD_DrawPoint(x-1,y+1);
	LCD_DrawPoint(x+1,y-1);
	LCD_DrawPoint(x-1,y-1);
	Draw_Circle(x,y,6);//画中心圈
}	  
Пример #5
0
/**
  * @brief: 画一个触摸点, 用来校准用的
  * @param: x,y:坐标
  * @param: color:颜色
  * @retval: none
  */
void TP_Drow_Touch_Point(u16 x,u16 y,u16 color)
{
	POINT_COLOR=color;
	LCD_DrawLine(x-12,y,x+13,y);//横线
	LCD_DrawLine(x,y-12,x,y+13);//竖线
	LCD_DrawPoint(x+1,y+1);
	LCD_DrawPoint(x-1,y+1);
	LCD_DrawPoint(x+1,y-1);
	LCD_DrawPoint(x-1,y-1);
	Draw_Circle(x,y,6);//画中心圈
}	  
Пример #6
0
void Draw_FilledCircle(int x0, int y0, int r, int backgroundColor, int borderColor, int Draw_Border) {

    for (int x = -r; x <= r; x++) {
        int dy = (int)(sqrt(r*r - x*x));
        for (int y = -dy; y <= dy; y++) {
            DRAW_PIXEL(x0+x, y0+y, backgroundColor);
        }
    }

    if (Draw_Border) Draw_Circle(x0,y0,r,borderColor);
}
Пример #7
0
// draw with RAIO
// ---------------------------------------------
void example_DrawWithRAIO( void )
{
	// rectangle
	Draw_Square (0, 0, 319, 239);
	Text_Foreground_Color ( COLOR_BLACK );
	RAIO_StartDrawing ( SQUARE_FILL );
	Text_Foreground_Color ( COLOR_BLUE );
	Draw_Square (210, 150, 260, 200);

	// line
	Draw_Line ( 10, 230, 310, 10 );
	Text_Foreground_Color ( COLOR_GREEN );
	RAIO_StartDrawing ( LINE );

	// circle
	Draw_Circle ( 90, 65, 25 );
	Text_Foreground_Color ( COLOR_RED );
	RAIO_StartDrawing ( CIRCLE_FILL );
}
Пример #8
0
/*----------------------------------------------------------------------*/
int main(int argc, char *argv[])
{
  SDL_Surface *screen;
  int width, height;
  Uint8  video_bpp;
  Uint32 videoflags;
  int done;
  SDL_Event event;
  Uint32 then, now, frames;

  if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    fprintf(stderr, "SDL_Init problem: %s", SDL_GetError());
    exit(1);
  }
  atexit(SDL_Quit);

  videoflags = SDL_SWSURFACE | SDL_ANYFORMAT;
  width = 640;
  height = 480;
  video_bpp = 0;

  while ( argc > 1 ) {
      --argc;
           if ( strcmp(argv[argc-1], "-width") == 0 ) {
      width = atoi(argv[argc]);
      --argc;
    } else if ( strcmp(argv[argc-1], "-height") == 0 ) {
      height = atoi(argv[argc]);
      --argc;
    } else if ( strcmp(argv[argc-1], "-bpp") == 0 ) {
      video_bpp = atoi(argv[argc]);
      videoflags &= ~SDL_ANYFORMAT;
      --argc;
    } else if ( strcmp(argv[argc], "-fast") == 0 ) {
      videoflags = FastestFlags(videoflags, width, height, video_bpp);
    } else if ( strcmp(argv[argc], "-hw") == 0 ) {
      videoflags ^= SDL_HWSURFACE;
    } else if ( strcmp(argv[argc], "-flip") == 0 ) {
      videoflags ^= SDL_DOUBLEBUF;
    } else if ( strcmp(argv[argc], "-fullscreen") == 0 ) {
      videoflags ^= SDL_FULLSCREEN;
    } else {
      fprintf(stderr, "Use: %s [-bpp N] [-hw] [-flip] [-fast] [-fullscreen]\n",
              argv[0]);
      exit(1);
    }
  }/*while*/

  /*Video mode activation*/
  screen = SDL_SetVideoMode(width, height, video_bpp, videoflags);
  if (!screen) {
    fprintf(stderr, "I can not activate video mode: %dx%d: %s\n",
            width, height, SDL_GetError());
    exit(2);
  }

{/*BEGIN*/
  Uint32 c_white = SDL_MapRGB(screen->format, 255,255,255);
  Uint32 c_gray = SDL_MapRGB(screen->format, 200,200,200);
  Uint32 c_dgray= SDL_MapRGB(screen->format, 64,64,64);
  Uint32 c_cyan = SDL_MapRGB(screen->format, 32,255,255);

  //SDL_Rect r = {100,300,50,50};
  //SDL_SetClipRect(screen, &r);  //Test of clipping code

  frames = 0;
  then = SDL_GetTicks();
  done = 0;
  while( !done ) {
  
  Draw_Line(screen, 100,100, 30,0, c_white);
  Draw_Line(screen, 30,0, 100,100, c_white);

  Draw_Line(screen, 100,100, 30,0, c_white);
  Draw_Line(screen, 30,0, 100,100, c_white);
  Draw_Line(screen, 0,0, 100,100, c_white);
  Draw_Line(screen, 100,100, 300,200, c_white);
  Draw_Line(screen, 200,300, 250,400,
                SDL_MapRGB(screen->format, 128,128,255));
  Draw_Line(screen, 500,50, 600,70,
                SDL_MapRGB(screen->format, 128,255,128));
  Draw_Line(screen, 500,50, 600,70,
                SDL_MapRGB(screen->format, 128,255,128));
  //Draw_Circle(screen, 100+frames%200, 100, 50, c_white);
  Draw_Circle(screen, 100+(frames/3)%200, 100+(frames/2)%173, 50,
              SDL_MapRGB(screen->format, 128+frames,255+frames,68+frames));

  /*-------------*/
  Draw_Circle(screen, 150,150, 5, c_white);
  Draw_Circle(screen, 150,150, 4,
                 SDL_MapRGB(screen->format, 64,64,64));
  Draw_Circle(screen, 150,150, 3,
                 SDL_MapRGB(screen->format, 255,0,0));
  Draw_Circle(screen, 150,150, 2,
                 SDL_MapRGB(screen->format, 0,255,0));
  Draw_Circle(screen, 150,150, 1,
                 SDL_MapRGB(screen->format, 0,0,255));
  /*-------------*/

  Draw_Line(screen, 500,100, 600,120,
                SDL_MapRGB(screen->format, 128,255,128));
  Draw_Circle(screen, 601,121, 2, c_white);

  Draw_Circle(screen, 400,200, 2, c_white);
  Draw_Line(screen, 400,200, 409,200, c_white);
  Draw_Circle(screen, 409,200, 2, c_white);
  Draw_Line(screen, 400,200, 400,250, c_white);
  Draw_Circle(screen, 400,250, 2, c_white);
  Draw_Line(screen, 409,200, 400,250, c_white);


  Draw_Line(screen, 400,300, 409,300, c_gray);
  Draw_Line(screen, 400,300, 400,350, c_gray);
  Draw_Line(screen, 409,300, 400,350, c_dgray);
  Draw_Rect(screen, 398,298, 4,4, c_cyan);
  Draw_Rect(screen, 407,298, 4,4, c_cyan);
  Draw_Rect(screen, 398,348, 4,4, c_cyan);

  Draw_HLine(screen, 10,400, 50, c_white);
  Draw_VLine(screen, 60,400, 360, c_white);
  Draw_Rect(screen, 500,400, 50,50, c_white);
  Draw_Pixel(screen, 510,410, c_white);
  Draw_Pixel(screen, 520,420,
             SDL_MapRGB(screen->format, 255,0,0));
  Draw_Pixel(screen, 530,430,
             SDL_MapRGB(screen->format, 0,255,0));
  Draw_Pixel(screen, 540,440,
             SDL_MapRGB(screen->format, 0,0,255));


  Draw_Ellipse(screen, 100,300, 60,30, c_white);
  
  Draw_FillEllipse(screen, 300,300, 30,60,
               SDL_MapRGB(screen->format, 64,64,200));
  Draw_Ellipse(screen, 300,300, 30,60,
               SDL_MapRGB(screen->format, 255,0,0));

  Draw_Round(screen, 200,20, 70,50, 10, c_white);
  Draw_Round(screen, 300,20, 70,50, 20,
             SDL_MapRGB(screen->format, 255,0,0));
  Draw_FillRound(screen, 390,20, 70,50, 20,
                 SDL_MapRGB(screen->format, 255,0,0));
  Draw_Round(screen, 390,20, 70,50, 20, c_cyan);

  /*Draw_Round(screen, 500,400, 5,3, 4, c_cyan);*/

  Draw_Rect(screen, 499,199, 52,72,
            SDL_MapRGB(screen->format, 255,255,0));
  //Draw_FillRect(screen, 500,200, 50,70,
  //              SDL_MapRGB(screen->format, 64,200,64));

  Draw_FillCircle(screen, 500,330, 30, c_cyan);

  SDL_UpdateRect(screen, 0, 0, 0, 0);



    ++frames;
    while ( SDL_PollEvent(&event) ) {
      switch (event.type) {
        case SDL_KEYDOWN:
        /*break;*/
        case SDL_QUIT:
          done = 1;
        break;
        default:
        break;
      }
    }/*while*/
  }/*while(!done)*/

}/*END*/

  now = SDL_GetTicks();
  if ( now > then ) {
    printf("%2.2f frames per second\n",
          ((double)frames*1000)/(now-then));
  }

  fprintf(stderr, "[END]\n");
  return 0;

}/*main*/
Пример #9
0
void main()
{
  unsigned char i;
  Init_CLK();
  LCD_Init();   //TFT³õʼ»¯
  LCD_Clear(BLACK); //ÇåÆÁ
 /* LCD_Clear(RED);
  delay_s(1);
  LCD_Clear(GREEN);
  delay_s(2);
  LCD_Clear(BLUE);
  delay_s(2);
 
  
  //showimage(); */
  POINT_COLOR=GREEN;
  LCD_DrawRectangle(0,0, 479, 271);
  POINT_COLOR=BLUE;
  LCD_DrawRectangle(5,5, 474, 266);
   POINT_COLOR=RED;
  Draw_Circle(100,100,100);
  LCD_DrawPicture(0,0,160,160, gImage_fg);
  while(1)
  {
    POINT_COLOR=RED;
     for(i=100;i>0;i--)
  {
    Draw_Circle(100,100,i);
    Draw_Circle(100,200,i);
    Draw_Circle(200,200,i);
    Draw_Circle(300,100,i);
    Draw_Circle(300,200,i);
    delay_ms(50);
  }
  POINT_COLOR=BLACK;
       for(i=0;i<101;i++)
  {
    Draw_Circle(100,100,i);
    Draw_Circle(100,200,i);
    Draw_Circle(200,200,i);
    Draw_Circle(300,100,i);
    Draw_Circle(300,200,i);
    delay_ms(50);
  }
  }
}
Пример #10
0
void Lcd_Init(void)
{

//调用一次这些函数,免得编译的时候提示警告
    LCD_CS =1;
    if(LCD_CS==0)
    {
        LCD_WR_REG_DATA(0,0);
        LCD_ShowString(0,0," ");
        LCD_ShowNum(0,0,0,0);
        LCD_Show2Num(0,0,0,0);
        LCD_DrawPoint_big(0,0);
        LCD_DrawRectangle(0,0,0,0);
        Draw_Circle(0,0,0);
    }
    LCD_REST=0;
    delayms(20);
    LCD_REST=1;
    delayms(20);
    LCD_CS =0;  //打开片选使能

    LCD_WR_REG(0xCB);
    LCD_WR_DATA8(0x39);
    LCD_WR_DATA8(0x2C);
    LCD_WR_DATA8(0x00);
    LCD_WR_DATA8(0x34);
    LCD_WR_DATA8(0x02);

    LCD_WR_REG(0xCF);
    LCD_WR_DATA8(0x00);
    LCD_WR_DATA8(0XC1);
    LCD_WR_DATA8(0X30);

    LCD_WR_REG(0xE8);
    LCD_WR_DATA8(0x85);
    LCD_WR_DATA8(0x00);
    LCD_WR_DATA8(0x78);

    LCD_WR_REG(0xEA);
    LCD_WR_DATA8(0x00);
    LCD_WR_DATA8(0x00);

    LCD_WR_REG(0xED);
    LCD_WR_DATA8(0x64);
    LCD_WR_DATA8(0x03);
    LCD_WR_DATA8(0X12);
    LCD_WR_DATA8(0X81);

    LCD_WR_REG(0xF7);
    LCD_WR_DATA8(0x20);

    LCD_WR_REG(0xC0);    //Power control
    LCD_WR_DATA8(0x23);   //VRH[5:0]

    LCD_WR_REG(0xC1);    //Power control
    LCD_WR_DATA8(0x10);   //SAP[2:0];BT[3:0]

    LCD_WR_REG(0xC5);    //VCM control
    LCD_WR_DATA8(0x3e); //对比度调节
    LCD_WR_DATA8(0x28);

    LCD_WR_REG(0xC7);    //VCM control2
    LCD_WR_DATA8(0x86);  //--

    LCD_WR_REG(0x36);    // Memory Access Control
    LCD_WR_DATA8(0x48); //	   //48 68竖屏//28 E8 横屏

    LCD_WR_REG(0x3A);
    LCD_WR_DATA8(0x55);

    LCD_WR_REG(0xB1);
    LCD_WR_DATA8(0x00);
    LCD_WR_DATA8(0x18);

    LCD_WR_REG(0xB6);    // Display Function Control
    LCD_WR_DATA8(0x08);
    LCD_WR_DATA8(0x82);
    LCD_WR_DATA8(0x27);

    LCD_WR_REG(0xF2);    // 3Gamma Function Disable
    LCD_WR_DATA8(0x00);

    LCD_WR_REG(0x26);    //Gamma curve selected
    LCD_WR_DATA8(0x01);

    LCD_WR_REG(0xE0);    //Set Gamma
    LCD_WR_DATA8(0x0F);
    LCD_WR_DATA8(0x31);
    LCD_WR_DATA8(0x2B);
    LCD_WR_DATA8(0x0C);
    LCD_WR_DATA8(0x0E);
    LCD_WR_DATA8(0x08);
    LCD_WR_DATA8(0x4E);
    LCD_WR_DATA8(0xF1);
    LCD_WR_DATA8(0x37);
    LCD_WR_DATA8(0x07);
    LCD_WR_DATA8(0x10);
    LCD_WR_DATA8(0x03);
    LCD_WR_DATA8(0x0E);
    LCD_WR_DATA8(0x09);
    LCD_WR_DATA8(0x00);

    LCD_WR_REG(0XE1);    //Set Gamma
    LCD_WR_DATA8(0x00);
    LCD_WR_DATA8(0x0E);
    LCD_WR_DATA8(0x14);
    LCD_WR_DATA8(0x03);
    LCD_WR_DATA8(0x11);
    LCD_WR_DATA8(0x07);
    LCD_WR_DATA8(0x31);
    LCD_WR_DATA8(0xC1);
    LCD_WR_DATA8(0x48);
    LCD_WR_DATA8(0x08);
    LCD_WR_DATA8(0x0F);
    LCD_WR_DATA8(0x0C);
    LCD_WR_DATA8(0x31);
    LCD_WR_DATA8(0x36);
    LCD_WR_DATA8(0x0F);

    LCD_WR_REG(0x2A);
    LCD_WR_DATA8(0x00);
    LCD_WR_DATA8(0x00);
    LCD_WR_DATA8(0x00);
    LCD_WR_DATA8(0xEF);

    LCD_WR_REG(0x2B);
    LCD_WR_DATA8(0x00);
    LCD_WR_DATA8(0x00);
    LCD_WR_DATA8(0x01);
    LCD_WR_DATA8(0x3F);
    LCD_WR_REG(0x11);    //Exit Sleep
    delayms(120);

    LCD_WR_REG(0x29);    //Display on
    LCD_WR_REG(0x2c);

}
Пример #11
0
void LCD_Init(void)
{
  P3OUT|=(BIT1+BIT2+BIT3+BIT6+BIT7);
  P4OUT=0xFF;
  P2OUT=0xFF;
  P1OUT|=BIT2;
  P3DIR|=(BIT1+BIT2+BIT3+BIT6+BIT7);
  P4DIR=0xFF;
  P2DIR=0xFF;
  P1DIR|=BIT2;
  P1OUT|=BIT2;
  
  SET_LCD_CS;
  if(GET_LCD_CS==0)
  {
      LCD_WR_REG_DATA(0,0);
      LCD_ShowString(0,0," ");
      LCD_ShowNum(0,0,0,0);
      LCD_Show2Num(0,0,0,0);
      LCD_DrawPoint_big(0,0);
      LCD_DrawRectangle(0,0,0,0);
      Draw_Circle(0,0,0);
  }

  SET_LCD_REST;
  delay_ms(5);	
  CLR_LCD_REST;
  delay_ms(5);
  SET_LCD_REST;
  SET_LCD_CS;
  SET_LCD_RD;
  SET_LCD_WR;
  delay_ms(5);
  CLR_LCD_CS ;  //打开片选使能

  LCD_WR_REG(0x00E2);	//PLL multiplier, set PLL clock to 120M
  LCD_WR_DATA(0x002d);	//N=0x36 for 6.5M, 0x23 for 10M crystal
  LCD_WR_DATA(0x0002);
  LCD_WR_DATA(0x0004);
  LCD_WR_REG(0x00E0);  // PLL enable
  LCD_WR_DATA(0x0001);
  delay_ms(1);
  LCD_WR_REG(0x00E0);
  LCD_WR_DATA(0x0003);
  delay_ms(5);
  LCD_WR_REG(0x0001);  // software reset
  delay_ms(5);
  LCD_WR_REG(0x00E6);	//PLL setting for PCLK, depends on resolution
  LCD_WR_DATA(0x0000);
  LCD_WR_DATA(0x00ff);
  LCD_WR_DATA(0x00be);

  LCD_WR_REG(0x00B0);	//LCD SPECIFICATION
  LCD_WR_DATA(0x0020);
  LCD_WR_DATA(0x0000);
  LCD_WR_DATA((HDP>>8)&0X00FF);  //Set HDP
  LCD_WR_DATA(HDP&0X00FF);
  LCD_WR_DATA((VDP>>8)&0X00FF);  //Set VDP
  LCD_WR_DATA(VDP&0X00FF);
  LCD_WR_DATA(0x0000);
  delay_ms(5);
  LCD_WR_REG(0x00B4);	//HSYNC
  LCD_WR_DATA((HT>>8)&0X00FF);  //Set HT
  LCD_WR_DATA(HT&0X00FF);
  LCD_WR_DATA((HPS>>8)&0X00FF);  //Set HPS
  LCD_WR_DATA(HPS&0X00FF);
  LCD_WR_DATA(HPW);			   //Set HPW
  LCD_WR_DATA((LPS>>8)&0X00FF);  //SetLPS
  LCD_WR_DATA(LPS&0X00FF);
  LCD_WR_DATA(0x0000);

  LCD_WR_REG(0x00B6);	//VSYNC
  LCD_WR_DATA((VT>>8)&0X00FF);   //Set VT
  LCD_WR_DATA(VT&0X00FF);
  LCD_WR_DATA((VPS>>8)&0X00FF);  //Set VPS
  LCD_WR_DATA(VPS&0X00FF);
  LCD_WR_DATA(VPW);			   //Set VPW
  LCD_WR_DATA((FPS>>8)&0X00FF);  //Set FPS
  LCD_WR_DATA(FPS&0X00FF);

  LCD_WR_REG(0x0036); //rotation
  LCD_WR_DATA(0x0000);
  LCD_WR_REG(0x00F0); //pixel data interface
  LCD_WR_DATA(0x0003);
  
  delay_ms(5);
  LCD_WR_REG(0x0029); //display on
  LCD_WR_REG(0x00BE); //set PWM for B/L
  LCD_WR_DATA(0x0006);
  LCD_WR_DATA(0x00f0);
  LCD_WR_DATA(0x0001);
  LCD_WR_DATA(0x00f0);
  LCD_WR_DATA(0x0000);
  LCD_WR_DATA(0x0000);

  LCD_WR_REG(0x00d0); 
  LCD_WR_DATA(0x000d);
  //----------LCD RESET---GPIO0-------------------//
  LCD_WR_REG(0x00B8);
  LCD_WR_DATA(0x0000);    //GPIO3=input, GPIO[2:0]=output
  LCD_WR_DATA(0x0001);    //GPIO0 normal
  LCD_WR_REG(0x00BA);
  LCD_WR_DATA(0x0000);  
}