/******************************************************************* * * _DemoFade */ static void _DemoFade(void) { GUI_MEMDEV_Handle hMem0, hMem1; GUI_RECT Rect = {0}; int x, y, v = 0, vz = 4; int xSize, ySize; xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); hMem0 = GUI_MEMDEV_CreateFixed(0, 0, 138, 65, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUICC_888); /* Contains the text */ hMem1 = GUI_MEMDEV_CreateFixed(0, 0, 138, 65, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUICC_888); /* Contains the bitmap */ x = (xSize - _bmSeggerLogoBlue.XSize) / 2; y = (ySize - _bmSeggerLogoBlue.YSize) / 3 * 2; Rect.x1 = _bmSeggerLogoBlue.XSize - 1; Rect.y1 = _bmSeggerLogoBlue.YSize - 1; /* Fill memory device with some text */ GUI_MEMDEV_Select(hMem0); GUI_SetColor(GUI_RED); GUI_SetFont(&GUI_Font32B_ASCII); GUI_SetTextMode(GUI_TM_TRANS); GUI_DispStringInRect("Fade in", &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER); GUI_DrawRectEx(&Rect); /* Fill memory device with bitmap */ GUI_MEMDEV_Select(hMem1); GUI_DrawBitmap(&_bmSeggerLogoBlue, 0, 0); /* Set device positions */ GUI_MEMDEV_SetOrg(hMem0, x, y); GUI_MEMDEV_SetOrg(hMem1, x, y); GUI_MEMDEV_Select(0); /* Fading loop */ while (1) { GUI_MEMDEV_FadeDevices(hMem0, hMem1, 1000); GUI_MEMDEV_FadeDevices(hMem1, hMem0, 1000); } }
/********************************************************************* * * _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_MEMDEV_Handle hMem; GUI_Init(); _Explain(); /* Explain the sample */ GUI_SetFont(&GUI_Font16B_ASCII); GUI_SetColor(GUI_WHITE); GUI_DispStringAt("Screen output:", 5, 59); _Draw(); /* Draw "Preview" on the screen */ /* Create and select a memory device with 1bpp color conversion (B/W) */ hMem = GUI_MEMDEV_CreateFixed(0, 75, 320, 64, 0, GUI_MEMDEV_APILIST_1, /* Used API list */ GUI_COLOR_CONV_1); /* Black/white color conversion */ GUI_MEMDEV_Select(hMem); _Draw(); /* Call the same routine as before for drawing into memory device */ GUI_MEMDEV_Select(0); /* Switch back from memory device to the display */ GUI_SetFont(&GUI_Font16B_ASCII); GUI_SetColor(GUI_WHITE); GUI_DispStringAt("Printer output:", 5, 154); _SendToPrinter(hMem, 170); /* Cleanup, end-of sample */ GUI_MEMDEV_Delete(hMem); while(1) { GUI_Exec(); } }
int main(void) { GUI_MEMDEV_Handle hMem0,hMem1; SysTick_Config(180000); SDRAM_Init(); LCD_Config(); GUI_Init(); GUI_SetFont(&GUI_Font32B_ASCII); GUI_SetBkColor(GUI_BLUE); GUI_SetColor(GUI_YELLOW); GUI_Clear(); // GUI_DispStringAt("blacklight",0,100); // GUIDEMO_Main(); hMem0 = GUI_MEMDEV_CreateFixed(0,0,100,50,GUI_MEMDEV_NOTRANS,GUI_MEMDEV_APILIST_32,GUI_COLOR_CONV_888); hMem1 = GUI_MEMDEV_CreateFixed(0,0,100,50,GUI_MEMDEV_NOTRANS,GUI_MEMDEV_APILIST_32,GUI_COLOR_CONV_888); GUI_MEMDEV_Select(hMem0); GUI_Clear(); GUI_DispString("Text"); GUI_MEMDEV_CopyToLCDAt(hMem0,0,0); while(1) { GUI_MEMDEV_Select(hMem1); GUI_MEMDEV_DrawPerspectiveX(hMem0,0,0,50,50-50*i/100,100-100*i/100,25*i/100); GUI_MEMDEV_CopyToLCDAt(hMem1,i,50+i); GUI_Delay(10); GUI_MEMDEV_Select(hMem1); GUI_Clear(); GUI_MEMDEV_CopyToLCDAt(hMem1,i,50+i); i+=1; if(i>100) { i=0; } } while(1); }
/********************************************************************* * * MainTask */ void MainTask(void) { WM_HWIN hWin; GUI_MEMDEV_Handle hMemWin; // Memory device to be used in window GUI_MEMDEV_Handle hMemDraw; // Memory device for drawing operation U32 * pDataWin; U32 * pDataDraw; int i, yPos, Cnt, xSizeWindow, ySizeWindow, xPosWindow, yPosWindow, xSizeDisplay, ySizeDisplay; GUI_RECT Rect; xSizeDisplay = LCD_GetXSize(); ySizeDisplay = LCD_GetYSize(); xSizeWindow = 100; ySizeWindow = 100; xPosWindow = (xSizeDisplay - xSizeWindow) / 2; yPosWindow = (ySizeDisplay - ySizeWindow) / 2; Cnt = 0; Rect.y0 = 0; Rect.y1 = ySizeWindow - 1; WM_SetCreateFlags(WM_CF_MEMDEV); GUI_Init(); WM_SetCallback(WM_HBKWIN, _cbBk); // // Create window // hWin = WINDOW_CreateUser(xPosWindow, yPosWindow, xSizeWindow, ySizeWindow, 0, WM_CF_SHOW, 0, 0, _cbWin, sizeof(hMemWin)); // // Create a memory device for the window // hMemWin = GUI_MEMDEV_CreateFixed(0, 0, 100, 100, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUICC_8888); // // Attach memory device to window data // WINDOW_SetUserData(hWin, &hMemWin, sizeof(hMemWin)); // // Create small memory device for drawing one line of gradient data // representing the real data to be used // hMemDraw = GUI_MEMDEV_CreateFixed(xPosWindow, yPosWindow, 1, ySizeWindow, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUICC_8888); // // Initialize random value // yPos = rand() % ySizeWindow; while (1) { // // Create some data to be added to the windows memory device // GUI_MEMDEV_Select(hMemDraw); GUI_DrawGradientV(xPosWindow, yPosWindow, xPosWindow, yPosWindow + yPos, GUI_RED, GUI_YELLOW); GUI_MEMDEV_Select(0); // // Get data pointers immediately before accessing data // pDataWin = GUI_MEMDEV_GetDataPtr(hMemWin); pDataDraw = GUI_MEMDEV_GetDataPtr(hMemDraw); // // Initially clear memory device // if (Cnt == 0) { memset(pDataWin, 0, sizeof(U32) * xSizeWindow * ySizeWindow); WM_InvalidateWindow(hWin); } // // Copy data from drawing device into windows memory device // for (i = 0, pDataWin += xSizeWindow * (ySizeWindow - 1) + Cnt; i <= yPos; i++, pDataWin -= xSizeWindow, pDataDraw++) { *pDataWin = *pDataDraw; } // // Optimized invalidating, only the new line will be drawn // Rect.x0 = Rect.x1 = Cnt; WM_InvalidateRect(hWin, &Rect); // // Increment counter // Cnt++; Cnt = (Cnt >= 100) ? 0 : Cnt; // // Modify random value // yPos += (rand() % 5) - 2; yPos = (yPos < 0) ? 0 : (yPos >= ySizeWindow) ? ySizeWindow - 1 : yPos; // // Wait a while and redraw window // GUI_Delay(50); } }