/********************************************************************* * * _MoveCursor */ static void _MoveCursor(){ int x, y, tm, cnt = 0; int yStep=-1; int xPos,yPos; xPos = LCD_GetXSize() / 2 - bmSeggerLogoBlue.XSize/2; yPos = LCD_GetYSize() / 2 - bmSeggerLogoBlue.YSize/2+25; GUI_DispStringHCenterAt("Cursor shape can be changed\nand the cursor can be moved", 160, 75); GUI_CURSOR_Show(); GUI_DrawBitmap(&bmSeggerLogoBlue, xPos, yPos ); y = 150; for (x = 0; x < 320; x++) { if ((x % 54) == 0) { GUI_CURSOR_Select(_apCursor[cnt++]); } tm = GUI_GetTime(); y += yStep; if(y<=80) yStep=1; if(y>=150) yStep=-1; GUI_CURSOR_SetPosition(x, y); while ((GUI_GetTime() - tm) < 10); } for (x = 320; x > 0; x--) { tm = GUI_GetTime(); if ((x % 54) == 0) { GUI_CURSOR_Select(_apCursor[cnt++]); } y += yStep; if(y<=80) yStep=1; if(y>=150) yStep=-1; GUI_CURSOR_SetPosition(x, y); while ((GUI_GetTime() - tm) < 10); } GUI_CURSOR_Hide(); GUI_Delay(500); }
/********************************************************************* * * 在触摸校正的时候使用这个来读取ADC的值 */ void Touch_MainTask(void) { GUI_CURSOR_Show(); GUI_CURSOR_Select(&GUI_CursorCrossL); GUI_SetBkColor(GUI_WHITE); GUI_SetColor(GUI_BLACK); GUI_Clear(); GUI_DispString("Measurement of\nA/D converter values"); while (1) { GUI_PID_STATE TouchState; int xPhys, yPhys; GUI_TOUCH_GetState(&TouchState); /* Get the touch position in pixel */ xPhys = GUI_TOUCH_GetxPhys(); /* Get the A/D mesurement result in x */ yPhys = GUI_TOUCH_GetyPhys(); /* Get the A/D mesurement result in y */ /* Display the measurement result */ GUI_SetColor(GUI_BLUE); GUI_DispStringAt("Analog input:\n", 0, 20); GUI_GotoY(GUI_GetDispPosY() + 2); GUI_DispString("x:"); GUI_DispDec(xPhys, 4); GUI_DispString(", y:"); GUI_DispDec(yPhys, 4); /* Display the according position */ GUI_SetColor(GUI_RED); GUI_GotoY(GUI_GetDispPosY() + 4); GUI_DispString("\nPosition:\n"); GUI_GotoY(GUI_GetDispPosY() + 2); GUI_DispString("x:"); GUI_DispDec(TouchState.x,4); GUI_DispString(", y:"); GUI_DispDec(TouchState.y,4); /* Wait a while */ GUI_Delay(100); }; }
/********************************************************************* * * MainTask */ void TOUCH_MainTask(void) { int aPhysX[2], aPhysY[2], aLogX[2], aLogY[2], i; GUI_Init(); GUI_SetBkColor(GUI_WHITE); GUI_Clear(); GUI_SetColor(GUI_BLACK); GUI_SetFont(&GUI_Font13B_ASCII); _Explain(); /* Set the logical values */ aLogX[0] = 15; aLogY[0] = 15; aLogX[1] = LCD_GetXSize() - 15; aLogY[1] = LCD_GetYSize() - 15; /* Get the physical values of the AD converter for 2 positions */ for (i = 0; i < 2; i++) { _GetPhysValues(aLogX[i], aLogY[i], &aPhysX[i], &aPhysY[i], _acPos[i]); } /* Use the physical values to calibrate the touch screen */ GUI_TOUCH_Calibrate(0, aLogX[0], aLogX[1], aPhysX[0], aPhysX[1]); /* Calibrate X-axis */ GUI_TOUCH_Calibrate(1, aLogY[0], aLogY[1], aPhysY[0], aPhysY[1]); /* Calibrate Y-axis */ /* Display the result */ GUI_CURSOR_Show(); GUI_Clear(); _DispStringCentered("Congratulation, your\n" "touch screen has been\n" "calibrated. Please use\n" "the cursor to test\n" "the calibration..."); /* Let the user play */ GUI_Delay(50); }
/* ********************************************************************************************************* * 函 数 名: MainTask * 功能说明: GUI主函数 * 形 参: 无 * 返 回 值: 无 ********************************************************************************************************* */ void MainTask(void) { int Value = 0; WM_HWIN hDlgFrame; /* 初始化 */ GUI_Init(); // TOUCH_Calibration(); GUI_CURSOR_Show(); WM_SetCallback(WM_HBKWIN, _cbBkWindow); WM_SetCreateFlags(WM_CF_MEMDEV); hDlgFrame = 0; while(1) { WM_HWIN hDlg, hText; char acText[3] = {0}; GUI_Delay(100); /* 如果对话框被关闭就重新的将其再打开 */ if (!WM_IsWindow(hDlgFrame)) { Value = 0; hDlgFrame = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0); } Value = (Value + 1) % 100; acText[0] = '0' + Value / 10; acText[1] = '0' + Value % 10; hDlg = WM_GetClientWindow(hDlgFrame); hText = WM_GetDialogItem(hDlg, GUI_ID_TEXT0); TEXT_SetText(hText, acText); } }
/********************************************************************* * * MainTask * ********************************************************************** */ void MainTask(void) { GUI_Init(); WM_EnableMemdev(WM_HBKWIN); WM_SetCreateFlags(WM_CF_MEMDEV); WM_SetCallback(WM_HBKWIN, _cbBkWindow); GUI_CURSOR_Show(); while(1) { _DemoListView(); } }
/********************************************************************* * * MainTask */ void MainTask(void) { GUI_Init(); GUI_CURSOR_Show(); WM_SetCallback(WM_HBKWIN, _cbBkWindow); WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */ while (1) { GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0); GUI_Delay(1000); } }
/********************************************************************* * * _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 }
/********************************************************************* * * MainTask */ void MainTask(void) { GUI_Init(); #if GUI_SUPPORT_MEMDEV WM_SetCreateFlags(WM_CF_MEMDEV); #endif GUI_CURSOR_Show(); WM_SetCallback(WM_HBKWIN, _cbBkWin); while(1) { _DemoMultiedit(); *_acInfoText = 0; WM_InvalidateWindow(WM_HBKWIN); GUI_Delay(SPEED); } }
void MainTask(void) { int Cnt = 0; WM_HWIN hDlg, hGraph = 0; GUI_Init(); GUI_CURSOR_Show(); WM_SetDesktopColor(GUI_BLACK); #if GUI_SUPPORT_MEMDEV WM_SetCreateFlags(WM_CF_MEMDEV); #endif hDlg = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0); while (1) { GUI_Delay(10); } }
void MainTask(void) { WM_HWIN hWin; GUI_Init(); GUI_CURSOR_Show(); WM_SetCreateFlags(WM_CF_MEMDEV); WM_EnableMemdev(WM_HBKWIN); WM_SetCallback(WM_HBKWIN, &_cbBkWindow); while (1) { hWin = GUI_CreateDialogBox(_aDialogOrder, GUI_COUNTOF(_aDialogOrder), &_cbDialogOrder, WM_HBKWIN, 0, 0); WM_MakeModal(hWin); GUI_ExecCreatedDialog(hWin); GUI_Delay(1500); } }
/******************************************************************* * * _DemoTransWindow */ static void _DemoTransWindow(void) { WM_HWIN hTransWin; WM_HWIN hFrameWin; WM_SetDesktopColor(GUI_RED); hTransWin = WM_CreateWindow(10, 10, 72, 52, WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_STAYONTOP, _cbTransWindow, 0); hFrameWin = FRAMEWIN_Create("Framewin", 0, WM_CF_SHOW, 100, 70, 120, 100); FRAMEWIN_SetActive(hFrameWin, 1); FRAMEWIN_SetMoveable(hFrameWin, 1); GUI_CURSOR_Show(); while (1) { WM_InvalidateWindow(hTransWin); GUI_Delay(20); } }
void Task3(void *Tags) { uint8 *P_SIFA,*P_SIFB; uint32 Length; WM_HWIN hWin; WM_SetCreateFlags(WM_CF_MEMDEV); hWin=CreateLogin(); Login_SetProgbar(hWin,0); Login_SetText(hWin,"Load Font..."); P_SIFA=LoadFile_ToRAM("songti16.sif"); if(P_SIFA==0){Login_SetText(hWin,"Load Font Fail!");GUI_Delay(10000);} Login_SetProgbar(hWin,50); P_SIFB=LoadFile_ToRAM("songti12.sif"); if(P_SIFB==0){Login_SetText(hWin,"Load Font Fail!");GUI_Delay(10000);} Login_SetProgbar(hWin,100); GUI_SIF_CreateFont((void*)P_SIFA, &SIFA_Font, GUI_SIF_TYPE_PROP); GUI_SIF_CreateFont((void*)P_SIFB, &SIFB_Font, GUI_SIF_TYPE_PROP); GUI_EndDialog(hWin,0); CreateWindow(); GUI_CURSOR_Show(); while(1) { // hItem=WM_GetDialogItem(hWin, ID_PROGBAR_0); // PROGBAR_SetValue(hItem, Tos_CPUInfor.Userate_CPU); // hItem=WM_GetDialogItem(hWin, ID_EDIT_0); // GetStringByFmt(&Buf[0],"%d",adc_value); // EDIT_SetText(hItem, &Buf[0]); // // CreateMywindow(); // GUI_Exec(); //// GUI_AA_SetFactor(3); //// GUI_SetColor(GUI_BLACK); //// GUI_AA_FillRoundedRect(10,10,54,54,5); //// Tos_TaskDelay(1000); //// GUI_SetColor(GUI_WHITE); //// GUI_AA_FillRoundedRect(10,10,54,54,5); //// GUI_AA_FillRoundedRect(100,100,154,154,5); //// GUI_AA_DrawLine(50,50,70,70); //// GUI_AA_DrawLine(70,50,50,70); //// GUI_DispDecAt(i++,20,20,4); // P_SIFA=LoadFile_ToRAM("c.gif"); // GUI_GIF_Draw(P_SIFA,RMema_Length(P_SIFA),0,0); GUI_Delay(10); //GUI_SendKeyMsg('a',1); } }
void GUIDEMO_Cursor(void) { int i = 0; GUIDEMO_ShowIntro("Cursor", "\nuC/GUI supports" "\nsoftware cursor"); GUI_SetBkColor(GUI_BLUE); GUI_Clear(); _DispCursor(); GUIDEMO_Delay(2000); GUIDEMO_NotifyStartNext(); GUI_CURSOR_Show(); for ( i = 0;(i < countof(_aCursor) && !GUIDEMO_CheckCancel()); i++) { _MoveCursor(_aCursor[i]); } GUI_CURSOR_SetPosition(0,0); GUI_CURSOR_Select(&GUI_CursorArrowM); }
/********************************************************************* * * MainTask */ void MainTask(void) { GUI_Init(); // // Check if recommended memory for the sample is available // if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { GUI_ErrorOut("Not enough memory available."); return; } #if GUI_SUPPORT_MEMDEV WM_SetCreateFlags(WM_CF_MEMDEV); #endif GUI_CURSOR_Show(); WM_SetCallback(WM_HBKWIN, _cbBkWin); while(1) { _DemoMultiedit(); *_acInfoText = 0; WM_InvalidateWindow(WM_HBKWIN); GUI_Delay(SPEED); } }
void MainTask(void) { WM_HWIN hItem, hDlg; GUI_Init(); #if GUI_SUPPORT_CURSOR GUI_CURSOR_Show(); #endif #if GUI_SUPPORT_MEMDEV WM_SetCreateFlags(WM_CF_MEMDEV); #endif hDlg = GUI_CreateDialogBox(_aMain, GUI_COUNTOF(_aMain), &_cbMain, 0, 0, 0); hItem = WM_GetDialogItem(hDlg, GUI_ID_TREEVIEW0); if (hItem == 0) { WM_DeleteWindow(hDlg); } else { WM_SetFocus(hItem); while (1) { GUI_Delay(100); } } }
/********************************************************************* * * MainTask */ void MainTask_TOUCHCAL(void) { int aPhysX[2], aPhysY[2], aLogX[2], aLogY[2], i; GUI_Init(); GUI_SetBkColor(GUI_WHITE); GUI_Clear(); GUI_SetColor(GUI_BLACK); GUI_SetFont(&GUI_Font13B_ASCII); _Explain(); /* Set the logical values */ aLogX[0] = 15; aLogY[0] = 15; aLogX[1] = LCD_GetXSize() - 15; aLogY[1] = LCD_GetYSize() - 15; /* Get the physical values of the AD converter for 2 positions */ for (i = 0; i < 2; i++) { _GetPhysValues(aLogX[i], aLogY[i], &aPhysX[i], &aPhysY[i], _acPos[i]); } /* Use the physical values to calibrate the touch screen */ GUI_TOUCH_Calibrate(0, aLogX[0], aLogX[1], aPhysX[0], aPhysX[1]); /* Calibrate X-axis */ //如果我们要存到外部存储器中 那么就存储这里的8个参数 GUI_TOUCH_Calibrate(1, aLogY[0], aLogY[1], aPhysY[0], aPhysY[1]); /* Calibrate Y-axis */ /* Display the result */ GUI_CURSOR_Show(); GUI_Clear(); _DispStringCentered("Congratulation, your\n" "touch screen has been\n" "calibrated. Please use\n" "the cursor to test\n" "the calibration..."); /* Let the user play */ while(1) { GUI_PID_STATE State; GUI_TOUCH_GetState(&State); if (State.Pressed == 1) { GUI_FillCircle(State.x, State.y, 3); } GUI_Delay(10); } }
void MainTask(void) { WM_HWIN hWin; GUI_Init(); // // Check if recommended memory for the sample is available // if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { GUI_ErrorOut("Not enough memory available."); return; } GUI_CURSOR_Show(); WM_SetCreateFlags(WM_CF_MEMDEV); WM_EnableMemdev(WM_HBKWIN); WM_SetCallback(WM_HBKWIN, &_cbBkWindow); while (1) { hWin = GUI_CreateDialogBox(_aDialogOrder, GUI_COUNTOF(_aDialogOrder), &_cbDialogOrder, WM_HBKWIN, 0, 0); WM_MakeModal(hWin); GUI_ExecCreatedDialog(hWin); GUI_Delay(1500); } }
void GUIDEMO_Dialog(void) { int i; WM_HWIN hWin; GUI_COLOR DesktopColorOld; GUI_CURSOR_Show(); GUIDEMO_ShowIntro("Dialog boxes", "Dialog boxes" "\ncan easily be created"); GUIDEMO_HideInfoWin(); DesktopColorOld = WM_SetDesktopColor(GUI_RED); /* Automatically update desktop window */ hWin = GUI_CreateDialogBox(aDialogCreate, GUI_COUNTOF(aDialogCreate), _cbCallback, 0, 0, 0); for (i = 0; i < GUI_COUNTOF(_aID); i++) { GUIDEMO_Delay(_aID[i].Time); GUI_SendKeyMsg(_aID[i].Id, 1); } GUIDEMO_Delay(1000); for (i = 0; i <= 100; i+=10) { if (WM_IsWindow(hWin)) { SLIDER_SetValue(WM_GetDialogItem(hWin, GUI_ID_SLIDER1), i); } GUIDEMO_Delay(100); } if (WM_IsWindow(hWin)) { GUIDEMO_Delay(1000); WM_MoveTo(hWin, 20,50); } if (WM_IsWindow(hWin)) { GUI_Delay(1000); WM_MoveTo(hWin,120,50); } /* Cleanup ... */ if (WM_IsWindow(hWin)) { GUI_Delay(1000); WM_DeleteWindow(hWin); } GUIDEMO_NotifyStartNext(); WM_SetDesktopColor(DesktopColorOld); /* Restore old settings */ }
void MainTask(void) { GUI_PID_STATE TouchState; GUI_Init(); GUI_CURSOR_Show(); GUI_Delay(1000); GUI_CURSOR_Select(&GUI_CursorCrossL); GUI_Delay(1000); while (1) { GUI_TOUCH_GetState(&TouchState); GUI_DispStringAt("Analog input: ", 0, 40); GUI_DispDec(GUI_TOUCH_GetxPhys(),4); GUI_DispString(","); GUI_DispDec(GUI_TOUCH_GetyPhys(),4); GUI_DispStringAt("TOUCH_X_MeasureX: ",0,60); GUI_DispDec(TouchState.x,4); GUI_DispString(","); GUI_DispDec(TouchState.y,4); GUI_Delay(100); }; }
/********************************************************************* * * MainTask */ void MainTask(void) { GUI_Init(); // // Check if recommended memory for the sample is available // if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { GUI_ErrorOut("Not enough memory available."); return; } #if GUI_SUPPORT_MEMDEV WM_SetCreateFlags(WM_CF_MEMDEV); #endif FRAMEWIN_SetDefaultSkin(FRAMEWIN_SKIN_FLEX); BUTTON_SetDefaultSkin(BUTTON_SKIN_FLEX); RADIO_SetDefaultSkin(RADIO_SKIN_FLEX); CHECKBOX_SetDefaultSkin(CHECKBOX_SKIN_FLEX); HEADER_SetDefaultSkin(HEADER_SKIN_FLEX); GUI_CURSOR_Show(); WM_SetCallback(WM_HBKWIN, _cbBkWin); while (1) { GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, 0, 0, 0); GUI_Delay(1000); } }
/********************************************************************* * * MainTask */ void MainTask(void) { WM_HWIN hScrollbar, hDlgOptions; GUI_RECT RectDlg, RectClient; int Cnt = 0, IndexEffect = 0, ButtonState = 0, DropdownState = 0; int ProgbarValue = 0, ProgbarInc = 1; int SliderValue = 0, SliderInc = 1; int ScrollbarValue = 0, ScrollbarInc = 1; int ListViewInc = 1; int ListBoxInc = 1; int MultiEditInc = 1; int Vz = 1; const WIDGET_EFFECT * _apEffect[] = {&WIDGET_Effect_3D, /* Array of effects */ &WIDGET_Effect_Simple, &WIDGET_Effect_None}; const char * _apEffects[] = {"Widget effect: 3D", "Widget effect: Simple", "Widget effect: None"}; GUI_Init(); GUI_CURSOR_Show(); WM_SetCallback(WM_HBKWIN, _cbBkWindow); WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */ WM_EnableMemdev(WM_HBKWIN); /* Enable use of memory devices for desktop windows */ /* Create framewindow and set its properties */ _hFrameWin = FRAMEWIN_CreateEx(0, 0, 640, 480, 0, WM_CF_SHOW, 0, 0, "", &_cbCallbackFramewin); FRAMEWIN_SetMoveable(_hFrameWin, 1); FRAMEWIN_SetText(_hFrameWin, _apEffects[0]); FRAMEWIN_SetFont(_hFrameWin, &GUI_Font13B_ASCII); /* Create main dialog window as child from framewindows client window */ _hDlg = GUI_CreateDialogBox(_aDlgWidgets, GUI_COUNTOF(_aDlgWidgets), &_cbCallbackWidgets, WM_GetClientWindow(_hFrameWin), 0, 0); /* Attach scrollbar to framewindows client window and set its properties */ hScrollbar = SCROLLBAR_CreateAttached(WM_GetClientWindow(_hFrameWin), 0); WM_GetWindowRectEx(_hDlg, &RectDlg); WM_GetClientRectEx(WM_GetClientWindow(_hFrameWin), &RectClient); SCROLLBAR_SetNumItems(hScrollbar, RectDlg.x1); SCROLLBAR_SetPageSize(hScrollbar, RectClient.x1); /* Create options dialog with 'stay on top' and 'moveable' attribute */ hDlgOptions = GUI_CreateDialogBox(_aDlgOptions, GUI_COUNTOF(_aDlgOptions), &_cbCallbackOptions, WM_HBKWIN, 0, 0); FRAMEWIN_SetMoveable(hDlgOptions, 1); WM_SetStayOnTop(hDlgOptions, 1); /* Main loop for modifying the widgets */ while (1) { if (_AutoMode) { Cnt++; /* Modify progbar */ if ((Cnt % 2) == 0) { ProgbarValue += ProgbarInc; if ((ProgbarValue == 110) || (ProgbarValue == -10)) { ProgbarInc *= -1; } PROGBAR_SetValue(_ahWin[PROGBAR0], ProgbarValue); } /* Modify slider */ if ((Cnt % 2) == 0) { int j; SliderValue += SliderInc; if ((SliderValue == 100) || (SliderValue == 0)) { SliderInc *= -1; } for (j = 0; j < 3; j++) { SLIDER_SetValue(_ahWin[SLIDER0 + j], SliderValue); } } /* Modify scrollbar */ if ((Cnt % 3) == 0) { int j; ScrollbarValue += ScrollbarInc; if ((ScrollbarValue == 90) || (ScrollbarValue == 0)) { ScrollbarInc *= -1; } for (j = 0; j < 3; j++) { SCROLLBAR_SetValue(_ahWin[SCROLLBAR0 + j], ScrollbarValue); } } /* Modify multipage */ if ((Cnt % 120) == 0) { MULTIPAGE_SelectPage(_ahWin[MULTIPAGE0], MULTIPAGE_GetSelection(_ahWin[MULTIPAGE0]) ^ 1); } /* Modify dropdown */ if ((Cnt % 120) == 0) { DropdownState ^= 1; if (DropdownState) { DROPDOWN_Expand(_ahWin[DROPDOWN0]); } else { DROPDOWN_Collapse(_ahWin[DROPDOWN0]); } } /* Modify button */ if ((Cnt % 40) == 0) { ButtonState ^= 1; BUTTON_SetPressed(_ahWin[BUTTON0], ButtonState); } /* Modify listbox */ if ((Cnt % 30) == 0) { int Sel; Sel = LISTBOX_GetSel(_ahWin[LISTBOX0]); if (Sel < 0) { Sel = 0; } LISTBOX_SetSel(_ahWin[LISTBOX0], Sel + ListBoxInc); Sel = LISTBOX_GetSel(_ahWin[LISTBOX0]); if ((Sel == (int)LISTBOX_GetNumItems(_ahWin[LISTBOX0]) - 1) || (Sel == 0)) { ListBoxInc *= -1; } } /* Modify listview */ if ((Cnt % 50) == 0) { int Sel; Sel = LISTVIEW_GetSel(_ahWin[LISTVIEW0]); if (Sel < 0) { Sel = 0; } LISTVIEW_SetSel(_ahWin[LISTVIEW0], Sel + ListViewInc); Sel = LISTVIEW_GetSel(_ahWin[LISTVIEW0]); if ((Sel == (int)LISTVIEW_GetNumRows(_ahWin[LISTVIEW0]) - 1) || (Sel == 0)) { ListViewInc *= -1; } } /* Modify multiedit */ if ((Cnt % 5) == 0) { int Sel, Len; char acBuffer[100]; MULTIEDIT_SetCursorOffset(_ahWin[MULTIEDIT0], MULTIEDIT_GetCursorCharPos(_ahWin[MULTIEDIT0]) + MultiEditInc); MULTIEDIT_GetText(_ahWin[MULTIEDIT0], acBuffer, sizeof(acBuffer)); Sel = MULTIEDIT_GetCursorCharPos(_ahWin[MULTIEDIT0]); Len = strlen(acBuffer); if ((Sel == (Len - 1)) || (Sel == 0)) { MultiEditInc *= -1; } if (!DropdownState) { WM_SetFocus(_ahWin[MULTIEDIT0]); } } /* Modify graph */ _AddValues(_ahWin[GRAPH0], 95); /* Move window */ if ((Cnt % 1200) == 0) { int Inc; WM_HWIN hScroll; WM_SCROLL_STATE ScrollState; hScroll = WM_GetScrollbarH(WM_GetClientWindow(_hFrameWin)); WM_GetScrollState(hScroll, &ScrollState); Inc = (ScrollState.NumItems - ScrollState.PageSize) / 2; ScrollState.v += Inc * Vz; if ((ScrollState.v >= Inc * 2) || (ScrollState.v <= 0)) { Vz *= -1; } SCROLLBAR_SetValue(hScroll, ScrollState.v); } /* Change effect */ if ((Cnt % 400) == 0) { int Index; WM_HWIN hWin; IndexEffect++; Index = IndexEffect % GUI_COUNTOF(_apEffect); _SetEffect(Index); hWin = WM_GetDialogItem(hDlgOptions, GUI_ID_RADIO0); RADIO_SetValue(hWin, Index); } } /* Wait a while */ GUI_Delay(10); } }
void MainTask_2D_text_bmp(void) { int i; horPos = ICONS_HOR_POS; verPos = ICONS_VER_POS; iconTouched = 0xFF; SetemWinRunning(1); GUI_SelectLayer(1); // select foregroung layer GUI_SetBkColor(GUI_TRANSPARENT); // select background as transparent color GUI_Clear(); // fill with the background color // get the number of icons iconNumber = GUI_COUNTOF(iconDrawFunctions); // compute padding to fit to whole display iconPadding = ((GUI_GetScreenSizeY() - (iconNumber * ICON_SIZE) - 2*ICONS_VER_POS) / iconNumber); // start time measurement timeMeasureStart(); // draw a background bitmap to the bottom LCD layer GUI_SelectLayer(0); // select the background layer // !! TO BE MODIFIED !! GUI_DrawBitmap(&bmbackground, 0, 0); GUI_SelectLayer(1); // set back the foregroung layer // now draw our icons one by one for (i = 0; i < iconNumber; i++) { iconDrawFunctions[i](horPos, verPos, ICON_SIZE); verPos += ICON_SIZE + iconPadding; } // add a title text GUI_SetTextMode(GUI_TM_TRANS); GUI_SetFont(&GUI_FontTimesNewRoman31); LCD_AA_SetAndMask(0xFFFFFFFF); GUI_DispStringInRect("STM32 Player", &rect, GUI_TA_CENTER); LCD_AA_SetAndMask(0x00FFFFFF); // end measurement time = timeMeasureEnd(); GUI_SetFont(&GUI_Font8_1); sprintf (timeString, "time to render: %d,%dms", time/10, time%10); GUI_DispStringAt(timeString, 10, 320 - 10); // optionally we can use cursor GUI_CURSOR_Show(); // the GUI is now rendered // in never ending loop just check if an incon is touched while(!tamperPushed) { GUI_TOUCH_GetState(&TouchState); // Get the touch position in pixel if (TouchState.Pressed) { if (iconTouched == 0xFF) // no icon was touched previously { GUI_CURSOR_SetPosition(TouchState.x, TouchState.y); // move the cursor to current touch position // check if the touch is in icons area if (TouchState.x > ICONS_HOR_POS && TouchState.x < ICONS_HOR_POS + ICON_SIZE) { if(TouchState.y > ICONS_VER_POS && TouchState.y < ICONS_VER_POS + iconNumber*(ICON_SIZE + iconPadding)) { // get he number of touched icon iconTouched = (TouchState.y - ICONS_VER_POS) / (ICON_SIZE + iconPadding); ReDrawIcon(GUI_RED, iconTouched); // draw again with hihghlight color } } } } else { ReDrawIcon(GUI_WHITE, iconTouched); iconTouched = 0xFF; } } SetemWinRunning(0); GUI_CURSOR_Hide(); }
void GUIDEMO_main(void) { #if GUI_WINSUPPORT int i; int xSize, ySize, xPos, yPos; #endif #if (GUI_SUPPORT_CURSOR|GUI_SUPPORT_TOUCH) GUI_CURSOR_Show(); #endif GUI_Clear(); #if GUI_WINSUPPORT #if LCD_NUM_DISPLAYS > 1 FRAMEWIN_CreateAsChild(10, 10, 100, 100, WM_GetDesktopWindowEx(1), "Display 1", NULL, WM_CF_SHOW); WM_SetDesktopColorEx(GUI_RED, 1); GUI_Delay(1000); #endif WM_SetCreateFlags(WM_CF_MEMDEV); /* Automatically use memory devices on all windows */ /* Calculate position and size of FrameWin[1] */ _ButtonSizeX = 30; _ButtonSizeY = 20; /* Create the control window incl. buttons */ _ahFrameWin[1] = FRAMEWIN_Create("Control", NULL, WM_CF_SHOW | WM_CF_STAYONTOP, LCD_GetXSize() - 80, LCD_GetYSize() - 60, 80, 60); _ahInfoWin[1] = WM_CreateWindowAsChild( 0, 0, 0, 0, WM_GetFirstChild(_ahFrameWin[1]), WM_CF_SHOW | WM_CF_STAYONTOP, &_cbCmdWin, 0); _ahButton[0] = BUTTON_CreateAsChild(4, 20, _ButtonSizeX, _ButtonSizeY, _ahInfoWin[1], 'S' , WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV); _ahButton[1] = BUTTON_CreateAsChild(40, 20, _ButtonSizeX, _ButtonSizeY, _ahInfoWin[1], 'N' , WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV); BUTTON_SetText(_ahButton[0], "Stop"); BUTTON_SetText(_ahButton[1], "Next"); _UpdateCmdWin(); WM_ExecIdle(); #endif /* Show Intro */ GUIDEMO_Intro(); #if GUI_WINSUPPORT /* Calculate position and size of FrameWin[0] */ xSize = LCD_GetXSize() / 2; ySize = 65; xPos = LCD_GetXSize() - xSize; yPos = 0; /* Create info window and run the individual demos */ _ahFrameWin[0] = FRAMEWIN_Create("µC/GUI Demo", NULL, WM_CF_STAYONTOP, xPos, yPos, xSize, ySize); // _ahInfoWin[0] = WM_GetFirstChild(_ahFrameWin[0]); _ahInfoWin[0] = WM_CreateWindowAsChild(0, 0, 0, 0, WM_GetFirstChild(_ahFrameWin[0]), WM_CF_SHOW | WM_CF_STAYONTOP, 0, 0); WM_ExecIdle(); #endif /* 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(_ahFrameWin); i++) { WM_DeleteWindow(_ahFrameWin[i]); } for (i = 0; i < countof(_ahInfoWin); i++) { WM_DeleteWindow(_ahInfoWin[i]); } #endif }
/********************************************************************* * * MainTask */ void CALIBRATION_Check(void) { int aPhysX[2], aPhysY[2], aLogX[2], aLogY[2], i; data1.d32 = BACKUP_RestoreParameter(RTC_BKP_DR0); data2.d32 = BACKUP_RestoreParameter(RTC_BKP_DR1); A2 = data2.b.A2 ; B2 = data2.b.B2 ; A1 = data1.b.A1 ; B1 = data1.b.B1 ; if(data2.b.IsCalibrated == 0) { GUI_SetBkColor(GUI_WHITE); GUI_Clear(); GUI_SetColor(GUI_BLACK); GUI_SetFont(&GUI_Font13B_ASCII); _Explain(); /* Set the logical values */ aLogX[0] = 15; aLogY[0] = 15; aLogX[1] = LCD_GetXSize() - 15; aLogY[1] = LCD_GetYSize() - 15; /* Get the physical values of the AD converter for 2 positions */ for (i = 0; i < 2; i++) { _GetPhysValues(aLogX[i], aLogY[i], &aPhysX[i], &aPhysY[i], _acPos[i]); } /* Use the physical values to calibrate the touch screen */ A1 = (1000 * ( aLogX[1] - aLogX[0]))/ ( aPhysX[1] - aPhysX[0]); B1 = (1000 * aLogX[0]) - A1 * aPhysX[0]; A2 = (1000 * ( aLogY[1] - aLogY[0]))/ ( aPhysY[1] - aPhysY[0]); B2 = (1000 * aLogY[0]) - A2 * aPhysY[0]; data1.b.A1 = A1; data1.b.B1 = B1; BACKUP_SaveParameter(RTC_BKP_DR0, data1.d32); data2.b.A2 = A2; data2.b.B2 = B2; data2.b.IsCalibrated = 1; BACKUP_SaveParameter(RTC_BKP_DR1, data2.d32); /* Display the result */ GUI_CURSOR_Show(); GUI_Clear(); _DispStringCentered("Touch screen has been\n" "calibrated. Please use\n" "the cursor to test\n" "the calibration..."); } CALIBRATION_Done = 1; GUI_Delay(1000); }
/********************************************************************* * * GUIDEMO_Speed */ void GUIDEMO_Speed(void) { int TimeStart, i; U32 PixelsPerSecond; unsigned aColorIndex[8]; int xSize, ySize, vySize; GUI_RECT Rect, ClipRect; char cText[40] = { 0 }; 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); } GUIDEMO_ShowIntro("High speed", "Multi layer clipping\n" "Highly optimized drivers"); for (i = 0; i< 8; i++) { aColorIndex[i] = GUI_Color2Index(_aColor[i]); } TimeStart = GUIDEMO_GetTime(); for (i = 0; ((GUIDEMO_GetTime() - TimeStart) < 5000) && (GUIDEMO_CheckCancel() == 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 ... // } GUIDEMO_NotifyStartNext(); PixelsPerSecond = _GetPixelsPerSecond(); GUI_SetClipRect(NULL); GUIDEMO_DrawBk(0); GUI_SetColor(GUI_WHITE); GUI_SetTextMode(GUI_TM_TRANS); GUI_SetFont(&GUI_FontRounded22); GUI_DrawBitmap(&bmSTLogo70x35, 5, 5); GUIDEMO_AddStringToString(cText, "Pixels/sec: "); GUIDEMO_AddIntToString(cText, PixelsPerSecond); GUI_DispStringHCenterAt(cText, xSize >> 1, (ySize - GUI_GetFontSizeY()) >> 1); GUIDEMO_Delay(4000); #if GUI_SUPPORT_CURSOR GUI_CURSOR_Show(); #endif }
void TH_GUI (void const *argument) { static volatile uint16_t i=0; static uint16_t Triggered_Sample=0; osEvent evt; GUI_MEMDEV_Handle hMem0; GUI_SelectLayer(0); hMem0 = GUI_MEMDEV_Create(0,0,480,272); if(!GUI_CURSOR_GetState()) GUI_CURSOR_Select(&GUI_CursorCrossM); GUI_CURSOR_Show(); while (1) { Anal_CH1_Set(/*Main loop start*/); Anal_CH2_Set(/*Wait start*/); evt = osSignalWait(DMA_ConvCpltSig,(uint32_t)2); if( evt.status == osEventTimeout) Error_Handler(); Anal_CH2_Reset(/*Wait finish*/); //osSignalSet(tid_Touch,GUI_TouchStateReqSig); Anal_CH3_Set(/*Copy start*/); for(i=0;i<ADC_BUFFER_LENGTH;i++) // <- Temporary. Take the full advantage of DMA ! values_BUF[i]=255-values[i]; Anal_CH3_Reset(/*Copy finish*/); HAL_ADC_Start_DMA(&g_AdcHandle, values, ADC_BUFFER_LENGTH); osSignalClear(tid_TH_GUI, DMA_ConvCpltSig); Anal_CH4_Set(/*Wait start*/); osSignalWait(GUI_TouchGetSig,(uint32_t)0); GUI_CURSOR_SetPosition(g_Touched.pState->x,g_Touched.pState->y); Anal_CH4_Reset(/*Wait finish*/); Trigger_Point = g_Touched.MSG; Triggered_Sample = Trigger(Trigger_Point, values_BUF, ADC_BUFFER_LENGTH, 1348000UL); //if(Triggered_Sample >=20)Triggered_Sample -=20; // Offset to see the edge in the center <- bullshit ? GUI_MEMDEV_Select(hMem0); GUI_MEMDEV_Clear(hMem0); GUI_SetColor(GUI_DARKGRAY); GUI_FillRect(0,0,480,272); GUI_SetColor(GUI_BLACK); GUI_DrawRect(34,5,474,266); GUI_SetColor(GUI_WHITE); GUI_FillRect(35,6,475,266); Draw_GraphGrid(440,260,40,40); GUI_SetColor(GUI_BLUE); /*Draw garph start*/HAL_GPIO_TogglePin(GPIOI,GPIO_PIN_1); GUI_DrawGraph((short*)&values_BUF[Triggered_Sample],440,35,6); // Useful: GUI_COUNTOF(values) /*Draw garph finish*/HAL_GPIO_TogglePin(GPIOI,GPIO_PIN_1); GUI_SetColor(GUI_ORANGE); GUI_DrawHLine(Trigger_Point,0,480); GUI_FillCircle(15,Trigger_Point,10); GUI_SetColor(GUI_YELLOW); GUI_DrawCircle(15,Trigger_Point,10); GUI_MEMDEV_CopyToLCD(hMem0); Anal_CH1_Reset(/*Main loop finish*/); osThreadYield (); // suspend thread } }