void GUIDEMO_Intro(void) { int xCenter = LCD_GET_XSIZE() / 2; int y; char acText[50] = "Version of uC/GUI: "; strcat(acText, GUI_GetVersionString()); GUI_SetBkColor(GUI_BLUE); GUI_SetColor(GUI_LIGHTRED); GUI_Clear(); GUI_SetFont(&GUI_Font24B_1); GUI_DispStringHCenterAt("uC/GUI", xCenter, y= 15); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font13H_ASCII); GUI_DispStringHCenterAt("Universal graphic software" "\nfor embedded applications" , xCenter, y += 30); GUI_SetColor(GUI_LIGHTRED); GUI_SetFont(&GUI_Font16_ASCII); GUI_DispStringHCenterAt("Any CPU - Any LCD - Any Application" , xCenter, y += 40); GUI_SetFont(&GUI_Font10S_ASCII); GUI_DispStringHCenterAt("Compiled " __DATE__ " "__TIME__, xCenter, y += 25); GUI_SetFont(&GUI_Font13HB_1); GUI_SetColor(GUI_WHITE); GUI_DispStringHCenterAt(acText, xCenter, y += 21); GUI_SetFont(&GUI_FontComic18B_1); GUI_SetColor(GUI_WHITE); GUI_DispStringHCenterAt("www.micrium.com", LCD_GET_XSIZE() / 2, LCD_GET_YSIZE() - 40); GUI_DrawBitmap(&bmMicriumLogo, (LCD_GET_XSIZE() - bmMicriumLogo.XSize) / 2, 150); GUI_SetFont(&GUI_Font10S_ASCII); GUI_DispStringAt("GUI_OS: ", 0,210); GUI_DispDecMin(GUI_OS); GUI_DispStringAt("GUI_ALLOC_SIZE: ",0, 220); GUI_DispDecMin(GUI_ALLOC_SIZE); GUI_DispStringAt("Compiler: " #ifdef _MSC_VER "Microsoft" #elif defined (NC308) "Mitsubishi NC308" #elif defined (NC30) "Mitsubishi NC30" #elif defined (__TID__) #if (((__TID__ >>8) &0x7f) == 48) /* IAR MC80 */ "IAR M32C" #elif (((__TID__ >>8) &0x7f) == 85) /* IAR V850 */ "IAR V850" #else /* IAR MC16 */ "IAR M32C" #endif #else "Unknown" #endif ,0, 230); GUIDEMO_Delay(5000); }
static void _cbCmdWin(WM_MESSAGE* pMsg) { switch (pMsg->MsgId) { case WM_PAINT: /* Update info in command window */ GUI_SetBkColor(GUI_GRAY); GUI_Clear(); GUI_DispStringAt("Demo ", 0, 0); GUI_DispDecMin(_iTest + 1); GUI_DispString("."); GUI_DispDecMin(_iTestMinor); GUI_DispString("/"); GUI_DispDecMin(countof(_apfTest)); default: WM_DefaultProc(pMsg); } }
static void _UpdateCmdWin(void) { #if GUI_WINSUPPORT && GUIDEMO_LARGE /* Update info in command window */ WM_HWIN hWin; GUI_CONTEXT ContextOld; GUI_SaveContext(&ContextOld); hWin = WM_SelectWindow(_ahInfoWin[1]); GUI_SetDefault(); GUI_SetBkColor(GUI_GRAY); GUI_Clear(); GUI_DispStringAt("Demo ", 0, 0); GUI_DispDecMin(_iTest + 1); GUI_DispString("."); GUI_DispDecMin(_iTestMinor); GUI_DispString("/"); GUI_DispDecMin(countof(_apfTest)); WM_SelectWindow(hWin); GUI_RestoreContext(&ContextOld); #endif }
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(); }
/* ******************************************************************* * * main() * ******************************************************************* */ void MainTask_test(void) { int Cnt =0; int i,YPos; int LCDXSize = LCD_GET_XSIZE(); int LCDYSize = LCD_GET_YSIZE(); const GUI_BITMAP *pBitmap; GUI_Init(); GUI_SetBkColor(GUI_RED); GUI_Clear(); GUI_Delay(1000); GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUI_Delay(1000); GUI_SetColor(GUI_WHITE); for (i=0; i<1000; i+=10) { GUI_DrawHLine(i,0,100); GUI_DispStringAt("Line ",0,i); GUI_DispDecMin(i); } GUI_Delay(1000); GUI_SetColor(0x0); GUI_SetBkColor(0xffffff); for (i=0; i<160; i++) { int len = (i<80) ? i : 160-i; GUI_DrawHLine(i,20,len+20); } GUI_Delay(1000); GUI_Clear(); if (LCD_GET_YSIZE()>(100+bmMicriumLogo_1bpp.YSize)) { pBitmap=&bmMicriumLogo; } else { GUI_SetColor(GUI_BLUE); pBitmap=&bmMicriumLogo_1bpp; } GUI_DrawBitmap(pBitmap,(LCDXSize-pBitmap->XSize)/2,10); YPos=20+pBitmap->YSize; GUI_SetFont(&GUI_FontComic24B_1); GUI_DispStringHCenterAt("www.micrium.com",LCDXSize/2,YPos); GUI_Delay(1000); GUI_SetColor(GUI_RED); GUI_DispStringHCenterAt("© 2004\n", LCDXSize/2,YPos+30); GUI_SetFont(&GUI_Font10S_1); GUI_DispStringHCenterAt("Micriµm Inc.",LCDXSize/2,YPos+60);; GUI_Delay(1000); }
/********************************************************************* * * _DrawLabel */ static void _DrawLabel(GUI_MEMDEV_Handle hMem, int xPos, int yPos) { GUI_MEMDEV_Handle hMemOld; int FontSizeY; int x0; int y0; int i; hMemOld = GUI_MEMDEV_Select(hMem); GUI_SetFont(&GUI_FontD9_AA4); GUI_SetTextMode(GUI_TM_TRANS); FontSizeY = GUI_GetFontSizeY(); for (i = 0; i < 5; i++) { x0 = xPos - 7; y0 = yPos + 96 - i * 20 - 7; GUI_DrawBitmap(&_bmCircleOrange_14x14, x0, y0); GUI_GotoXY(x0 + 7, y0 + 7 - FontSizeY / 2); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_SetColor(GUI_BLACK); GUI_DispDecMin((i + 1) * 2); } GUI_MEMDEV_Select(hMemOld); }
void GUIDEMO_ShowColorBar(void) { int nBars = 13; int YSize = LCD_GetYSize(); int y0 = 70; int yStep = (YSize - y0 - (YSize < 320 ? 0 : 60)) / nBars; int i; int x0 = 60; int NumColors = LCD_GetDevCap(LCD_DEVCAP_NUMCOLORS); int xsize = LCD_GetDevCap(LCD_DEVCAP_XSIZE); xsize -=x0; GUIDEMO_ShowIntro("Color bar", "uC/GUI integrated color" "\nmanagement always find the" "\nbest available color for any" "\nlogical color"); GUI_SetColor(GUI_WHITE); GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetFont(&GUI_Font8x16); GUI_DispString("Color bars\n"); GUI_SetFont(&GUI_Font8_ASCII); #ifdef LCD_CONTROLLER GUI_DispString("\nLCD_CONTROLLER: "); GUI_DispDecMin(LCD_CONTROLLER); GUI_DispString("\n"); #endif GUI_DispDecMin(LCD_BITSPERPIXEL); GUI_DispString(" bpp"); #ifdef LCD_BUSWIDTH GUI_DispString(", "); GUI_DispDecMin(LCD_BUSWIDTH); GUI_DispString(" bit bus"); #endif GUI_DispString(", "); GUI_DispDecMin(NumColors); GUI_DispString(" colors\n"); #if (LCD_FIXEDPALETTE) GUI_DispString("Fixed palette: "); GUI_DispDecMin(LCD_FIXEDPALETTE); #else GUI_DispString("(Custom)"); #endif GUI_SetFont(&GUI_Font8x8); GUI_SetColor(GUI_WHITE); GUI_DispStringAt("Red", 0, y0 + yStep); GUI_DispStringAt("Green", 0, y0 + 3 * yStep); GUI_DispStringAt("Blue", 0, y0 + 5 * yStep); GUI_DispStringAt("Grey", 0, y0 + 6 * yStep); GUI_DispStringAt("Yellow", 0, y0 + 8 * yStep); GUI_DispStringAt("Cyan", 0, y0 + 10 * yStep); GUI_DispStringAt("Magenta", 0, y0 + 12 * yStep); for (i = 0; (i < xsize) && !GUIDEMO_CheckCancel(); i++) { U16 cs = (255 * (U32)i) / xsize; U16 x = x0 + i;; /* Red */ GUI_SetColor(cs); GUI_DrawVLine(x, y0, y0 + yStep - 1); GUI_SetColor(0x0000ff + (255 - cs) * 0x10100L); GUI_DrawVLine(x, y0 + yStep, y0 + 2 * yStep - 1); /* Green */ GUI_SetColor(cs<<8); GUI_DrawVLine(x, y0 + 2 * yStep, y0 + 3 * yStep - 1); GUI_SetColor(0x00ff00 + (255 - cs) * 0x10001L); GUI_DrawVLine(x, y0 + 3 * yStep, y0 + 4 * yStep - 1); /* Blue */ GUI_SetColor(cs * 0x10000L); GUI_DrawVLine(x, y0 + 4 * yStep, y0 + 5 * yStep - 1); GUI_SetColor(0xff0000 + (255 - cs) * 0x00101L); GUI_DrawVLine(x, y0 + 5 * yStep, y0 + 6 * yStep - 1); /* Gray */ GUI_SetColor(cs * 0x10101L); GUI_DrawVLine(x, y0 + 6 * yStep, y0 + 7 * yStep - 1); /* Yellow */ GUI_SetColor(cs * 0x00101L); GUI_DrawVLine(x, y0 + 7 * yStep, y0 + 8 * yStep - 1); GUI_SetColor(0x00ffff + (255 - cs) * 0x10000L); GUI_DrawVLine(x, y0 + 8 * yStep, y0 + 9 * yStep - 1); /* Cyan */ GUI_SetColor(cs * 0x10100L); GUI_DrawVLine(x, y0 + 9 * yStep, y0 + 10 * yStep - 1); GUI_SetColor(0xffff00 + (255 - cs) * 0x00001L); GUI_DrawVLine(x, y0 + 10 * yStep, y0 + 11 * yStep - 1); /* Magenta */ GUI_SetColor(cs * 0x10001L); GUI_DrawVLine(x, y0 + 11 * yStep, y0 + 12 * yStep - 1); GUI_SetColor(0xff00ff + (255 - cs) * 0x00100L); GUI_DrawVLine(x, y0 + 12 * yStep, y0 + 13 * yStep - 1); } GUIDEMO_Wait(); }
/********************************************************************* * * _LCDBench */ static void _LCDBench(void) { GUI_POINT Point; float aPixelrateBitmap[5] = {0, 0, 0, 0, 0}; float PixelrateBigFont; float PixelrateF6x8; float FillratePPS; char * s; char ac[80]; int BitsPerPixel; int xSizeString; int ySizeFont; int NumColors; int MirrorX; int MirrorY; int SwapXY; int xSize; int ySize; BitsPerPixel = LCD_GetBitsPerPixelEx(0); xSize = LCD_GetXSizeEx(0); ySize = LCD_GetYSizeEx(0); MirrorX = LCD_GetMirrorXEx(0); MirrorY = LCD_GetMirrorYEx(0); SwapXY = LCD_GetSwapXYEx(0); NumColors = (1 << BitsPerPixel); _InitXbppDDP(); // // Say hi ! // GUI_X_Log("\nLCD driver benchmark. All values are \xb5""s/pixel"); GUI_X_Log("\nLower values are better."); GUI_SetBkColor(GUI_RED); GUI_SetColor(GUI_WHITE); GUI_Clear(); GUI_SetFont(&GUI_FontComic18B_1); GUI_DispStringHCenterAt("LCD driver", xSize / 2, ySize / 3 - 10); GUI_DispStringHCenterAt("Benchmark" , xSize / 2, ySize / 3 + 20); GUI_Delay(1000); GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetLBorder(1); // // Log color depth, controller, orientation and cache // sprintf(ac, "\nColor depth: %d", BitsPerPixel); GUI_X_Log(ac); sprintf(ac, "\nOrientation: LCD_MIRROR_X = %d, LCD_MIRROR_Y = %d, LCD_SWAP_XY = %d", MirrorX, MirrorY, SwapXY); GUI_X_Log(ac); // // Measure filling // Point.x = xSize; Point.y = ySize; FillratePPS = _Measure(&_ExecFill, &Point) * (float)(2 * ((U32)xSize - 4) * ((U32)ySize - 4)); sprintf(ac, "\nFill: %f", (float)1E6 / FillratePPS); GUI_X_Log(ac); // // Measure small font // GUI_SetFont(&GUI_Font6x8); s = _acSmall; xSizeString = GUI_GetStringDistX(s); ySizeFont = GUI_GetFontSizeY(); PixelrateF6x8 = _Measure(&_ExecSmallFont, s) * (float)2 * xSizeString * ySizeFont * 8; sprintf(ac, "\nF6x8: %f", (float)1E6 / PixelrateF6x8); GUI_X_Log(ac); // // Measure big font // GUI_SetFont(&GUI_FontComic18B_ASCII); s = _acBig; xSizeString = GUI_GetStringDistX(s); ySizeFont = GUI_GetFontSizeY(); PixelrateBigFont = _Measure(&_ExecBigFont, s) * (float)2 * xSizeString * ySizeFont * 2; sprintf(ac, "\nFBig: %f", (float)1E6 / PixelrateBigFont); GUI_X_Log(ac); // // Measure 1bpp bitmap // aPixelrateBitmap[0] = _Measure(&_Exec1bpp, NULL) * (float)2 * _bm_1bpp_58x8.XSize * 8; sprintf(ac, "\n1bpp: %f", (float)1E6 / aPixelrateBitmap[0]); GUI_X_Log(ac); // // Measure 2bpp bitmap // aPixelrateBitmap[1] = _Measure(&_Exec2bpp, NULL) * (float)2 * _bm_2bpp_32x11.XSize * 11; sprintf(ac, "\n2bpp: %f", (float)1E6 / aPixelrateBitmap[1]); GUI_X_Log(ac); // // Measure 4bpp bitmap // aPixelrateBitmap[2] = _Measure(&_Exec4bpp, NULL) * (float)2 * _bm_4bpp_32x11.XSize * 11; sprintf(ac, "\n4bpp: %f", (float)1E6 / aPixelrateBitmap[2]); GUI_X_Log(ac); // // Measure 8bpp bitmap // aPixelrateBitmap[3] = _Measure(&_Exec8bpp, NULL) * (float)2 * _bm_8bpp_32x11.XSize * 11; sprintf(ac, "\n8bpp: %f", (float)1E6 / aPixelrateBitmap[3]); GUI_X_Log(ac); // // Measure device dependent bitmap // aPixelrateBitmap[4] = _Measure(&_ExecXbppDDP, NULL) * (float)2 * XSIZE_XBPP * YSIZE_XBPP; sprintf(ac, "\nXDDP: %f", (float)1E6 / aPixelrateBitmap[4]); GUI_X_Log(ac); // // Show results on display // GUI_Clear(); if (xSize < 320) { GUI_SetFont(&GUI_Font6x8); } else { GUI_SetFont(&GUI_Font8x16); } GUI_GotoXY(0, 0); GUI_DispDecMin(BitsPerPixel); GUI_DispString(" bpp, "); GUI_DispDecMin(NumColors); GUI_DispString(" colors\n\nMIRROR_X "); GUI_DispDecMin(MirrorX); GUI_DispString(", MIRROR_Y "); GUI_DispDecMin(MirrorY); GUI_DispString(", SWAPXY "); GUI_DispDecMin(SwapXY); GUI_SetLBorder(1); GUI_SetFont(&GUI_Font6x8); GUI_DispChar('\n'); _DispFillrate("\nFill: ", FillratePPS, " Fill"); _DispFillrate("\nF6x8: ", PixelrateF6x8, " F6x8"); _DispFillrate("\nFBig: ", PixelrateBigFont, " FComic18"); _DispFillrate("\n1bpp: ", aPixelrateBitmap[0], " Bitmap 1bpp"); _DispFillrate("\n2bpp: ", aPixelrateBitmap[1], " Bitmap 2bpp"); _DispFillrate("\n4bpp: ", aPixelrateBitmap[2], " Bitmap 4bpp"); _DispFillrate("\n8bpp: ", aPixelrateBitmap[3], " Bitmap 8bpp"); _DispFillrate("\nXDDP: ", aPixelrateBitmap[4], " 8/16bppDDP"); }
void GUIDEMO_ColorBar(void) { int nBars = 13; int NumColors = LCD_GetDevCap(LCD_DEVCAP_NUMCOLORS); int XSize = LCD_GetXSize(); int i, yStep, y0, x0; int lcd_ysize; int BitsPerPixel; lcd_ysize = LCD_GetYSize(); y0 = 70; x0 = 60; GUIDEMO_ShowIntro("Color bar", "emWin features " "\nan integrated color" "\nmanagement" "\nwill always find the best available color" "\nfor any logical color"); XSize -= x0; yStep = (lcd_ysize - y0 - 60) / nBars; GUI_SetColor(GUI_WHITE); GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetFont(&GUI_Font8x16); GUI_DispString("Color bars\n"); GUI_SetFont(&GUI_Font8_ASCII); #ifdef LCD_CONTROLLER GUI_DispString("\nLCD_CONTROLLER: "); GUI_DispDecMin(LCD_CONTROLLER); GUI_DispString("\n"); #endif BitsPerPixel = LCD_GetBitsPerPixel(); GUI_DispDecMin(BitsPerPixel); GUI_DispString(" bpp"); #ifdef LCD_BUSWIDTH GUI_DispString(", "); GUI_DispDecMin(LCD_BUSWIDTH); GUI_DispString(" bit bus"); #endif GUI_DispString(", "); GUI_DispDecMin(NumColors); GUI_DispString(" colors\n"); GUI_SetFont(&GUI_Font8x8); GUI_SetColor(GUI_WHITE); GUI_DispStringAt("Red", 0, y0 + yStep); GUI_DispStringAt("Green", 0, y0 + 3 * yStep); GUI_DispStringAt("Blue", 0, y0 + 5 * yStep); GUI_DispStringAt("Grey", 0, y0 + 6 * yStep); GUI_DispStringAt("Yellow", 0, y0 + 8 * yStep); GUI_DispStringAt("Cyan", 0, y0 + 10 * yStep); GUI_DispStringAt("Magenta", 0, y0 + 12 * yStep); for (i = 0; (i < XSize) && !GUIDEMO_CheckCancel(); i++) { U16 cs = (255 * (U32)i) / XSize; U16 x = x0 + i;; /* Red */ GUI_SetColor(cs); GUI_DrawVLine(x, y0, y0 + yStep - 1); GUI_SetColor(0x0000ff + (255 - cs) * 0x10100L); GUI_DrawVLine(x, y0 + yStep, y0 + 2 * yStep - 1); /* Green */ GUI_SetColor(cs<<8); GUI_DrawVLine(x, y0 + 2 * yStep, y0 + 3 * yStep - 1); GUI_SetColor(0x00ff00 + (255 - cs) * 0x10001L); GUI_DrawVLine(x, y0 + 3 * yStep, y0 + 4 * yStep - 1); /* Blue */ GUI_SetColor(cs * 0x10000L); GUI_DrawVLine(x, y0 + 4 * yStep, y0 + 5 * yStep - 1); GUI_SetColor(0xff0000 + (255 - cs) * 0x00101L); GUI_DrawVLine(x, y0 + 5 * yStep, y0 + 6 * yStep - 1); /* Gray */ GUI_SetColor(cs * 0x10101L); GUI_DrawVLine(x, y0 + 6 * yStep, y0 + 7 * yStep - 1); /* Yellow */ GUI_SetColor(cs * 0x00101L); GUI_DrawVLine(x, y0 + 7 * yStep, y0 + 8 * yStep - 1); GUI_SetColor(0x00ffff + (255 - cs) * 0x10000L); GUI_DrawVLine(x, y0 + 8 * yStep, y0 + 9 * yStep - 1); /* Cyan */ GUI_SetColor(cs * 0x10100L); GUI_DrawVLine(x, y0 + 9 * yStep, y0 + 10 * yStep - 1); GUI_SetColor(0xffff00 + (255 - cs) * 0x00001L); GUI_DrawVLine(x, y0 + 10 * yStep, y0 + 11 * yStep - 1); /* Magenta */ GUI_SetColor(cs * 0x10001L); GUI_DrawVLine(x, y0 + 11 * yStep, y0 + 12 * yStep - 1); GUI_SetColor(0xff00ff + (255 - cs) * 0x00100L); GUI_DrawVLine(x, y0 + 12 * yStep, y0 + 13 * yStep - 1); } GUIDEMO_Wait(); }