int _ExecKeyboard(void) { int y0 = 75; int XSize = LCD_GetXSize(); int YSize = LCD_GetYSize(); int XStep = XSize / 4; int YStep = (YSize - y0) / 4; int i; int Key; BUTTON_Handle ahButton[16]; BUTTON_Handle hButtonESC; EDIT_Handle hEdit; GUI_RECT rText = {0}; rText.x1 = LCD_GetXSize() - 3; rText.y1 = 20; GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUI_SetFont(&GUI_FontComic18B_ASCII); GUI_SetColor(GUI_WHITE); GUI_DispStringInRect("µC/GUI", &rText, GUI_TA_RIGHT | GUI_TA_VCENTER); rText.y0 +=20; rText.y1 +=20; GUI_DispStringInRect("Touch screen demo", &rText, GUI_TA_RIGHT | GUI_TA_VCENTER); /* Create Keyboard Buttons */ for (i=0; _acText[i]; i++) { int XPos = (i%4) * XStep + 3; int YPos = (i/4) * YStep + 3 + y0; char c = _acText[i]; int Id = c ? c : 1; char ac[2] = {0}; char *s= ac; ac[0] = c; ahButton[i] = BUTTON_Create( XPos, YPos, XStep - 5, YStep - 5, Id, BUTTON_CF_SHOW ); BUTTON_SetText(ahButton[i], s); BUTTON_EnableMemdev(ahButton[i]); } hButtonESC = BUTTON_Create( 3, 3, 80, 25, GUI_ID_CANCEL, BUTTON_CF_SHOW ); BUTTON_SetText(hButtonESC, "ESC"); hEdit = EDIT_Create( 5, y0 - 30, XSize - 10, 25, ' ', 80, 0 ); EDIT_SetFont(hEdit, &GUI_Font8x16); /* Handle Keyboard until ESC or ENTER is pressed */ do { Key = GUIDEMO_WaitKey(); switch (Key) { case 0: case GUI_ID_CANCEL: break; default: EDIT_AddKey(hEdit, Key); } } while ((Key != 'N') && (Key!=GUI_ID_CANCEL) && (Key!=0)); /* Cleanup */ for (i=0; i< countof(ahButton); i++) { BUTTON_Delete(ahButton[i]); } BUTTON_Delete(hButtonESC); EDIT_Delete(hEdit); return Key; }
/********************************************************************* * * _DrawBkCircle */ static void _DrawBkCircle(int DrawLogo) { static GUI_MEMDEV_Handle hMemStretch; GUI_MEMDEV_Handle hMemGradient; GUI_MEMDEV_Handle hMemCircle; GUI_MEMDEV_Handle hMemOld; int CircleWidth; int ySizeV; int xSize; int ySize; int i; U32 * pData; xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); ySizeV = LCD_GetVYSize(); if (ySizeV > ySize) { GUI_SetBkColor(BK_COLOR_1); GUI_ClearRect(0, 0, xSize, ySizeV); } if (hMemStretch == 0) { CircleWidth = (CIRCLE_RADIUS << 1) + 1; hMemCircle = GUI_MEMDEV_CreateFixed(0, 0, CircleWidth, CircleWidth, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUI_COLOR_CONV_8888); hMemStretch = GUI_MEMDEV_CreateEx (0, 0, xSize, ySize, GUI_MEMDEV_NOTRANS); hMemGradient = GUI_MEMDEV_CreateFixed(0, 0, 1, CIRCLE_RADIUS, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUI_COLOR_CONV_8888); // // Initialize background // hMemOld = GUI_MEMDEV_Select(hMemCircle); GUI_SetBkColor(BK_COLOR_1); GUI_Clear(); // // Create Gradient // GUI_MEMDEV_Select(hMemGradient); GUI_DrawGradientV(0, 0, 0, CIRCLE_RADIUS, BK_COLOR_0, BK_COLOR_1); // // Get color and draw circles // pData = (U32 *)GUI_MEMDEV_GetDataPtr(hMemGradient); GUI_MEMDEV_Select(hMemCircle); for (i = 0; i < CIRCLE_RADIUS; i++, pData++) { GUI_SetColor(*pData); GUI_DrawCircle(CIRCLE_RADIUS, CIRCLE_RADIUS, i); } // // Stretch and display // GUI_MEMDEV_Select(hMemStretch); GUI_MEMDEV_DrawPerspectiveX(hMemCircle, 0, 0, ySize, ySize, xSize, 0); GUI_MEMDEV_Delete(hMemCircle); GUI_MEMDEV_Delete(hMemGradient); GUI_MEMDEV_Select(hMemOld); } GUI_MEMDEV_Write(hMemStretch); if (DrawLogo) { GUI_DrawBitmap(&bmSTLogo70x35, LOGO_DIST_BORDER, LOGO_DIST_BORDER); } }
/********************************************************************* * * MainTask */ void MainTask(void) { GUI_MOVIE_INFO Info; GUI_MOVIE_HANDLE hMovie; int xSize, ySize; #ifdef WIN32 HANDLE hFile; const char acFileName[] = "C:\\Work\\Grafik\\Video\\FFmpeg\\FFmpeg.emf"; #define PARAM &hFile #else FS_FILE * pFile; const char acFileName[] = "\\FFmpeg.emf"; #define PARAM pFile #endif GUI_Init(); // // Get display size // xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); // // Create file handle // #ifdef WIN32 hFile = CreateFile(acFileName, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); #else FS_Init(); pFile = FS_FOpen(acFileName, "r"); #endif // // Get physical size of movie // if (GUI_MOVIE_GetInfoEx(_GetData, PARAM, &Info) == 0) { // // Check if display size fits // if ((Info.xSize <= xSize) && (Info.ySize <= ySize)) { // // Create and play movie // hMovie = GUI_MOVIE_CreateEx(_GetData, PARAM, _cbNotify); if (hMovie) { GUI_MOVIE_Show(hMovie, (xSize - Info.xSize) / 2, (ySize - Info.ySize) / 2, 1); } } else { // // Error message // GUI_SetFont(GUI_FONT_13_ASCII); GUI_DispStringHCenterAt("Video can not be shown.\n\nDisplay size too small.", xSize / 2, (ySize - GUI_GetFontSizeY()) / 2); } } while (1) { GUI_Exec(); GUI_X_Delay(1); } }
/** * @brief Initializes the menu. * @param None. * @retval None. */ void k_InitMenu(void) { WM_HWIN hItem; uint8_t i = 0; GUI_SetLayerVisEx (0, 0); GUI_DrawBitmap(&bmbackground, 0,0); settings.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP); GUI_SetLayerVisEx (0, 1); GUI_SelectLayer(1); GUI_Clear(); WM_SetCallback(WM_HBKWIN, _cbBk); WM_CreateWindowAsChild(0, 0, LCD_GetXSize(), 25, WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS , _cbStatus, 0); hIcon = ICONVIEW_CreateEx(0, 26, LCD_GetXSize(), LCD_GetYSize()- 26, WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND , ICONVIEW_CF_AUTOSCROLLBAR_V, ID_ICONVIEW_MENU, 112, 105); ICONVIEW_SetFont(hIcon, &GUI_Font13B_ASCII); ICONVIEW_SetBkColor(hIcon, ICONVIEW_CI_SEL, GUI_LIGHTBLUE |GUI_TRANSPARENT); ICONVIEW_SetSpace(hIcon, GUI_COORD_Y, 10); ICONVIEW_SetFrame(hIcon, GUI_COORD_Y, 10); for (i = 0; i < k_ModuleGetNumber(); i++) { ICONVIEW_AddBitmapItem(hIcon,module_prop[i].module->icon, (char *)module_prop[i].module->name); } if(settings.b.enable_sprite) { _ShowSprites(); } hItem = BUTTON_CreateEx(0, 0, 40, 23, WM_HBKWIN, WM_CF_SHOW, 0, ID_BUTTON_BKGND); WM_SetCallback(hItem, _cbButton); }
/** * @brief Show full screen * @param None * @retval None */ static uint8_t _ShowFullScreen(void) { int XPos, YPos, nx, ny, n; WM_HWIN hItem; if(hMovie != 0) { FullScreen = 1; WM_CreateWindowAsChild(0, 0, LCD_GetXSize(), LCD_GetYSize(), WM_HBKWIN, WM_CF_SHOW | WM_CF_STAYONTOP, _cbFullScreen, 0); if((Video_Info.xSize != LCD_GetXSize()) ||(Video_Info.ySize != LCD_GetYSize())) { nx = (LCD_GetXSize() * 1000) / Video_Info.xSize; ny = (LCD_GetYSize() * 1000) / Video_Info.ySize; if (nx < ny) { n = nx; } else { n = ny; } XPos = (LCD_GetXSize() - ((Video_Info.xSize * n) / 1000)) / 2; YPos = (LCD_GetYSize() - ((Video_Info.ySize * n) / 1000)) / 2; GUI_MOVIE_ShowScaled(hMovie, XPos, YPos, n, 1000, 0); } else { XPos = (LCD_GetXSize() - Video_Info.xSize) / 2; YPos = (LCD_GetYSize() - Video_Info.ySize) / 2; GUI_MOVIE_Show(hMovie, XPos, YPos, 0); VideoPlayer_State = VIDEO_PLAY; hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_PLAY_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); } } return 0; }
/** * @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; }
/********************************************************************* * * MainTask */ void MainTask(void) { WM_HWIN hTree; TREEVIEW_ITEM_Handle hNode; int xSize, ySize; char acBuffer[(TREEVIEW_DEPTH << 1) + 1]; // // Initialize emWin // WM_SetCreateFlags(WM_CF_MEMDEV); GUI_Init(); xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); // // Set defaults for background and widgets // WM_SetCallback(WM_HBKWIN, _cbBk); SCROLLBAR_SetDefaultSkin(SCROLLBAR_SKIN_FLEX); SCROLLBAR_SetDefaultWidth(20); SCROLLBAR_SetThumbSizeMin(25); // // // GUI_SetFont(GUI_FONT_24_ASCII); GUI_DispStringHCenterAt("Customized TREEVIEW widget", 160, 5); // // Create TREEVIEW // hTree = TREEVIEW_CreateEx(0, 35, xSize, ySize - 35, WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS, 0, GUI_ID_TREEVIEW0); TREEVIEW_SetAutoScrollV(hTree, 1); TREEVIEW_SetFont(hTree, GUI_FONT_24_ASCII); TREEVIEW_SetIndent(hTree, 30); TREEVIEW_SetTextIndent(hTree, 20); TREEVIEW_SetImage(hTree, TREEVIEW_BI_PLUS, &bmPlus); TREEVIEW_SetImage(hTree, TREEVIEW_BI_MINUS, &bmMinus); TREEVIEW_SetImage(hTree, TREEVIEW_BI_CLOSED, &bmClosed); TREEVIEW_SetImage(hTree, TREEVIEW_BI_OPEN, &bmOpen); TREEVIEW_SetImage(hTree, TREEVIEW_BI_LEAF, &bmLeaf); TREEVIEW_SetBitmapOffset(hTree, TREEVIEW_BI_PM, -21, -6); TREEVIEW_SetOwnerDraw(hTree, _TREEVIEW_OwnerDraw); TREEVIEW_SetBkColor(hTree, TREEVIEW_CI_SEL, USER_COLOR); TREEVIEW_SetBkColor(hTree, TREEVIEW_CI_UNSEL, GUI_BLACK); TREEVIEW_SetTextColor(hTree, TREEVIEW_CI_SEL, GUI_WHITE); TREEVIEW_SetTextColor(hTree, TREEVIEW_CI_UNSEL, GUI_WHITE); WIDGET_SetEffect(hTree, &WIDGET_Effect_None); // // Fill TREEVIEW // hNode = TREEVIEW_InsertItem(hTree, TREEVIEW_ITEM_TYPE_NODE, 0, 0, "Tree"); _FillNode(hTree, hNode, NUM_CHILD_NODES, NUM_CHILD_ITEMS, TREEVIEW_DEPTH, TREEVIEW_DEPTH, acBuffer, acBuffer); TREEVIEW_ITEM_Expand(hNode); WM_SetFocus(hTree); while (1) { GUI_Delay(100); } }
static void _DrawBk(int DrawLogo) { int xSize, ySize; xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); GUI_DrawGradientV(0, 0, xSize, ySize, BK_COLOR_0, BK_COLOR_1); if (DrawLogo) { GUI_DrawBitmap(&bmSeggerLogo70x35, 5, 5); } }
/********************************************************************* * * _SetupAnimationData */ static void _SetupAnimationData(ANIM_DATA * pData) { // // Get display size // pData->xSize = LCD_GetXSize(); pData->ySize = LCD_GetYSize(); pData->xPart = pData->xSize / 10; pData->yPart = pData->ySize / 10; pData->Size = (pData->yPart * 4) / 5; }
/********************************************************************* * * _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 GUIDEMO_main(void) { #if GUI_WINSUPPORT int i; #endif #if GUI_WINSUPPORT WM_SetCreateFlags(WM_CF_MEMDEV); /* Automatically use memory devices on all windows */ _ButtonSizeX = 27; _ButtonSizeY = 14; _ahButton[0] = BUTTON_Create(LCD_GetXSize() - _ButtonSizeX * 2 - 5, LCD_GetYSize() - _ButtonSizeY - 3, _ButtonSizeX, _ButtonSizeY, 'H' , WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV); _ahButton[1] = BUTTON_Create(LCD_GetXSize() - _ButtonSizeX - 3, LCD_GetYSize() - _ButtonSizeY - 3, _ButtonSizeX, _ButtonSizeY, 'N' , WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV); BUTTON_SetFont(_ahButton[0], &GUI_Font8_ASCII); BUTTON_SetFont(_ahButton[1], &GUI_Font8_ASCII); BUTTON_SetText(_ahButton[0], "Stop"); BUTTON_SetText(_ahButton[1], "Next"); _UpdateCmdWin(); WM_ExecIdle(); #endif /* Show Intro */ GUIDEMO_Intro(); /* Run the individual demos ! */ for (_iTest = 0; _apfTest[_iTest]; _iTest++) { GUI_CONTEXT ContextOld; GUI_SaveContext(&ContextOld); _iTestMinor = 0; _UpdateCmdWin(); (*_apfTest[_iTest])(); _CmdNext = 0; GUI_RestoreContext(&ContextOld); } /* Cleanup */ #if GUI_WINSUPPORT for (i = 0; i < countof(_ahButton); i++) { BUTTON_Delete(_ahButton[i]); } #endif }
/** * @brief Initializes the menu. * @param None. * @retval None */ void k_InitMenu(void) { WM_HWIN hItem; uint8_t i = 0; settings.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP); WM_SetCallback(WM_HBKWIN, _cbBk); hStatusWin = WM_CreateWindowAsChild(0, 0, LCD_GetXSize(), 25, WM_HBKWIN, WM_CF_SHOW | WM_CF_LATE_CLIP , _cbStatus, 0); hIcon = ICONVIEW_CreateEx(0, 26, LCD_GetXSize(), LCD_GetYSize()- 26, WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS, ICONVIEW_CF_AUTOSCROLLBAR_V, ID_ICONVIEW_MENU, 92, 90); ICONVIEW_SetFont(hIcon, &GUI_Font13B_ASCII); ICONVIEW_SetTextColor(hIcon, ICONVIEW_CI_UNSEL, GUI_BLUE); ICONVIEW_SetTextColor(hIcon, ICONVIEW_CI_SEL, GUI_BLUE); ICONVIEW_SetBkColor(hIcon, ICONVIEW_CI_SEL, GUI_LIGHTBLUE |GUI_TRANSPARENT); ICONVIEW_SetSpace(hIcon, GUI_COORD_Y, 10); ICONVIEW_SetFrame(hIcon, GUI_COORD_Y, 10); for (i = 0; i < k_ModuleGetNumber(); i++) { ICONVIEW_AddBitmapItem(hIcon,module_prop[i].module->icon, (char *)module_prop[i].module->name); } hItem = BUTTON_CreateEx(0, 0, 40, 23, WM_GetDesktopWindowEx(0), WM_CF_SHOW, 0, ID_BUTTON_BKGND); WM_SetCallback(hItem, _cbButton); }
void GUIDEMO_Graph(void) { _YSize = (LCD_GetYSize() - 100); GUIDEMO_ShowIntro("Drawing a graph", "\nOptimized drawing routine" "\nfor drawing graph data"); GUI_Clear(); _Label(); _DemoRandomGraph(); GUIDEMO_NotifyStartNext(); _DemoSineWave(); }
LISTBOX_Handle GListBox_Init() { int Entries = GUI_COUNTOF(g_stListBox) - 1; LISTBOX_Handle hListBox; int xSize = LCD_GetXSize(); //int ySize = GUI_GetYDistOfFont(&GUI_Font13B_1) * Entries; int ySize = LCD_GetYSize(); /* Create the listbox */ hListBox = LISTBOX_Create(g_stListBox, 0, 0, xSize, ySize, WM_CF_SHOW); return hListBox; }
/** * @brief Start play * @param filename: pointer to the video file name * @retval None */ static uint8_t _StartPlay(GUI_MOVIE_HANDLE *hmovie, char * filename, FIL * file, uint16_t x0, uint16_t y0) { static char tmp[FILEMGR_FILE_NAME_SIZE]; int ms, frames; uint32_t duration; WM_HWIN hItem; if(f_open(file, filename, FA_OPEN_EXISTING | FA_READ) == FR_OK) { PrevFrameIndex = 0; LostFrames = 0; previous_total = 0; GUI_MOVIE_GetInfoEx(_GetData, file, &Video_Info); *hmovie = GUI_MOVIE_CreateEx(_GetData, file, _cbNotify) ; GUI_MOVIE_SetPeriod (*hmovie, VIDEO_FRAME_TIME); if((Video_Info.xSize == 0) || (Video_Info.ySize == 0) || (Video_Info.xSize > 1024) || (Video_Info.ySize > 768)) { GUI_MOVIE_Delete(*hmovie); return 1; } GUI_MOVIE_Show(*hmovie, ((LCD_GetXSize() - Video_Info.xSize)/2), ((LCD_GetYSize() - Video_Info.ySize)/2), 0); hTimer = WM_CreateTimer(playbackwin, 0, 1000, 0); /* Update video total time */ hItem = WM_GetDialogItem(playbackwin, ID_TIME); ms = Video_Info.msPerFrame; frames = Video_Info.NumFrames; duration = (frames * ms)/1000; sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 ); TEXT_SetText(hItem, tmp); WM_InvalidateWindow(playbackwin); elapsed_time = 0; hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_NAME); FILEMGR_GetFileOnly (tmp, filename); TEXT_SetText(hItem, tmp); hItem = WM_GetDialogItem(playbackwin, ID_ELAPSED_TIME); TEXT_SetText(hItem, "00:00"); WM_InvalidateWindow(hItem); WM_Paint(hItem); } return 0; }
/********************************************************************* * * GUIDEMO_DemoFrameWin */ void GUIDEMO_DemoFrameWin(void) { FRAMEWIN_Handle hFrame; LISTBOX_Handle hListBox; int xSize = LCD_GetXSize(); int ySize = LCD_GetYSize(); int i, x, y, w, h; const GUI_FONT* pFont = &GUI_FontComic18B_1; GUI_COLOR DesktopColorOld; #if GUIDEMO_LARGE GUIDEMO_ShowIntro("Frame Window & Listbox", NULL); #else GUIDEMO_ShowIntro("Frame Window\n & Listbox", NULL); #endif DesktopColorOld = GUIDEMO_SetBkColor(GUI_RED); DesktopColorOld = WM_SetDesktopColor(DesktopColorOld); /* Automatically update desktop window */ x = BORDER; #if GUIDEMO_LARGE y = 75; #else y = BORDER; #endif w = xSize - x - BORDER; h = ySize - y - BORDER; if (w > 140) { w = 140; } if (h > 120) { h = 120; } hFrame = FRAMEWIN_Create("Select language", NULL, WM_CF_SHOW, x, y, w, h); FRAMEWIN_SetActive(hFrame, 1); FRAMEWIN_SetMoveable(hFrame, 1); FRAMEWIN_AddMaxButton(hFrame, FRAMEWIN_BUTTON_RIGHT, 0); FRAMEWIN_AddMinButton(hFrame, FRAMEWIN_BUTTON_RIGHT, 1); FRAMEWIN_SetFont(hFrame, &GUI_Font13_ASCII); hListBox = LISTBOX_CreateAsChild(_asLang, WM_GetClientWindow(hFrame), 0, 0, 0, 0, WM_CF_SHOW | WM_SF_ANCHOR_LEFT | WM_SF_ANCHOR_TOP | WM_SF_ANCHOR_RIGHT | WM_SF_ANCHOR_BOTTOM); WM_SetFocus(hListBox); LISTBOX_SetFont(hListBox, pFont); GUIDEMO_Wait(); for (i = 0; (i < 10) && !GUIDEMO_CheckCancel(); i++) { LISTBOX_IncSel(hListBox); GUIDEMO_Delay(250); } for (i = 0; (i < 10) && !GUIDEMO_CheckCancel(); i++) { LISTBOX_DecSel(hListBox); GUIDEMO_Delay(250); } GUIDEMO_Delay(500); LISTBOX_Delete(hListBox); FRAMEWIN_Delete(hFrame); WM_SetDesktopColor(DesktopColorOld); }
/********************************************************************* * * GUIDEMO_Intro * ********************************************************************** */ void GUIDEMO_Intro(void) { char acVersion[30] = "Version of emWin: "; int xCenter, xSize, ySize; xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); xCenter = xSize >> 1; GUIDEMO_DrawBk(0); GUI_AA_SetFactor(3); GUI_AA_DrawArc(60*3,60*3,50*3,50*3,0,180); GUI_SetTextMode(GUI_TM_TRANS); // // emWin // GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_FontRounded22); GUI_DispStringHCenterAt("emWin", xCenter, (FACTOR_EMWIN * ySize) >> SCREEN_DIV); // // emWin description // GUI_SetFont(&GUI_FontSouvenir18); GUI_DispStringHCenterAt("Universal graphic software\nfor embedded applications", xCenter, (FACTOR_DESC * ySize) >> SCREEN_DIV); // // Any text // GUI_SetColor(0x2288ff); GUI_DispStringHCenterAt("Any CPU - Any Display - Any Application", xCenter, (FACTOR_ANY_COMP * ySize) >> SCREEN_DIV); // // Compiled // GUI_SetFont(&GUI_Font10S_ASCII); GUI_DispStringHCenterAt("Compiled " __DATE__ " "__TIME__, xCenter, ((FACTOR_ANY_COMP * ySize) >> SCREEN_DIV) + DIST_ANY_COMP); // // Version // GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_FontSouvenir18); strcat(acVersion, GUI_GetVersionString()); GUI_DispStringHCenterAt(acVersion, xCenter, (FACTOR_VERSION * ySize) >> SCREEN_DIV); // // Logo // GUI_DrawBitmap(&bmSeggerLogo, (xSize - bmSeggerLogo.XSize) >> 1, (FACTOR_LOGO * ySize) >> SCREEN_DIV); // // www.segger.com // GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_FontRounded22); GUI_DispStringHCenterAt("www.segger.com", xCenter, (FACTOR_WWW * ySize) >> SCREEN_DIV); GUIDEMO_Delay(5000); }
/********************************************************************* * * _DemoVScreen */ static void _DemoVScreen(void) { GUI_RECT Rect; unsigned j; int xSize; int ySize; int n; int aDelay[] = { 20, 5 }; xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); GUI_SetFont(&GUI_FontComic24B_ASCII); GUI_SetTextMode(GUI_TM_TRANS); Rect.x0 = 0; Rect.y0 = 0; Rect.x1 = xSize - 1; Rect.y1 = ySize - 1; GUI_SetColor(GUI_WHITE); GUI_DispStringInRect("Default screen", &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER); GUI_Delay(250); Rect.y0 += ySize; Rect.y1 += ySize; GUI_DrawGradientV(Rect.x0, Rect.y0, Rect.x1, Rect.y1, 0xFFFFFF, 0x000000); Rect.y1 -= ySize / 3; GUI_SetColor(GUI_DARKGREEN); GUI_DispStringInRect("Here is the virtual screen", &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER); n = ySize / 5; for (j = 0; j < GUI_COUNTOF(aDelay); j++) { if (_Loop(0, 5, n, aDelay[j]) == 1) { return; } GUI_SetOrg(0, ySize); GUI_Delay(250); if (_Loop(ySize, -5, n, aDelay[j]) == 1) { return; } GUI_SetOrg(0, 0); GUI_Delay(250); if (GUIDEMO_CheckCancel()) { return; } } for (j = 0; j < 5; j++) { GUI_SetOrg(0, ySize); GUI_Delay(200); GUI_SetOrg(0, 0); GUI_Delay(200); if (GUIDEMO_CheckCancel()) { return; } } GUIDEMO_Delay(1000); }
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) { // // 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(); }
/********************************************************************* * * GUIDEMO_Intro * ********************************************************************** */ void GUIDEMO_Intro(void) { char acVersion[30] = "Version of STemWin: "; int xCenter, xSize, ySize; xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); xCenter = xSize >> 1; GUIDEMO_DrawBk(0); GUI_SetTextMode(GUI_TM_TRANS); // // emWin // GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_FontRounded22); GUI_DispStringHCenterAt("STemWin", xCenter, (FACTOR_EMWIN * ySize) >> SCREEN_DIV); // // emWin description // GUI_SetFont(&GUI_Font16_ASCII); GUI_DispStringHCenterAt("Universal graphic software\nfor embedded applications", xCenter, (FACTOR_DESC * ySize) >> SCREEN_DIV); // // Any text // GUI_SetColor(0x2288ff); GUI_DispStringHCenterAt("For STM32 MCU Products - Cortex M3 - Cortex M4", xCenter, (FACTOR_ANY_COMP * ySize) >> SCREEN_DIV); // // Compiled // GUI_SetFont(&GUI_Font10S_ASCII); GUI_DispStringHCenterAt("Compiled " __DATE__ " "__TIME__, xCenter, ((FACTOR_ANY_COMP * ySize) >> SCREEN_DIV) + DIST_ANY_COMP); // // Version // GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font16_ASCII); strcat(acVersion, GUI_GetVersionString()); GUI_DispStringHCenterAt(acVersion, xCenter, (FACTOR_VERSION * ySize) >> SCREEN_DIV); // // Logo // GUI_DrawBitmap(&bmSTLogo, (xSize - bmSeggerLogo.XSize) >> 1, (FACTOR_LOGO * ySize) >> SCREEN_DIV); // // www.segger.com // GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_FontRounded22); GUI_DispStringHCenterAt("www.st.com/stm32", xCenter, (FACTOR_WWW * ySize) >> SCREEN_DIV); GUIDEMO_Delay(5000); }
static void _DemoSineWave(void) { PARAM Param; I16 * pStart; int t0, Cnt = 0; GUI_HMEM hMem; GUI_RECT Rect; Rect.x0 = 19; Rect.y0 = (LCD_GetYSize() - 20) - _YSize; Rect.x1 = LCD_GetXSize() - 2; Rect.y1 = LCD_GetYSize() - 21; hMem = GUI_ALLOC_AllocZero((LCD_GetXSize() + 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_GetXSize() + 90); _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_ALLOC_Free(hMem); }
void GUIDEMO_Touch(void) { #define ID_KEYBOARD 1 #define ID_TESTCAL 2 #define ID_CALIBRATE 3 int i, r; int XSize = LCD_GetXSize(); int YSize = LCD_GetYSize(); int XMid = XSize / 2; int YMid = YSize / 2; //GUIDEMO_NotifyStartNext(); GUIDEMO_HideInfoWin(); do { GUI_RECT rText;/*= {0, 80, XSize, 120};*/ BUTTON_Handle ahButton[3]; rText.x0=0; rText.y0=50; rText.x1=XSize; rText.y1=90; GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUI_DrawBitmap(&bmMicriumLogo, (XSize - 1 - bmMicriumLogo.XSize) / 2, 15); GUI_SetFont(&GUI_Font16B_1); GUI_DispStringInRect("µC/GUI Touch screen demo", &rText, GUI_TA_HCENTER | GUI_TA_VCENTER); ahButton[0] = BUTTON_Create( XMid - 50, YMid - 30, 100, 50, ID_CALIBRATE,BUTTON_CF_SHOW ); ahButton[1] = BUTTON_Create( XMid - 90, YMid + 30, 80, 30, ID_KEYBOARD, BUTTON_CF_SHOW ); ahButton[2] = BUTTON_Create( XMid + 10, YMid + 30, 80, 30, ID_TESTCAL,BUTTON_CF_SHOW ); BUTTON_SetText (ahButton[0], "Calibrate"); BUTTON_SetBkColor(ahButton[0], 0, GUI_RED); BUTTON_SetText (ahButton[1], "Keyboard"); BUTTON_SetText (ahButton[2], "Test calibration"); BUTTON_SetFont(ahButton[0], &GUI_FontComic18B_ASCII); r = GUIDEMO_WaitKey(); if (r==0) { r = ID_KEYBOARD; BUTTON_SetState(ahButton[1],BUTTON_STATE_PRESSED); GUIDEMO_Delay(500); } for (i=0; i< countof(ahButton); i++) { BUTTON_Delete(ahButton[i]); } switch (r) { case ID_KEYBOARD: init_uart0(); send_press_key(); break; case ID_CALIBRATE: _ExecCalibration(); break; case ID_TESTCAL: _TestCalibration(); break; } } while (r && (r!='n') && (r!='N')); }
void MainTask(void) { int XSize, YSize; #if GUI_SUPPORT_MEMDEV WM_SetCreateFlags(WM_CF_MEMDEV); #endif GUI_Init(); XSize = LCD_GetXSize(); YSize = LCD_GetYSize(); GUI_DrawBitmap(&bmLogoBitmap, (XSize - bmLogoBitmap.XSize) / 2, (YSize - bmLogoBitmap.YSize) / 3); GUI_SetFont(&GUI_Font24B_ASCII); GUI_DispStringHCenterAt("www.segger.com", XSize / 2, (YSize - bmLogoBitmap.YSize) / 3 + bmLogoBitmap.YSize + 10); GUI_Delay(1000); WM_SetDesktopColor(GUI_BLACK); /* Not required since desktop is not visible */ GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0); }
/********************************************************************* * * GUIDEMO_VScreen */ void GUIDEMO_VScreen(void) { int ySize, vySize; ySize = LCD_GetYSize(); vySize = LCD_GetVYSize(); if (vySize < (ySize << 1)) { return; } GUIDEMO_ShowIntro("VScreen demo", "Demonstrates how to use\n" "virtual screens"); GUIDEMO_DrawBk(1); _DemoVScreen(); GUI_SetOrg(0, 0); }
/********************************************************************* * * GUIDEMO_VScreen */ void GUIDEMO_VScreen(void) { int vySize; int ySize; ySize = LCD_GetYSize(); vySize = LCD_GetVYSize(); if (vySize < (ySize * 2)) { GUIDEMO_ConfigureDemo("Virtual Screen", "Works only with a virtual screen with at least twice the ySize of the display.\nDemo will be skipped...", GUIDEMO_SHOW_CURSOR | GUIDEMO_SHOW_INFO | GUIDEMO_SHOW_CONTROL); return; } GUIDEMO_ConfigureDemo("Virtual Screen", "Demonstrates how to use\nvirtual screens", GUIDEMO_SHOW_CURSOR | GUIDEMO_SHOW_INFO | GUIDEMO_SHOW_CONTROL); GUIDEMO_DrawBk(); _DemoVScreen(); GUI_SetOrg(0, 0); }
/********************************************************************* * * _cbBkWindow */ static void _cbBkWindow(WM_MESSAGE * pMsg) { int xPos, yPos; xPos = LCD_GetXSize() / 2 - bmSeggerLogoBlue.XSize/2; yPos = LCD_GetYSize() / 2 - bmSeggerLogoBlue.YSize/2 ; switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("DIALOG_SliderColor - Sample", 160, 5); GUI_DrawBitmap(&bmSeggerLogoBlue, xPos, yPos ); default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _cbBk */ static void _cbBk(WM_MESSAGE * pMsg) { int xSize, ySize; switch (pMsg->MsgId) { case WM_PAINT: xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); GUI_DrawGradientV(0, 0, xSize, ySize, GUI_BLUE, GUI_BLACK); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_SetTextMode(GUI_TM_TRANS); GUI_DispStringHCenterAt("WIDGET_Spinbox - Sample", 160, 5); break; default: WM_DefaultProc(pMsg); } }
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); } }
/********************************************************************* * * _GetPixelsPerSecond */ static U32 _GetPixelsPerSecond(void) { GUI_COLOR BkColor; GUI_COLOR Color; I32 PixelsPerSecond; I32 PixelCnt; I32 t0; I32 t; U32 xSize; U32 ySize; U32 Cnt; U32 x0; U32 x1; U32 y0; U32 y1; // // 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 = GUIDEMO_GetTime(); do { GUI_FillRect(x0, y0, x1, y1); Cnt++; t = GUIDEMO_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; }