/********************************************************************* * * GUIDEMO_Delay * * This function has to be called if the current step of the sample * is the last one and consists of a single frame */ void GUIDEMO_Delay(int TimeDelay) { PROGBAR_Handle hProg; int NextState; U32 TimeStart; U32 TimeDiff; hProg = WM_GetDialogItem(_hDialogControl, GUI_ID_PROGBAR0); if (TimeDelay > SHOW_PROGBAR_AT) { _ShowProgress(); } PROGBAR_SetValue(hProg, 0); PROGBAR_SetMinMax(hProg, 0, TimeDelay); TimeStart = GUI_GetTime(); do { TimeDiff = GUIDEMO_GetTime() - TimeStart; if (TimeDelay > SHOW_PROGBAR_AT) { PROGBAR_SetValue(hProg, TimeDiff); } GUI_Delay(5); NextState = GUIDEMO_CheckCancel(); } while (TimeDiff < (U32)TimeDelay && !NextState); if (TimeDelay > SHOW_PROGBAR_AT) { _HideProgress(); } GUI_Exec(); }
int GUIDEMO_Delay(int t) { int r = 0; #if GUI_WINSUPPORT int tRem, tEnd = GUI_GetTime() + t; PROGBAR_Handle hProg; WM_SetForegroundWindow(_ahButton[0]); hProg = (t >100) ? PROGBAR_Create(_FrameWinPosX[1] + 10, _FrameWinPosY[1] + 25, _FrameWinSizeX[1] - 20, 7, WM_CF_SHOW|WM_CF_STAYONTOP) : 0; #if GUI_SUPPORT_MEMDEV PROGBAR_EnableMemdev(hProg); #endif PROGBAR_SetMinMax(hProg, 0, t); for (; tRem = tEnd - GUI_GetTime(), (tRem > 0) && !GUIDEMO_CheckCancel();) { PROGBAR_SetValue(hProg, t - tRem); WM_ExecIdle(); GUI_Delay(10); } PROGBAR_Delete(hProg); _UpdateCmdWin(); WM_ExecIdle(); #else GUI_Delay(t); #endif return r; }
int GUIDEMO_Delay(int t) { int r = 0; #if GUI_WINSUPPORT int tm, value; #if GUIDEMO_LARGE PROGBAR_Handle hProg; #endif WM_SetForegroundWindow(_ahButton[0]); #if GUIDEMO_LARGE hProg = (t >100) ? PROGBAR_CreateAsChild(10, 10, 60, 7, _ahInfoWin[1], 0, WM_CF_SHOW | WM_CF_STAYONTOP| WM_CF_MEMDEV) : 0; PROGBAR_SetMinMax(hProg, 0, t); #endif tm = GUI_GetTime(); do { value = GUI_GetTime() - tm; #if GUIDEMO_LARGE PROGBAR_SetValue(hProg, value); WM_ExecIdle(); #endif GUI_Delay(10); } while ((value < t) && !GUIDEMO_CheckCancel()); #if GUIDEMO_LARGE PROGBAR_Delete(hProg); #endif _UpdateCmdWin(); WM_ExecIdle(); #else GUI_Delay(t); #endif return r; }
/******************************************************************* * * _DemoProgBar */ static void _DemoProgBar(void) { int i; PROGBAR_Handle ahProgBar[2]; GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("WIDGET_Progbar - Sample", 160, 5); GUI_SetFont(&GUI_Font8x16); GUI_DispStringAt("Progress bar", 100,80); // // Create the progbars // ahProgBar[0] = PROGBAR_Create(100,100,100,20, WM_CF_SHOW); ahProgBar[1] = PROGBAR_Create( 80,150,140,10, WM_CF_SHOW); // // Use memory device (optional, for better looks) // PROGBAR_EnableMemdev(ahProgBar[0]); PROGBAR_EnableMemdev(ahProgBar[1]); PROGBAR_SetMinMax(ahProgBar[1], 0, 500); PROGBAR_SetFont(ahProgBar[0], &GUI_Font8x16); GUI_Delay(500); while(1) { PROGBAR_SetFont(ahProgBar[0], &GUI_Font8x16); if (LCD_GetDevCap(LCD_DEVCAP_BITSPERPIXEL) <= 4) { PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_DARKGRAY); PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_LIGHTGRAY); } else { PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_GREEN); PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_RED); } PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_HCENTER); PROGBAR_SetText(ahProgBar[0], NULL); for (i=0; i<=100; i++) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], i); GUI_Delay(5); } PROGBAR_SetText(ahProgBar[0], "Tank empty"); for (; i>=0; i--) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 200-i); GUI_Delay(5); } PROGBAR_SetText(ahProgBar[0], "Any text..."); PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_LEFT); for (; i<=100; i++) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 200+i); GUI_Delay(5); } PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_RIGHT); for (; i>=0; i--) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 400-i); GUI_Delay(5); } PROGBAR_SetFont(ahProgBar[0], &GUI_FontComic18B_1); PROGBAR_SetText(ahProgBar[0], "Any font..."); for (; i<=100; i++) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 400+i); GUI_Delay(5); } GUI_Delay(500); } }
void GUIDEMO_DemoProgBar(void) { int i, iRep; int XMid = LCD_GetXSize() / 2; int YMid = LCD_GetYSize() / 2; int Length[2] = {100, 140}; int Height[2] = {20, 10}; #if GUIDEMO_LARGE int MaxReps = 2; #else int MaxReps = 1; #endif PROGBAR_Handle ahProgBar[2]; GUIDEMO_ShowIntro("Widgets", "\nProgressbars in" "\nall variations"); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font8x16); GUI_DispStringHCenterAt("Progress bar", XMid, YMid - 40); /* Create `em */ ahProgBar[0] = PROGBAR_Create(XMid - Length[0] / 2, YMid - 15, Length[0], Height[0], WM_CF_SHOW); ahProgBar[1] = PROGBAR_Create(XMid - Length[1] / 2, YMid + 20, Length[1], Height[1], WM_CF_SHOW); /* Use memory device (optional, for better looks) */ #if GUI_SUPPORT_MEMDEV PROGBAR_EnableMemdev(ahProgBar[0]); PROGBAR_EnableMemdev(ahProgBar[1]); #endif GUIDEMO_Delay (1000); PROGBAR_SetMinMax(ahProgBar[1], 0, 500); for (iRep = 0; iRep < MaxReps; iRep++) { PROGBAR_SetFont(ahProgBar[0], &GUI_Font8x16); #if (LCD_BITSPERPIXEL == 2) PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_BLACK); PROGBAR_SetBarColor(ahProgBar[1], 0, GUI_BLACK); PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_LIGHTGRAY); #elif (LCD_BITSPERPIXEL <= 4) PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_DARKGRAY); PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_LIGHTGRAY); #else PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_GREEN); PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_RED); #endif for (i = 0; (i <= 100) && !GUIDEMO_CheckCancel(); i++) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], i); GUI_Delay(5); } PROGBAR_SetText(ahProgBar[0], "Tank empty"); for (; (i >= 0)&& !GUIDEMO_CheckCancel(); i--) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 200 - i); GUI_Delay(5); } PROGBAR_SetText(ahProgBar[0], "Any text ..."); PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_LEFT); for (; (i <= 100)&& !GUIDEMO_CheckCancel(); i++) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 200 + i); GUI_Delay(5); } for (; (i >= 0)&& !GUIDEMO_CheckCancel(); i--) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 400 - i); GUI_Delay(5); } PROGBAR_SetFont(ahProgBar[0], &GUI_FontComic18B_1); PROGBAR_SetText(ahProgBar[0], "Any font ..."); for (; (i <= 100)&& !GUIDEMO_CheckCancel(); i++) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 400 + i); GUI_Delay(5); } GUIDEMO_Delay(1000); } GUIDEMO_Delay(1000); PROGBAR_Delete(ahProgBar[0]); PROGBAR_Delete(ahProgBar[1]); GUIDEMO_Delay(1000); GUI_SetFont(&GUI_Font10S_ASCII); }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; // USER START (Optionally insert additional variables) // USER END switch (pMsg->MsgId) { case WM_INIT_DIALOG: { // hItem = WM_GetDialogItem(pMsg->hWin, ID_FRAMEWIN_0); //// FRAMEWIN_SetResizeable(hItem,1); // FRAMEWIN_SetFont(hItem,GUI_FONT_COMIC24B_ASCII); //// FRAMEWIN_SetMoveable(hItem,1); //// GUI_ExecCreatedDialog(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); BUTTON_SetSkin(hItem,BUTTON_SKIN_FLEX); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1); BUTTON_SetSkin(hItem,BUTTON_SKIN_FLEX); // // Initialization of 'Edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0); EDIT_SetText(hItem, "blabalbalablablaba"); // // Initialization of 'Listwheel' // hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTWHEEL_0); LISTWHEEL_SetLBorder(hItem,10); LISTWHEEL_SetFont(hItem,GUI_FONT_COMIC24B_ASCII); LISTWHEEL_AddString(hItem, "jeden"); LISTWHEEL_AddString(hItem, "dwa"); LISTWHEEL_AddString(hItem, "trzy"); LISTWHEEL_AddString(hItem, "cztery"); LISTWHEEL_AddString(hItem, "piec"); LISTWHEEL_AddString(hItem, "szesc"); LISTWHEEL_AddString(hItem, "siedem"); // // Initialization of 'Checkbox' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0); CHECKBOX_SetText(hItem, "Check"); // // Initialization of 'Checkbox' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_1); CHECKBOX_SetText(hItem, "Check"); // USER START (Optionally insert additional code for further widget initialization) // USER END hItem=WM_GetDialogItem(pMsg->hWin,ID_PROGBAR_0); PROGBAR_SetMinMax(hItem,0,15); PROGBAR_SetSkin(hItem,PROGBAR_SKIN_FLEX); break; } case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_EDIT_0: // Notifications sent by 'Edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END WM_DeleteWindow(hBox); hBox = MESSAGEBOX_Create("Keyboard not supported yet!","ERROR", GUI_MESSAGEBOX_CF_MOVEABLE); break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_0: // Notifications sent by 'Button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: { CreateMojeokno2(); hItem=WM_GetDialogItem(pMsg->hWin,ID_PROGBAR_0); PROGBAR_SetValue(hItem,il++); break; } } break; case ID_BUTTON_1: // Notifications sent by 'Button' switch(NCode) { case WM_NOTIFICATION_CLICKED: { break; } case WM_NOTIFICATION_RELEASED: { CreateGraph(); // WM_DeleteWindow(hBox); // hBox = MESSAGEBOX_Create("Release the BUTTON !","ERROR", GUI_MESSAGEBOX_CF_MOVEABLE); // WM_DeleteWindow(hBox); break; } } break; case ID_LISTWHEEL_0: // Notifications sent by 'Listwheel' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_SEL_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_0: // Notifications sent by 'Checkbox' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_1: // Notifications sent by 'Checkbox' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; // USER START (Optionally insert additional code for further Ids) // USER END } break; // USER START (Optionally insert additional message handling) // USER END default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * MainTask * ********************************************************************** */ void MainTask(void) { GUI_Init(); WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */ WM_EnableMemdev(WM_HBKWIN); WM_SetCallback(WM_HBKWIN, &_cbBkWin); GUI_SetBkColor(GUI_BLUE); GUI_SetFont(&GUI_Font16B_1); GUI_Clear(); ahButton[0] = BUTTON_Create(318-52,152,75-21, 20, GUI_ID_ADC, BUTTON_CF_SHOW ); BUTTON_SetTextColor(ahButton[0],BUTTON_CI_UNPRESSED,GUI_GREEN); BUTTON_SetFont(ahButton[0],&GUI_Font16B_1); BUTTON_SetText(ahButton[0],"Inc"); ahButton[1] = BUTTON_Create(318-52,174,75-21, 20, GUI_ID_DAC, BUTTON_CF_SHOW ); BUTTON_SetTextColor(ahButton[1],BUTTON_CI_UNPRESSED,GUI_GREEN); BUTTON_SetFont(ahButton[1],&GUI_Font16B_1); BUTTON_SetText(ahButton[1],"Dec"); ahButton[2] = BUTTON_Create(318-52,196,75-21, 20, GUI_ID_FFT, BUTTON_CF_SHOW ); BUTTON_SetTextColor(ahButton[2],BUTTON_CI_UNPRESSED,GUI_GREEN); BUTTON_SetFont(ahButton[2],&GUI_Font16B_1); BUTTON_SetText(ahButton[2],"Switch"); ahButton[3] = BUTTON_Create(318-52,218,75-21, 20, GUI_ID_Spectrum, BUTTON_CF_SHOW ); BUTTON_SetTextColor(ahButton[3],BUTTON_CI_UNPRESSED,GUI_GREEN); BUTTON_SetFont(ahButton[3],&GUI_Font16B_1); BUTTON_SetText(ahButton[3],"Spectr"); ahProgbar[0]=PROGBAR_Create(318-52,2,75-21,20,WM_CF_SHOW); PROGBAR_SetBarColor(ahProgbar[0],0,GUI_MAGENTA); PROGBAR_SetBarColor(ahProgbar[0],1,GUI_RED); PROGBAR_SetFont(ahProgbar[0],&GUI_Font16B_1); PROGBAR_SetMinMax(ahProgbar[0],0,100); WIDGET_SetEffect(ahProgbar[0], &WIDGET_Effect_3D); ahScrollbar[0]=SCROLLBAR_Create(0,11,12,217,0,GUI_ID_OSCLevel,WM_CF_SHOW,SCROLLBAR_CF_VERTICAL); SCROLLBAR_SetNumItems(ahScrollbar[0],200); SCROLLBAR_SetValue(ahScrollbar[0],100); DispButton(); DispChInfo(); ConfigRefresh=0; fRefresh =1; while(1) { if(ConfigRefresh == 0) { if (fRefresh) { fRefresh = 0; if(g_DSO.HoldEn == 1) { DispChInfo(); } } if (g_DSO.HoldEn == 0) { StopADC(); /* 暂停采样 */ DispFrame(); DispChInfo(); DispCh1Wave(); FFT_Convert(); StartADC(); /* 开始采样 */ } PROGBAR_SetValue(ahProgbar[0],OSCPUUsage); } GUI_Delay(50); } }