/*********************************************************************
*
*       _Loop
*/
static int _Loop(int y, int d, int n, int Delay) {
  do {
    y += d;
    GUI_SetOrg(0, y);
    GUI_Delay(Delay);
    if (GUIDEMO_CheckCancel()) {
      return 1;
    }
  } while (--n);
  return 0;
}
Example #2
0
void GUIDEMO_Speed(void) {
  int t = GUI_GetTime();
  int i = 0;
  int XSize = LCD_GET_XSIZE();
  int YSize = LCD_GET_YSIZE();
  I32 NumPixels=0;
  U16 aColorIndex[8];
  GUIDEMO_ShowIntro("High speed",
                    "Multi layer clipping"
                    "\nHighly optimized drivers"
                    );
  for (i = 0; i< 8; i++) {
    aColorIndex[i] = GUI_Color2Index(_aColor[i]);
  }  
  for (i = 0; (((t + 8000) - (int)GUI_GetTime()) > 0) && !GUIDEMO_CheckCancel(); i++) {
    GUI_RECT r;
    GUI_SetColorIndex(aColorIndex[i&7]);
    /* Calculate random positions */
    r.x0 = rand() % XSize - XSize / 2;
    r.y0 = rand() % YSize - YSize / 2;
    r.x1 = r.x0 + rand() % XSize;
    r.y1 = r.y0 + rand() % YSize;
    GUI_FillRect(r.x0, r.y0, r.x1, r.y1);
    /* Clip rectangle to visible area and add the number of pixels (for speed computation) */
    if (r.x1 >= XSize)
      r.x1 = XSize - 1;
    if (r.y1 >= YSize)
      r.y1 = YSize - 1;
    if (r.x0 < 0 )
      r.x0 = 0;
    if (r.y1 < 0)
      r.y1 = 0;
    NumPixels += (r.x1 - r.x0) * (r.y1 - r.y0);
    /* Allow short breaks so we do not use all available CPU time ... */
  }
  t = (GUI_GetTime() - t) / 100;
  GUI_Clear();
  GUIDEMO_NotifyStartNext();
  #if GUIDEMO_LARGE
    GUI_SetFont(&GUI_FontComic24B_ASCII);
  #else
    GUI_SetFont(&GUI_Font16B_ASCII);
  #endif
  GUI_SetColor(GUI_WHITE);
  GUI_DispStringAt("Pixels/sec: ", 10, (LCD_GetYSize() - GUI_GetFontSizeY()) / 2);
  if (t == 0)
    t++;
  GUI_DispDecMin(10 * (NumPixels / t));
  GUIDEMO_Wait();
}
Example #3
0
/*********************************************************************
*
*       _ShowGraph
*/
static void _ShowGraph(GRAPH_Handle hGraph, GRAPH_DATA_Handle hData[], int DataCount, void (* pfAddData)(GRAPH_DATA_Handle hData, int DataID)) {
  int Data_xSize;
  int NextState;
  int TimeStart;
  int TimeDiff;
  int TimeStep;
  int Count;
  int xSize;
  int i;

  xSize      = LCD_GetXSize();
  Data_xSize = xSize - (DIST_TO_BORDER << 1) - (BORDER_LEFT + BORDER_RIGHT);
  Count      = 0;
  //
  // Attach data objects
  //
  for (i = 0; i < DataCount; i++) {
    GRAPH_AttachData(hGraph, hData[i]);
  }
  //
  // Add values before GRAPH is displayed
  //
  while (Count < Data_xSize) {
    for (i = 0; i < DataCount; i++) {
      pfAddData(hData[i], i);
    }
    Count++;
  }
  //
  // Add values depending on time
  //

  TimeStart = GUIDEMO_GetTime();
  do {
    TimeDiff = GUIDEMO_GetTime() - TimeStart;
    for (i = 0; i < DataCount; i++) {
      pfAddData(hData[i], i);
    }
    NextState = GUIDEMO_CheckCancel();
    TimeStep  = GUIDEMO_GetTime() - TimeStart;
    if ((TimeStep - TimeDiff) < TIME_STEP) {
      GUI_Delay(TIME_STEP - (TimeStep - TimeDiff));
    }
  } while ((TimeDiff < TIME_RUN) && (NextState == 0));
  for (i = 0; i < DataCount; i++) {
    GRAPH_DetachData(hGraph, hData[i]);
  }
  GUIDEMO_NotifyStartNext();
}
Example #4
0
static void _DemoOrData(void) {
  int i;
  PARAM Param;
  GUI_RECT Rect = {19, (LCD_YSIZE - 20) - YSIZE, (LCD_XSIZE - 2), (LCD_YSIZE - 21)};
  GUI_HMEM hMem = GUI_ALLOC_AllocZero((LCD_XSIZE + 90) * sizeof(I16));
  _ShowText("Several waves...");
  Param.aY = (I16*)GUI_ALLOC_h2p(hMem);
  _GetSineData(Param.aY, LCD_XSIZE + 90);
  GUI_MEMDEV_Draw(&Rect, _Draw, &Param, 0, GUI_MEMDEV_NOTRANS);
  for (i = 0; (i < 90) && !GUIDEMO_CheckCancel(); i++) {
    _DrawOrData(GUI_GREEN, ++Param.aY);
    GUI_Delay(10);
  }
  GUI_ALLOC_Free(hMem);
}
Example #5
0
static void _DemoSineWave(void) {
  PARAM Param;
  I16 * pStart;
  int t0, Cnt = 0;
  GUI_HMEM hMem;
  GUI_RECT Rect;
  Rect.x0 = 19;
  Rect.y0 = (LCD_YSIZE - 20) - _YSize;
  Rect.x1 = LCD_XSIZE - 2;
  Rect.y1 = LCD_YSIZE - 21;
  hMem = GUI_ALLOC_AllocZero((LCD_XSIZE + 90) * sizeof(I16));
  _ShowText("Sine wave");
  GUI_LOCK();
  pStart = (I16*)GUI_ALLOC_h2p(hMem);
  GUI_UNLOCK();    /* Note: unlocking is permitted only if no further allocation is done so hMem stays valid */
  _GetSineData(pStart, LCD_XSIZE + 90);
  /*
  GUI_SetFont(&GUI_Font6x8);
  GUI_DispStringAt("msec/graph:", 10, 50);
  */
  _LabelMS();
  t0 = GUI_GetTime();
  while(((GUI_GetTime() - t0) < 10000) && !GUIDEMO_CheckCancel()) {
    U32 t1, tDiff2;
    if (Cnt % 90) {
      Param.aY++;
    } else {
      Param.aY = pStart;
    }
    t1 = GUI_GetTime();
    GUI_MEMDEV_Draw(&Rect, _Draw2, &Param, 0, GUI_MEMDEV_NOTRANS);
    tDiff2 = GUI_GetTime() - t1;
    if (tDiff2 < 100) {
      GUI_Delay(100 - tDiff2);
    }
    if(!((++Cnt) % 10)) {
      _DisplayTime(tDiff2);
      /*
      GUI_GotoXY(80, 50);
      GUI_SetColor(GUI_WHITE);
      GUI_SetBkColor(GUI_RED);
      GUI_DispDecSpace(tDiff2, 3);
      */
    }
  }
  GUI_ALLOC_Free(hMem);
}
Example #6
0
static void _MoveCursor(const GUI_CURSOR* Cursor){
  int x, y;
  int xMax, yMax;
  xMax = LCD_GetXSize()/2;
  yMax = LCD_GetYSize()/2;
  GUI_CURSOR_Select(Cursor);  
  for(x = y = 0; ((x != xMax)  && (y != yMax)  && !GUIDEMO_CheckCancel()); x += 4, y += 4) {
    if ( x == xMax) {
      x = xMax;
    }
    if ( y == yMax) {
      y = yMax;
    }
    GUI_CURSOR_SetPosition(x,y);
    GUIDEMO_Delay(75);
  }
}
Example #7
0
void GUIDEMO_Cursor(void) {
  int i = 0;
  GUIDEMO_ShowIntro("Cursor",
                    "\nuC/GUI supports"
                    "\nsoftware cursor");
  GUI_SetBkColor(GUI_BLUE);
  GUI_Clear();
  _DispCursor();
  GUIDEMO_Delay(2000);
  GUIDEMO_NotifyStartNext();
  GUI_CURSOR_Show(); 
  for ( i = 0;(i < countof(_aCursor) && !GUIDEMO_CheckCancel()); i++) {
      _MoveCursor(_aCursor[i]);
  }
  GUI_CURSOR_SetPosition(0,0);
  GUI_CURSOR_Select(&GUI_CursorArrowM);  
}
int GUIDEMO_WaitKey(void) {
  int r = 0;
  int tMax = GUI_GetTime() + 4000;
  int tDiff; 
  #if GUI_WINSUPPORT
    PROGBAR_Handle hProg = PROGBAR_Create(LCD_GetXSize() - 70, 
                                          LCD_GetYSize() - 40, 
                                          80, 5, WM_CF_SHOW);
  #endif
  while (tDiff = tMax-GUI_GetTime(), (tDiff > 0) && !GUIDEMO_CheckCancel()) {
    if ((r = GUI_GetKey()) != 0)
      break;
  }
  #if GUI_WINSUPPORT
    PROGBAR_Delete(hProg);
    WM_ExecIdle();
  #endif
  return r;
}
Example #9
0
/*********************************************************************
*
*       _cbEffect
*/
static int _cbEffect(int TimeRem, void * pVoid) {
  GUI_PID_STATE State;
  int           Pressed;

  GUI_USE_PARA(TimeRem);
  Pressed = *((int *)pVoid);
  GUI_Exec();
  GUI_PID_GetState(&State);
  if (State.Pressed) {
    *((int *)pVoid) = 1;
    return 0;
  } else {
    if ((State.Pressed == 0) && (Pressed == 1)) {
      *((int *)pVoid) = 0;
      _Next   = 1;
      return 1;
    }
    _Next = GUIDEMO_CheckCancel();
    return _Next;
  }
}
Example #10
0
static void _DemoSineWave(void) {
  PARAM Param;
  I16 * pStart;
  int t0, Cnt = 0;
  GUI_RECT Rect = {19, (LCD_YSIZE - 20) - YSIZE, (LCD_XSIZE - 2), (LCD_YSIZE - 21)};
  GUI_HMEM hMem = GUI_ALLOC_AllocZero((LCD_XSIZE + 90) * sizeof(I16));
  _ShowText("Sine wave");
  pStart = (I16*)GUI_ALLOC_h2p(hMem);
  _GetSineData(pStart, LCD_XSIZE + 90);
  /*
  GUI_SetFont(&GUI_Font6x8);
  GUI_DispStringAt("msec/graph:", 10, 50);
  */
  _LabelMS();
  t0 = GUI_GetTime();
  while(((GUI_GetTime() - t0) < 10000) && !GUIDEMO_CheckCancel()) {
    int t1, tDiff2;
    if (Cnt % 90) {
      Param.aY++;
    } else {
      Param.aY = pStart;
    }
    t1 = GUI_GetTime();
    GUI_MEMDEV_Draw(&Rect, _Draw2, &Param, 0, GUI_MEMDEV_NOTRANS);
    tDiff2 = GUI_GetTime() - t1;
    if (tDiff2 < 100) {
      GUI_Delay(100 - tDiff2);
    }
    if(!((++Cnt) % 10)) {
      _DisplayTime(tDiff2);
      /*
      GUI_GotoXY(80, 50);
      GUI_SetColor(GUI_WHITE);
      GUI_SetBkColor(GUI_RED);
      GUI_DispDecSpace(tDiff2, 3);
      */
    }
  }
  GUI_ALLOC_Free(hMem);
}
Example #11
0
static void _DemoRandomGraph(void) {
  PARAM Param;
  int tDiff, t0;
  int Cnt = 0;
  GUI_HMEM hMem;
  GUI_RECT Rect;
  int lcd_xsize;
  int lcd_ysize;
  lcd_xsize = LCD_GetXSize();
  lcd_ysize = LCD_GetYSize();
  Rect.x0 = 19;
  Rect.y0 = (lcd_ysize - 20) - _YSize;
  Rect.x1 = lcd_xsize - 2;
  Rect.y1 = lcd_ysize - 21;
  hMem = GUI_ALLOC_AllocZero((LCD_GetXSize() - 20) * sizeof(I16));
  _ShowText("Random graph");
  GUI_LOCK();
  Param.aY = (I16*)GUI_ALLOC_h2p(hMem);
  GUI_UNLOCK();    /* Note: unlocking is permitted only if no further allocation is done so hMem stays valid */
  _LabelMS();
  t0 = GUI_GetTime();
  while(((tDiff = (GUI_GetTime() - t0)) < 10000) && !GUIDEMO_CheckCancel()) {
    U32 t1, tDiff2;
    _GetRandomData(Param.aY, tDiff, (lcd_xsize - 20));
    t1 = GUI_GetTime();
    GUI_MEMDEV_Draw(&Rect, _Draw, &Param, 0, GUI_MEMDEV_NOTRANS);
    tDiff2 = GUI_GetTime() - t1;
    if (tDiff2 < 100) {
      GUI_Delay(100 - tDiff2);
    }
    if(!((++Cnt)%10)) {
      _DisplayTime(tDiff2);
    }
  }
  GUI_ALLOC_Free(hMem);
}
Example #12
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();
  }
}
Example #14
0
void GUIDEMO_ColorBar(void) {
  int nBars = 13;
  int NumColors = LCD_GetDevCap(LCD_DEVCAP_NUMCOLORS);
  int XSize = LCD_GetXSize();
  int i, yStep, y0, x0;
  int lcd_ysize;
  int BitsPerPixel;
  
  lcd_ysize = LCD_GetYSize();
  y0 = 70;
  x0 = 60;
  GUIDEMO_ShowIntro("Color bar",
                    "emWin features "
                    "\nan integrated color"
                    "\nmanagement"
                    "\nwill always find the best available color"
                    "\nfor any logical color");
	XSize -= x0;
  yStep = (lcd_ysize - y0 - 60) / nBars;
  GUI_SetColor(GUI_WHITE);
  GUI_SetBkColor(GUI_BLACK); 
  GUI_Clear();
	GUI_SetFont(&GUI_Font8x16);
	GUI_DispString("Color bars\n");
  GUI_SetFont(&GUI_Font8_ASCII);
  #ifdef LCD_CONTROLLER
    GUI_DispString("\nLCD_CONTROLLER: ");
    GUI_DispDecMin(LCD_CONTROLLER);
    GUI_DispString("\n");
  #endif
  BitsPerPixel = LCD_GetBitsPerPixel();
  GUI_DispDecMin(BitsPerPixel);
  GUI_DispString(" bpp");
  #ifdef LCD_BUSWIDTH
    GUI_DispString(", ");
    GUI_DispDecMin(LCD_BUSWIDTH);
    GUI_DispString(" bit bus");
  #endif
  GUI_DispString(", ");
  GUI_DispDecMin(NumColors);
  GUI_DispString(" colors\n");
  GUI_SetFont(&GUI_Font8x8);
  GUI_SetColor(GUI_WHITE);
  GUI_DispStringAt("Red",     0, y0 +      yStep);
  GUI_DispStringAt("Green",   0, y0 + 3  * yStep);
  GUI_DispStringAt("Blue",    0, y0 + 5  * yStep);
  GUI_DispStringAt("Grey",    0, y0 + 6  * yStep);
  GUI_DispStringAt("Yellow",  0, y0 + 8  * yStep);
  GUI_DispStringAt("Cyan",    0, y0 + 10 * yStep);
  GUI_DispStringAt("Magenta", 0, y0 + 12 * yStep);
  for (i = 0; (i < XSize) && !GUIDEMO_CheckCancel(); i++) {
    U16 cs = (255 * (U32)i) / XSize;
    U16 x = x0 + i;;
/* Red */
    GUI_SetColor(cs);
    GUI_DrawVLine(x, y0, y0 + yStep - 1);
    GUI_SetColor(0x0000ff + (255 - cs) * 0x10100L);
    GUI_DrawVLine(x, y0 + yStep, y0 + 2 * yStep - 1);
/* Green */
    GUI_SetColor(cs<<8);
    GUI_DrawVLine(x, y0 + 2 * yStep, y0 + 3 * yStep - 1);
    GUI_SetColor(0x00ff00 + (255 - cs) * 0x10001L);
    GUI_DrawVLine(x, y0 + 3 * yStep, y0 + 4 * yStep - 1);
/* Blue */
    GUI_SetColor(cs * 0x10000L);
    GUI_DrawVLine(x, y0 + 4 * yStep, y0 + 5 * yStep - 1);
    GUI_SetColor(0xff0000 + (255 - cs) * 0x00101L);
    GUI_DrawVLine(x, y0 + 5 * yStep, y0 + 6 * yStep - 1);
/* Gray */
    GUI_SetColor(cs * 0x10101L);
    GUI_DrawVLine(x, y0 + 6 * yStep, y0 + 7 * yStep - 1);
/* Yellow */
    GUI_SetColor(cs * 0x00101L);
    GUI_DrawVLine(x, y0 + 7 * yStep, y0 + 8 * yStep - 1);
    GUI_SetColor(0x00ffff + (255 - cs) * 0x10000L);
    GUI_DrawVLine(x, y0 + 8 * yStep, y0 + 9 * yStep - 1);
/* Cyan */
    GUI_SetColor(cs * 0x10100L);
    GUI_DrawVLine(x, y0 + 9 * yStep, y0 + 10 * yStep - 1);
    GUI_SetColor(0xffff00 + (255 - cs) * 0x00001L);
    GUI_DrawVLine(x, y0 + 10 * yStep, y0 + 11 * yStep - 1);
/* Magenta */
    GUI_SetColor(cs * 0x10001L);
    GUI_DrawVLine(x, y0 + 11 * yStep, y0 + 12 * yStep - 1);
    GUI_SetColor(0xff00ff + (255 - cs) * 0x00100L);
    GUI_DrawVLine(x, y0 + 12 * yStep, y0 + 13 * yStep - 1);
  }
  GUIDEMO_Wait();
}
void GUIDEMO_Bitmap(void) {
    int XSize = LCD_GetXSize();
    int YSize = LCD_GetYSize();
    GUIDEMO_ShowIntro("Bitmaps",
                      "Showing"
                      "\ndifferent bitmaps with"
                      "\nand without compression");
    GUI_SetBkColor(GUI_BLUE);
    GUI_Clear();
#if GUI_WINSUPPORT & GUI_SUPPORT_MEMDEV
    WM_EnableMemdev(WM_HBKWIN);
#endif
#if GUIDEMO_LARGE
    GUI_DrawBitmap(&_bmLadyBug, 20, 50);
    GUI_SetFont(&GUI_Font13_1);
    GUI_DispStringAt("RLE Compressed bitmaps", 10, 10);
    GUIDEMO_Wait();
    GUI_Clear();
    GUI_DispStringAt("1/2/4/8 bpp bitmaps", 10, 10);
    GUI_DrawBitmap(&GUIDEMO_bm4bpp, 20, 50);
    GUIDEMO_Delay(4000);
    GUIDEMO_NotifyStartNext();
    /* Tile display with image */
    {
        int ix, iy;
        for (ix = 0; ix < XSize / GUIDEMO_bm4bpp.XSize + 1; ix++) {
            for (iy = 0; iy < YSize / GUIDEMO_bm4bpp.YSize + 1; iy++) {
                GUI_DrawBitmap(&GUIDEMO_bm4bpp,
                               GUIDEMO_bm4bpp.XSize * ix ,
                               GUIDEMO_bm4bpp.YSize * iy);
            }
        }
    }
    GUIDEMO_Delay(2000);
    GUIDEMO_NotifyStartNext();
    GUIDEMO_ShowInfo("Bitmaps may also be\nmagnified and rotated");
    GUI_SetTextMode(GUI_TM_TRANS);
    GUI_SetFont(&GUI_Font16_1);
    {
        int i, tm;
        double xMul, Angle;
        for (i = 200; (i < 3000) && !GUIDEMO_CheckCancel();) {
            tm = GUI_GetTime();
            GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, i, i);
            GUI_DispStringHCenterAt("Bitmaps can be magnified...", XSize / 2, 100);
            GUI_Exec();
            while ((GUI_GetTime() < (tm + 10)) && !GUIDEMO_CheckCancel());
            i += (GUI_GetTime() - tm) * 6;
        }
        GUIDEMO_Delay(2000);
        GUIDEMO_NotifyStartNext();
        GUI_Clear();
        GUI_DispStringHCenterAt("...and rotated.", XSize / 2, ((YSize + GUIDEMO_bm4bpp.YSize) >> 1) + 5);
        for (Angle = 0; Angle < PI4 && !GUIDEMO_CheckCancel();) {
            tm = GUI_GetTime();
            xMul = cos(Angle) * 1000;
            GUI_ClearRect((XSize - GUIDEMO_bm4bpp.XSize) >> 1, (YSize - GUIDEMO_bm4bpp.YSize) >> 1, (XSize + GUIDEMO_bm4bpp.XSize) >> 1, (YSize + GUIDEMO_bm4bpp.YSize) >> 1);
            GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, xMul, 1000);
            GUI_Exec();
            while ((GUI_GetTime() < (tm + 10)) && !GUIDEMO_CheckCancel());
            Angle += (GUI_GetTime() - tm) / 250.0f;
        }
        GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, 1000, 1000);
    }
    GUIDEMO_Wait();
