/********************************************************************* * * GUI_Init * * Purpose: * Init of GUI internal data structures & variables */ int GUI_Init(void) { int r; GUI_DEBUG_LOG("\nGUI_Init()"); /* Init system wide globals first */ GUI_DecChar = '.'; GUI_X_Init(); /* Init context */ _InitContext(&GUI_Context); GUITASK_INIT(); r = LCD_Init(); #if GUI_WINSUPPORT WM_Init(); #endif GUITASK_COPY_CONTEXT(); #if defined(GUI_TRIAL_VERSION) #if GUI_TRIAL_VERSION GUI_DispString( "This software\n" "contains an eval-\n" "uC/GUI build.\n" "\n" "A license is\n" "required to use\n" "it in a product.\n\n" "www.segger.com\n"); GUI_GotoXY(0, 0); GUI_X_Delay(1000); GUI_Clear(); #endif #endif return r; }
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); } }
/********************************************************************* * * 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); } }
/******************************************************************** * * _InitController * * Purpose: * Initializes the LCD controller * */ static void _InitController(void) { _SetReg(_PWR_CTRL_1, 0x0628); _SetReg(_PWR_CTRL_3, 0x0006); _SetReg(_PWR_CTRL_4, 0x0A32); _SetReg(_PWR_CTRL_2, 0x0040); _SetReg(_REGULATOR_CTRL, 0x0050); _SetReg(_PWR_CTRL_3, 0x0016); GUI_X_Delay(15); _SetReg(_PWR_CTRL_1, 0x5660); GUI_X_Delay(15); _SetReg(_PWR_CTRL_4, 0x2A4E); _SetReg(_DRVR_OUT_CTRL, 0x0100); _SetReg(_LCD_WAVE_CTRL, 0x0300); _SetReg(_ENTRY_MODE, 0x1038); _SetReg(_DISPLAY_CTRL_2, 0x0202); _SetReg(_DISPLAY_CTRL_4, 0x0000); _SetReg(_GAMMA_CTRL_1, 0x0000); _SetReg(_GAMMA_CTRL_2, 0x0402); _SetReg(_GAMMA_CTRL_3, 0x0106); _SetReg(_GAMMA_CTRL_4, 0x0700); _SetReg(_GAMMA_CTRL_5, 0x0104); _SetReg(_GAMMA_CTRL_6, 0x0301); _SetReg(_GAMMA_CTRL_7, 0x0707); _SetReg(_GAMMA_CTRL_8, 0x0305); _SetReg(_GAMMA_CTRL_9, 0x0208); _SetReg(_GAMMA_CTRL_10, 0x0F0B); GUI_X_Delay(15); _SetReg(_EPROM_CTRL_REG_2, 0x0002); _SetReg(_DRVR_OUT_CTRL_X, 0x2700); _SetReg(_BASE_IMG_DIS_CTRL, 0x0001); _SetReg(_PANEL_INTERFACE_CTRL_1, 0x0119); _SetReg(_PANEL_INTERFACE_CTRL_2, 0x010A); _SetReg(_PANEL_INTERFACE_CTRL_3, 0x0004); _SetReg(_TEST_REG_1, 0x0100); _SetReg(_DISPLAY_CTRL_1, 0x0001); GUI_X_Delay(15); _SetReg(_DISPLAY_CTRL_1, 0x0021); GUI_X_Delay(15); _SetReg(_DISPLAY_CTRL_1, 0x0023); GUI_X_Delay(15); _SetReg(_DISPLAY_CTRL_1, 0x0033); GUI_X_Delay(15); _SetReg(_DISPLAY_CTRL_1, 0x0133); GUI_X_Delay(15); _SetReg(_TEST_REG_1, 0x0000); GUI_X_Delay(20); }
/********************************************************************* * * _AnimDemo */ static void _AnimDemo(ANIM_DATA * pData) { GUI_ANIM_HANDLE hAnim; // // Create animation object // // Remark: The min time/frame here is 100 to be able to notice // the colors. In a real application this value should // be significantly smaller to ensure a smooth motion. // // Slice callback routine --------------+ // Custom *void pointer ---------+ | // Minimum time per frame --+ | | // Duration ----------+ | | | // | | | | hAnim = GUI_ANIM_Create(4000, 50, pData, _SliceInfo); // // Add animation items // // Animation routine to be called ------------------------+ // Custom *void pointer ---------------------------+ | // Method of position calculation + | | // End on timeline ---------+ | | | // Start on timeline -+ | | | | // | | | | | GUI_ANIM_AddItem(hAnim, 0, 2000, ANIM_ACCEL, pData, _AnimDrawCircle); GUI_ANIM_AddItem(hAnim, 500, 2500, ANIM_DECEL, pData, _AnimDrawRect); GUI_ANIM_AddItem(hAnim, 1000, 3000, ANIM_ACCELDECEL, pData, _AnimFillCircle); GUI_ANIM_AddItem(hAnim, 1500, 3500, ANIM_LINEAR, pData, _AnimFillRect); // // Animation item with custom defined position calculation // GUI_ANIM_AddItem(hAnim, 2000, 4000, _CalcPosition, pData, _AnimDrawCross); // // Start animation // GUI_ANIM_Start(hAnim); // // Execute animation until end is reached // while (GUI_ANIM_Exec(hAnim) == 0) { // // Idle time for other tasks // GUI_X_Delay(5); } // // Delete animation object // GUI_ANIM_Delete(hAnim); }
/********************************************************************* * * 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 }
/********************************************************************* * * _InitController * * Purpose: * Initializes the display controller */ static void _InitController(void) { #ifndef WIN32 LCD_X_8080_8_Init(); GUI_X_Delay(50); LCD_X_8080_8_Write00(0xeb); /* SET LCD BIAS RATIO: 12 */ LCD_X_8080_8_Write00(0x81); /* SET VBIAS POTENTIOMETER AND GAIN */ LCD_X_8080_8_Write00(0x90); LCD_X_8080_8_Write00(0xa6); /* SET NORMAL DISPLAY */ LCD_X_8080_8_Write00(0xd0); /* SET GRAY SCALE MODE */ LCD_X_8080_8_Write00(0xc0); /* SET LCD MAPPING CONTROL */ LCD_X_8080_8_Write00(0x04); LCD_X_8080_8_Write00(0xa3); /* SET LINE RATE */ LCD_X_8080_8_Write00(0xaf); /* SET DISPLAY ENABLE */ #endif // WIN32 }
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(); }
/********************************************************************* * * _InitController */ static void _InitController(void) { #ifndef WIN32 _WriteReg(0x060806, 0x0100); /* Software Reset register */ _WriteReg(0x060804, 0x0000); /* Power save configuration register */ _WriteReg(0x060810, 0x0000); /* PLL setting register 0 */ _WriteReg(0x060812, 0x0017); /* PLL setting register 1 */ _WriteReg(0x060814, 0x0035); /* PLL setting register 2 */ _WriteReg(0x060810, 0x0001); /* PLL setting register 0 */ GUI_X_Delay(100); _WriteReg(0x060816, 0x0005); /* Internal clock configuration register */ _WriteReg(0x060804, 0x0002); /* Power save configuraion register */ _WriteReg(0x060820, 0x004D); /* Panel setting miscellaneous register */ _WriteReg(0x060822, 0x0001); /* Display setting register */ _WriteReg(0x060824, XSIZE_PHYS >> 3); /* Horizontal display width register */ _WriteReg(0x060826, 0x0028); /* Horizontal non-display period register */ _WriteReg(0x060828, YSIZE_PHYS); /* Vertical display height register */ _WriteReg(0x06082A, 0x000A); /* Vertical no-displayperiod register */ _WriteReg(0x06082C, 0x0010); /* HS pulse width register */ _WriteReg(0x06082E, 0x0010); /* HS pulse start position register */ _WriteReg(0x060830, 0x0002); /* VS Pulse width register */ _WriteReg(0x060832, 0x0004); /* VS Pulse start position register */ _WriteReg(0x060850, 0x0000); /* PIP layer setting register */ _WriteReg(0x060852, 0x8400); /* PIP layer start address register 0 */ _WriteReg(0x060854, 0x0003); /* PIP layer start address register 1 */ _WriteReg(0x060856, 0x0028); /* PIP layer width register */ _WriteReg(0x060858, 0x0020); /* PIP layer height register */ _WriteReg(0x06085A, 0x0060); /* PIP layer X start position register */ _WriteReg(0x06085C, 0x00D0); /* PIP layer Y start position register */ _WriteReg(0x060862, 0x0040); /* Alpha blending register */ _WriteReg(0x060864, 0x0000); /* Transparency register */ _WriteReg(0x060866, 0x0000); /* Transparency key color register 0 */ _WriteReg(0x060868, 0x0000); /* Transparency key color register 1 */ _WriteReg(0x0608D0, 0x0001); /* GPIO configuration register */ _WriteReg(0x0608D2, 0x0001); /* GPIO status and control regsietr */ _WriteReg(0x0608D4, 0x0000); /* GPIO Pull-down control register */ #endif }
/* ********************************************************************************************************* * GUI_X_ExecIdle() ********************************************************************************************************* */ void GUI_X_ExecIdle (void) { GUI_X_Delay(1); }
/********************************************************************* * * MainTask */ void MainTask(void) { TREEVIEW_ITEM_Handle hNode; WM_HWIN hTree; int xSize; int ySize; int yPos; int r; int TimeStart; int TimeUsed; int ySizeText; U32 BytesFree; U32 BytesUsed; char acBuffer[(TREEVIEW_DEPTH << 1) + 1]; char acNumNodes[30] = "Nodes: "; char acNumLeaves[30] = "Leaves: "; char acNumTotal[30] = "Total: "; char acTimeUsed[30] = "Time: "; char acBytesUsed[30] = "Memory: "; // // Initialize emWin // WM_SetCreateFlags(WM_CF_MEMDEV); GUI_Init(); xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); // // Set defaults for background and widgets // WM_SetDesktopColor(GUI_BLACK); SCROLLBAR_SetDefaultSkin(SCROLLBAR_SKIN_FLEX); SCROLLBAR_SetDefaultWidth(20); SCROLLBAR_SetThumbSizeMin(25); TEXT_SetDefaultFont(GUI_FONT_6X8); // // Draw info message before creating the widgets // GUI_DrawGradientV(0, 0, xSize - 1, ySize - 1, GUI_BLUE, GUI_BLACK); GUI_SetFont(GUI_FONT_20F_ASCII); GUI_DispStringHCenterAt("Filling TREEVIEW widget...", xSize >> 1, ySize / 3); GUI_X_Delay(1000); // // Create TREEVIEW // hTree = TREEVIEW_CreateEx(0, 0, xSize, ySize, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_TREEVIEW0); TREEVIEW_SetAutoScrollV(hTree, 1);//管理自动使用垂直滚动条。 TREEVIEW_SetSelMode(hTree, TREEVIEW_SELMODE_ROW); // // Fill TREEVIEW // hNode = TREEVIEW_InsertItem(hTree, TREEVIEW_ITEM_TYPE_NODE, 0, 0, "Tree"); BytesFree = GUI_ALLOC_GetNumFreeBytes(); TimeStart = GUI_GetTime(); r = _FillNode(hTree, hNode, NUM_CHILD_NODES, NUM_CHILD_ITEMS, TREEVIEW_DEPTH, TREEVIEW_DEPTH, acBuffer, acBuffer); TimeUsed = GUI_GetTime() - TimeStart; BytesUsed = BytesFree - GUI_ALLOC_GetNumFreeBytes(); if (r) { // // Error message // WM_DeleteWindow(hTree); GUI_MessageBox("Error", "Not enough memory available!", 0); } else { // // Show result // yPos = 20; ySizeText = GUI_GetYDistOfFont( TEXT_GetDefaultFont()) + 5; _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acNumNodes, _NumNodes); _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acNumLeaves, _NumLeaves); _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acNumTotal, _NumNodes + _NumLeaves); _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acTimeUsed, TimeUsed); _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acBytesUsed, BytesUsed); WM_SetFocus(hTree); } while (1) { GUI_Delay(100); } }
static void _InitController(void) { int j; LCD_X_SPI4_16_Init(); // // Set the Register Index for the Driver Control // _PortAPI.pfWrite16_A0(0x0001); // Command - R01h _PortAPI.pfWrite16_A1(0x0000); // Data - SHL(0), SGS(0), NL(0) // // Set the Register Index for the Polarity Control // _PortAPI.pfWrite16_A0(0x0002); // Command - R02h _PortAPI.pfWrite16_A1(0x014C); // Data - BC(1), EOR(0), NW(4C) // // Set the Register Index for the Contrast Control // _PortAPI.pfWrite16_A0(0x0005); // Command - R05h _PortAPI.pfWrite16_A1(0x0030); // Data - CT(0x30) // // Set the Register Index for the Power Control (1) // _PortAPI.pfWrite16_A0(0x0003); // Command - R03h _PortAPI.pfWrite16_A1(0x0070); // Data - VC(1), VR(1), VF(1), SLP(0), STB(0) // // Wait a while... // GUI_X_Delay(100); // // Set the Register Index for the Power Control (2) // _PortAPI.pfWrite16_A0(0x0004); // Command - R04h _PortAPI.pfWrite16_A1(0x0061); // Data - TC(0), BS(0), BT(6), VRG(1) // // Set the Register Index for the Entry Mode // _PortAPI.pfWrite16_A0(0x0006); // Command - R06h _PortAPI.pfWrite16_A1(0x0000); // Data - AM(0), ID(0) // // Set the Register Index for the Display Mode Control // _PortAPI.pfWrite16_A0(0x0023); // Command - R23h _PortAPI.pfWrite16_A1(0x0003); // Data - DSPM(3) // // Set the Register Index for the Frame Rate Control // _PortAPI.pfWrite16_A0(0x0028); // Command - R28h _PortAPI.pfWrite16_A1(0x0018); // Data - CSEL2(0), CSEL(1), CTN(0) // // Set the Register Index for power adjust // _PortAPI.pfWrite16_A0(0x0037); // Command - R37h _PortAPI.pfWrite16_A1(0x0000); // Data - VFR1(0), VFR4(0) // // Set the Register Index for the Display Control // _PortAPI.pfWrite16_A0(0x0007); // Command - R07h _PortAPI.pfWrite16_A1(0x0001); // Data - BW(0), REV(0), D(1) // // Wait a while... // GUI_X_Delay(100); // // Clear RAM // _PortAPI.pfWrite16_A0(0x0008); // Command - R08h _PortAPI.pfWrite16_A1(0x0000); // Data- AX(0), AY(0) _PortAPI.pfWrite16_A0(0x0009); // Command - R09h for (j = 0; j < 80 * 240; j++) { _PortAPI.pfWrite16_A1(0x0000); } }
/********************************************************************* * * TouchTask * * Function decription: * Handles a controller driven touch screen and uses GUI_TOUCH_StoreState() * to pass the values to emWin. Please note that multitasking for * emWin is not required at this point. */ void TouchTask(void) { static U16 xOld; static U16 yOld; static U8 PressedOld; U16 x, y, xDiff, yDiff; U8 Pressed; do { // TBD: Insert function which returns: // 1, if the touch screen is pressed // 0, if the touch screen is released // // Touch screen is pressed // if (Pressed) { x = 0; // TBD: Insert function which reads current x value y = 0; // TBD: Insert function which reads current y value // // The touch has already been pressed // if (PressedOld == 1) { // // Calculate difference between new and old position // xDiff = (x > xOld) ? (x - xOld) : (xOld - x); yDiff = (y > yOld) ? (y - yOld) : (yOld - y); // // Store state if new position differs significantly from old position // if (xDiff + yDiff > 2) { xOld = x; yOld = y; GUI_TOUCH_StoreState(x, y); } } // // The touch was previously released // Store state regardless position // else { if ((x != 0) && (y != 0)) { xOld = x; yOld = y; PressedOld = 1; GUI_TOUCH_StoreState(x, y); } } } // // Touch screen is not pressed // Store state if it was released recently // else { if (PressedOld == 1) { PressedOld = 0; GUI_TOUCH_StoreState(-1, -1); } } // // Make sure // GUI_X_Delay(20); } while (1); }