/********************************************************************* * * _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); }
/** * @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; }
/********************************************************************* * * _Main */ static void _Main(void) { int xSize; int ySize; WM_SelectWindow(WM_HBKWIN); GUI_Clear(); #if (GUI_SUPPORT_CURSOR | GUI_SUPPORT_TOUCH) // GUI_CURSOR_Show(); #endif // // Create and configure Control and Information window // xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); _hDialogControl = GUI_CreateDialogBox(_aFrameWinControl, GUI_COUNTOF(_aFrameWinControl), &_cbFrameWinControl, WM_HBKWIN, xSize - CONTROL_SIZE_X, ySize - CONTROL_SIZE_Y); _hDialogInfo = GUI_CreateDialogBox(_aFrameWinInfo, GUI_COUNTOF(_aFrameWinInfo), &_cbFrameWinInfo, WM_HBKWIN, (xSize >> 1) - 1, 0); WM_HideWindow(_hDialogInfo); // // Show Intro // WM_InvalidateWindow(_hDialogControl); WM_DisableMemdev(WM_HBKWIN); GUI_Exec(); WM_EnableMemdev(WM_HBKWIN); GUI_SetBkColor(GUI_RED); GUI_Clear(); GUI_SetBkColor(GUI_GREEN); GUI_Clear(); GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUIDEMO_Intro(); // // Run the demos // for (_iDemo = 0; _GUIDemoConfig.apFunc[_iDemo]; _iDemo++) { _ClearHalt(); GUIDEMO_UpdateControlText(); (*_GUIDemoConfig.apFunc[_iDemo])(); _iDemoMinor = 0; _Pressed = 0; } _iDemo = 0; // // Cleanup // WM_DeleteWindow(_hDialogControl); WM_DeleteWindow(_hDialogInfo); #if (GUI_SUPPORT_CURSOR | GUI_SUPPORT_TOUCH) GUI_CURSOR_Hide(); #endif }
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 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); }
static void _DispCursor(void) { GUI_CURSOR_Hide(); GUI_SetTextMode(GUI_TM_TRANS); GUI_SetFont(&GUI_FontComic24B_1); GUI_DispStringAt ("Available\n cursors:" , 20, 30); GUI_SetFont(&GUI_FontComic18B_1); /* Display the arrow cursor */ GUI_DispStringAt ("arrow cursors:" , 0, 90); GUI_DrawBitmap (&GUI_BitmapArrowS , 10, 110); GUI_DispStringAt ("S" , 10, 140); GUI_DrawBitmap (&GUI_BitmapArrowM , 40, 110); GUI_DispStringAt ("M" , 40, 140); GUI_DrawBitmap (&GUI_BitmapArrowL , 70, 110); GUI_DispStringAt ("L" , 70, 140); /* Display the arrow cursor inverted */ GUI_DispStringAt ("inverted arrow cursors:", 125, 90); GUI_DrawBitmap (&GUI_BitmapArrowSI , 145, 110); GUI_DispStringAt ("S" , 145, 140); GUI_DrawBitmap (&GUI_BitmapArrowMI , 175, 110); GUI_DispStringAt ("M" , 175, 140); GUI_DrawBitmap (&GUI_BitmapArrowLI , 205, 110); GUI_DispStringAt ("L" , 205, 140); /* Display the cross cursor */ GUI_DispStringAt ("cross cursors:" , 0, 155); GUI_DrawBitmap (&GUI_BitmapCrossS , 10, 185); GUI_DispStringAt ("S" , 10, 200); GUI_DrawBitmap (&GUI_BitmapCrossM , 40, 180); GUI_DispStringAt ("M" , 40, 200); GUI_DrawBitmap (&GUI_BitmapCrossL , 70, 175); GUI_DispStringAt ("L" , 70, 200); /* Display the cross cursor inverted */ GUI_DispStringAt ("inverted cross cursors:", 125, 155); GUI_DrawBitmap (&GUI_BitmapCrossSI , 145, 185); GUI_DispStringAt ("S" , 145, 200); GUI_DrawBitmap (&GUI_BitmapCrossMI , 175, 180); GUI_DispStringAt ("M" , 175, 200); GUI_DrawBitmap (&GUI_BitmapCrossLI , 205, 175); GUI_DispStringAt ("L" , 205, 200); }
void MainTask(void) { // // Init GUI // WM_SetCreateFlags(WM_CF_MEMDEV); GUI_Init(); #if GUI_SUPPORT_CURSOR GUI_CURSOR_Hide(); // Hide cursor before first page is shown #endif // // Show SEGGER logo // GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_FillRect(0, 0, LCD_GetXSize(), LCD_GetYSize()); GUI_DrawBitmap(&bmIMAGE_SeggerLogo_300x150_565c, (LCD_GetXSize() - 300) / 2, (LCD_GetYSize() - 150) / 2); GUI_X_Delay(SEGGERDEMO_DELAY); GUI_Clear(); // // Start GUIDEMO samples, GUIDEMO_Main is an endless loop itself. Therefor we can start it as task directly. // GUIDEMO_Main(); }
void MainTask_Gyro(void) { SysTICK(); float Buffer[6] = {0}; uint8_t Xval, Yval = 0x00; Demo_GyroConfig(); SetemWinRunning(1); GUI_SelectLayer(1); // select foregroung layer GUI_SetBkColor(STBLUE); // select background color as a solid color GUI_Clear(); // fill with the background color GRAPH_DATA_Handle hData1, hData2, hData3; GRAPH_SCALE_Handle hScale; WM_HWIN hGraph; hGraph = GRAPH_CreateEx(0, 0, 240, 320, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_GRAPH0); hData1 = GRAPH_DATA_YT_Create(GUI_GREEN, 240, 0, 0); hData2 = GRAPH_DATA_YT_Create(GUI_RED, 240, 0, 0); //hData3 = GRAPH_DATA_YT_Create(GUI_BLUE, 240, 0, 0); GRAPH_AttachData(hGraph, hData1); GRAPH_AttachData(hGraph, hData2); //GRAPH_AttachData(hGraph, hData3); hScale = GRAPH_SCALE_Create(19, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 20); GRAPH_SCALE_SetFactor(hScale, 0.5); GRAPH_SCALE_SetNumDecs(hScale, 0.01); GRAPH_SCALE_SetFont(hScale, &GUI_Font16_1); GRAPH_SCALE_SetTextColor(hScale, GUI_BLACK); GRAPH_AttachScale(hGraph, hScale); GRAPH_SetBorder(hGraph, 20, 0, 0, 0); GRAPH_SetGridVis(hGraph, 1); GRAPH_SetColor(hGraph, GUI_WHITE, GRAPH_CI_BK); GRAPH_SetColor(hGraph, GUI_LIGHTGRAY, GRAPH_CI_BORDER); GRAPH_SetColor(hGraph, GUI_BLACK, GRAPH_CI_FRAME); GRAPH_SetColor(hGraph, GUI_DARKGRAY, GRAPH_CI_GRID); GRAPH_SetLineStyleH(hGraph, GUI_LS_DOT); GRAPH_SetLineStyleV(hGraph, GUI_LS_DOT); GRAPH_SetGridDistX(hGraph, 50); GRAPH_SetGridDistY(hGraph, 20); GUI_Exec(); STM_EVAL_LEDToggle(LED4); STM_EVAL_LEDToggle(LED3); // the GUI is now rendered // in never ending loop just check if an incon is touched while(!tamperPushed) { if(open){ /* Read Gyro Angular data */ Demo_GyroReadAngRate(Buffer); /* Update autoreload and capture compare registers value*/ Xval = ABS((int8_t)(Buffer[0])); Yval = ABS((int8_t)(Buffer[1])); GRAPH_DATA_YT_AddValue(hData1, Xval*2); GRAPH_DATA_YT_AddValue(hData2, Yval*2); GUI_Exec(); open=0; } } // WM_DeleteWindow(hGraph); SetemWinRunning(0); GUI_CURSOR_Hide(); }
/********************************************************************* * * _Main */ static void _Main(void) { int xSize; int ySize; /* 设置要用于绘制的活动窗口 */ WM_SelectWindow(WM_HBKWIN); GUI_Clear(); #if (GUI_SUPPORT_CURSOR | GUI_SUPPORT_TOUCH) //GUI_CURSOR_Show(); #endif // // Create and configure Control and Information window // xSize = LCD_GetXSize();// ySize = LCD_GetYSize();// if(win_foucus_button_x) _hDialogControl = GUI_CreateDialogBox(_aFrameWinControl, GUI_COUNTOF(_aFrameWinControl), &_cbFrameWinControl, WM_HBKWIN, 0, 0); //_hDialogInfo = GUI_CreateDialogBox(_aFrameWinInfo, GUI_COUNTOF(_aFrameWinInfo), &_cbFrameWinInfo, WM_HBKWIN, (xSize >> 1) - 1, 0); else _hDialogDis = GUI_CreateDialogBox(_aFrameWinDis, GUI_COUNTOF(_aFrameWinDis), &_cbFrameWinDis, WM_HBKWIN, 0, 0); /*是窗口不可见*/ //WM_SetFocus(_hDialogDis); //WM_HideWindow(_hDialogInfo); // // Show Intro ///* 使窗口无效 */ // //WM_HideWindow(_hDialogDis); //else //WM_HideWindow(_hDialogControl); WM_InvalidateWindow(_hDialogDis); /* 禁用存储设备用于重绘 */ WM_DisableMemdev(WM_HBKWIN); //WM_HideWindow(_hDialogControl); /* 执行回调函数(通常用以重绘) */ GUI_Exec1(); /* 允许存储设备用于重绘 */ WM_EnableMemdev(WM_HBKWIN); /*GUIDEMO_Intro(); // // Run the demos // for (_iDemo = 0; _GUIDemoConfig.apFunc[_iDemo]; _iDemo++) { _ClearHalt(); GUIDEMO_UpdateControlText(); (*_GUIDemoConfig.apFunc[_iDemo])(); _iDemoMinor = 0; _Pressed = 0; } _iDemo = 0;*/ // // Cleanup // // // WM_DeleteWindow(_hDialogInfo); #if (GUI_SUPPORT_CURSOR | GUI_SUPPORT_TOUCH) GUI_CURSOR_Hide(); #endif }
/********************************************************************* * * GUIDEMO_Speed */ void GUIDEMO_Speed(void) { int TimeStart, i; U32 PixelsPerSecond; unsigned aColorIndex[8]; int xSize, ySize, vySize; GUI_RECT Rect, ClipRect; char cText[40] = { 0 }; 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); } GUIDEMO_ShowIntro("High speed", "Multi layer clipping\n" "Highly optimized drivers"); 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(0); GUI_SetColor(GUI_WHITE); GUI_SetTextMode(GUI_TM_TRANS); GUI_SetFont(&GUI_FontRounded22); GUI_DrawBitmap(&bmSTLogo70x35, 5, 5); GUIDEMO_AddStringToString(cText, "Pixels/sec: "); GUIDEMO_AddIntToString(cText, PixelsPerSecond); GUI_DispStringHCenterAt(cText, xSize >> 1, (ySize - GUI_GetFontSizeY()) >> 1); GUIDEMO_Delay(4000); #if GUI_SUPPORT_CURSOR GUI_CURSOR_Show(); #endif }
void MainTask_2D_text_bmp(void) { int i; horPos = ICONS_HOR_POS; verPos = ICONS_VER_POS; iconTouched = 0xFF; SetemWinRunning(1); GUI_SelectLayer(1); // select foregroung layer GUI_SetBkColor(GUI_TRANSPARENT); // select background as transparent color GUI_Clear(); // fill with the background color // get the number of icons iconNumber = GUI_COUNTOF(iconDrawFunctions); // compute padding to fit to whole display iconPadding = ((GUI_GetScreenSizeY() - (iconNumber * ICON_SIZE) - 2*ICONS_VER_POS) / iconNumber); // start time measurement timeMeasureStart(); // draw a background bitmap to the bottom LCD layer GUI_SelectLayer(0); // select the background layer // !! TO BE MODIFIED !! GUI_DrawBitmap(&bmbackground, 0, 0); GUI_SelectLayer(1); // set back the foregroung layer // now draw our icons one by one for (i = 0; i < iconNumber; i++) { iconDrawFunctions[i](horPos, verPos, ICON_SIZE); verPos += ICON_SIZE + iconPadding; } // add a title text GUI_SetTextMode(GUI_TM_TRANS); GUI_SetFont(&GUI_FontTimesNewRoman31); LCD_AA_SetAndMask(0xFFFFFFFF); GUI_DispStringInRect("STM32 Player", &rect, GUI_TA_CENTER); LCD_AA_SetAndMask(0x00FFFFFF); // end measurement time = timeMeasureEnd(); GUI_SetFont(&GUI_Font8_1); sprintf (timeString, "time to render: %d,%dms", time/10, time%10); GUI_DispStringAt(timeString, 10, 320 - 10); // optionally we can use cursor GUI_CURSOR_Show(); // the GUI is now rendered // in never ending loop just check if an incon is touched while(!tamperPushed) { GUI_TOUCH_GetState(&TouchState); // Get the touch position in pixel if (TouchState.Pressed) { if (iconTouched == 0xFF) // no icon was touched previously { GUI_CURSOR_SetPosition(TouchState.x, TouchState.y); // move the cursor to current touch position // check if the touch is in icons area if (TouchState.x > ICONS_HOR_POS && TouchState.x < ICONS_HOR_POS + ICON_SIZE) { if(TouchState.y > ICONS_VER_POS && TouchState.y < ICONS_VER_POS + iconNumber*(ICON_SIZE + iconPadding)) { // get he number of touched icon iconTouched = (TouchState.y - ICONS_VER_POS) / (ICON_SIZE + iconPadding); ReDrawIcon(GUI_RED, iconTouched); // draw again with hihghlight color } } } } else { ReDrawIcon(GUI_WHITE, iconTouched); iconTouched = 0xFF; } } SetemWinRunning(0); GUI_CURSOR_Hide(); }