Exemplo n.º 1
0
/*******************************************************************
*
*       _DemoAntialiasing

  Draws lines with different antialiasing factors
*/
static void _DemoAntialiasing(void) {
  int i, x1, x2, y1, y2;
  const GUI_FONT *font_old;
  y1 = 65;
  y2 = 5;
  /* Set drawing attributes */
  GUI_SetColor(GUI_WHITE);
  GUI_SetBkColor(GUI_BLACK);
  GUI_SetPenShape(GUI_PS_FLAT);
  GUI_Clear();
  /* draw headline */
  font_old = GUI_SetFont(&GUI_Font24_ASCII);
  GUI_SetTextAlign(GUI_TA_HCENTER);
  GUI_DispStringAt("AA_Lines - Sample", 160, 5);
  /* Draw lines without antialiased */
  GUI_Delay(1000);
  GUI_SetFont(&GUI_Font8x16);
  GUI_SetTextAlign(GUI_TA_LEFT);
  GUI_DispStringAtCEOL("draw normal lines using", 5, 40);
  GUI_DispStringAtCEOL("GUI_DrawLine", 5, 55);
  GUI_Delay(2500);
  x1 = 20;
  x2 = 100;
  GUI_SetFont(font_old);
  GUI_DispStringHCenterAt("Normal", (x1 + x2) / 2, 30 + y1);
  for (i = 1; i < 8; i++) {
    GUI_SetPenSize(i);
    GUI_DrawLine(x1, 40 + i * 15 + y1, x2, 40 + i * 15 + y1 + y2);
  }
  /* Draw lines with antialiasing quality factor 2 */
  GUI_Delay(3000);
  GUI_SetFont(&GUI_Font8x16);
  GUI_DispStringAtCEOL("", 5, 40);
  GUI_DispStringAtCEOL("", 5, 55);
  GUI_Delay(200);
  GUI_DispStringAtCEOL("draw antialiased lines using", 5, 40);
  GUI_DispStringAtCEOL("GUI_AA_DrawLine", 5, 55);
  GUI_Delay(3500);
  x1 = 120;
  x2 = 200;
  GUI_AA_SetFactor(2);
  GUI_SetFont(font_old);
  GUI_DispStringHCenterAt("Antialiased\nusing factor 2", (x1 + x2) / 2, 30 + y1);
  for (i = 1; i < 8; i++) {
    GUI_SetPenSize(i);
    GUI_AA_DrawLine(x1, 40 + i * 15 + y1, x2, 40 + i * 15 + y1 + y2);
  }
  /* Draw lines with antialiasing quality factor 6 */
  GUI_Delay(1500);
  x1 = 220;
  x2 = 300;
  GUI_AA_SetFactor(6);
  GUI_SetFont(font_old);
  GUI_DispStringHCenterAt("Antialiased\nusing factor 6", (x1 + x2) / 2, 30 + y1);
  for (i = 1; i < 8; i++) {
    GUI_SetPenSize(i);
    GUI_AA_DrawLine(x1, 40 + i * 15 + y1, x2, 40 + i * 15 + y1 + y2);
  }
  GUI_Delay(7500);
}
/*******************************************************************
*
*       _DrawEye
*/
static void _DrawEye(int xPos0, int yPos0, int xPos1, int yPos1, int rx, int ry) {
  int Hyp;
  int dx;
  int dy;
  int x;
  int y;

  GUI_SetColor(GUI_WHITE);
  GUI_FillEllipse(xPos0, yPos0, rx, ry);
  GUI_SetColor(GUI_BLACK);
  GUI_DrawEllipse(xPos0, yPos0, rx, ry);
  //
  // Calculate the coordinates
  //
  dx  = xPos1 - xPos0 + 1;
  dy  = yPos1 - yPos0 + 1;
  Hyp = GUI__sqrt32(dx * dx + dy * dy);
  x   = (dx * _Min(rx - 5, abs(dx)) * FACTOR / Hyp) + xPos0 * FACTOR;
  y   = (dy * _Min(ry - 5, abs(dy)) * FACTOR / Hyp) + yPos0 * FACTOR;
  //
  // Draw the pupil
  //
  GUI_AA_SetFactor(FACTOR);
  GUI_AA_EnableHiRes();
  GUI_SetColor(0xD00000);
  GUI_AA_FillCircle(x, y, (int)(5.75 * FACTOR));
  GUI_SetColor(GUI_BLACK);
  GUI_AA_FillCircle(x, y, (int)(3.75 * FACTOR));
  GUI_SetColor(GUI_GRAY);
  GUI_AA_FillCircle(x - (int)(1.25 * FACTOR), y - (int)(1.25 * FACTOR), (int)(1.25 * FACTOR));
  GUI_AA_DisableHiRes();
}
Exemplo n.º 3
0
/*******************************************************************
*
*       MainTask
*
********************************************************************
*/
void MainTask_AppClock(void)
{
	WM_HWIN hWinClock;
	GUI_AUTODEV AutoDev;
	PARAM       Param;

	int hour = 0;
	time_t oldtimestamp = 0;
	time_t curtimestamp = 0;
	struct tm *currUtime;

	//Init time
	curtimestamp = time(0);
	oldtimestamp = curtimestamp;
	currUtime=localtime(&curtimestamp);

	hWinClock = WM_CreateWindowAsChild(0, 0, 320, 240, WM_HBKWIN, WM_CF_SHOW, _cbClock, 0);
	WM_SelectWindow(hWinClock);
	WM_SetCreateFlags(WM_CF_MEMDEV);
	WM_SetFocus(hWinClock);
	_MoveShiftWindow(&hWinClock, MEMDEV_ANIMATION_LEFT, WM_Shift_ToLCD, 0);

	/*hWinClock = WM_CreateWindow(0, 0, 320, 240, WM_CF_SHOW, _cbClock, 0);
	WM_SetFocus(hWinClock);
	//_MoveShiftWindow(&hWinCalendar, MEMDEV_ANIMATION_LEFT, WM_Shift_ToLCD, 0);
	WM_EnableMemdev(hWinClock);*/

	/*	GUI_SetBkColor(GUI_WHITE);
	GUI_Clear();
	GUI_SetColor(GUI_BLACK);*/

	GUI_AA_EnableHiRes();
	GUI_AA_SetFactor(MAG);
	GUI_MEMDEV_CreateAuto(&AutoDev);

	while (!GUI_CheckCancel(APP_Clock))
	{
		GUI_Delay(10);
		curtimestamp = time(0);
		currUtime = localtime(&curtimestamp);
		if (1 == curtimestamp - oldtimestamp)
		{
			Param.Angle1 = (59 - currUtime->tm_sec) * 6 * (3.1415926f / 180);
			Param.Angle2 = (3599 - ((currUtime->tm_min * 60) + (currUtime->tm_sec)))*0.1*(3.1415926f / 180);
			hour = (currUtime->tm_hour>12) ? (currUtime->tm_hour - 12) : (currUtime->tm_hour);
			Param.Angle3 = (43199 - ((hour * 3600) + (currUtime->tm_min * 60) + (currUtime->tm_sec)))*0.0083333*(3.1415926f / 180);
			GUI_RotatePolygon(Param.aPoint1, _aNeedle[0], GUI_COUNTOF(_aNeedle[0]), Param.Angle1);
			GUI_RotatePolygon(Param.aPoint2, _aNeedle[1], GUI_COUNTOF(_aNeedle[1]), Param.Angle2);
			GUI_RotatePolygon(Param.aPoint3, _aNeedle[2], GUI_COUNTOF(_aNeedle[2]), Param.Angle3);
			GUI_MEMDEV_DrawAuto(&AutoDev, &Param.AutoDevInfo, &Draw, &Param);
		}
		oldtimestamp = curtimestamp;
	}
	WM_DeleteWindow(hWinClock);
	hWinClock = 0;
}
Exemplo n.º 4
0
/*********************************************************************
*
*       GUIDEMO_Intro
*
**********************************************************************
*/
void GUIDEMO_Intro(void) {
  char acVersion[30] = "Version of emWin: ";
  int  xCenter, xSize, ySize;

  xSize   = LCD_GetXSize();
  ySize   = LCD_GetYSize();
  xCenter = xSize >> 1;

  GUIDEMO_DrawBk(0);
	GUI_AA_SetFactor(3);
	GUI_AA_DrawArc(60*3,60*3,50*3,50*3,0,180);
  GUI_SetTextMode(GUI_TM_TRANS);
  //
  // emWin
  //
  GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_FontRounded22);
  GUI_DispStringHCenterAt("emWin", xCenter, (FACTOR_EMWIN * ySize) >> SCREEN_DIV);
  //
  // emWin description
  //
  GUI_SetFont(&GUI_FontSouvenir18);
  GUI_DispStringHCenterAt("Universal graphic software\nfor embedded applications", xCenter, (FACTOR_DESC * ySize) >> SCREEN_DIV);
  //
  // Any text
  //
  GUI_SetColor(0x2288ff);
  GUI_DispStringHCenterAt("Any CPU - Any Display - Any Application", xCenter, (FACTOR_ANY_COMP * ySize) >> SCREEN_DIV);
  //
  // Compiled
  //
  GUI_SetFont(&GUI_Font10S_ASCII);
  GUI_DispStringHCenterAt("Compiled " __DATE__ " "__TIME__,          xCenter, ((FACTOR_ANY_COMP * ySize) >> SCREEN_DIV) + DIST_ANY_COMP);
  //
  // Version
  //
  GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_FontSouvenir18);
  strcat(acVersion, GUI_GetVersionString());
  GUI_DispStringHCenterAt(acVersion, xCenter,  (FACTOR_VERSION * ySize) >> SCREEN_DIV);
  //
  // Logo
  //
  GUI_DrawBitmap(&bmSeggerLogo, (xSize - bmSeggerLogo.XSize) >> 1, (FACTOR_LOGO * ySize) >> SCREEN_DIV);
  //
  // www.segger.com
  //
  GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_FontRounded22);
  GUI_DispStringHCenterAt("www.segger.com", xCenter, (FACTOR_WWW * ySize) >> SCREEN_DIV);
  GUIDEMO_Delay(5000);
}
Exemplo n.º 5
0
/*******************************************************************
*
*       _ShowHiresAntialiasing
*
* Function description
*   This function creates the memory auto devices and handle the
*   rotation of the pointers
*/
static void _ShowHiresAntialiasing(void) {
  GUI_AUTODEV aAuto[2];
  PARAM       Param;
  unsigned         i;

  Param.Factor = 3;
  GUI_SetBkColor(GUI_BLACK);
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);
  GUI_SetTextAlign(GUI_TA_HCENTER);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_DispStringAt("AA_HiResAntialiasing - Sample", 160, 5);
  GUI_SetFont(&GUI_Font6x8);
  GUI_DispStringHCenterAt("Using\nhigh\nresolution\nmode", 110, 180);
  GUI_DispStringHCenterAt("Not using\nhigh\nresolution\nmode", 210, 180);
  //
  // Create GUI_AUTODEV objects
  //
  for (i = 0; i < countof(aAuto); i++) {
    GUI_MEMDEV_CreateAuto(&aAuto[i]);
  }
  //
  // Calculate pointer for high resolution
  //
  for (i = 0; i < countof(_aPointer); i++) {
    _aPointerHiRes[i].x = _aPointer[i].x * Param.Factor;
    _aPointerHiRes[i].y = _aPointer[i].y * Param.Factor;
  }
  GUI_AA_SetFactor(Param.Factor); /* Set antialiasing factor */
  while (1) {
    for (i = 0; i < 1800; i++) {
      float Angle = (i >= 900) ? 1800 - i : i;
      Angle *= 3.1415926f / 1800;
      //
      // Draw pointer with high resolution
      //
      GUI_AA_EnableHiRes();
      GUI_RotatePolygon(Param.aPoints, _aPointerHiRes, countof(_aPointer), Angle);
      GUI_MEMDEV_DrawAuto(&aAuto[0], &Param.AutoInfo, _DrawHiRes, &Param);
      //
      // Draw pointer without high resolution
      //
      GUI_AA_DisableHiRes();
      GUI_RotatePolygon(Param.aPoints, _aPointer, countof(_aPointer), Angle);
      GUI_MEMDEV_DrawAuto(&aAuto[1], &Param.AutoInfo, _Draw, &Param);
      GUI_Delay(2);
    }
  }
}
Exemplo n.º 6
0
/*********************************************************************
*
*       _DrawAlphaCircles
*/
static void _DrawAlphaCircles(int mx, int my, int r, int a, int FactorAA) {
  int Index;
  int x;
  int y;
  I32 SinHQ;
  I32 CosHQ;
  U32 a1000;
  U32 i;
  const GUI_COLOR aColor[] = {
    0xC00FFF38,
    0xC000FF8E,
    0xC000FCEA,
    0xC000B4FF,
    0xC0004EFF,
    0xC01304FF,
    0xC06E00FF,
    0xC0D200FF,
    0xC0FF00D2,
    0xC0FF006E,
    0xC0FF0413,
    0xC0FF4E00,
    0xC0FFB400,
    0xC0EAFC00,
    0xC08EFF00,
    0xC038FF0F
  };

  mx    *= FactorAA;
  my    *= FactorAA;
  r     *= FactorAA;
  a1000  = a * -1000;
  GUI_AA_EnableHiRes();
  GUI_AA_SetFactor(FactorAA);
  for (i = 0, Index = 0; i < 360000; i += 22500, Index++) {
    SinHQ = GUI__SinHQ(i + a1000);
    CosHQ = GUI__CosHQ(i + a1000);
    x     = SHIFT_RIGHT_16(r * CosHQ);
    y     = SHIFT_RIGHT_16(r * SinHQ);
    GUI_SetColor(aColor[Index % (int)GUI_COUNTOF(aColor)]);
    GUI_AA_FillCircle(mx + x, my + y, r);
  }
  GUI_AA_DisableHiRes();
}
/*******************************************************************
*
*       _ShowHiResPixels

  This is frame-function for the callback. It creates the window
  and handles the rotation of polygons and colors.
*/
static void _ShowHiResPixels(void) {
    WM_HWIN hWindow;
    const GUI_FONT *font_old;
    float pi, step, angle;
    int i, tm;
    pi = 3.1415926f;
    step = pi / 180;
    GUI_SetBkColor(GUI_BLACK);
    GUI_Clear();
    GUI_SetColor(GUI_WHITE);
    GUI_SetTextAlign(GUI_TA_HCENTER);
    font_old = GUI_SetFont(&GUI_Font24_ASCII);
    GUI_DispStringAt("AA_HiResPixels - Sample", 160, 5);
    GUI_SetFont(font_old);
    GUI_SetColor(GUI_RED);
    GUI_DispStringHCenterAt("not\nantialised", 65, 100);
    GUI_SetColor(GUI_GREEN);
    GUI_DispStringHCenterAt("antialised", 160, 100);
    GUI_SetColor(GUI_BLUE);
    GUI_DispStringHCenterAt("antialised\nwith high\nresolution", 255, 100);
    hWindow = WM_CreateWindow(35, 140, 250, 60, WM_CF_SHOW | WM_CF_MEMDEV, &_cbWindow, 0);
    WM_SelectWindow(hWindow);
    GUI_AA_SetFactor(AA_FACTOR);
    while (1) {
        for (i=0, angle=0; i<360; i++) {
            tm = GUI_GetTime();
            angle += step;
            GUI_RotatePolygon(_aPolygonHiRes, _aPolygonHiRes_src, POLY_POINTS, angle);
            GUI_RotatePolygon(_aPolygon, _aPolygon_src, POLY_POINTS, angle);
            _CalcColor();
            WM_InvalidateWindow(hWindow);
            while (((GUI_GetTime()-tm) < 50) || (WM_Exec1() != 0));
        }
    }
    WM_DeleteWindow(hWindow);
}