/********************************************************************* * * _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); }
static void _SetResizeCursor(int Mode) { const GUI_CURSOR GUI_UNI_PTR * pNewCursor = NULL; if (Mode) { int Direction; Direction = Mode & (FRAMEWIN_RESIZE_X | FRAMEWIN_RESIZE_Y); if (Direction == FRAMEWIN_RESIZE_X) { pNewCursor = &_ResizeCursorH; } else if (Direction == FRAMEWIN_RESIZE_Y) { pNewCursor = &_ResizeCursorV; } else { Direction = Mode & (FRAMEWIN_REPOS_X | FRAMEWIN_REPOS_Y); if ((Direction == (FRAMEWIN_REPOS_X | FRAMEWIN_REPOS_Y)) || !Direction) { pNewCursor = &_ResizeCursorDD; } else { pNewCursor = &_ResizeCursorDU; } } } if (pNewCursor) { const GUI_CURSOR GUI_UNI_PTR * pOldCursor; pOldCursor = GUI_CURSOR_Select(pNewCursor); if (_pOldCursor == NULL) { _pOldCursor = pOldCursor; } } else if (_pOldCursor) { GUI_CURSOR_Select(_pOldCursor); _pOldCursor = NULL; } }
/********************************************************************* * * 在触摸校正的时候使用这个来读取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); }; }
/********************************************************************* * * GUIDEMO_Cursor */ void GUIDEMO_Cursor(void) { GUIDEMO_ShowIntro("Cursor", "emWin supports\nsoftware cursors"); _DispCursor(); GUIDEMO_Wait(4000); GUIDEMO_CursorShow(); #if (GUI_SUPPORT_CURSOR && GUI_SUPPORT_TOUCH) if (GUIDEMO_GetConfFlag(GUIDEMO_CF_SUPPORT_TOUCH)) { GUI_CURSOR_SetPosition(0,0); GUI_CURSOR_Select(&GUI_CursorArrowM); } #endif }
/********************************************************************* * * GUI_CURSOR_Show */ void GUI_CURSOR_Show(void) { GUI_LOCK(); LCDDEV_L0_GetRect(&_ClipRect); _Hide(); _CursorOn = 1; /* Set function pointer which window manager can use */ GUI_CURSOR_pfTempHide = _TempHide; GUI_CURSOR_pfTempUnhide = _TempUnhide; if (!_pCursor) { GUI_CURSOR_Select(GUI_DEFAULT_CURSOR); } else { _Show(); } GUI_UNLOCK(); }
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); }
static void _MoveCursor(const GUI_CURSOR* Cursor){ int x, y; int xMax, yMax; xMax = LCD_GetXSize()/2; yMax = LCD_GetYSize()/2; GUI_CURSOR_Select(Cursor); for(x = y = 0; ((x != xMax) && (y != yMax) && !GUIDEMO_CheckCancel()); x += 4, y += 4) { if ( x == xMax) { x = xMax; } if ( y == yMax) { y = yMax; } GUI_CURSOR_SetPosition(x,y); GUIDEMO_Delay(75); } }
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); }; }
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 } }