/******************************************************************* * * _DemoSineWave */ 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(405 * sizeof(I16)); GUI_SetColor(GUI_WHITE); GUI_SetBkColor(GUI_RED); GUI_ClearRect(0, 55, LCD_XSIZE, 75); GUI_SetFont(&GUI_FontComic18B_1); GUI_DispStringAt("Sine wave", 20, 55); pStart = GUI_ALLOC_h2p(hMem); _GetSineData(pStart, 405); GUI_SetFont(&GUI_Font6x8); t0 = GUI_GetTime(); while((GUI_GetTime() - t0) < 10000) { int t1, tDiff2; if (Cnt++ % 90) { Param.aY++; } else { Param.aY = pStart; } t1 = GUI_GetTime(); GUI_MEMDEV_Draw(&Rect, _Draw2, &Param, 0, 0); tDiff2 = GUI_GetTime() - t1; if (tDiff2 < 100) { GUI_Delay(100 - tDiff2); } } GUI_ALLOC_Free(hMem); }
/** * @brief Get the number of pixels per second * @param None * @retval Pixels per second */ static U32 _GetPixelsPerSecond(void) { GUI_COLOR Color, BkColor; U32 x0, y0, x1, y1, xSize, ySize; I32 t, t0; U32 Cnt, PixelsPerSecond, PixelCnt; /* Find an area which is not obstructed by any windows */ xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); Cnt = 0; x0 = 0; x1 = xSize - 1; y0 = 65; y1 = ySize - 60 - 1; Color = GUI_GetColor(); BkColor = GUI_GetBkColor(); GUI_SetColor(BkColor); /* Repeat fill as often as possible in 100 ms */ t0 = GUI_GetTime(); do { GUI_FillRect(x0, y0, x1, y1); GUI_Exec(); Cnt++; t = GUI_GetTime(); } while ((t - (t0 + 100)) <= 0); /* Compute result */ t -= t0; PixelCnt = (x1 - x0 + 1) * (y1 - y0 + 1) * Cnt; PixelsPerSecond = PixelCnt / t * 1000; GUI_SetColor(Color); return PixelsPerSecond; }
int GUIDEMO_Delay(int t) { int r = 0; #if GUI_WINSUPPORT int tRem, tEnd = GUI_GetTime() + t; PROGBAR_Handle hProg; WM_SetForegroundWindow(_ahButton[0]); hProg = (t >100) ? PROGBAR_Create(_FrameWinPosX[1] + 10, _FrameWinPosY[1] + 25, _FrameWinSizeX[1] - 20, 7, WM_CF_SHOW|WM_CF_STAYONTOP) : 0; #if GUI_SUPPORT_MEMDEV PROGBAR_EnableMemdev(hProg); #endif PROGBAR_SetMinMax(hProg, 0, t); for (; tRem = tEnd - GUI_GetTime(), (tRem > 0) && !GUIDEMO_CheckCancel();) { PROGBAR_SetValue(hProg, t - tRem); WM_ExecIdle(); GUI_Delay(10); } PROGBAR_Delete(hProg); _UpdateCmdWin(); WM_ExecIdle(); #else GUI_Delay(t); #endif return r; }
/********************************************************************* * * _MoveCursor */ static void _MoveCursor(){ int x, y, tm, cnt = 0; int yStep=-1; int xPos,yPos; xPos = LCD_GetXSize() / 2 - bmSeggerLogoBlue.XSize/2; yPos = LCD_GetYSize() / 2 - bmSeggerLogoBlue.YSize/2+25; GUI_DispStringHCenterAt("Cursor shape can be changed\nand the cursor can be moved", 160, 75); GUI_CURSOR_Show(); GUI_DrawBitmap(&bmSeggerLogoBlue, xPos, yPos ); y = 150; for (x = 0; x < 320; x++) { if ((x % 54) == 0) { GUI_CURSOR_Select(_apCursor[cnt++]); } tm = GUI_GetTime(); y += yStep; if(y<=80) yStep=1; if(y>=150) yStep=-1; GUI_CURSOR_SetPosition(x, y); while ((GUI_GetTime() - tm) < 10); } for (x = 320; x > 0; x--) { tm = GUI_GetTime(); if ((x % 54) == 0) { GUI_CURSOR_Select(_apCursor[cnt++]); } y += yStep; if(y<=80) yStep=1; if(y>=150) yStep=-1; GUI_CURSOR_SetPosition(x, y); while ((GUI_GetTime() - tm) < 10); } GUI_CURSOR_Hide(); GUI_Delay(500); }
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); }
int GUIDEMO_Delay(int t) { int r = 0; #if GUI_WINSUPPORT int tm, value; #if GUIDEMO_LARGE PROGBAR_Handle hProg; #endif WM_SetForegroundWindow(_ahButton[0]); #if GUIDEMO_LARGE hProg = (t >100) ? PROGBAR_CreateAsChild(10, 10, 60, 7, _ahInfoWin[1], 0, WM_CF_SHOW | WM_CF_STAYONTOP| WM_CF_MEMDEV) : 0; PROGBAR_SetMinMax(hProg, 0, t); #endif tm = GUI_GetTime(); do { value = GUI_GetTime() - tm; #if GUIDEMO_LARGE PROGBAR_SetValue(hProg, value); WM_ExecIdle(); #endif GUI_Delay(10); } while ((value < t) && !GUIDEMO_CheckCancel()); #if GUIDEMO_LARGE PROGBAR_Delete(hProg); #endif _UpdateCmdWin(); WM_ExecIdle(); #else GUI_Delay(t); #endif return r; }
/******************************************************************* * * _DemoRandomGraph */ static void _DemoRandomGraph(void) { PARAM Param; int tDiff, t0; 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)); GUI_SetColor(GUI_WHITE); GUI_SetBkColor(GUI_RED); GUI_ClearRect(0, 55, LCD_XSIZE, 75); GUI_SetFont(&GUI_FontComic18B_1); GUI_DispStringAt("Random graph", 20, 55); GUI_Lock(); Param.aY = GUI_ALLOC_h2p(hMem); GUI_SetFont(&GUI_Font6x8); t0 = GUI_GetTime(); while((tDiff = (GUI_GetTime() - t0)) < 10000) { int t1, tDiff2; _GetRandomData(Param.aY, tDiff, (LCD_XSIZE - 20)); t1 = GUI_GetTime(); GUI_MEMDEV_Draw(&Rect, _Draw, &Param, 0, 0); tDiff2 = GUI_GetTime() - t1; if (tDiff2 < 100) { GUI_Delay(100 - tDiff2); } } GUI_Unlock(); GUI_ALLOC_Free(hMem); }
void GUI_Delay(int Period) { int EndTime = GUI_GetTime()+Period; int tRem; /* remaining Time */ while (tRem = EndTime- GUI_GetTime(), tRem>0) { GUI_Exec(); GUI_X_Delay((tRem >5) ? 5 : tRem); } }
/********************************************************************* * * _cbFrameWinControl */ static void _cbFrameWinControl(WM_MESSAGE * pMsg) { WM_HWIN hItem; int xSize; int ySize; int NCode; int Id; switch (pMsg->MsgId) { case WM_KEY: WM_SendMessage(WM_HBKWIN, pMsg); break; case WM_INIT_DIALOG: hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_PROGBAR0); PROGBAR_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); PROGBAR_SetFont(hItem, &GUI_FontD6x8); hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_HALT); BUTTON_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_NEXT); BUTTON_SetFocussable(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_TEXT0); TEXT_SetText(hItem, "Intro"); TEXT_SetFont(hItem, &GUI_Font8_ASCII); break; case WM_PAINT: xSize = WM_GetWindowSizeX(pMsg->hWin); ySize = WM_GetWindowSizeY(pMsg->hWin); GUI_DrawGradientV(0, 0, xSize - 1, ySize - 1, 0xFFFFFF, 0xDCCEC0); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (NCode) { case WM_NOTIFICATION_RELEASED: switch (Id) { case GUI_ID_HALT: if (_Halt) { _Halt = 0; _HaltTime = GUI_GetTime() - _HaltTimeStart; WM_MakeModal(0); } else { _Halt = 1; _HaltTimeStart = GUI_GetTime() - _HaltTime; WM_MakeModal(pMsg->hWin); } break; case GUI_ID_NEXT: _Next = 1; // Will be set to 0 by GUIDEMO_GetNextState() _ClearHalt(); // Clear _Halt, so the next sample demonstrates immediately break; } break; } break; default: WM_DefaultProc(pMsg); } }
/** * @brief Run speed test * @param None * @retval Pixels per second */ static int Run_SpeedTest(void) { int TimeStart, i; U32 PixelsPerSecond; unsigned aColorIndex[8]; int xSize, ySize, vySize; GUI_RECT Rect, ClipRect; xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); vySize = LCD_GetVYSize(); #if GUI_SUPPORT_CURSOR GUI_CURSOR_Hide(); #endif if (vySize > ySize) { ClipRect.x0 = 0; ClipRect.y0 = 0; ClipRect.x1 = xSize; ClipRect.y1 = ySize; GUI_SetClipRect(&ClipRect); } Stop_Test = 0; for (i = 0; i< 8; i++) { aColorIndex[i] = GUI_Color2Index(_aColor[i]); } TimeStart = GUI_GetTime(); for (i = 0; ((GUI_GetTime() - TimeStart) < 5000) &&( Stop_Test == 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 ... */ } PixelsPerSecond = _GetPixelsPerSecond(); GUI_SetClipRect(NULL); return PixelsPerSecond; }
/******************************************************************* * * _LiftUp */ static void _LiftUp(int dy) { int i, tm; for (i = 0; i < (dy/4); i++) { tm = GUI_GetTime(); WM_MoveWindow(_hWindow1, 0, -4); WM_MoveWindow(_hWindow2, 0, -4); while ((GUI_GetTime() - tm) < 20) { WM_Exec(); } } }
/******************************************************************* * * _Wait */ static int _Wait(int Delay) { int EndTime, r = 1; EndTime = GUI_GetTime() + Delay; while (GUI_GetTime() < EndTime) { GUI_Exec(); if (GUI_GetKey() == GUI_ID_OK) { r = 0; break; } } return r; }
void MainTask(void) { static GUI_PID_STATE OldState; GUI_PID_STATE CurrentState; int tEnd; GUI_Init(); BUTTON_SetReactOnLevel(); // // Check if recommended memory for the sample is available // if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { GUI_ErrorOut("Not enough memory available."); return; } do { WM_HWIN hButton0, hButton1; WM_SetCallback(WM_HBKWIN, _cbBkWin); hButton0 = _CreateButton(100, 220, 170, 150, 5, 25, "Dashboard" , &bmDashboard , GUI_ID_BUTTON0); hButton1 = _CreateButton(370, 220, 170, 150, 5, 25, "Cash Terminal", &bmCashTerminal, GUI_ID_BUTTON1); WM_SetFocus(hButton0); tEnd = GUI_GetTime() + 4000; do { GUI_PID_GetState(&CurrentState); if ((OldState.x != CurrentState.x) || (OldState.y != CurrentState.y)) { tEnd = GUI_GetTime() + 10000; } OldState = CurrentState; GUI_Delay(100); if (GUI_GetTime() >= tEnd) { if (_AppSelectionOld) { _AppSelection = ((_AppSelectionOld - 1) ^ 1) + 1; } else { _AppSelection = APP_DASHBOARD; } } } while (!_AppSelection && !_Break); WM_DeleteWindow(hButton0); WM_DeleteWindow(hButton1); if (!_Break) { switch (_AppSelection) { case APP_DASHBOARD: AppDashBoard(); break; case APP_CASHTERMINAL: AppCashTerminal(); break; } GUI_CURSOR_Hide(); _AppSelectionOld = _AppSelection; _AppSelection = 0; } } while (!_Break); }
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(); }
void MainTask(void) { int Cnt; int TestTime; GUI_Init(); while(1) { Cnt = 0; TestTime = GUI_GetTime() + 1000; while ((TestTime - GUI_GetTime()) >= 0) { _CalcPrimes(sizeof(_aIsPrime)); Cnt++; } _PrintResult(Cnt); } }
/********************************************************************* * * _Measure */ static float _Measure(void (* pfOutput)(void * p), void * p) { int Period = LCDTEST_MEASURE_PERIOD; int Cnt = 0; int t0; int t; pfOutput(p); // Eliminate one time effects like color conversion t0 = GUI_GetTime(); while ((t=GUI_GetTime()-t0) < Period) { pfOutput(p); Cnt++; } GUI_Clear(); return 1000 * (float)Cnt / (float)t; }
/********************************************************************* * * GUIDEMO_Delay * * This function has to be called if the current step of the sample * is the last one and consists of a single frame */ void GUIDEMO_Delay(int TimeDelay) { PROGBAR_Handle hProg; int NextState; U32 TimeStart; U32 TimeDiff; hProg = WM_GetDialogItem(_hDialogControl, GUI_ID_PROGBAR0); if (TimeDelay > SHOW_PROGBAR_AT) { _ShowProgress(); } PROGBAR_SetValue(hProg, 0); PROGBAR_SetMinMax(hProg, 0, TimeDelay); TimeStart = GUI_GetTime(); do { TimeDiff = GUIDEMO_GetTime() - TimeStart; if (TimeDelay > SHOW_PROGBAR_AT) { PROGBAR_SetValue(hProg, TimeDiff); } GUI_Delay(5); NextState = GUIDEMO_CheckCancel(); } while (TimeDiff < (U32)TimeDelay && !NextState); if (TimeDelay > SHOW_PROGBAR_AT) { _HideProgress(); } GUI_Exec(); }
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); }
void MainTask(void) { static GUI_PID_STATE OldState; GUI_PID_STATE CurrentState; int tEnd; GUI_Init(); do { WM_HWIN hButton0, hButton1; WM_SetCallback(WM_HBKWIN, _cbBkWin); hButton0 = _CreateButton(100, 220, 170, 150, 5, 25, "Dashboard" , &bmDashboard , GUI_ID_BUTTON0); hButton1 = _CreateButton(370, 220, 170, 150, 5, 25, "Cash Terminal", &bmCashTerminal, GUI_ID_BUTTON1); WM_SetFocus(hButton0); tEnd = GUI_GetTime() + 4000; do { GUI_PID_GetState(&CurrentState); if ((OldState.x != CurrentState.x) || (OldState.y != CurrentState.y)) { tEnd = GUI_GetTime() + 10000; } OldState = CurrentState; GUI_Delay(100); if (GUI_GetTime() >= tEnd) { if (_AppSelectionOld) { _AppSelection = ((_AppSelectionOld - 1) ^ 1) + 1; } else { _AppSelection = APP_DASHBOARD; } } } while (!_AppSelection && !_Break); WM_DeleteWindow(hButton0); WM_DeleteWindow(hButton1); if (!_Break) { switch (_AppSelection) { case APP_DASHBOARD: AppDashBoard(); break; case APP_CASHTERMINAL: AppCashTerminal(); break; } GUI_CURSOR_Hide(); _AppSelectionOld = _AppSelection; _AppSelection = 0; } } while (!_Break); }
/********************************************************************* * * _WaitForPressedState * * Purpose: * Waits until the touch is in the given pressed state for at least 150 ms * pressed 1:表示触摸按下 。0:没有按下 */ static void _WaitForPressedState(int Pressed) { GUI_PID_STATE State; do { GUI_TOUCH_GetState(&State); /*获取触摸的状态*/ GUI_Delay(10); /*该函数调用GUI_X_Delay()*/ if (State.Pressed == Pressed) { /*如果触摸按下*/ int TimeStart = GUI_GetTime();/*获取GUI起始时间*/ do { GUI_TOUCH_GetState(&State); GUI_Delay(10); if (State.Pressed != Pressed) { /*如果确实没有按下返回,反之延时*/ break; } else if ((GUI_GetTime() - 150) > TimeStart) { return; } } while (1); } } while (1); }
/********************************************************************* * * _WaitForPressedState * * Purpose: * Waits until the touch is in the given pressed state for at least 250 ms */ static void _WaitForPressedState(int Pressed) { GUI_PID_STATE State; do { GUI_TOUCH_GetState(&State); GUI_Delay(10); if (State.Pressed == Pressed) { int TimeStart = GUI_GetTime(); do { GUI_TOUCH_GetState(&State); GUI_Delay(10); if (State.Pressed != Pressed) { break; } else if ((GUI_GetTime() - 150) > TimeStart) { return; } } while (1); } } while (1); }
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; }
/******************************************************************* * * _DemoRedrawing * * Function description * Demonstrates how useful can be a callback */ static void _DemoRedrawing(void) { int i; int tm; int tDiff; _ChangeInfoText("Demonstrating redrawing"); GUI_Delay(SPEED); _LiftUp(40); GUI_Delay(SPEED/3); _ChangeInfoText("Using a callback for redrawing"); GUI_Delay(SPEED/3); for (i = 0; i < 55; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hWindow1, 1, 1); WM_MoveWindow(_hWindow2, -1, -1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 0; i < 55; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hWindow1, -1, -1); WM_MoveWindow(_hWindow2, 1, 1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } GUI_Delay(SPEED/4); _LiftDown(30); GUI_Delay(SPEED/2); _ChangeInfoText("Without redrawing"); GUI_Delay(SPEED); _LiftUp(30); GUI_Delay(SPEED/4); WM_SetCallback(WM_HBKWIN, _cbBkWindowOld); for (i = 0; i < 55; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hWindow1, 1, 1); WM_MoveWindow(_hWindow2, -1, -1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 0; i < 55; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hWindow1, -1, -1); WM_MoveWindow(_hWindow2, 1, 1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } GUI_Delay(SPEED/3); WM_SetCallback(WM_HBKWIN, _cbBkWindow); _LiftDown(40); GUI_Delay(SPEED); }
/******************************************************************* * * _DemoMoveWindow Demonstrates the use of WM_MoveWindow */ static void _DemoMoveWindow(void) { int i, tm, tDiff; _ChangeInfoText("WM_MoveWindow()"); GUI_Delay(SPEED); for (i = 0; i < 55; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hWindow1, 1, 1); WM_MoveWindow(_hWindow2, -1, -1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 0; i < 55; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hWindow1, -1, -1); WM_MoveWindow(_hWindow2, 1, 1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } GUI_Delay(SPEED); }
/******************************************************************* * * _DemoMoveTo Demonstrates the use of WM_MoveTo */ static void _DemoMoveTo(void) { int i, tm, tDiff; _ChangeInfoText("WM_MoveTo()"); GUI_Delay(SPEED); for (i = 1; i < 56; i++) { tm = GUI_GetTime(); WM_MoveTo(_hWindow1, 50 + i, 70 + i); WM_MoveTo(_hWindow2, 105 - i, 125 - i); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 1; i < 56; i++) { tm = GUI_GetTime(); WM_MoveTo(_hWindow1, 105 - i, 125 - i); WM_MoveTo(_hWindow2, 50 + i, 70 + i); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } GUI_Delay(SPEED); }
/******************************************************************* * * _DemoResizeWindow Demonstrates the use of WM_ResizeWindow */ static void _DemoResizeWindow(void) { int i, tm,tDiff; _ChangeInfoText("WM_ResizeWindow()"); GUI_Delay(SPEED); _LiftUp(30); for (i = 0; i < 20; i++) { tm = GUI_GetTime(); WM_ResizeWindow(_hWindow1, 1, 1); WM_ResizeWindow(_hWindow2, -1, -1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 0; i < 40; i++) { tm = GUI_GetTime(); WM_ResizeWindow(_hWindow1, -1, -1); WM_ResizeWindow(_hWindow2, 1, 1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 0; i < 20; i++) { tm = GUI_GetTime(); WM_ResizeWindow(_hWindow1, 1, 1); WM_ResizeWindow(_hWindow2, -1, -1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } _LiftDown(30); GUI_Delay(SPEED); }
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); }
/******************************************************************* * * _DemoClipping * * Function description * Demonstrates clipping at parent borders */ static void _DemoClipping(void) { int i; int tm; int tDiff; _ChangeInfoText("Demonstrating clipping of child"); GUI_Delay(SPEED); for (i = 0; i < 25; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hChild, 1, 0); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 0; i < 25; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hChild, 0, 1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 0; i < 50; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hChild, -1, 0); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 0; i < 25; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hChild, 0, -1); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } for (i = 0; i < 25; i++) { tm = GUI_GetTime(); WM_MoveWindow(_hChild, 1, 0); tDiff = 15 - (GUI_GetTime() - tm); GUI_Delay(tDiff); } GUI_Delay(SPEED); }
/********************************************************************* * * GUI_TIMER_Restart */ void GUI_TIMER_Restart(GUI_TIMER_HANDLE hObj) { GUI_TIMER_Obj* pObj; GUI_LOCK(); { if (hObj == 0) { hObj = _hActiveTimer; } pObj = GUI_TIMER_H2P(hObj); pObj->t0 = GUI_GetTime() +pObj->Period; _Unlink(hObj); _Link(hObj); } GUI_UNLOCK(); }
/********************************************************************* * * GUI_Delay */ void GUI_Delay(int Period) { #if 0 int EndTime = GUI_GetTime()+Period; int tRem; /* remaining Time */ GUI_ASSERT_NO_LOCK(); while (tRem = EndTime - GUI_GetTime(), tRem>0) { GUI_Exec(); GUI_X_Delay((tRem >5) ? 5 : tRem); } #else int EndTime = GUI_GetTime()+Period; int tRem; /* remaining Time */ GUI_ASSERT_NO_LOCK(); Period /= 5; while(Period--) { GUI_Exec(); GUI_X_Delay(5); } #endif }