Beispiel #1
0
void DrawTime(HWND hwnd, HBRUSH hBrushRed) {
    PAINTSTRUCT ps;
    HDC hdc;
    
    hdc = BeginPaint(hwnd, &ps);
    SetMapMode(hdc, MM_ISOTROPIC);

    SetWindowExtEx(hdc, WINDOW_WIDTH, WINDOW_HEIGHT, NULL);
    SetViewportExtEx(hdc, WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, NULL);

    SelectObject(hdc, GetStockObject(NULL_PEN));
    SelectObject(hdc, hBrushRed);
    SetBkMode(hdc, TRANSPARENT);
    if (n_chess % 2 + 1 == 1) {
        SetViewportOrgEx(hdc, PLAYER1_TIME_X1, PLAYER1_TIME_Y1, NULL);

        _DisplayTime(hwnd, hdc);

        SetViewportOrgEx(hdc, PLAYER2_TIME_X1 - 80, PLAYER2_TIME_Y1, NULL);
        
        DisplayTwoDigits(hdc, 0, FALSE);
        DisplayColon(hdc);
        DisplayTwoDigits(hdc, 0, FALSE);
    } else {
        SetViewportOrgEx(hdc, PLAYER1_TIME_X1, PLAYER1_TIME_Y1, NULL);
        DisplayTwoDigits(hdc, 0, FALSE);
        DisplayColon(hdc) ;
        DisplayTwoDigits(hdc, 0, FALSE);

        SetViewportOrgEx (hdc, PLAYER2_TIME_X1 - 80, PLAYER2_TIME_Y1, NULL);

        _DisplayTime(hwnd, hdc);
    }
    EndPaint(hwnd,&ps);
}
Beispiel #2
0
static void _DemoRandomGraph(void) {
  PARAM Param;
  int tDiff, 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 - 20) * sizeof(I16));
  _ShowText("Random graph");
  Param.aY = (I16*)GUI_ALLOC_h2p(hMem);
  /*
  GUI_SetFont(&GUI_Font6x8);
  GUI_DispStringAt("msec/graph:", 10, 50);
  */
  _LabelMS();
  t0 = GUI_GetTime();
  while(((tDiff = (GUI_GetTime() - t0)) < 10000) && !GUIDEMO_CheckCancel()) {
    int 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_GotoXY(80, 50);
      GUI_SetColor(GUI_WHITE);
      GUI_SetBkColor(GUI_RED);
      GUI_DispDecSpace(tDiff2, 3);
      */
    }
  }
  GUI_ALLOC_Free(hMem);
}
Beispiel #3
0
void DisplayTime(HWND hwnd) {
    HBRUSH hBrushRed;
    HDC hdc;
    PAINTSTRUCT ps;

	hBrushRed = CreateSolidBrush(RGB(255, 0, 0));
	hdc = BeginPaint(hwnd, &ps);

	_DisplayTime(hwnd, hdc);

	EndPaint (hwnd, &ps) ;
}
Beispiel #4
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);
}
Beispiel #5
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);
}
Beispiel #6
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);
}