#else
    {
        const GUI_BITMAP * pBm;
        int TextModeOld = GUI_SetTextMode(GUI_TM_XOR);
        GUI_SetFont(&GUI_Font8_ASCII);
        pBm = &_bmLadyBug;
        GUI_DrawBitmap(pBm, (XSize - (int)pBm->XSize) / 2, (YSize - (int)pBm->YSize) / 2);
        GUI_DispStringAt("RLE Compressed bitmaps", 8, 10);
        GUIDEMO_Wait();
        GUI_Clear();
        GUI_SetTextMode(GUI_TM_TRANS);
        pBm = &GUIDEMO_bm4bpp;
        GUI_DrawBitmap(pBm, (XSize - (int)pBm->XSize) / 2, (YSize - (int)pBm->YSize) / 2);
        GUI_DispStringAt("1/2/4/8 bpp bitmaps", 8, 10);
        GUIDEMO_Wait();
        GUI_Clear();
        {
            int i, tm;
            double xMul, Angle;
            for (i = 200; (i < 2000) && !GUIDEMO_CheckCancel();) {
                tm = GUI_GetTime();
                GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, i, i);
                GUI_DispStringAt("Bitmaps can be magnified...", 8, 10);
                GUI_Exec();
                while ((GUI_GetTime() < (tm + 10)) && !GUIDEMO_CheckCancel());
                i += (GUI_GetTime() - tm) * 6;
            }
            GUIDEMO_Delay(2000);
            GUIDEMO_NotifyStartNext();
            GUI_Clear();
            for (Angle = 0; Angle < PI4 && !GUIDEMO_CheckCancel();) {
                tm = GUI_GetTime();
                xMul = cos(Angle) * 1000;
                GUI_ClearRect((XSize - GUIDEMO_bm4bpp.XSize) >> 1, (YSize - GUIDEMO_bm4bpp.YSize) >> 1, (XSize + GUIDEMO_bm4bpp.XSize) >> 1, (YSize + GUIDEMO_bm4bpp.YSize) >> 1);
                GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, xMul, 1000);
                GUI_DispStringAt("...and rotated.", 8, 10);
                GUI_Exec();
                while ((GUI_GetTime() < (tm + 10)) && !GUIDEMO_CheckCancel());
                Angle += (GUI_GetTime() - tm) / 250.0f;
            }
            GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, 1000, 1000);
            GUI_DispStringAt("...and rotated.", 8, 10);
        }
        GUIDEMO_Wait();
        GUI_SetTextMode(TextModeOld);
    }
