Esempio n. 1
0
/*********************************************************************
*
*       GUIDEMO_UpdateControlText
*/
void GUIDEMO_UpdateControlText(void) {
  TEXT_Handle hText;
  char        acText[20] = { 0 };

  hText = WM_GetDialogItem(_hDialogControl, GUI_ID_TEXT0);
  GUIDEMO_AddStringToString(acText, "Demo ");
  GUIDEMO_AddIntToString   (acText, _iDemo + 1);
  GUIDEMO_AddStringToString(acText, ".");
  GUIDEMO_AddIntToString   (acText, _iDemoMinor);
  GUIDEMO_AddStringToString(acText, "/");
  GUIDEMO_AddIntToString   (acText, _GUIDemoConfig.NumDemos - 1);
  TEXT_SetText             (hText,  acText);
}
Esempio n. 2
0
/*********************************************************************
*
*       GUIDEMO_Speed
*/
void GUIDEMO_Speed(void) {
  GUI_RECT ClipRect;
  GUI_RECT Rect;
  unsigned aColorIndex[8];
  char     cText[40] = { 0 };
  U32      PixelsPerSecond;
  int      TimeStart;
  int      vySize;
  int      xSize;
  int      ySize;
  int      i;

  xSize  = LCD_GetXSize();
  ySize  = LCD_GetYSize();
  vySize = LCD_GetVYSize();
  if (vySize > ySize) {
    ClipRect.x0 = 0;
    ClipRect.y0 = 0;
    ClipRect.x1 = xSize;
    ClipRect.y1 = ySize;
    GUI_SetClipRect(&ClipRect);
  }
  GUIDEMO_ShowIntro("High speed", "Multi layer clipping\nHighly optimized drivers");
  GUIDEMO_HideControlWin();
  for (i = 0; i< 8; i++) {
    aColorIndex[i] = GUI_Color2Index(_aColor[i]);
  }
  TimeStart = GUIDEMO_GetTime();
  for (i = 0; ((GUIDEMO_GetTime() - TimeStart) < 5000) && (GUIDEMO_CheckCancel() == 0); i++) {
    GUI_SetColorIndex(aColorIndex[i&7]);
    //
    // Calculate random positions
    //
    Rect.x0 = rand() % xSize - xSize / 2;
    Rect.y0 = rand() % ySize - ySize / 2;
    Rect.x1 = Rect.x0 + 20 + rand() % xSize;
    Rect.y1 = Rect.y0 + 20 + rand() % ySize;
    GUI_FillRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1);
    //
    // Clip rectangle to visible area and add the number of pixels (for speed computation)
    //
    if (Rect.x1 >= xSize) {
      Rect.x1 = xSize - 1;
    }
    if (Rect.y1 >= ySize) {
      Rect.y1 = ySize - 1;
    }
    if (Rect.x0 < 0 ) {
      Rect.x0 = 0;
    }
    if (Rect.y1 < 0) {
      Rect.y1 = 0;
    }
    GUI_Exec();
    //
    // Allow short breaks so we do not use all available CPU time ...
    //
  }
  GUIDEMO_NotifyStartNext();
  PixelsPerSecond = _GetPixelsPerSecond();
  GUI_SetClipRect(NULL);
  GUIDEMO_DrawBk();
  GUI_SetColor(GUI_WHITE);
  GUI_SetTextMode(GUI_TM_TRANS);
  GUI_SetFont(&GUI_FontRounded22);
  GUI_DrawBitmap(&bmSeggerLogo70x35, 5, 5);
  GUIDEMO_AddStringToString(cText, "Pixels/sec: ");
  GUIDEMO_AddIntToString(cText, PixelsPerSecond);
  GUI_DispStringHCenterAt(cText, xSize / 2, (ySize - GUI_GetFontSizeY()) / 2);
  GUIDEMO_Delay(4000);
}
void GUIDEMO_ColorBar(void) {
  GUI_COLOR ColorStartBlack, ColorStartWhite;
  char      acText[80] = { 0 };
  int       NumColors, BitsPerPixel, xSize, ySize;
  int       Time, TimeStart;
  int       Dir, Index;

  xSize = LCD_GetXSize();
  ySize = LCD_GetYSize();
  GUIDEMO_ShowIntro("Color bar",
                    "STemWin features an integrated\n"
                    "color management which automatically finds\n"
                    "the best available color for any logical color");
  GUIDEMO_DrawBk(1);
  //
  // Heading
  //
	GUI_SetColor(GUI_WHITE);
	GUI_SetFont(&GUI_FontRounded22);
	GUI_DispStringHCenterAt("Color bars", xSize >> 1, 12);
  GUI_SetFont(&GUI_Font16_ASCII);
  //
  // Colors
  //
  GUI_DispStringAt("Red",     1, Y_START);
  GUI_DispStringAt("Green",   1, Y_START + Y_STEP *  2);
  GUI_DispStringAt("Blue",    1, Y_START + Y_STEP *  4);
  GUI_DispStringAt("Grey",    1, Y_START + Y_STEP *  5 + (Y_STEP >> 1));
  GUI_DispStringAt("Yellow",  1, Y_START + Y_STEP *  7);
  GUI_DispStringAt("Cyan",    1, Y_START + Y_STEP *  9);
  GUI_DispStringAt("Magenta", 1, Y_START + Y_STEP * 11);
  //
  // Additional Information
  //
  GUI_SetFont(&GUI_Font8_ASCII);
  //
  // LCD Controller
  //
  #ifdef LCD_CONTROLLER
    GUIDEMO_AddStringToString(acText, "LCD Controller: ");
    GUIDEMO_AddStringToString(acText, LCD_CONTROLLER);
    GUI_DispStringAt         (acText, 12, ySize - 45);
    GUIDEMO_ClearText        (acText);
  #endif
  //
  // BPP and number of colors
  //
  BitsPerPixel = LCD_GetBitsPerPixel();
  GUIDEMO_AddIntToString   (acText, BitsPerPixel);
  GUIDEMO_AddStringToString(acText, " bpp");
  NumColors = LCD_GetDevCap(LCD_DEVCAP_NUMCOLORS);
  if (NumColors) {
    GUIDEMO_AddStringToString(acText, ", ");
    GUIDEMO_AddIntToString   (acText, NumColors);
    GUIDEMO_AddStringToString(acText, " colors");
  }
  GUI_DispStringAt(acText, 12, ySize - 25);
  //
  // Gradients
  //
  TimeStart = GUIDEMO_GetTime();
  while (((GUIDEMO_GetTime() - TimeStart) < TIME_RUN) && (GUIDEMO_CheckCancel() == 0)) {
    Time  = (GUIDEMO_GetTime() - TimeStart) % ((TIME_PAUSE + TIME_STEP) << 1);
    Dir   = Time / (TIME_PAUSE + TIME_STEP);
    Time -= Dir * (TIME_PAUSE + TIME_STEP);
    if (Time > TIME_PAUSE) {
      continue;
    }
    Index = ((Time * 0xFF) / TIME_STEP) ^ (Dir * 0xFF);
    ColorStartBlack = 0x000000 + 0x010101 * Index;
    ColorStartWhite = 0xFFFFFF - ColorStartBlack;
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  0, xSize, (Y_START + Y_STEP *  1) - 1, GUI_RED,     ColorStartBlack);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  1, xSize, (Y_START + Y_STEP *  2) - 1, GUI_RED,     ColorStartWhite);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  2, xSize, (Y_START + Y_STEP *  3) - 1, GUI_GREEN,   ColorStartBlack);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  3, xSize, (Y_START + Y_STEP *  4) - 1, GUI_GREEN,   ColorStartWhite);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  4, xSize, (Y_START + Y_STEP *  5) - 1, GUI_BLUE,    ColorStartBlack);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  5, xSize, (Y_START + Y_STEP *  6) - 1, GUI_BLUE,    ColorStartWhite);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  6, xSize, (Y_START + Y_STEP *  7) - 1, GUI_GRAY,    ColorStartBlack);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  7, xSize, (Y_START + Y_STEP *  8) - 1, GUI_YELLOW,  ColorStartWhite);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  8, xSize, (Y_START + Y_STEP *  9) - 1, GUI_YELLOW,  ColorStartBlack);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  9, xSize, (Y_START + Y_STEP * 10) - 1, GUI_CYAN,    ColorStartWhite);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP * 10, xSize, (Y_START + Y_STEP * 11) - 1, GUI_CYAN,    ColorStartBlack);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP * 11, xSize, (Y_START + Y_STEP * 12) - 1, GUI_MAGENTA, ColorStartWhite);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP * 12, xSize, (Y_START + Y_STEP * 13) - 1, GUI_MAGENTA, ColorStartBlack);
    GUI_Exec();
  }
}