#endif
#if GUI_WINSUPPORT & GUI_SUPPORT_MEMDEV
    WM_DisableMemdev(WM_HBKWIN);
#endif
}
Example #16
0
void GUIDEMO_DemoProgBar(void) {
  int i, iRep;
  int XMid = LCD_GetXSize() / 2;
  int YMid = LCD_GetYSize() / 2;
  int Length[2] = {100, 140};
  int Height[2] = {20, 10};
  #if GUIDEMO_LARGE
    int MaxReps = 2;
  #else
    int MaxReps = 1;
  #endif
  PROGBAR_Handle ahProgBar[2];
  GUIDEMO_ShowIntro("Widgets", 
                    "\nProgressbars in"
                    "\nall variations");
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_Font8x16);
  GUI_DispStringHCenterAt("Progress bar", XMid, YMid - 40);
  /* Create `em */  
  ahProgBar[0] = PROGBAR_Create(XMid - Length[0] / 2,
                                YMid - 15,
                                Length[0], 
                                Height[0], 
                                WM_CF_SHOW);
  ahProgBar[1] = PROGBAR_Create(XMid - Length[1] / 2,
                                YMid + 20,
                                Length[1], 
                                Height[1], 
                                WM_CF_SHOW);
  /* Use memory device (optional, for better looks) */
  #if GUI_SUPPORT_MEMDEV
    PROGBAR_EnableMemdev(ahProgBar[0]);
    PROGBAR_EnableMemdev(ahProgBar[1]);
  #endif
  GUIDEMO_Delay (1000);
  PROGBAR_SetMinMax(ahProgBar[1], 0, 500);
  for (iRep = 0; iRep < MaxReps; iRep++) {
    PROGBAR_SetFont(ahProgBar[0], &GUI_Font8x16);
    #if   (LCD_BITSPERPIXEL == 2)
      PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_BLACK);
      PROGBAR_SetBarColor(ahProgBar[1], 0, GUI_BLACK);
      PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_LIGHTGRAY);
    #elif (LCD_BITSPERPIXEL <= 4)
      PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_DARKGRAY);
      PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_LIGHTGRAY);
    #else
      PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_GREEN);
      PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_RED);
    #endif
    for (i = 0; (i <= 100) && !GUIDEMO_CheckCancel(); i++) {
      PROGBAR_SetValue(ahProgBar[0], i);
      PROGBAR_SetValue(ahProgBar[1], i);
      GUI_Delay(5);
    }
    PROGBAR_SetText(ahProgBar[0], "Tank empty");
    for (; (i >= 0)&& !GUIDEMO_CheckCancel(); i--) {
      PROGBAR_SetValue(ahProgBar[0], i);
      PROGBAR_SetValue(ahProgBar[1], 200 - i);
      GUI_Delay(5);
    }
    PROGBAR_SetText(ahProgBar[0], "Any text ...");
    PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_LEFT);
    for (; (i <= 100)&& !GUIDEMO_CheckCancel(); i++) {
      PROGBAR_SetValue(ahProgBar[0], i);
      PROGBAR_SetValue(ahProgBar[1], 200 + i);
      GUI_Delay(5);
    }
    for (; (i >= 0)&& !GUIDEMO_CheckCancel(); i--) {
      PROGBAR_SetValue(ahProgBar[0], i);
      PROGBAR_SetValue(ahProgBar[1], 400 - i);
      GUI_Delay(5);
    }
    PROGBAR_SetFont(ahProgBar[0], &GUI_FontComic18B_1);
    PROGBAR_SetText(ahProgBar[0], "Any font ...");
    for (; (i <= 100)&& !GUIDEMO_CheckCancel(); i++) {
      PROGBAR_SetValue(ahProgBar[0], i);
      PROGBAR_SetValue(ahProgBar[1], 400 + i);
      GUI_Delay(5);
    }
    GUIDEMO_Delay(1000);
  }
  GUIDEMO_Delay(1000);
  PROGBAR_Delete(ahProgBar[0]);
  PROGBAR_Delete(ahProgBar[1]);
  GUIDEMO_Delay(1000);
  GUI_SetFont(&GUI_Font10S_ASCII);
}
Example #17
0
void GUIDEMO_ShowColorBar(void) {
  int nBars = 13;
  int YSize = LCD_GetYSize();
  int y0 = 70; 
  int yStep = (YSize - y0 - (YSize < 320 ? 0 : 60)) / nBars;
  int i;
  int x0 = 60;
  int NumColors = LCD_GetDevCap(LCD_DEVCAP_NUMCOLORS);
  int xsize = LCD_GetDevCap(LCD_DEVCAP_XSIZE);
	xsize -=x0;
  GUIDEMO_ShowIntro("Color bar",
                    "uC/GUI integrated color"
                    "\nmanagement always find the"
                    "\nbest available color for any"
					"\nlogical color");
  GUI_SetColor(GUI_WHITE);
  GUI_SetBkColor(GUI_BLACK); 
  GUI_Clear();
	GUI_SetFont(&GUI_Font8x16);
	GUI_DispString("Color bars\n");
	GUI_SetFont(&GUI_Font8_ASCII);
  #ifdef LCD_CONTROLLER
    GUI_DispString("\nLCD_CONTROLLER: ");
    GUI_DispDecMin(LCD_CONTROLLER);
    GUI_DispString("\n");
  #endif
  GUI_DispDecMin(LCD_BITSPERPIXEL);
  GUI_DispString(" bpp");
  #ifdef LCD_BUSWIDTH
    GUI_DispString(", ");
    GUI_DispDecMin(LCD_BUSWIDTH);
    GUI_DispString(" bit bus");
  #endif
  GUI_DispString(", ");
  GUI_DispDecMin(NumColors);
  GUI_DispString(" colors\n");
  #if (LCD_FIXEDPALETTE) 
    GUI_DispString("Fixed palette: ");
    GUI_DispDecMin(LCD_FIXEDPALETTE);
  #else
    GUI_DispString("(Custom)");
  #endif
  GUI_SetFont(&GUI_Font8x8);
  GUI_SetColor(GUI_WHITE);
  GUI_DispStringAt("Red",     0, y0 +      yStep);
  GUI_DispStringAt("Green",   0, y0 + 3  * yStep);
  GUI_DispStringAt("Blue",    0, y0 + 5  * yStep);
  GUI_DispStringAt("Grey",    0, y0 + 6  * yStep);
  GUI_DispStringAt("Yellow",  0, y0 + 8  * yStep);
  GUI_DispStringAt("Cyan",    0, y0 + 10 * yStep);
  GUI_DispStringAt("Magenta", 0, y0 + 12 * yStep);
  for (i = 0; (i < xsize) && !GUIDEMO_CheckCancel(); i++) {
    U16 cs = (255 * (U32)i) / xsize;
    U16 x = x0 + i;;
/* Red */
    GUI_SetColor(cs);
    GUI_DrawVLine(x, y0, y0 + yStep - 1);
    GUI_SetColor(0x0000ff + (255 - cs) * 0x10100L);
    GUI_DrawVLine(x, y0 + yStep, y0 + 2 * yStep - 1);
/* Green */
    GUI_SetColor(cs<<8);
    GUI_DrawVLine(x, y0 + 2 * yStep, y0 + 3 * yStep - 1);
    GUI_SetColor(0x00ff00 + (255 - cs) * 0x10001L);
    GUI_DrawVLine(x, y0 + 3 * yStep, y0 + 4 * yStep - 1);
/* Blue */
    GUI_SetColor(cs * 0x10000L);
    GUI_DrawVLine(x, y0 + 4 * yStep, y0 + 5 * yStep - 1);
    GUI_SetColor(0xff0000 + (255 - cs) * 0x00101L);
    GUI_DrawVLine(x, y0 + 5 * yStep, y0 + 6 * yStep - 1);
/* Gray */
    GUI_SetColor(cs * 0x10101L);
    GUI_DrawVLine(x, y0 + 6 * yStep, y0 + 7 * yStep - 1);
/* Yellow */
    GUI_SetColor(cs * 0x00101L);
    GUI_DrawVLine(x, y0 + 7 * yStep, y0 + 8 * yStep - 1);
    GUI_SetColor(0x00ffff + (255 - cs) * 0x10000L);
    GUI_DrawVLine(x, y0 + 8 * yStep, y0 + 9 * yStep - 1);
/* Cyan */
    GUI_SetColor(cs * 0x10100L);
    GUI_DrawVLine(x, y0 + 9 * yStep, y0 + 10 * yStep - 1);
    GUI_SetColor(0xffff00 + (255 - cs) * 0x00001L);
    GUI_DrawVLine(x, y0 + 10 * yStep, y0 + 11 * yStep - 1);
/* Magenta */
    GUI_SetColor(cs * 0x10001L);
    GUI_DrawVLine(x, y0 + 11 * yStep, y0 + 12 * yStep - 1);
    GUI_SetColor(0xff00ff + (255 - cs) * 0x00100L);
    GUI_DrawVLine(x, y0 + 12 * yStep, y0 + 13 * yStep - 1);
  }
  GUIDEMO_Wait();
}
Example #18
0
/*********************************************************************
*
*       _Action
*
* Purpose:
*   Does some action with the widget
*/
static void _Action(WM_HWIN hList) {
  unsigned ColoredCol   = 0;
  unsigned ColoredRow   = 0;
  unsigned NumRows;
  unsigned Index;
  unsigned i;
  int      SortedColumn = -1;
  int      ColorIndex   = 0;
  int      Reverse      = 0;

  Index = 0;
  do {
    if (_aAction[Index].pDescription) {
      GUIDEMO_ShowInfo(_aAction[Index].pDescription);
    }
    switch (_aAction[Index].Job) {
    case JOB_COLOR:
      NumRows = LISTVIEW_GetNumRows(hList);
      for (i = 0; i < NumRows; i++) {
        LISTVIEW_SetItemBkColor(hList, ColoredCol, ColoredRow, LISTVIEW_CI_UNSEL, _aColor[ColorIndex]);
        if (++ColorIndex == GUI_COUNTOF(_aColor)) {
          ColorIndex = 0;
        }
        if (++ColoredCol == LISTVIEW_GetNumColumns(hList)) {
          ColoredCol = 0;
        }
        if (++ColoredRow == NumRows) {
          ColoredRow = 0;
        }
      }
      break;
    case JOB_INCSEL:
      LISTVIEW_IncSel(hList);
      break;
    case JOB_DECSEL:
      LISTVIEW_DecSel(hList);
      break;
    case JOB_REVERSE:
      Reverse ^= 1;
      LISTVIEW_SetSort(hList, SortedColumn, Reverse);
      break;
    case JOB_ADDROWS:
      for (i = 0; i < 40; i++) {
        _AddRow(hList, 0);
      }
      break;
    case JOB_SETSORT:
      if (SortedColumn == -1) {
        SortedColumn = 0;
      } else {
        SortedColumn++;
        if (SortedColumn == (int)LISTVIEW_GetNumColumns(hList)) {
          SortedColumn = 0;
        }
      }
      LISTVIEW_SetSort(hList, SortedColumn, Reverse);
      break;
    }
    GUI_Delay(_aAction[Index].Delay);
  } while ((++Index < GUI_COUNTOF(_aAction)) && (GUIDEMO_CheckCancel() == 0));
}
Example #19
0
/*********************************************************************
*
*       _DemoBarGraph
*/
static void _DemoBarGraph(void) {
  GUI_MEMDEV_Handle hMem;
  int               ayOrg[] = { 10, 20, 40, 50, 90, 100, 80, 30, 20, 10 };
  int               ayCur[] = { 10, 20, 40, 50, 90, 100, 80, 30, 20, 10 };
  int               aAdd[GUI_COUNTOF(ayOrg)];
  int               NextState;
  int               TimeStart;
  int               xPosGraph;
  int               yPosGraph;
  int               AddBlend;
  int               NumItems;
  int               TimeDiff;
  int               TimeStep;
  int               Blend;
  int               xSize;
  int               ySize;
  int               i;

  //
  // Initialize values; 
  //
  AddBlend  = 1;
  Blend     = 64;
  NumItems  = GUI_COUNTOF(ayOrg);
  xSize     = LCD_GetXSize();
  ySize     = LCD_GetYSize();
  xPosGraph = (xSize - GRAPH_WIDTH)  / 2;
  yPosGraph = (ySize - GRAPH_HEIGHT) / 2;
  //
  // Create MEMDEV
  //
  hMem = GUI_MEMDEV_Create(xPosGraph, yPosGraph, GRAPH_WIDTH + 7 + 1, GRAPH_HEIGHT + 1);
  if (hMem == 0) {
    return;
  }
  GUI_MEMDEV_CopyFromLCD(hMem);
  for (i = 0; i < NumItems; i++) {
    aAdd[i] = (i & 1) * 2 - 1;
  }
  _DrawLabel(0, xPosGraph, yPosGraph);
  TimeStart = GUIDEMO_GetTime();
  do {
    TimeDiff = GUIDEMO_GetTime() - TimeStart;
    _DrawDiagramAt(hMem, xPosGraph, yPosGraph, ayCur, Blend);
    Blend += AddBlend;
    if ((Blend >= 164) || (Blend <= 8)) {
      AddBlend = -AddBlend;
    }
    for (i = 0; i < NumItems; i++) {
      *(ayCur + i) += *(aAdd + i);
      if ((*(ayCur + i) > (*(ayOrg + i) + 10)) || (*(ayCur + i) < (*(ayOrg + i) - 10))) {
        *(aAdd + i) = -*(aAdd + i);
      }
    }
    TimeStep = GUIDEMO_GetTime() - TimeStart;
    if ((TimeStep - TimeDiff) < TIME_STEP) {
      GUI_Delay(TIME_STEP - (TimeStep - TimeDiff));
    } else {
      GUI_Exec();
    }
    NextState = GUIDEMO_CheckCancel();
  } while ((TimeDiff < SHOW_TIME) && (NextState == 0));
  GUI_MEMDEV_Delete(hMem);
}